开发中遇到的问题---杂项

1、hibernate执行后报错

  2018.03.08-15:17:01 [http-nio-8080-exec-3] ERROR internal.ast.ErrorCounter org.hibernate.hql.internal.ast.ErrorCounter.reportError(ErrorCounter.java:50)  - line 1:23: unexpected token: t_user_statistics

  原因:

try {
            StringBuffer sql = new StringBuffer();
            //查询总用户数
            sql.append(" SELECT c_trueAccountCount FROM t_user_statistics where 1=1");
            
            if(!StringUtil.isNullOrEmpty(endDate)){
                sql.append(" AND c_date = '" + endDate + "'");
            }
            // 执行
            Query query = super.getSessionFactory().getCurrentSession().createQuery(sql.toString());
            return ((Number) query.setMaxResults(1).list().get(0)).intValue();
        } catch (Exception re) {
             log.error(StringUtil.getStackTrace(re));
             return 0;
        }

Sql语句没有加  where 1=1之间加的and

posted @ 2018-03-08 15:25  张小铁  阅读(135)  评论(0编辑  收藏  举报