簡體   English   中英

Hibernate HQL找不到命名參數

[英]Hibernate HQL could not locate named parameter

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM