【发布时间】:2011-05-23 01:51:08
【问题描述】:
你好 我有这样的映射:
<class entity-name="Person">
<id name="id" type="long" column="ID">
<generator class="sequence"/>
</id>
<property name="FirstName" column="FIRST_NAME" type="string"/>
<property name="LastName" column="LAST_NAME" type="string"/>
<bag name="Addresses" inverse="true" lazy="false" cascade="all"> <key column="Person_ID"/>
<one-to-many class="Address"/> </bag>
<class entity-name="Address">
<id name="id" type="long" column="ID">
<generator class="sequence"/>
</id>
<property name="City" column="City" type="string"/>
<property name="Country" column="Country" type="string"/>
<property name="PersonId" column="Person_ID" type="long"/>
</class>
我需要找到所有住在巴黎的人。为此,我使用类似的查询 select p from Person p inner join Address a on p.Id=a.PersonId where a.City like 'Paris' 没关系。 但是 Nhbernate 执行另一个查询,从 Address a where a.PersonId in 中选择一个(所有住在巴黎的人的 id) 但没必要,山NHibernate可以从join(first query)中获取Address的所有字段
我可以阻止运行第二个查询并从第一个查询中获取所有需要的信息吗????
【问题讨论】:
标签: nhibernate nhibernate-mapping