EntityTransaction (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.persistence Interface EntityTransaction


public interface EntityTransaction

The EntityTransaction interface is used to control resource transactions on resource-local entity managers. The EntityManager.getTransaction() method returns the EntityTransaction interface.

从以下版本开始:
Java Persistence 1.0

方法摘要
 void begin()
          Start the resource transaction.
 void commit()
          Commit the current transaction, writing any unflushed changes to the database.
 boolean getRollbackOnly()
          Determine whether the current transaction has been marked for rollback.
 boolean isActive()
          Indicate whether a transaction is in progress.
 void rollback()
          Roll back the current transaction
 void setRollbackOnly()
          Mark the current transaction so that the only possible outcome of the transaction is for the transaction to be rolled back.
 

方法详细信息

begin

void begin()
Start the resource transaction.

抛出异常:
IllegalStateException - if isActive() is true.

commit

void commit()
Commit the current transaction, writing any unflushed changes to the database.

抛出异常:
IllegalStateException - if isActive() is false.
RollbackException - if the commit fails.

rollback

void rollback()
Roll back the current transaction

抛出异常:
IllegalStateException - if isActive() is false.
PersistenceException - if an unexpected error condition is encountered.

setRollbackOnly

void setRollbackOnly()
Mark the current transaction so that the only possible outcome of the transaction is for the transaction to be rolled back.

抛出异常:
IllegalStateException - if isActive() is false.

getRollbackOnly

boolean getRollbackOnly()
Determine whether the current transaction has been marked for rollback.

抛出异常:
IllegalStateException - if isActive() is false.

isActive

boolean isActive()
Indicate whether a transaction is in progress.

抛出异常:
PersistenceException - if an unexpected error condition is encountered.

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.