<< mysql的授权语法-GRANT Syntax | 首页 | ORACLE函数大全 >>

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.
标签 : ,


Avatar: anoob

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...

Re: a different object with the same identifier value was already associated with the session

It did help me also. I have a lot of cascades so merge() was the thing. Thanks.

发表评论 发送引用通报