如何使用实体查询框架对以下查询进行建模

Posted

技术标签:

【中文标题】如何使用实体查询框架对以下查询进行建模【英文标题】:How to use the entity query framework to model the following query 【发布时间】:2010-08-30 17:13:07 【问题描述】:

我们有一个查询,需要检查某个整数字段点是否不为空,以及约会日期是否早于当前日期?上述场景的限制表达式怎么写?

@Entity
public class User 

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

【问题讨论】:

【参考方案1】:

如果使用休眠

<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"/>

【讨论】:

以上是关于如何使用实体查询框架对以下查询进行建模的主要内容,如果未能解决你的问题,请参考以下文章