Example usage for javax.transaction UserTransaction UserTransaction

List of usage examples for javax.transaction UserTransaction UserTransaction

Introduction

In this page you can find the example usage for javax.transaction UserTransaction UserTransaction.

Prototype

UserTransaction

Source Link

Usage

From source file:org.apache.ode.daohib.JotmTransactionFactory.java

/**
 * {@inheritDoc}/*from  w  w w.j  ava2s  . c o  m*/
 */
public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext)
        throws HibernateException {
    /*
     * JTA TransactionManager returns a JTA transaction. We need a user transaction to use
     * hibernate's JTATransactionFactory.
     */
    // UserTransaction ut = getUserTransaction();
    UserTransaction ut;
    try {
        ut = new UserTransaction() {
            javax.transaction.Transaction transaction = txManager.getTransaction();

            public void begin() throws NotSupportedException, SystemException {
                // TODO Auto-generated method stub
            }

            public void commit() throws HeuristicMixedException, HeuristicRollbackException,
                    IllegalStateException, RollbackException, SecurityException, SystemException {
                transaction.commit();
            }

            public int getStatus() throws SystemException {
                // TODO Auto-generated method stub
                return transaction.getStatus();
            }

            public void rollback() throws IllegalStateException, SecurityException, SystemException {
                // TODO Auto-generated method stub
                transaction.rollback();
            }

            public void setRollbackOnly() throws IllegalStateException, SystemException {
                // TODO Auto-generated method stub
                transaction.setRollbackOnly();
            }

            public void setTransactionTimeout(int i) throws SystemException {
                // TODO Auto-generated method stub
            }
        };
    } catch (SystemException e) {
        throw new HibernateException(e);
    }

    return new JotmTransaction(ut, jdbcContext, transactionContext);
}