[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3808) Manual fetching of associations

Ovidio Mallo (JIRA) noreply at atlassian.com
Mon Mar 9 17:01:38 EDT 2009


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

Ovidio Mallo commented on HHH-3808:
-----------------------------------

Shawn, I guess we are talking about the same thing but just to be sure, I'll make a little example using the classical Item entity which has a set of Bids associated to it.

Assume I have already somehow (no matter how!) loaded a set of Items from the database:
    Item[] items = ...;

Then, in a second step, if I want to load the Bids of *exactly* those items, this is not always possible with subselect fetching or batch fetching since the existing fetching strategies depend on how the Item entities have been retrieved from the database. Using the suggested API, retrieving the Bids (and associating them to their respective parent Items for later usage!) of a user-defined set of Items could be accomplished as follows (the suggested API is really just an example):
    mySession.fetch(Item.class, items, "bids");

It's really just a matter of having full control about the set of Item entities on which the Bids collections are loaded which is very valuable when it comes to improving performance. I think something similar cannot be accomplished with the current API.

Please let me know whether I need to be more precise since I'm rather new to Hibernate so I might not express things clear enough.

> Manual fetching of associations
> -------------------------------
>
>                 Key: HHH-3808
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3808
>             Project: Hibernate Core
>          Issue Type: New Feature
>          Components: core
>            Reporter: Ovidio Mallo
>
> In performance critical parts of an application, batch fetching and subselect fetching not always allow for an efficient and specific prefetching of entity associations. Therefore, I wanted to propose to add some API which allows to prefetch a given association for a user defined set of entities. This could be something like
>     Session#fetch(Class ownerClass, Serializable[] ownerIds, String propertyName)
> or
>     Session#fetch(Class ownerClass, Object[] owners, String propertyName)
> or something similar. The method would then load the association for the given entities (just like batch fetching would do) and put the associations in the session cache for later usage.
> I think this would greatly help when performance really matters and you want to have full control about the set of entities on which an association is fetched.

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