tags:

views:

289

answers:

2

Hello,

I can't seem to find any solid answer to the problem, I'm hoping someone will be able to help me here.

Sample query:

select * from A a inner join B b on a.Id = b.Id Or a.Date = b.Date

Basically I want to know if it's possible to implement the second part of the join condition using criteria, and if it is possible, how to go about it. If anyone can please let me know, that will be great! Thanks a bunch!

+1  A: 

It might be, but that query is more clear written in HQL:

select a from A a, B b where a.Id = b.Id or a.Date = b.Date

As you can see, it's almost the same as the SQL.

Diego Mijelshon
Although I can't exactly use HQL because of some custom wrapper we put in to alter the result, but it gave me some though on how I can change the way I query it. Thanks for taking the time to answer my question!
Akey
A: 

Unfortunately you cannot define ANSI syntax joins with NHibernate. With NH2 and onward you can define them on HQL using a WITH clause and i say so because if you use Diego's solution you will have to set up a ISNULL OR pattern in your queries if you want to perform multiple joins.

Jaguar