What is your cascade setting for your parent table. Does it cascade deletes. I think you would update the parent object after removing the children. Or can you loop through the childs calling the session.delete() and then commit the transaction?
I did find out from browsing through the O'reilly EJB3 book (version 5) that I'm essentially doing things the right way. They recommend "always wire both sides" of a relationship. In this context it's saying do both to delete the object:
However, in this case that's when I get this exception. I'm going to ask on the JBoss forums and see if their gurus have any thoughts on what I'm doing wrong.
Joe J. Wang
Joined: Feb 26, 2003
Only a guess, not sure what is the correct answer, (just started to learn EJB3. )
How about you make the parent bean detached from the EM, (is there any method in em to do this job? clear() will detach all the managed entities), and then do em.remove(akid)? then if you want to use the parent, em.find(parent.class, xxx)... [ June 27, 2006: Message edited by: Joe J. Wang ]
SCJP, SCJD, SCWCD, SCEA I.
Joined: May 30, 2003
I'm having a similar problem.
I do parent.remove(child) then em.remove(child)
But still get an exception - what is the correct process?