NHibernate fetch = "join" mapping attribute not working

Matching a dictionary with NH. The declaration is as follows:

<hibernate-mapping ... <map name="CostsByRole" table="JobAccountingSnapshotCosts" lazy="false" fetch="join" access="nosetter.camelcase-underscore"> <key column="SnapshotId" /> <index column="RoleCode" type="String" /> <element column="Amount" type="Decimal" /> </map> </hibernate-mapping> 

I expect one SQL query to be created, but instead I get two: a selection for the actual object, followed by a selection of the contents of the dictionary.

Any ideas?

+4
source share
2 answers

HQL queries do not take into account the values ​​specified for the selection in the mapping. You must specify them exclusively in every HQL query. Its supposedly by design. The value of the selection attribute is used only by Criteria and Load / Get queries.

+6
source

Assuming this is not a typo on presentation, the problem is likely to be part of join="fetch" in your mapping. It should be fetch="join" , and since select is selected for fetch by default, this will lead to your sequential selection problem.

+1
source

All Articles