persistence@glassfish.java.net

Re: ManyToMany with list of an utility class which contains the other objekt fur mapping and an additional attribute

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Tue, 18 Sep 2007 12:50:56 -0700

There is no portable way to support ManyToMany relationships with an extra
attribute. Some providers can do it in their own way. For a portable solution,
you need to map them as 2 OneToMany relationships with an Entity that represents
that extra attribute.

Regards,
-marina

PLC_David wrote:
> Hello Gordon,
>
> I don't understand it :confused:. I've deleted @Entity in the
> ShoppingCartPropertiesDTO, but how is the @manytomany
> in CustomerDTO ??
>
> If I have the ShoppingCartPropertiesDTO without the @Entity than I get
> following exception:
>
> Exception Description: Missing descriptor for [ShoppingCartPropertiesDTO].
> Verify that the descriptor has been properly registered with the Session.
>
> Could you write what you mean, please ?
>
>
>
> Gordon Yorke wrote:
>
>>Hello,
>> Yes you can map the ShoppingCartPropertiesDTO using the @ManyToMany
>>annotation. The ShoppingCartPropertiesDTO will have to be marked as an
>>Entity. Not marking the ShoppingCartPropertiesDTO as an Entity is most
>>likely the cause of the exception you are seeing.
>>--Gordon
>>
>>-----Original Message-----
>>From: PLC_David [mailto:spaceman2k4_at_gmx.de]
>>Sent: Monday, September 17, 2007 7:12 PM
>>To: persistence_at_glassfish.dev.java.net
>>Subject: ManyToMany with list of an utility class which contains the
>>other objekt fur mapping and an additional attribute
>>
>>
>>
>>Hallo, I work with JPA for the first time.
>>
>>My database:
>>
>>Customer : ID | NAME | other columns
>>Product : ID | DISCRIMINATOR | NAME |other columns | HARDWARE_INTERFACE |
>>XML_ID
>>Customer_Product_Rel: CUSTOMER_ID | PRODUCT_ID | AMOUNT
>>
>>My objects:
>>
>>@Entity
>>CustomerDTO: attributes like id, name ... and
>>List<ShoppingCartPropertiesDTO> products = new
>>ArrayList<ShoppingCartPropertiesDTO>();
>>
>>ShoppingCartPropertiesDTO: private ProductDTO product = null; private
>>Integer amount = null;
>>
>>@Entity
>>@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
>>@DiscriminatorColumn(name = "DISCRIMINATOR", discriminatorType =
>>DiscriminatorType.STRING, length = 2)
>>abstract class Product: id, name ,descr, ...
>>
>>@Entity(name="SoftwareDTO")
>>@DiscriminatorValue("SW")
>>public class SoftwareDTO extends ProductDTO: private SystemRequirementsDTO
>>systemRequirements = null; private String language = null;
>>
>>
>>My question: Can I map the customer with a list of the additional object
>>(ShoppingCartPropertiesDTO) which contains the product and the amount? And
>>how is the ManyToMany annotation ?
>>
>>
>>
>>An additional question: What means the exception with missing descriptor
>>??
>>
>>Exception Description: Missing descriptor for [ShoppingCartPropertiesDTO].
>>Verify that the descriptor has been properly registered with the Session.
>> at
>>oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:120)
>> at
>>oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:60)
>> at test.JPATester.runTest2(JPATester.java:186)
>>Caused by: Exception [TOPLINK-7009] (Oracle TopLink Essentials - 2.0
>>(Build
>>b58g-fcs (09/07/2007))):
>>oracle.toplink.essentials.exceptions.ValidationException
>>
>>
>>
>>Thanks for all posts
>>David
>>
>>
>>
>>--
>>View this message in context:
>>http://www.nabble.com/ManyToMany-with-list-of-an-utility-class-which-contains-the-other-objekt-f%C3%BCr-mapping-and-an-additional-attribute-tf4470610.html#a12746960
>>Sent from the java.net - glassfish persistence mailing list archive at
>>Nabble.com.
>>
>>
>
>