[hibernate-issues] [Hibernate-JIRA] Created: (HHH-4071) Need for a new -to-many fetch mode, retrieving children ids only (otherwise L2 cache is poorly used when retrieving collections of cached objects)

Yannick le Restif (JIRA) noreply at atlassian.com
Wed Aug 5 11:11:12 EDT 2009


Need for a new -to-many fetch mode, retrieving children ids only (otherwise L2 cache is poorly used when retrieving collections of cached objects)
--------------------------------------------------------------------------------------------------------------------------------------------------

                 Key: HHH-4071
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4071
             Project: Hibernate Core
          Issue Type: Improvement
          Components: caching (L2)
    Affects Versions: 3.3.0.SP1
         Environment: hibernate : 3.3.0
database : probably not pertinent (sybase 12.5)
            Reporter: Yannick le Restif


The proposed improvement  is a -to-many association fetch mode (maybe lazy mode) where only children ids would be fetched when we fetch the collection, rather than whole children entities, as it is the case now.

Suppose we use a second level cache for children entities, and that we warm this cache up at application start : We will still fetch these children entites each time we fetch a collection of such entities, althought all of them were available in the second level cache !
Of course using a collections cache helps a bit, but only a bit, because of course we will then fetch a *given* collection only once, but that could still mean a lot of unnecessary entity fetching if one entity is in many collections.

With the new fetch mode proposed, we would only fetch the children ids list, and then get the entities one by one lazily, allowing for using the cache, so the only SQL generated would for example be if we are fetching Bids for an Item :
SELECT bids.id FROM bids WHERE bids.item_id = 123
instead of
SELECT bids.id, bids.user, bids.date, ... FROM bids WHERE bids.item_id = 123

If the collection itself is cached, the result can be cached as the collection value (L2 collections cache only contains collections of ids, if I'm not mistaking...?)
The mode could then also be used warm collections caches up.

Maybe there is a way to get around this, but I found neither that was satisfactory.
The "best" I found is to link the father entity to a collection of "id entities", themselves linked (one-to-one) to the "real", big entity. But this is not handy.


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