From: Maarten W. (JIRA) <no...@at...> - 2006-07-28 00:59:16
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1954?page=all ] Maarten Winkels updated HHH-1954: --------------------------------- Attachment: proxy-evict.patch This one-line fix sets the session of a proxy to NULL when evicting. This solves the problem and all other tests run fine. > Proxies are never unassociated (evicted) from a session > ------------------------------------------------------- > > Key: HHH-1954 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1954 > Project: Hibernate3 > Type: Bug > Versions: 3.2.0.cr3 > Reporter: Maarten Winkels > Attachments: Person.hbm.xml, Person.java, ProxyEvictTest.java, proxy-evict.patch > > > When evicting (either directly or by cascade) a proxy from a session, the proxy is removed from an internal map (proxiesByKey), but the proxy's lazy initializer still has reference to the session. This allows for lazy initialization of a proxy even after the proxy is evicted. This seems semantically incorrect: The documentation of LazyInitializer.getSession() reads: "Get the session, if this proxy is attached" an proxy evicted from a session should cleary not remain attached to the session. > The current implementation leads to concurrent modification exceptions, when one thread detaches entities from one session and another attaches these entities to another. The method AbstractLazyInitializer.isConnectedToSession() is called when locking a proxy to a session. This will search the old session for the proxy (in the containsProxy() call). When another thread is manipulating this sessions proxy ByLey map, a concurrent modification exception will occure. > Note that each session is used in a thread-safe context by the application! When reassociating a proxy to the new session, hibernate breaks the thread-safety by querying the other session. -- 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 |