JBoss 4.2.2.GA / JDK 6, Seam 2.1.1GA, POJO
I have the unfortunate situation where I persist an entity (let's call it an Order) but a database trigger can throw an exception if the saving is not allowed (due to more complicated DB-related constraints/logic).
When I persist, I can catch the PersistenceException, do a addFacesMessage and wrap it in an @ApplicationException. In pages.xml I have a
<exception class="java.sql.BatchUpdateException">
<redirect view-id="/main.xhtml">
<message>BatchUpdateException</message>
</redirect>
</exception>
When I persist the entity the following happens
- I go to the main page. Fine
- I see the
BatchUpdateException
message. Fine.
- I get a new conversation (even if I didn't request endConversation in pages.xml)
- The message I added in my action is lost.
- New transaction is alive (due to new conversation). Fine.
The DB exception is fatal for the transaction(?) but is there some form of semi-graceful way of handling this situation?