超级无敌美少女二宝 2013-06-26 10:16 采纳率: 100%
浏览 2369
已采纳

在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条回答

  • 天太长 2013-06-27 10:19
    关注

    hql语句拼错了啊。。

    感觉应该是

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

    这句或许该改成

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

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?