]
Chris Bredesen commented on HHH-3019:
-------------------------------------
This fails on Sun 1.5.0_13 (Linux) as well.
LAZY 1:1 (self-) reference with Inheritance ---> WRONG INTERFACES
implemented by Javassist/CGLIB created Proxies
----------------------------------------------------------------------------------------------------------------
Key: HHH-3019
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3019
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.4, 3.2.4.sp1, 3.2.5
Environment: Win-XP, Jboss 4.2.2.GA, Java 1.6, Hibernate 3.2.4Sp1
Reporter: S.Schnabl
Priority: Blocker
Attachments: Hibernate_lazy_1-to-1_with-proxy_TestCase.rar
Hello, following simple testcase:
EntityC, EntityB, EntityA are interfaces and have their respective implementations
EntityCImpl, EntityBImpl, EntityAImpl. Inheritance structure is following:
-> EntityC extends EntityB extends EntityA.
Now EntityA has a 1:1 reference for another Entity, which at least must implement
Interface 'EntityA' itself. These relation is described like following:
@OneToOne(fetch = FetchType.LAZY, targetEntity = EntityAImpl.class)
public EntityA getNextEntity() {
return this.nextEntity;
}
Testcase: ( for complete testcase and entity structure see attached zip-file. Sorry, but
only a jboss-variante attached due to short of time. Simply deploy the server.ear file
from release-directory and run the src/client/TestCaseClient.java)
Mainly the testcase does the following:
// create a entityA
EntityA a = new EntityAImpl();
this.em.persist(a);
// create a EntityB, which inherits from EntityA
EntityB b = new EntityBImpl();
this.em.persist(b);
// link B to A
a.setNextEntity(b);
// load EntityA, which has an 1:1 attached EntityB(-Proxy!)
EntityA a = this.em.find(EntityAImpl.class, idEntityA);
// load attached EntityB - should be from expected type EntityB(-Proxy!)
Object b = a.getNextEntity();
// Now check, which Interfaces these EntityB implements: should be
// EntityA and EntityB, but NOT EntityC
if (b instanceof HibernateProxy)
System.out.println("Loaded object is instanceof " +
HibernateProxy.class.getSimpleName()); // true
if (b instanceof EntityB)
System.out.println("Loaded object is instanceof " +
EntityBImpl.class.getSimpleName()); // true
if (b instanceof EntityC)
System.out.println("Loaded object is instanceof " +
EntityCImpl.class.getSimpleName()); // TRUE - ERROR !!!!!!!! That's a bug ! We loaded
an EntityB which CANNOT be of Type EntityC !!!!
As you can see, the proxy implents wrongly the Interface EntityC, which must NOT
implemented, cause we have only an EntityB linked to EntityA!!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: