Skip to content

Instantly share code, notes, and snippets.

@srstsavage
Created January 24, 2014 21:43
Show Gist options
  • Save srstsavage/8607219 to your computer and use it in GitHub Desktop.
Save srstsavage/8607219 to your computer and use it in GitHub Desktop.
HibernateUtil.closeSession
public static void closeSession() {
Session s = threadSession.get();
if( s != null && s.isOpen() && s.getTransaction() != null && s.getTransaction().isActive() ){
rollbackTransaction();
}
threadSession.set(null);
if (s != null ){
if( s.isOpen() ){
s.close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment