users@glassfish.java.net

Re: Problem with _at_JoinTable

From: <glassfish_at_javadesktop.org>
Date: Tue, 06 Jan 2009 10:45:16 PST

Hello Stephan,

In setting setCameraUserIdCollection, you are not setting the other side of the manyToMany relation, the IndyAxisCameras->IndyMobilePhones relation. Since the cameraUserIdCollection is mapped by the phoneNumberCollection, it is the data in the phoneNumberCollection that controls the relationship table. Since this collection is left unchanged, nothing is put into the relation table. You will need to also update the phoneNumberCollections in both IndyAxisVideoServers and IndyMobilePhones. You can get away with setting the owning side of a bidirectional relationship, but the non-only side will only reflect the relationship changes after it is refreshed from the database.

JPA requires that you maintain both sides of any bidirectional relationship, otherwise what is in your entities may not reflect what is in the database.

Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

http://forums.java.net/jive/thread.jspa?messageID=324344