Skip to content

Commit

Permalink
transaction closing and cleanup improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Dec 12, 2018
1 parent e79339f commit 3d3efd2
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -102,7 +102,7 @@ public Session beginTransaction(boolean readOnly) {
session.setHibernateFlushMode(FlushMode.MANUAL);

LOGGER.trace("Marking transaction as read only.");
session.doWork(connection -> connection.createStatement().execute("SET TRANSACTION READ ONLY"));
session.doWork(connection -> connection.createStatement().execute("SET TRANSACTION READ ONLY"));
}
return session;
}
Expand Down Expand Up @@ -135,6 +135,10 @@ void rollbackTransaction(Session session, Throwable ex, String message, Operatio
}

public void cleanupSessionAndResult(Session session, OperationResult result) {
if (session != null && session.getTransaction().isActive()) {
session.getTransaction().commit();
}

if (session != null && session.isOpen()) {
session.close();
}
Expand Down

0 comments on commit 3d3efd2

Please sign in to comment.