Example usage for javax.persistence EntityTransaction equals

List of usage examples for javax.persistence EntityTransaction equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

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

Usage

From source file:org.eclipse.jubula.client.core.persistence.Persistor.java

/**
 * @param s/*from   w w  w . ja va  2s  . c  om*/
 *            Session which is used for the transaction
 * @param tx
 *            transaction to rollback
 * @throws PMException
 *             in case of failed rollback
 */
public void rollbackTransaction(EntityManager s, EntityTransaction tx) throws PMException {

    Validate.notNull(s);
    if (tx != null) {
        // FIXME NLS
        Validate.isTrue(tx.equals(s.getTransaction()), "Session and Transaction don't match"); //$NON-NLS-1$
        try {
            tx.rollback();
        } catch (PersistenceException e) {
            log.error(Messages.RollbackFailed, e);
            if (s.equals(GeneralStorage.getInstance().getMasterSession())) {
                GeneralStorage.getInstance().recoverSession();
            }
            throw new PMException(Messages.RollbackFailed, MessageIDs.E_DATABASE_GENERAL);
        } finally {
            removeLocks(s);
        }
    }
}

From source file:org.eclipse.jubula.client.core.persistence.Persistor.java

/**
 * @param s/*  w  ww .  j a  v  a2 s  .  c  om*/
 *            session
 * @param tx
 *            transaction
 * @throws PMReadException
 *             {@inheritDoc}
 * @throws PMAlreadyLockedException
 *             {@inheritDoc}
 * @throws PMDirtyVersionException
 *             {@inheritDoc}
 * @throws PMException
 *             {@inheritDoc}
 * @throws ProjectDeletedException
 *             if the project was deleted in another instance
 */
public void commitTransaction(EntityManager s, EntityTransaction tx) throws PMReadException,
        PMAlreadyLockedException, PMDirtyVersionException, PMException, ProjectDeletedException {

    Validate.notNull(s);
    Validate.notNull(tx);
    Validate.isTrue(tx.equals(s.getTransaction()), Messages.SessionAndTransactionDontMatch);
    try {
        tx.commit();
    } catch (PersistenceException e) {
        if (s != null && s.equals(GeneralStorage.getInstance().getMasterSession())) {
            PersistenceManager.handleDBExceptionForMasterSession(null, e);
        } else {
            PersistenceManager.handleDBExceptionForAnySession(null, e, s);
        }
    } finally {
        removeLocks(s);
    }
}