a different object with the same identifier value was already associated with the session
I have found two solution to this issue. Here it is, there are two.
1. Use cascase = none.
2. Use merge instead of saveandupdate.
The problem here is that you pass in a detached object which gets reattached to the Session. You also fetch the same object with the find. This causes the exception.
- You could change the query to do all the validation you require and therefore don't return it into the Session.
- Otherwise you'd have to evict the entity returned from the query.
Re: a different object with the same identifier value was already associated with the session
thanks it solved my problem....
but i would like to know why it was coming? even i though i have asked hibernate to manage session (thread)
when i checked the session after the commit it seemed to be closed...regarding to which session was this error thrown...