【发布时间】:2011-08-01 10:43:04
【问题描述】:
public class Entity {
private boolean suspended;
private String code;
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@DateTimeFormat(style = "S-")
private DateTime validFrom;
@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
@DateTimeFormat(style = "S-")
private DateTime validTill;
}
查询含义:“代码在给定时间内是否唯一有效?”
如何重写这个查询:
select count(o) from Entity o
where o <> :this and o.code = :code and (
(o.validFrom between :validFrom and :validTill and not o.suspended) or
(o.validTill between :validFrom and :validTill and not o.suspended) or
(:validFrom between o.validFrom and o.validTill and not o.suspended)
)
【问题讨论】:
标签: jpa criteriaquery