[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3414) fetch profiles

Tedi Zanfolim (JIRA) noreply at atlassian.com
Wed Feb 8 19:46:10 EST 2012


    [ https://hibernate.onjira.com/browse/HHH-3414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45426#comment-45426 ] 

Tedi Zanfolim commented on HHH-3414:
------------------------------------

FetchProfiles won't work if multiple fetchOverrides referring to multiple bags are specified. It seems multiple bags are not supported in the join strategy, which is probably a bad idea since it might cause a huge Cartesian product. Anyway, it would be nice to get an error message, instead of only the first collection getting loaded.

For the record, the mapping below will just load roles, without ever complaining that emails won't be eagerly loaded.

@FetchProfile(name = "Person-all", fetchOverrides = {
				@FetchProfile.FetchOverride(entity = Person.class, association = "roles", mode = FetchMode.JOIN),
				@FetchProfile.FetchOverride(entity = Person.class, association = "emails", mode = FetchMode.JOIN),



> fetch profiles
> --------------
>
>                 Key: HHH-3414
>                 URL: https://hibernate.onjira.com/browse/HHH-3414
>             Project: Hibernate ORM
>          Issue Type: New Feature
>          Components: core, metamodel
>            Reporter: Steve Ebersole
>            Assignee: Steve Ebersole
>
> The concept of fetch profiles as we are discussing here is basically to allow users to dynamically affect the mapped fetching strategy for associations at runtime.
> Consider the following example:
> <class name="Person">
>     ...
>     <set name="addresses" lazy="true" fetch="subselect" ...>
>         ...
>     </set>
> </class>
> <class name="Address">
>     ...
> </class>
> This follows the normal recommendation to map associations as lazy and use a dynamic fetching strategy (ala HQL/Criteria) to modify this lazy behavior at runtime.
> The fetaure discussed here would allow the same behavior for loading as well:
> <hibernate-mapping>
>     <fetch-profile name="person-details">
>         <fetch path="Person.addresses" style="join"/>
>     </fetch-profile>
> </hibernate-mapping>
> Or:
> <hibernate-mapping>
> <class name="Person">
>     ...
>     <fetch-profile name="person-details">
>         <fetch path="addresses" style="join"/>
>     </fetch-profile>
>     <set name="addresses" lazy="true" fetch="subselect" ...>
>         ...
>     </set>
> </class>
> </hibernate-mapping>
> Now, doing:
> session.enableFetchProfile( "person-details" ).get( Person.class, 1 )...
> will load Person#1 as well as their addresses in a single joined query.

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