Is there any way to continue using an thread bound hibernate session after constraintviolation exception has been thrown? I\'m giving a short example here:
Use a StatelessSession instead of a Session. That is the trick.
With a StatelessSession you can continue after any exceptions as it is possible in SQL (even inside one transaction - no commit/rollback is done by hibernate). That is ideal for bulk updates/inserts or for checking if unique constraints are violated.
But beware, a StatelessSession has many Restrictions compared with a normal session. Please refer to the Hibernate documentaion / Javadocs for that.