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