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();


有什么不见了???我要设置的两个参数均为字符串类型,请帮助...

最佳答案

尝试删除参数上的单引号

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();

10-06 10:55