コード例 #1
0
  /**
   * Commit the current transaction, writing any unflushed changes to the database.
   *
   * @throws IllegalStateException if isActive() is false.
   * @throws RollbackException if the commit fails.
   */
  public void commit() {
    assertActive();

    if (tx.getRollbackOnly()) {
      // This is thrown by the underlying transaction but we want to have a RollbackException here
      // so intercept it
      if (NucleusLogger.TRANSACTION.isDebugEnabled()) {
        NucleusLogger.TRANSACTION.debug(Localiser.msg("015020"));
      }
      throw new RollbackException(Localiser.msg("015020"));
    }

    try {
      tx.commit();
    } catch (NucleusTransactionException nte) {
      Throwable cause = nte.getCause();
      Throwable pe = null;
      if (cause instanceof NucleusException) {
        pe = NucleusJPAHelper.getJPAExceptionForNucleusException((NucleusException) cause);
      } else {
        pe = cause;
      }
      throw new RollbackException(Localiser.msg("015007"), pe);
    } catch (NucleusException ne) {
      throw NucleusJPAHelper.getJPAExceptionForNucleusException(ne);
    }
  }
コード例 #2
0
 /* (non-Javadoc)
  * @see org.datanucleus.jta.TransactionManagerLocator#getTransactionManager(org.datanucleus.ClassLoaderResolver)
  */
 public TransactionManager getTransactionManager(ClassLoaderResolver clr) {
   Class cls = clr.classForName("com.atomikos.icatch.jta.UserTransactionManager");
   try {
     return (TransactionManager) cls.newInstance();
   } catch (Exception e) {
     NucleusLogger.TRANSACTION.debug(
         "Exception obtaining Atomikos transaction manager " + e.getMessage());
     return null;
   }
 }