[jboss-user] [EJB 3.0] - Re: javax.persistence.EntityNotFoundException: deleted entit
jochen.reinhardt
do-not-reply at jboss.com
Mon Mar 23 06:43:52 EDT 2009
So how do you delete the other entities? What does your code look like?
I think the correct way would be to remove the relationship, first. Something like that:
| // clear the relationship
| // depending on your relation context you may have to call EntityManager.merge(...)
| List<Event> relatedEvents = event.getRelatedEvents();
| for (Event relatedEvent : relatedEvents)
| {
| relatedEvent.getRelatedEvents().remove(event);
| }
| // on both sides! That's important!
| event.setRelatedEvents(new ArrayList<Event>(0))
| // remove the event
| entityManager.remove(event);
|
Please try it that way!
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4220175#4220175
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4220175
More information about the jboss-user
mailing list