Add session rollback handling in Connection.java, improve resource management, and refine debug logging in LoginController.
This commit is contained in:
@@ -97,10 +97,20 @@ public class Connection {
|
||||
sqlSessionFactory = createSqlSessionFactory(settings, addMappers);
|
||||
}
|
||||
|
||||
try (SqlSession session = sqlSessionFactory.openSession()) {
|
||||
SqlSession session = null;
|
||||
try {
|
||||
session = sqlSessionFactory.openSession();
|
||||
consumer.accept(session);
|
||||
session.commit();
|
||||
} catch (Exception e) {
|
||||
if (session != null) {
|
||||
session.rollback();
|
||||
}
|
||||
log.error("Failed to run query", e);
|
||||
} finally {
|
||||
if (session != null) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user