2 u011215281 u011215281 于 2013.06.26 18:16 提问

在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

1个回答

u010982200
u010982200   2013.06.27 18:19
已采纳

hql语句拼错了啊。。

感觉应该是

else {
        whereHQL = " and createTimeStart>='"
                + messagestatisticsForm.getCreateTimeStart() + "'";
    }

这句或许该改成

whereHQL+=" and createTimeStart>='"
                + messagestatisticsForm.getCreateTimeStart() + "'";

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

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!