Even if fruit is not abstract, the results are still polymorphic in the test. Would it help if I opened a pull on hibernate-orm to allow easier reproduction? Here's a diff of my hibernate-orm local. The test was run after a gradlew clean at the top of hibernate-orm. I further modified the test to close the initial em before asking for the second (otherwise is the same em).
diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/inheritance/Fruit.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/inheritance/Fruit.java
index 922f1fd..b9a394d 100644
--- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/inheritance/Fruit.java
+++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/inheritance/Fruit.java
@@ -11,7 +11,7 @@ import javax.persistence.InheritanceType;
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
-publicabstract class Fruit {
+public class Fruit {
Long id;
@Id
diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/inheritance/InheritanceTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/inheritance/InheritanceTest.java
index 5e8c8a9..3c4cae0 100644
--- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/inheritance/InheritanceTest.java
+++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/inheritance/InheritanceTest.java
@@ -52,11 +52,20 @@ public class InheritanceTest extends BaseEntityManagerFunctionalTestCase {
assertNotNull( result1 );
// 2.
- Strawberry result2 = (Strawberry) firstSession.find(Fruit.class, newId);
- System.out.println("2. result is:" + result2);
-
+ firstSession.clear();
+ Fruit result2 = firstSession.getReference(Fruit.class, newId);
+ System.out.println("2.(getReference) result is:" + result2);
firstSession.getTransaction().commit();
- firstSession.close();
+ firstSession.clear();
+ firstSession.close();
+ EntityManager secondSession = getOrCreateEntityManager( );
+ secondSession.getTransaction().begin();
+ secondSession.clear();
+ Fruit result3 = secondSession.getReference(Fruit.class, newId);
+ System.out.println("3.(getReference) result is:" + result3);
+
+ secondSession.getTransaction().commit();
+ secondSession.close();
}
@Override
results snipped from test report:
2.(getReference) result is:org.hibernate.jpa.test.inheritance.Strawberry@7a04d48b
3.(getReference) result is:org.hibernate.jpa.test.inheritance.Strawberry@7ecb36d4
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
Even if fruit is not abstract, the results are still polymorphic in the test. Would it help if I opened a pull on hibernate-orm to allow easier reproduction? Here's a diff of my hibernate-orm local. The test was run after a gradlew clean at the top of hibernate-orm. I further modified the test to close the initial em before asking for the second (otherwise is the same em).
results snipped from test report:
2.(getReference) result is:org.hibernate.jpa.test.inheritance.Strawberry@7a04d48b
3.(getReference) result is:org.hibernate.jpa.test.inheritance.Strawberry@7ecb36d4