Hi,
Can someone please help me with this "Session is closed" exception"?
I am trying to write the change of my User class to the database, like this:
Code:
UAProfile profile = getCurrentProfile();
UAProfile profile2 = findCurrentProfile();
UserProfileDAO usdao = new UserProfileDAO();
profile2.setScreenHeight(profile.getScreenHeight());
usdao.makePersistent(profile2);
HibernateUtil.commitTransaction();
And in the findCurrentProfile(), I open and close the session. Why I get teh Session is closed exception? Can someone please help?
Thank you.
Code:
private UAProfile findCurrentProfile() {
UserProfileDAO userProfileDao = new UserProfileDAO();
try {
UAProfile ua = userProfileDao.getUAProfileByName(getPath());
return ua;
} catch (HibernateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
HibernateUtil.closeSession();
} catch (HibernateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}
Code:
net.sf.hibernate.HibernateException: Session is closed
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3339)
at net.sf.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:86)
at db.HibernateUtil.rollbackTransaction(HibernateUtil.java:207)
at db.HibernateUtil.commitTransaction(HibernateUtil.java:192)
at net.sf.tacos.demo.tree.fs.FileTreePage.change(FileTreePage.java:136)