I have a persistent class Author
with two fields: int id
, String name
.
Problem is that whenever I execute query this way:
Session s = HibernateUtil.getSessionFactory().getCurrentSession();
s.beginTransaction();
Query q = s.createQuery("from Author");
return (Author)q.list().get(0);
It works fine and returns me an Author object with filled fields. But whenever I try to put a condition in my query, for example:
Session s = HibernateUtil.getSessionFactory().getCurrentSession();
s.beginTransaction();
Query q = s.createQuery("from Author a where a.id=41");
return (Author)q.list().get(0);
my application crashes down. This is the top most error that I receive in error stack:
java.lang.reflect.UndeclaredThrowableException
at $Proxy0.createQuery(Unknown Source)
Please help me, it has taken me more than 3 hours but I am upto no solution yet. Thanks.