16

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

Something like Restrictions.eq(true, false) ?

Christopher Klewes
  • 11,181
  • 18
  • 74
  • 102

3 Answers3

12

I use in NHibernate (C#):

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

or in Hibernate (Java):

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

:-)

Stefan Steinegger
  • 63,782
  • 15
  • 129
  • 193
6

In Hibernate you might use sqlRestriction:

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

Behrang
  • 46,888
  • 25
  • 118
  • 160
0

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

Restrictions.sqlRestriction("1=0")
S'chn T'gai Spock
  • 1,203
  • 18
  • 16