Hibernate not equal example criteria
Hibernate has example criteria: For example:
Example equal = Example.create(mydbObject);
Is there a way to do the opposite, For example:
E开发者_如何学Goxample notEqual = Example.createNotEqual(mydbObject);
or anything similar that to create a not equal criteria. I don't want to go through each fields and not Restrictions.ne on it.
Thanks,
I looking for the same restriction method for "not equal" and according to the document, it's
List list = getSession().createCriteria("you.pakcage.hibernate.Example")
.add(Restrictions.ne("myProperty","blablabla"))
.list();
by this way you retreat a list contain all the Example
object except those whose myProperty
property is "blablabla
".
May be not exactly what you what, but it achieve the same thing for me .
Use it with s.createCriteria(YourClass.class).add(Restrictions.not(notEqual));
.
Criteria cri = session.createCriteria(Your.class);
cri.add(Restrictions.not(Restrictions.eq("parameter", "test")));
-- Restrictions.not will be negation of the expression
精彩评论