1) You are using HQL, so you need to understand that you cannot specify the names of columns that are in the database in the projections of the HQL query
String hql = "select user_id from login where user_name= :username and password= :password";
Here, in your Login class, you don't have a field like user_id , and you gave user_id to the predictions. HQL maps the class to the database, so the Login class will have an entry table, and the userId field will have the user_id field in the database. And what you wrote is a simple SQL query, not a HQL query.
Please use this HQL query.
String hql="Select log.userId from Login log where log.username=:username and log.password=:password"
Here log is an alias, as in normal Java.
Login log=new Login() log.userId
source share