[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3019) LAZY 1:1 (self-) reference with Inheritance ---> WRONG INTERFACES implemented by Javassist/CGLIB created Proxies

Chris Bredesen (JIRA) noreply at atlassian.com
Tue Jul 8 20:41:12 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3019?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30607 ] 

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: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list