I have a user table structured this way
id name email
1 cc [email protected]
2 rr [email protected]
3 cc [email protected]
I am writing a query to save a log when ever it finds an email matching any of the row with the below hql
String hql = "FROM User c WHERE c.email = :email order by c.id";
return (User) _sessionFactory.getCurrentSession().createQuery(hql).setParameter("email", email);
When I run my code I get this error
java.lang.ClassCastException: org.hibernate.internal.QueryImpl cannot be cast to com.models.User
at com.models.UserDao.getByEmail(UserDao.java:62)
.getResultList()at the end of your command.