-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: JPA delete problem on @OneToMany: deleted entity passed to
PostPosted: Mon Mar 09, 2009 7:50 am 
Newbie

Joined: Mon Mar 09, 2009 7:44 am
Posts: 1
Hello,
I'm doing an relationship with two Entity (Parent - Child). So, in
Parent class I had a collection of Child. When I remove one item (child)
from the collection, its appears ok. But in database the operation doesn't
happen. I'd tried to remove by em.remove(child) , but this error occur: "
org.hibernate.ObjectDeletedException: deleted entity passed to persist: [
model.Child#]"
It happens because in the parent I have the CASCADE.PERSIST on the Children Set like this:
Code:
@OneToMany (fetch = EAGER, cascade=CascadeType.ALL)
   public Set<Child> getChildren()

so if I remove the CASCADE.PERSIST, leaving it like this:
Code:
@OneToMany(cascade={CascadeType.MERGE, CascadeType.REFRESH, CascadeType.REMOVE)
public Set<Child> getChildren()

It works perfect for removing the child but when I am going to create the child, it doesn't create the child, so I am feeling like in a dead lock.
Someone can help me?
Thanks a lot


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.