-->
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: org.hibernate.ObjectDeletedException: deleted entity passed
PostPosted: Fri May 22, 2009 1:42 pm 
Newbie

Joined: Fri May 22, 2009 1:07 pm
Posts: 2
I am having a bidirectional relationship between objects.
And have cascade all defined on the opposite side e.g.

DeskImpl Class
===========
@OneToMany(mappedBy="desk", fetch = FetchType.EAGER, cascade = { CascadeType.ALL }, targetEntity = BookImpl.class)
public Set<Book> getBooks() {
return books;
}

BookImpl.class
===========
@ManyToOne(fetch = FetchType.EAGER, targetEntity = DeskImpl.class)
@JoinColumn(name = "oid_desk")
public Desk getDesk() {
return desk;
}

I have a column entityId which along with version has a unique constraint on it.
Whenever the Desk it updated there is a newer version of desk created and it is attached to the same Book and persisted.
and the older desk is unlinked from the book (This happens within its own tx and I see the data correctly reflected in the database.)

This is a unit test I am running
===================
1) Update the desk (As mentioned earlier I am able to see these changes)
2) delete the desk (I expect the delete on desk to cascase to book). However if I run this entire operation as one unit test
(Although I am running each operation (update, delete) in it own tx) I get the error on the delete operation.
Caused by: org.hibernate.ObjectDeletedException: deleted entity passed to persist: [com.jpm.ibt.primegps.domain.reference.BookImpl#<null>]

3) If I run the update as a seperate test (as mentioned the database changes are seen fine)
and then I do another test by looking up that desk and then doing the remove. The operation is successfull without any issues.

It has led me to believe there is definitely some bug in the hibernate implementation where within a particular session it is not able to perform two operations update and delete consistently.

Please let me know if anyone has seen this issue before and how to resolve it.
It seems a bit strange.


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.