My update code as follow :
Session session = HibernateUtil.currentSession();
try {
HibernateUtil.beginTransaction();
session.saveOrUpdate(pojo);
HibernateUtil.commitTransaction();
} catch (HibernateException e) {
throw new InfrastructureException(e);
} finally {
HibernateUtil.closeSession();
}
when I update pojo, system throws :
org.hibernate.SessionException: Session is closed
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:131)
at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:119)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:95)
at com.muyi.hibernate.session.HibernateUtil.commitTransaction(HibernateUtil.java:120)
at com.muyi.hibernate.dao.AbstractDao.update(AbstractDao.java:60)
......
I have confirmed that my logic has no problems , so I don't understand what's problems cause that. Are there anyone had met this problem ??
oh God, help me......
|