[英]Create join using criteria in nHibernate
Using nHibernate criteria, I want to create a join between two entities which have a foreign key relationship but do not have entity relationship. 使用nHibernate标准,我想在两个具有外键关系但不具有实体关系的实体之间创建联接。
EmployerEntity 雇主实体
LocationEntity 位置实体
SQL equivalent query is SQL等效查询为
Select EMP.EMP_Name from TBL_EMP as EMP inner join TBL_LOC as LOC on EMP.EMP_ID = LOC.EMP_ID 从TBL_EMP中选择EMP.EMP_Name作为EMP内部连接TBL_LOC作为EMP上的LOC.EMP_ID = LOC.EMP_ID
It's not designed to work this way. 它并非旨在以这种方式工作。 Why are you not including the entity relationship?
为什么不包括实体关系?
If the relationship was clearly out of the question you could potentially use a cartesian product instead of a join. 如果关系显然不可行,则可以使用笛卡尔积而不是联接。
select emp.EmployerName
from Employer as emp, Location as loc
where emp.EmployerID = loc.EmployerID
HQL reference: http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-from HQL参考: http : //docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-from
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.