Is there something like Restrictions.eq(true, false) in Criteria API?
Asked Answered
E

3

16

I need a generic Criterion which forces the result to zero matches.

Something like Restrictions.eq(true, false) ?

Erg answered 19/4, 2010 at 11:58 Comment(2)
What kind if criteria are you talking about? What technology? Language? Platform?Archle
Added the java tag for upcoming readers, thank you StefanErg
A
12

I use in NHibernate (C#):

Restrictions.Sql("(1=0)");

or in Hibernate (Java):

Restrictions.sqlRestriction("(1=0)");

:-)

Archle answered 19/4, 2010 at 12:25 Comment(1)
Restrictions.sqlRestriction("(1=0)") seems to do the trick.Anagnorisis
M
6

In Hibernate you might use sqlRestriction:

http://ajava.org/online/hibernate3api/org/hibernate/criterion/Restrictions.html#sqlRestriction(java.lang.String)

Milestone answered 19/4, 2010 at 16:21 Comment(0)
V
0

I used below code in hibernate and it worked for me:

Restrictions.sqlRestriction("1=0")
Victorious answered 7/2, 2017 at 12:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.