-
1. Re: ManyToMany constraints problem
fowlks Dec 4, 2006 3:49 PM (in response to melampo)I am having the same problem. Did you ever solve this issue?
- Kevin -
2. Re: ManyToMany constraints problem
melampo Dec 5, 2006 10:59 AM (in response to melampo)No, sorry... I have not solve it...
-
3. Re: ManyToMany constraints problem
fowlks Dec 5, 2006 2:22 PM (in response to melampo)I've solved my problem which i belive is the same as yours. My solution was to use the em.merge instead of a em.persist. This is weird because my Owner object is new e.g. (has never been persist before). But this works!!!!! So basicly i have a check to see if child object has a known ID if so then merge else call persist.
- Kevin -
4. Re: ManyToMany constraints problem
melampo Dec 7, 2006 2:56 AM (in response to melampo)Ok... I am going to try that.
Thanks. -
5. Re: ManyToMany constraints problem
martinwhs Dec 7, 2006 10:51 AM (in response to melampo)Is there a reason for the usage of CascadeType.PERSIST on the many-to-many relationship in the etiquetas class?
Since that very relationship is mapped by the etiquetas field in the libros class, you probably won't ever manipulate the collection of libros in the etiquetas, but only do reads on it. Therefor I would suggest removing the cascadeType in the etiquetas class.
The decision wether to use cascading on relationships affects the way you use the entitymanager. You can do everything without cascading, it is just less comfortable (more persist and merge calls). In this very case you would have to manage the etiquetas seperatly. This is maybe a good idea, since they don't seem to form a composition with libros (can live without them).
If you don't feel comfortable with cascading, then you can turn it off and do things manually.
Best regards,
Martin