【发布时间】:2013-06-04 13:31:37
【问题描述】:
NHibernate 为什么要翻译这个 HQL:
select count(*) from TeacherResource as tr
inner join fetch tr.Product as pr
where pr.CatalogTitle like '%ame%'
进入这个无效的 SQL(包括 where 子句但省略了表连接):
select count(*) as col_0_0_
from TeacherResources teacherres0_
where product1_.CatalogTitle like '%ame%'
以及如何执行符合预期的计数?
这是实体的相关部分:
Public Class TeacherResource
Public Overridable Property TeacherResourceId As Guid
Public Overridable Property Product As BvCustomProduct
End Class
和映射:
<class name="TeacherResource" table="TeacherResources">
<id name="TeacherResourceId">
<generator class="guid"/>
</id>
<many-to-one name="Product" column="ProductBvin"/>
</class>
【问题讨论】:
-
我们可以看看你的映射吗?
tr.Product是收藏吗? -
这是一个单一的实体。我已经添加了映射。
标签: nhibernate hql