Example usage for javax.transaction Status STATUS_UNKNOWN

List of usage examples for javax.transaction Status STATUS_UNKNOWN

Introduction

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

Prototype

int STATUS_UNKNOWN

To view the source code for javax.transaction Status STATUS_UNKNOWN.

Click Source Link

Document

A transaction is associated with the target object but its current status cannot be determined.

Usage

From source file:org.hibernate.transaction.JTATransaction.java

public boolean wasCommitted() throws TransactionException {

    //if (!begun || commitFailed) return false;

    final int status;
    try {/*from  w ww .j av a2  s .  c  o m*/
        status = userTransaction.getStatus();
    } catch (SystemException se) {
        log.error("Could not determine transaction status", se);
        throw new TransactionException("Could not determine transaction status: ", se);
    }
    if (status == Status.STATUS_UNKNOWN) {
        throw new TransactionException("Could not determine transaction status");
    } else {
        return status == Status.STATUS_COMMITTED;
    }
}

From source file:org.hibernate.transaction.JTATransaction.java

public boolean isActive() throws TransactionException {

    if (!begun || commitFailed || commitSucceeded) {
        return false;
    }//ww  w  .  j  ava  2s  . c  o m

    final int status;
    try {
        status = userTransaction.getStatus();
    } catch (SystemException se) {
        log.error("Could not determine transaction status", se);
        throw new TransactionException("Could not determine transaction status: ", se);
    }
    if (status == Status.STATUS_UNKNOWN) {
        throw new TransactionException("Could not determine transaction status");
    } else {
        return status == Status.STATUS_ACTIVE;
    }
}

From source file:org.j2free.jpa.Controller.java

/**
 * /*from w w  w  .j  ava 2 s  .  c  o  m*/
 * @return
 * @throws SystemException
 */
public String getTransactionStatus() throws SystemException {
    if (tx == null) {
        return "Null transaction";
    }

    switch (tx.getStatus()) {
    case Status.STATUS_ACTIVE:
        return "Active";
    case Status.STATUS_COMMITTED:
        return "Committed";
    case Status.STATUS_COMMITTING:
        return "Committing";
    case Status.STATUS_MARKED_ROLLBACK:
        return "Marked for rollback";
    case Status.STATUS_NO_TRANSACTION:
        return "No Transaction";
    case Status.STATUS_PREPARED:
        return "Prepared";
    case Status.STATUS_ROLLEDBACK:
        return "Rolledback";
    case Status.STATUS_ROLLING_BACK:
        return "Rolling back";
    case Status.STATUS_UNKNOWN:
        return "Declared Unknown";
    default:
        return "Undeclared Unknown Status";
    }
}