I have the following Model Activity
with the language-depending property Title
. The language-dependency is defined with two additional entities Translation
(Title is of 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
This works fine so far. But as soon as I add act into the select-statement, I've got a problem with the join of TranslationValuesSet:
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 figure out why Hibernate doesn't like that!?
Thx for any tipps!
... turns out that I need to define an alias for the first join. This does the trick (notice alias title
):
select act from Activity act join fetch act.Title title join fetch title.TranslationValuesSet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With