I want to make sure I am handleing transactions properly. I was hoping to find an SLSB example in caveat emptor (using the hibernate integration code, but I didn't see any).
Right now I'm basically doing this inside an SLSB method:
Code:
Transaction tx = null;
try {
Session sess = HibernateContext.getSession(DBO_SESSION);
sess.save(order);
} catch (HibernateException e) {
throw new DataStoreException(e.getMessage(), e);
}
What I'd like to know is, how to I latch on to the containers transaction to do a rollback, given that you don't use sessiong.beginTransaction with CMT?
When a hibernate exception is thrown, I want to rollback the work I did. Will the container handle this automatically somehow? I'm basically just looking for an example of the proper way to roll back a unit of work with CMT & hibernate, when a hibernate exception is thrown.