如何使用实体查询框架来建模以下查询

时间:2010-08-30 17:13:08

标签: hibernate orm jpa seam hql

我们有一个查询,需要检查某个整数字段点是否为空,以及约会日期是否在当前日期之前?如何为上述场景编写限制表达式?

@Entity
public class User {

...
Integer points;
Date appointmentDate;
...
}

1 个答案:

答案 0 :(得分:4)

如果使用Hibernate

<framework:hibernate-entity-query name="requiredList" scope="conversation" ejbql="from User u where u.appointmentDate < current_date and u.points is not null"/>

如果使用JPA

<framework:entity-query name="requiredList" scope="conversation" ejbql="from User u where u.appointmentDate < current_date and u.points is not null"/>