我就是敲了這些代碼之後報的錯誤
private String getCondition() {
String whereHQL = "";
if (messagestatisticsForm.getSendMobileID() != null) {
whereHQL = " where sendMobileID="
+ messagestatisticsForm.getSendMobileID();
}
if (!StringUtils.isBlank(messagestatisticsForm.getCreateTimeStart())) {
if ("".equals(whereHQL)) {
whereHQL = " where createTimeStart>='"
+ messagestatisticsForm.getCreateTimeStart() + "'";
} else {
whereHQL = " and createTimeStart>='"
+ messagestatisticsForm.getCreateTimeStart() + "'";
}
}
if (!StringUtils.isBlank(messagestatisticsForm.getCreateTimeEnd())) {
if ("".equals(whereHQL)) {
whereHQL = " where createTimeEnd<='"
+ messagestatisticsForm.getCreateTimeEnd() + "'";
} else {
whereHQL = " and createTimeEnd<='"
+ messagestatisticsForm.getCreateTimeEnd() + "'";
}
}
// whereHQL += " order by id";
return whereHQL;
}
控制台中報的錯誤
ERROR [org.hibernate.hql.PARSER] - line 1:56: unexpected token: and
hql語句拼錯了啊。。
感覺應該是
else {
whereHQL = " and createTimeStart>='"
+ messagestatisticsForm.getCreateTimeStart() + "'";
}
這句或許該改成
whereHQL+=" and createTimeStart>='"
+ messagestatisticsForm.getCreateTimeStart() + "'";
具體哪裡拼錯了你調試一下很容易看到。。