users = (List<User>) currentSession.getCurrentSession().createQuery("FROM User as u "
+ " LEFT JOIN FETCH u.tests as p"
+" WHERE u.registrationDate BETWEEN "
+"':tenDaysBeforeDate' AND ':currDate' "
+"ORDER BY u.registrationDate DESC").setParameter("tenDaysBeforeDate", tenDaysBeforeDate).setParameter("currDate", currDate).list();
缺少什么?我试图设置的参数都是字符串类型,请帮助...
答案 0 :(得分:2)
尝试删除参数上的单引号
users = (List<User>) currentSession.getCurrentSession().createQuery("FROM User as u "
+ "LEFT JOIN FETCH u.patients as p "
+"WHERE u.registrationDate BETWEEN "
+":tenDaysBeforeDate AND :currDate "
+"ORDER BY u.registrationDate DESC").setParameter("tenDaysBeforeDate", tenDaysBeforeDate).setParameter("currDate", currDate).list();