private boolean rollbackIfNecessary(
      Transactional transactional, Exception e, EntityTransaction txn) {
    boolean commit = true;

    //check rollback clauses
    for (Class<? extends Exception> rollBackOn : transactional.rollbackOn()) {

      //if one matched, try to perform a rollback
      if (rollBackOn.isInstance(e)) {
        commit = false;

        //check ignore clauses (supercedes rollback clause)
        for (Class<? extends Exception> exceptOn : transactional.ignore()) {
          //An exception to the rollback clause was found, DON'T rollback
          // (i.e. commit and throw anyway)
          if (exceptOn.isInstance(e)) {
            commit = true;
            break;
          }
        }

        //rollback only if nothing matched the ignore check
        if (!commit) {
          txn.rollback();
        }
        //otherwise continue to commit

        break;
      }
    }

    return commit;
  }
private boolean rollbackIfNecessary ( Transactional transactional , Exception e , EntityTransaction txn ) { boolean commit = true ; for ( Class < ? extends Exception > rollBackOn : transactional . rollbackOn ( ) ) { if ( rollBackOn . isInstance ( e ) ) { commit = false ; for ( Class < ? extends Exception > exceptOn : transactional . ignore ( ) ) { if ( exceptOn . isInstance ( e ) ) { commit = true ; break ; } } if ( ! commit ) { txn . rollback ( ) ; } break ; } } return commit ; }
Returns True if rollback DID NOT HAPPEN (i.e. if commit should continue).

@param transactional The metadata annotaiton of the method
@param e The exception to test for rollback
@param txn A JPA Transaction to issue rollbacks on