休眠不等于示例条件 [英] Hibernate not equal example criteria

查看:179
本文介绍了休眠不等于示例条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hibernate有一个示例标准:
例如:

 示例equal = Example.create(mydbObject); 

有没有办法做相反的事情,
例如:

 示例notEqual = Example.createNotEqual(mydbObject); 

或类似的任何东西来创建不相等的条件。

谢谢,

解决方案

我寻找与不等于相同的限制方法,根据文件,它是

  List list = getSession()。createCriteria(you.pakcage.hibernate.Example)
.add(Restrictions.ne(myProperty,blablabla))
.list() ;

通过这种方式您可以撤消包含所有的列表示例 myProperty 属性为< blablabla 的$ c>对象外。

可能并不完全符合你的要求,但它对我来说也是一样。


Hibernate has example criteria: For example:

Example equal = Example.create(mydbObject);

Is there a way to do the opposite, For example:

Example 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 .

这篇关于休眠不等于示例条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆