1. Session was already closed exception when using hibernate
This exception occurs because the session has been closed
If you are not using the sessionfactory.getsession () to get the session.
Instead of using the Sessionfactory.getcurrentsession () method to get the session, Hibernate automatically closes the session when the transaction ends, whether it is committing or rolling back.
So do not need to shut down manually.
public boolean insert (Liftinfo Liftinfo) {Session session = Hibernateutil.currentsession (); Transaction tr = null;try {tr = session.begintransaction (); Session.save (Liftinfo); Tr.commit (); System.out.println ("Add success:");} catch (Hibernateexception e) {//TODO auto-generated catch Blocktr.rollback (); System.out.println ("Add failed"); E.printstacktrace (); return false;} finally {hibernateutil.closesession ();//here if Session.close () is written, error}return true;}