JPAContainer, Hibernate and commit exceptions

Hello, I’m trying to use the “entity manager per request” pattern, as implemented in http://goo.gl/v8zoZ

So :

  • I set up the
    LazyHibernateServletFilter

  • I setup my JPAContainer using :
    [font=Courier New]

    container.getEntityProvider().setEntityManager(null);
    LazyHibernateEntityManagerProvider entityManagerProvider = new LazyHibernateEntityManagerProvider();
    container.getEntityProvider().setEntityManagerProvider(entityManagerProvider);
    container.getEntityProvider().setLazyLoadingDelegate(new HibernateLazyLoadingDelegate());

[/font]

  • I setup a Component (e.g. Table) to use the container

when trying to commit :
myTable.commit();
I’d like to catch exceptions (such as
org.hibernate.exception.ConstraintViolationException
)

But it appears that exceptions are actually thrown in the servlet filter, and even there I cannot catch them properly.

So, what is the correct pattern to catch exceptions using JPAContainer with Hibernate ?

Thanks for your help

Sorry, my mistake, obviously a try/catch around the commit() is not enough, you have to set up an ErrorHandler…