Join Fetch: "The request selected to connect, but the owner of the selected association was

I have the following Activity model with the Title language property. Language dependency is defined by two additional Translation objects (the name has this type, many-to-one) and TranslationValue (one-to-many).

If I write the following hql:

 from Activity act join fetch act.Title join fetch act.Title.TranslationValuesSet 

So far this is wonderful. But as soon as I add an action to the select-statement, I have a problem with the TranslationValuesSet connection:

 select act from Activity act join fetch act.Title join fetch act.Title.TranslationValuesSet 

NHibernate.QueryException: Query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=,role=Translation.TranslationValuesSet,tableName=TranslationValue,tableAlias=translatio3_,origin=Translation translatio2_,colums={translatio2_.TranslationId ,className=TranslationValue}}] [select act from Activity act join fetch act.Title join fetch act.Title.TranslationValuesSet

I can’t understand why Hibernate doesn't like this !?

thanks for any tips!

+8
nhibernate hql
source share
1 answer

... it turns out that I need to define an alias for the first connection. This does the trick (see the Alias title ):

 select act from Activity act join fetch act.Title title join fetch title.TranslationValuesSet 
+9
source share

All Articles