Hibernate Criteria: Left Outer Join with restrictions on both tables

陌路散爱 提交于 2019-12-01 03:59:16

You can specify left outer join in the createalias...

.CreateAlias("products", "p", NHibernate.SqlCommand.JoinType.LeftOuterJoin)
.Add(Restrictions.Eq("p.inventedName", inventedName));

Be aware that you are doing a left outer join with a restriction on that column...essentially making it an inner join. If you also want applicants without products then you'll have to check for null product too.

Update:

.CreateAlias("products", "p", JoinType.LEFT_OUTER_JOIN)
.Add(Restrictions.Eq("p.inventedName", inventedName));

I solved this my problem creating a new criteria and I could use LEFT_OUTER_JOIN in both cases.

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