NHibernate的fetch ="join".映射属性似乎不起作用 [英] NHibernate fetch="join" mapping attribute does not appear to work

查看:78
本文介绍了NHibernate的fetch ="join".映射属性似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用NH映射字典.声明如下:

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>

我希望生成一个SQL查询,但是却得到两个:对实际对象进行选择,然后对字典内容进行选择.

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查询不考虑为映射中的访存设置的值.您需要在每个HQL查询中专门指定它们.据推测是设计使然.提取属性值仅由Criteria查询和Load/Get使用.

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.

这篇关于NHibernate的fetch ="join".映射属性似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆