Hi Maarten:
Code:
Session sess = factory.openSession();
Transaction tx = null;
try {
tx = sess.beginTransaction();
// do some work
...
tx.commit();
}
catch (Exception e) {
if (tx!=null) {
try{
tx.rollback();
}
catch(Exception e){
log.warn("Exception Occured when rolling back" ,e);
}
}
finally {
sess.close();
}
It could be done this way too. I think it really depends on how you wanted your layer to behave.
What I feel about the documentation is , it is meant to give you an idea how to implement.
Anyways Hibernate guys correct me if I am wrong