Hi,
It seems that @UnitOfWork can only be applied to resource methods. This means that if the transaction fails, there's nowhere for me to catch whatever exception is thrown (because it's DW that's invoking my method). This gives me no control over what I return to users.
What's the proper way to fix this? One thing I've tried is creating the session and transaction explicitly:
try (Session session = fooDao.factory.openSession()) {
Transaction transaction = session.beginTransaction();
fooDao.doStuff();
transaction.commit();
} catch (Exception e) {
... error handling
}
But then in fooDao I get org.hibernate.HibernateException: No session currently bound to execution context. This probably relates to the last question I asked in the group, where `session` is valid but `sessionFactory.getCurrentSession` does not return it for some reason. What am I missing?
Thanks,
A