hibernate中的java条件集参数
我有这张桌子:
合同
|id | personId | initDate | endDate|
当personId>;时,我想在hibernate查询中包含personId;0和/或介于0和/或a之间,日期不同于null
我有:
Query query = session.createQuery("from Contract")
检查条件后如何正确设置参数
public List<Contract> getByPersonIdAndDates(int personId, Date initDate, Date endDate) {
if(personId > 0)
...
if(initDate != null and endDate != null)
...
# 1 楼答案
您需要使用标准。它只是一个模板(不知道如何处理日期)