[jboss-user] [EJB 3.0] - Re: Many to Many realtionship question
Wolfgang Knauf
do-not-reply at jboss.com
Mon Aug 17 08:13:40 EDT 2009
Hi,
you basically need two steps to persist data:
1) create a correct in-memory state
2) persist it
It seems that your original use case failed in step 1: the relation has to be defined correct in memory, so that both sides know each other.
If step 1 has the correct outcome, step 2 should work no matter which side is saved.
BUT you should take care for your "Cascade" type: with a "@ManyToMany", the default is to cascade nothing. So, if your relationship contains a new child item, it is not inserted by default. You have to set "cascade = CascadeType.MERGE" to insert new childs when saving the parent.
Hope this helps
Wolfgang
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4249907#4249907
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4249907
More information about the jboss-user
mailing list