persistence@glassfish.java.net

Re: Problem with inheritance...

From: Adam Bien <abien_at_adam-bien.com>
Date: Mon, 14 Aug 2006 21:28:29 +0200

Hi Andrei,

yes you are right. I would like to inherit the persistence capability
and not the entity (as "persistent" relationship).

The second problem comes from "lazy" loading. It seems to be a bug. It
only happens, in case I'm annotating relationships with the
FetchType.LAZY...

greetings,

adam
Andrei Ilitchev schrieb:
> Hi Adam,
>
> Here's my understanding of the problem you are experiencing, please
> correct me if I am wrong:
>
> You defined a base Entity class A:
> @Entity
> @Table(name="A")
> public class A implements Serializable {
> @Id
> @Column(name="ID")
> public Integer getId() {
> return id;
> }
> ...
> }
>
> In case you defined derived class B without Entity annotation:
> public class B extends A {
> ...
> }
> during deployment you are getting the following exception:
>> Exception [TOPLINK-129] (Oracle TopLink Essentials - 2006.4 (Build
>> 060412)): oracle.toplink.essentials.exceptions.DescriptorException
>> Exception Description: The set method for the attribute
>> [detailRoleName] does not take a ValueHolderInterface as its
>> parameter, but the mapping uses indirection.
>> Mapping:
>> oracle.toplink.essentials.mappings.OneToOneMapping[detailRoleName]
>
> Otherwise, if you define the derived class with Entity annotation:
> @Entity
> public class B extends A {
> ...
> }
> during deployment you are getting exception indicating that B has no
> primary key specified
>> (It should define either an @Id, @EmbeddedId or an @IdClass).
>
> ----- Original Message ----- From: "Adam Bien" <abien_at_adam-bien.com>
> To: <persistence_at_glassfish.dev.java.net>
> Cc: <persistence_at_glassfish.dev.java.net>
> Sent: Monday, August 14, 2006 12:35 PM
> Subject: Problem with inheritance...
>
>
>> Problem/limitation:
>>
>> I generate entities with annotations (@Id, @Entity) etc.
>>
>> The coded classes inherit from the generated ones.
>> Now I have a problem during deployment:
>>
>> I get either the exception:
>>
>> Exception [TOPLINK-129] (Oracle TopLink Essentials - 2006.4 (Build
>> 060412)): oracle.toplink.essentials.exceptions.DescriptorException
>> Exception Description: The set method for the attribute
>> [detailRoleName] does not take a ValueHolderInterface as its
>> parameter, but the mapping uses indirection.
>> Mapping:
>> oracle.toplink.essentials.mappings.OneToOneMapping[detailRoleName]
>>
>>
>> if I mark the concrete-entity as @Entity or:
>>
>> Test Name : tests.persistence.DefaultProviderVerification
>> Test Assertion : Test validity of EJB 3.0 persistence unit. This test
>> tests validity using a portable persistence provider. Please refer to
>> EJB 3.0 Persistence API Specification for further information.
>> Test Description : For [ template#ejb-jar.jar#null ]
>> Exception Description: Entity class [class ...EJBSecondDetailBE] has
>> no primary key specified. It should define either an @Id, @EmbeddedId
>> or an @IdClass.
>>
>> The primary key is specified, but in the superclass
>> (AbstractSecondDetailBE). It seems, like the annotations are not
>> "inherited".
>>
>> thanks and greetings,
>>
>> adam
>>
>>
>


-- 
 Dipl. Inf. adam bien
 
 BEA Technical Director
 Sun Certified Java Programmer
 Sun Certified Enterprise Java Architect 
 Sun Enterprise Java Trainer
 
 Mobile: 0049(0)170 280 3144
 eMail:  abien_at_adam-bien.com
 Homepage: www.adam-bien.com
 Weblog: http://www.adam-bien.com/roller/page/abien 
 ----------
Book author:
   
   Enterprise Architekturen
   entwickler.press 2006
   ISBN: 393504299X
 
 and Enterprise Java Frameworks, 
 J2EE Patterns, J2EE HotSpots and Struts.