Emmanuel Bernard commented on Bug OGM-230

I've investigated what you saw in InheritanceTest. It's due to the fact that you were not testing the right thing.
Your test basically calls result.toString() which triggers the object loading. After that, javassist's proxy simply delegates toString() to an actual strawberry object.

Here is a proper test

diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/inheritance/InheritanceTest.java b/hibernate-entitymanager/src/test
index 5e8c8a9..e746da1 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
@@ -30,6 +30,8 @@ import org.junit.Test;
 import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
 
 /**
  * @author Emmanuel Bernard
@@ -51,9 +53,12 @@ public class InheritanceTest extends BaseEntityManagerFunctionalTestCase {
         Strawberry result1 = firstSession.find(Strawberry.class, newId);
         assertNotNull( result1 );
 
+               firstSession.clear();
         // 2.
-        Strawberry result2 = (Strawberry) firstSession.find(Fruit.class, newId);
+        Fruit result2 = firstSession.getReference(Fruit.class, newId);
         System.out.println("2. result is:" + result2);
+               System.out.println("2. result is:" + result2.getClass().getName());
+               assertTrue( result2 instanceof Strawberry );
 
         firstSession.getTransaction().commit();
         firstSession.close();

The test fails right after printing

2. result is:org.hibernate.jpa.test.inheritance.Strawberry@73947cfc
2. result is:org.hibernate.jpa.test.inheritance.Fruit_$$_javassist_50

I should have spotted that quicker but I'm a bit rusty on those subjects.

So yes only keep the find test and remove the getReference test from the pull request.

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