[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3357) session.clear() takes too long

Gerald Glocker (JIRA) noreply at atlassian.com
Fri Jul 11 04:42:12 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30632 ] 

Gerald Glocker commented on HHH-3357:
-------------------------------------

Evict also takes very long when the session cache has many proxies. The reason is the same check whether the old session still uses the proxy.

Generally it makes sense to perform this search in the old session because there is no guarantee that the proxy is also removed from the old session and not used any more. In the case of evict() and clear() the proxy is actually removed from the persistence context and we don't need the expensive check. 

For these reasons a better solution would rahter be to add in LazyInitializer a new method that sets the session to null without any other checks. The new method should be used only when we are sure that the proxies don't remain in the persistence context, thus by evict() and clear().

The proposed solution is implemented in the attached patch.

> session.clear() takes too long
> ------------------------------
>
>                 Key: HHH-3357
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3357
>             Project: Hibernate3
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 3.2.5, 3.2.6
>            Reporter: Jay Erb
>
> Clearing a session that contains a large number of Proxies takes a very long time. The reason for this is that  null is set on the LazyInitializer when clearing the StatefulPersistenceContext, whenever a new session is set on an AbstractLazyInitializer, a check is done to see if the AbstractLazyInitializer is still attached to its previous session (and correctly throws an exception if it is). This check performs a linear search through all Proxies in the PersistenceContext. Since we're setting the session to null, do we really need to do this expensive linear search?
> I propose we not perform the linear search if the session being set on the AbstractLazyInitializer is null.

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