编写条件/ hibernate查询的问题?

时间:2014-05-06 09:40:19

标签: hibernate criteria hibernate-criteria

我们如何在条件查询和hibernate查询中编写以下sql查询?

接下来是

sql查询,

SELECT * FROM table1 ORDER BY testId DESC LIMIT 1;

我写了如下,

Criteria tobaccoID = sessionFactory.getCurrentSession().createCriteria(table1.class);
tobaccoID.add(Restrictions.eq("surveyId",send_Survey));
tobaccoID.addOrder(Order.desc("testId")); // How can I specify the limit 1 here
tobaccoID.add(Restrictions.eq("algorithmno", lifeStyleHabbitsOne));
tobaccoID.add(Restrictions.eq("stringno", "01"));
ScrollableResults tobaccoIDP=tobaccoID.scroll();

但我不知道如何设置限制。

任何建议。

0 个答案:

没有答案
相关问题