2 Replies Latest reply on Oct 4, 2009 10:41 PM by Miguel Z

    ConstraintViolationException no transaction rollback

    Miguel Z Newbie
      I'm using:

      Seam 2.2.0 GA
      Tomcat 6.0.18
      Mysql 5.1 with InnoDB

      -> Seam Transaction Management and POJOs used:

      in components.xml
      <transaction:entity-transaction entity-manager="#{entityManager}"/>

      Using EntityHome components in a seam-gen generated CRUD Example with two entities in a parent-child relation (without cascade delete) and FlushType.Manual, as expected, I get a Hibernate ConstraintViolationException (caused by the corresponding Mysql-Exception) when I remove a parent instance with existing child instances.

      My problem is, that there seems no way to recover cleanly from this exception.

      The transaction does not get rolled back and the locks keep existing in Mysql-InnoDB causing further Timeout, LockExceptions etc...

      Even if I handle the exception and destroy the conversation in pages.xml (with debug=false in components.xml and JSF/Facelets-Debug disabled in web.xml) like this:

      <exception class="org.hibernate.exception.ConstraintViolationException">
              <end-conversation before-redirect="false"/>
              <redirect view-id="/error.xhtml">
                  <message severity="warn">MySQLIntegrityConstraintViolationException</message>

      the transaction is still alive and holds the locks:

      ---TRANSACTION 0 55373, ACTIVE 24 sec, OS thread id 3520
      17 lock struct(s), heap size 1024, 17 row lock(s), undo log entries 5
      MySQL thread id 42, query id 4014 localhost ...

      It seems that the transaction doesn't get rolled back and closed on every arbitrary non-catched runtime-exception as stated in the documentation ?!

      Any comments?