Saturday, 7 September 2013

org.hibernate.QueryParameterException: could not locate named parameter [userId]

org.hibernate.QueryParameterException: could not locate named parameter
[userId]

I need help, I am getting the aforementioned exception. Where am I going
wrong? In the mapping from class to table, I have used the following:
private String userId; private String password;
Below is the class where I write my query.
public class LoginManager extends HibernateUtil { private String loginId;
public String checkCredentials(String userId, String password) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
try {
loginId = (String) session.createQuery("select user_id from
com.project.model.Login where user_id=:userId and password=:password")
.setParameter("userId",userId).setParameter("password",
password).list().toString();
} catch (HibernateException e) {
e.printStackTrace();
session.getTransaction().rollback();
}
session.getTransaction().commit();
return loginId;
}
}

No comments:

Post a Comment