以下HQL的标准表示

时间:2013-09-06 00:23:34

标签: hibernate criteria

我在sql后面有以下HQL ..

SQL ....

SELECT * FROM POS_took WHERE DELETEDDATE IS NOT NULL 

它对应的HQL是......

session.createQuery("from postook where deleted is not null")

和java Entity类是......

class postook
{

//all the properties defined here 

private DateTime deleted;

//and it corresponding setters and getters is defined.

现在请告知上述HQL的等效标准表示

1 个答案:

答案 0 :(得分:2)

Criteria criteria = getSession().createCriteria(postook.class);
criteria.add(Restrictions.isNotNull("deleted"));

详情请见http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch12.html