Hi there,
the enclosed code always throws the exception java.lang.ClassCastExceptionon line
resultSet = (Systemuser) query.uniqueResult();
Could you please give me some ideas?
Any advice is highly appreciated.
Lamborghini
Code:
public Systemuser login(String userName, String password) {
Session session = null;
Transaction tx = null;
Systemuser systemuser= null;
try {
session = HibernateSessionFactory.currentSession();
tx = session.beginTransaction();
Query query = session
.createQuery("from Systemuser where username = :UserName and pin = :Password");
query.setParameter("UserName", userName);
query.setParameter("Password", password);
systemuser= (Systemuser) query.uniqueResult();
tx.commit();
} catch (HibernateException he) {
he.printStackTrace();
if (tx != null)
try {
tx.rollback();
} catch (HibernateException he1) {
he1.printStackTrace();
}
} finally {
try {
if (session != null)
session.close();
} catch (HibernateException he1) {
he1.printStackTrace();
}
}
return systemuser;
}