-->
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: Plagued by "Deleted entity passed to persist"
PostPosted: Mon May 28, 2012 5:56 am 
Newbie

Joined: Mon May 28, 2012 4:29 am
Posts: 1
I have read around that this is because I'm trying to persist an entity that has been otherwise removed, but I guess I'm not sure what constitutes "removed" or what makes an entity "removed".
I'm trying to make the fairly basic OneToMany/ManyToOne with e.g. a shopping cart and items, items pointing back to parent cart. I want to be able to:
-delete an item from the cart
-delete the cart and all items

I have tried about 20 different examples, every time I google a new one I rush to try it. I am using annotations, something like:

Cart:
@OneToMany(mappedBy="cart", cascade={CascadeType.ALL})
private Set<Item> items = new HashSet<>();

Item:
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "cart", insertable = false, updatable = false, nullable = false)
private Cart cart;

I have tried @PreRemove on item to remove it from the cart's set, unlinking type methods on the entities to disconnect them before persisting etc. but it seems whatever I do I'm plagued by the "deleted entity passed to persist" error on committing the transaction.
I have read so much my head is now spinning and feel far less confident about it than I did a few days ago - please could someone point me to a good example for this?
Thanks,
Phil


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.