-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Confusing interfaces
PostPosted: Tue May 25, 2004 11:56 am 
Newbie

Joined: Tue Apr 27, 2004 4:31 am
Posts: 13
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:


Top
 Profile  
 
 Post subject: Confusing interfaces
PostPosted: Wed May 26, 2004 7:51 am 
Newbie

Joined: Tue Apr 27, 2004 4:31 am
Posts: 13
Hello again,

The problem occurs when two sub-interfaces provide methods with exactly the same signature, like getEmailAddresses(). It appears that the interface to use is determined at run-time per method called.

The interface is cast, although there is no need to do so - and this results in a ClassCastException.

Still I do not have a clue on how to solve this particular problem.

Anyone?

Erwin


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.