Mapping a dictionary with NH. 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 am expecting a single SQL query to be generated but instead I get two: a select for the actual object, followed by a select for the contents of the dictionary.
HQL queries do not consider the values set for fetch in the mapping. You need to specify them exclusively in each HQL query. Its supposedly by design. The fetch attributes value is used only by Criteria queries and by Load/Get.