Hello there,
I came across a problem that appears to be a bug to me.
We use a number of entities and amongst them we have a Role (subclassed by for example BusinessRelation), and a Party.
A Party is played by a Role, and is opted to be lazy loaded, through it's IParty interface. Besides, Role is a subclass of Party.
The mapping is as follows:
Code:
<joined-subclass extends="nl.anva.commons.domein.rolepattern.Party"
name="Role"
lazy="true"
dynamic-update="true"
dynamic-insert="true"
proxy="IRole"
>
<key column="id"/>
<many-to-one
name="playedBy"
column="playedById"
class="Party"
/>
<...>
</joined-subclass>
<class
name="Party"
table="Party"
proxy="IParty"
dynamic-update="true"
dynamic-insert="true"
optimistic-lock="version"
lazy="true"
>
<id
name="id"
column="id"
unsaved-value="null"
>
<generator class="uuid.hex"/>
</id>
<version
column="version"
name="version"
type="integer"
/>
<...>
<property name="startdatum"/>
</class>
The problem is that in several occasions the playedBy references an interface, other than IParty. Instead it is a IPrivateRelation interface that cannot be cast to the IBusinessRelation we need.
Turning the lazy-option of Party to false solves this problem for now, but it is definitely lazy-loading what we want to use here.
The stack trace is:
(In this case we expect a AbstractPerson as Actor (derived from Party), that is mistakenly loaded as an AbstractOrganisation.
Code:
java.lang.ClassCastException
at nl.bfwa.commons.domein.actor.IAbstractOrganisatie$$FastClassByCGLIB$$d1928892.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:183)
at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:108)
at nl.bfwa.commons.domein.role.IVertegenwoordigde$$EnhancerByCGLIB$$82c0d6fa.getEmailAdressen(<generated>)
at nl.bfwa.domein.controller.InteresseTest.assertPersoon(InteresseTest.java:85)
at nl.bfwa.domein.controller.InteresseTest.assertParticuliereRelatie(InteresseTest.java:110)
at nl.bfwa.domein.controller.InteresseFindTest.testFindAllProspects(InteresseFindTest.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)17:50:04,069 DEBUG AbstractController:99 - closing session for nl.bfwa.domeincontroller.DatabaseController@18e261d
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
Any suggestions?
Kind Regards,
Erwin Tennekes
Code: