Example usage for javax.persistence.spi PersistenceUnitTransactionType equals

List of usage examples for javax.persistence.spi PersistenceUnitTransactionType equals

Introduction

In this page you can find the example usage for javax.persistence.spi PersistenceUnitTransactionType equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.impetus.kundera.persistence.EntityManagerImpl.java

private void onLookUp(PersistenceUnitTransactionType transactionType) {
    // TODO transaction should not be null;
    if (transactionType != null && transactionType.equals(PersistenceUnitTransactionType.JTA)) {
        if (this.entityTransaction == null) {
            this.entityTransaction = new KunderaEntityTransaction(this);
        }/*from w w w  .j av  a  2s .c  om*/
        Context ctx;
        try {
            ctx = new InitialContext();

            this.utx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");

            if (this.utx == null) {
                throw new KunderaException(
                        "Lookup for UserTransaction returning null for :{java:comp/UserTransaction}");
            }
            // TODO what is need to check?
            if (!(this.utx instanceof KunderaJTAUserTransaction)) {
                throw new KunderaException("Please bind [" + KunderaJTAUserTransaction.class.getName()
                        + "] for :{java:comp/UserTransaction} lookup" + this.utx.getClass());
            }

            if (!this.entityTransaction.isActive()) {
                this.entityTransaction.begin();
                this.setFlushMode(FlushModeType.COMMIT);
                ((KunderaJTAUserTransaction) this.utx).setImplementor(this);
            }

        } catch (NamingException e) {
            logger.error("Error during initialization of entity manager, Caused by:", e);
            throw new KunderaException(e);
        }

    }
}