org.hibernate.hql.ast.QuerySyntaxException:无法在类上找到合适的构造函数

时间:2014-04-28 11:44:17

标签: java hibernate

下面的hql查询似乎找不到指定的构造函数。 varable匹配的路径和路径。

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,它就可以工作。

任何帮助..PLease ..

1 个答案:

答案 0 :(得分:1)

如果您只想要时间,例如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;
}