A transaction is an atomic unit of work. There are only two outcomes, either success or failure. In hibernate one way to manage transactions is as given below.
Session session = null;
Transaction tx = null;
try {
session = sessionFactory.openSession();
tx = session.beginTransaction();
//perform the transactions here
// some more transactions
tx.commit();
} catch (RuntimeException ex) {
tx.rollback();
} finally {
session.close();
}