在s2sh中遇到的问题 初学者

我就是敲了这些代码之后报的错误

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() + "'";

具体哪里拼错了你调试一下很容易看到。。