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

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dropwizard-user/9c35519d-8cb6-4fe4-94fe-645190c43649n%40googlegroups.com.

Reply via email to