1 package org.hibernate.util; 3 4 import javax.transaction.Status ; 5 import javax.transaction.SystemException ; 6 import javax.transaction.TransactionManager ; 7 8 import org.hibernate.TransactionException; 9 import org.hibernate.engine.SessionFactoryImplementor; 10 11 14 public final class JTAHelper { 15 16 private JTAHelper() {} 17 18 public static boolean isRollback(int status) { 19 return status==Status.STATUS_MARKED_ROLLBACK || 20 status==Status.STATUS_ROLLING_BACK || 21 status==Status.STATUS_ROLLEDBACK; 22 } 23 24 public static boolean isInProgress(int status) { 25 return status==Status.STATUS_ACTIVE || 26 status==Status.STATUS_MARKED_ROLLBACK; 27 } 28 29 33 public static boolean isTransactionInProgress(SessionFactoryImplementor factory) { 34 TransactionManager tm = factory.getTransactionManager(); 35 try { 36 return ( tm!=null && isTransactionInProgress( tm.getTransaction() ) ); 37 } 38 catch (SystemException se) { 39 throw new TransactionException( "could not obtain JTA Transaction", se ); 40 } 41 } 42 43 public static boolean isTransactionInProgress(javax.transaction.Transaction tx) throws SystemException { 44 return tx != null && JTAHelper.isInProgress( tx.getStatus() ); 45 } 46 } 47 | Popular Tags |