下面的 hql 查询似乎没有找到指定的构造函数。变量的路径和编号匹配。
List<ServiceRuleVO> serviceRules = session.createQuery("select new com.xxx.modules.service.valueobject.ServiceRuleVO(id, serviceTypeId, "
+ "petLocationId, startDate, startTime, endDate, endTime, status, recurFrequency, recurCount, recurInterval, "
+ " recurByDays, recurByMonths, recurByMonthDay, billable, payable, modifiedBy, modifiedTime) from ServiceRule where "
+ "(startDate<=:toDate and (endDate>=:fromDate or endDate=:neverEndDate)) "
+ "or (id in (select distinct serviceRuleId from ServiceException where "
+ "(startDate>=:fromDateIntSE and startDate<=:toDateIntSE) or "
+ "(startDate<:fromDateIntSE1 and endDate between :fromDateIntSE2 and :toDateIntSE2)))")
.setParameter("toDate", toDate)
.setParameter("fromDate", fromDate)
.setParameter("neverEndDate", neverEndDate)
.setParameter("fromDateIntSE", fromDateInt)
.setParameter("toDateIntSE", toDateInt)
.setParameter("fromDateIntSE1", fromDateInt)
.setParameter("fromDateIntSE2", fromDateInt)
.setParameter("toDateIntSE2", toDateInt)
.list();
ServiceRuleVO 构造函数是
public ServiceRuleVO(int id, int serviceTypeId, int petLocationId,
Date startDate, Time startTime, Date endDate, Time endTime, int status, String recurFrequency,
int recurCount, int recurInterval, String recurByDays,
String recurByMonths, int recurByMonthDay, int billable, int payable,
int modifiedBy, int modifiedTime) { ... }
如果从 SQL 和构造函数中删除时间变量 starttime 和 end time,它就会起作用。
任何帮助..请..
最佳答案
如果您只想要时间,例如 09:56:20,
您可以使用 java.util.Date,并使用 TemporalType.TIME,如下所示
@Temporal(value = TemporalType.TIME)
@Column(name = "START_TIME")
public Date getStartTime () {
return startTime;
}
@Temporal(value = TemporalType.TIME)
@Column(name = "END_TIME")
public Date getEndTime () {
return endTime;
}
关于java - org.hibernate.hql.ast.QuerySyntaxException : Unable to locate appropriate constructor on class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23340199/