在hibernate中通过CriteriaAPI实现以下条件逻辑
我有一个pojo类名teedObject 它由以下属性、getter和setter组成,如下所示 此pojo通过hibernate映射到名为boa_rep_dect的表在hibernate中通过CriteriaAPI实现以下条件逻辑,hibernate,hql,criteria,Hibernate,Hql,Criteria,我有一个pojo类名teedObject 它由以下属性、getter和setter组成,如下所示 此pojo通过hibernate映射到名为boa_rep_dect的表 class teedObject { private long abcID ; private String syncSystem ; private String hookId; //and consisits of setters and getters } 现在我想通过条件实现下面的
class teedObject
{
private long abcID ;
private String syncSystem ;
private String hookId;
//and consisits of setters and getters
}
现在我想通过条件实现下面的查询
select abc_id, count(*) from boa_rep_deed where sync_system = ? And hook_id = ? group by abc_id order by abc_id
如图所示,同步系统将由用户输入,钩子id也将由用户输入
请告知如何通过标准来实施这一点
我提出了以下方法,请告知
List<teedObject> hytlow = null;
Criteria criteria = session.createCriteria(teedObject.class);
criteria.add(Restrictions.ne("abcID ", abcID));
criteria.add(Restrictions.eq("syncSystem", syncSystem));
criteria.add(Restrictions.eq("hookId", hookId));
hytlow = criteria.list();
你试过什么?您是否阅读过文档,其中有几个类似查询的示例@JBNizet你能看到我更新后的订单也可以这样解决…addOrder(Order.asc(“abc_id”);我发布了一个链接,指向文档中解释如何做到这一点的部分。读一下。
select abc_id, count(*) from boa_rep_deed where sync_system = ? And hook_id = ? group by abc_id order by abc_id