Hi All,
I'm having some problems with function session.openSession()
It doesn't open any session!?
Here is the code I have at the moment:
The currentSession() is called from listUser() function.
public static Session currentSession() throws HibernateException {
Session s = session.get();
//Open a new Session, if this Thread has none yet
if (s == null) {
s = sessionFactory.openSession(); <-- here is the problem...
session.set(s);
}
return s;
}
public static List<user> listUser(){
Session session = null;
Transaction tx = null;
try {
session = currentSession(); <-------it always jumps to" finally" closing the session?!
tx = session.beginTransaction();
List list = session.createQuery("from user").list();
tx.commit();
return list;
} catch (RuntimeException ex) {
if (tx != null) {
tx.rollback();
}
throw ex;
} finally {
userUtil.closeSession();
}
}
What seems to be a problem..... Any ideas?
The sessionFactory.openSession(); always fails!
Thanks
Greg.
|