How to join Two tables of two non relashinship defined columns using Nhibernate QueryOver

爱⌒轻易说出口 提交于 2019-11-27 16:27:09
Radim Köhler

There are similar questions, e.g.

And the answer is:

  1. either use HQL and CROSS JOIN (with WHERE)
  2. There is NO way how to do that with QueryOver/Criteria)

See the doc:

14.2. The from clause

Multiple classes may appear, resulting in a cartesian product or "cross" join.

from Formula, Parameter

from Formula as form, Parameter as param

So using HQL in your case, we can do it like this:

SELECT ...
FROM EMPLOYEE E, DEPARTMENT D 
WHERE D.Code = E.SomeCode
...

BUT I would suggest: create that mapping in the code. Simply introduce many-to-one relation. It will be loaded lazily (only if used) and will nicely serve to our needs - be used in QueryOver as a relation for Join

If there is such relation, if this exist in the business object domain, we should not be scared to use it. We can hide it via security etc...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!