[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3383) QueryKey is storing references to entities instead of identifiers

Adrien (JIRA) noreply at atlassian.com
Mon Jan 16 08:06:15 EST 2012


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

Adrien commented on HHH-3383:
-----------------------------

There is the same problem with composite-id with a key-many-to-one. The primary key contains an entity that is kept in memory in the cache key. At least in version 3.6.9.


> QueryKey is storing references to entities instead of identifiers
> -----------------------------------------------------------------
>
>                 Key: HHH-3383
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3383
>             Project: Hibernate ORM
>          Issue Type: Improvement
>          Components: caching (L2)
>    Affects Versions: 3.3.0.CR1
>         Environment: ehcache 1.5.0b2
>            Reporter: Manuel Dominguez Sarmiento
>            Assignee: Steve Ebersole
>             Fix For: 3.2.7, 3.3.2, 3.5.0.Beta-1
>
>         Attachments: HHH-3383.patch
>
>
> Context: query caching
> Hibernate is storing full entity references when building QueryKeys and the query has restrictions which reference entities. This happens either with Criteria or HQL queries.
> Although this is not incorrect, when the referenced entities reference in turn "heavy" object graphs, this causes a very significant memory usage increase, since references to detached entities will remain in the cache. This is even more evident when using disk persistence with ehcache, since the full object graphs are serialized to disk.
> This could be easily improved (correct me if I'm wrong) by storing ONLY entity identifiers in the QueryKey instead of full entities, since all the query really needs is the identifier property. The memory usage would decrease dramatically.
> So far the workaround we've found is explicitly using restrictions that reference identifiers instead of properties in HQL queries, however this is not particularly elegant, and still leaves open the issue with Criteria queries. The same cannot be done without criteria.createCriteria() which generates an unnecessary join in most cases.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list