We have standard web application with Hibernate. We use TreaLocal pattern. Our standard scenario:
Code:
Session session = ....getSession();
try {
.
.
session.update(MyObject);
.
.
session.save(MyObject);
.
.
session.flush();
session.getConnection.commit();
} catch (Exception e) {
session.getConnection().rollback();
}
Are there some differencies, when I will use transaction ? For example:
Code:
Session session = ....getSession();
Transaction tr = session.beginTransaction();
try {
.
.
session.update(MyObject);
.
.
session.save(MyObject);
.
.
session.flush();
tr.commit();
} catch (Exception e) {
tr.rollback();
}