How can I write the following SQL using CreateCriteria:
SELECT * FROM FooBar fb
WHERE EXISTS (SELECT FooBarId FROM Baz b WHERE b.FooBarId = fb.Id)
createcriteriaexistsnhibernate
How can I write the following SQL using CreateCriteria:
SELECT * FROM FooBar fb
WHERE EXISTS (SELECT FooBarId FROM Baz b WHERE b.FooBarId = fb.Id)
Best Answer
Here is how you can do it:
...assuming there is a collection property (one-to-many) "Bazs" in the FooBar object.
Alternatively you could use detached criteria like that: