wasRolledBack
method is not included in the Hibernate 5.0.6
version Transaction
interface Here .
4.3.1
version that was taking place in the wasRolledBack
method.
Existing methods:
public interface Transaction {
void begin();
void commit();
void rollback();
TransactionStatus getStatus();
void registerSynchronization(Synchronization synchronization) throws HibernateException;
void setTimeout(int seconds);
int getTimeout();
void markRollbackOnly();
}
I did not test, but you can use the getStatus
method.
Example:
TransactionStatus transactionStatus = session.getTransaction().getStatus();
if(transactionStatus.equals(TransactionStatus.ROLLED_BACK)){
//action s.a :)
}
EDIT 1:
TransactionStatus
Enum Constant and Description:
ACTIVE : The transaction has been begun, but not yet completed.
COMMITTED : The transaction has been competed successfully.
COMMITTING :Status code indicating a transaction that has begun the
second phase of the two-phase commit protocol, but not yet completed
this phase.
FAILED_COMMIT:The transaction attempted to commit, but
failed.
MARKED_ROLLBACK:The transaction has been marked for rollback only.
NOT_ACTIVE:The transaction has not yet been begun
ROLLED_BACK:The transaction has been rolled back.
ROLLING_BACK:Status code indicating a transaction that is in the
process of rolling back.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…