gpt4 book ai didi

java - Hibernate HQL 无法找到命名参数

转载 作者:行者123 更新时间:2023-12-02 02:42:11 25 4
gpt4 key购买 nike

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

关于java - Hibernate HQL 无法找到命名参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45281272/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com