[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-511) reattach object from same session

Markus Bäurle (JIRA) noreply at atlassian.com
Thu Mar 22 15:49:10 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-511?page=comments#action_26520 ] 

Markus Bäurle commented on HHH-511:
-----------------------------------

What is the current state of this bug?

I think the priority should be raised at least to major, because the needed workarounds are really ugly. What about the patch? Can it be applied into a new hibernate version?

I have the scenario above: The first transactional method throws an exception and the transaction is therefor rollbacked causing a clear() on the session. The following updates do not work anymore with the famous error message: Found two representations of same collection...

I use Spring with a HibernateInterceptor so I just cannot throw the session away and create a new one.

I solved the problem with a call to Session.merge() before update(), but this solution is ugly because merge() creates a new persistent instance, so I have to replace all references to the old detached instance with the new attached persistent instance. Unlike the scenario above I cannot use refresh() because it overwrites the current state with the state from the db discarding all changes.

> reattach object from same session
> ---------------------------------
>
>          Key: HHH-511
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-511
>      Project: Hibernate3
>         Type: Bug

>   Components: core
>     Reporter: Gavin King
>     Priority: Minor
>  Attachments: reattach-same-session.patch, reattach-same-session.patch
>
>
> http://forum.hibernate.org/viewtopic.php?p=2231400#2231400
> There is a problem when you reattach a collection to the same session that it was previously attached to, after calling clear(). Hibernate checks the collections session reference, at reattach and concludes it is  already attached.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira





More information about the hibernate-issues mailing list