org.hibernate.QueryException:Expected positional parameter count: 1

来源:互联网 发布:zoomla 逐浪cms 编辑:程序博客网 时间:2024/05/02 01:30

org.hibernate.QueryException:Expected positional parameter count: 1  


org.hibernate.QueryException:Expected positional parameter count: 1, actual parameters: [] [from LhClient c where c.wnamw=?]

Query query=session.createQuery("from LhClient c where c.wnamw=?");
query.setString(0, wxy);

在hql语句中有一个占位符“?”,则在query.setParameter()处,一定要有一个相对用的位被传入,否则会出现上述异常



++
1\
String hql="from User where username=? and userpass=?"; 
query.setParameter(0,"乔丹",Hibernate.STRING);  
或者
query.setString(0, "乔丹");
2\
   String hql1="from User where username=:username and userpass=:userpass";  
query1.setParameter("username","乔丹",Hibernate.STRING); 

0 0
原创粉丝点击