EntityTransaction (Java EE 5)

Java EE API


javax.persistence Interface EntityTransaction


public interface EntityTransaction


EntityTransaction 接口,用于控制本地资源实体管理器的资源事务。getTransaction EntityManager.getTransaction() 方法返回 EntityTransaction 接口。
英文文档:

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

Since:
Java Persistence 1.0

Method Summary
 void
 void
 boolean
 boolean
 void
 void
 

Method Detail

public void begin()
开始资源事务。
ThrowsIllegalStateException: 如果 #isActive() 为 true。
英文文档:

begin

void begin()
Start the resource transaction.

Throws:
IllegalStateException - if isActive() is true.

public void commit()
提交当前事务,将未刷新的更改写入数据库。
ThrowsIllegalStateException: 如果 #isActive() 为 false。
ThrowsRollbackException: 如果提交失败。
英文文档:

commit

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

Throws:
IllegalStateException - if isActive() is false.
RollbackException - if the commit fails.

public void rollback()
回滚当前事务
ThrowsIllegalStateException: 如果 #isActive() 为 false。
ThrowsPersistenceException: 如果遇到不可预料的错误情况。
英文文档:

rollback

void rollback()
Roll back the current transaction

Throws:
IllegalStateException - if isActive() is false.
PersistenceException - if an unexpected error condition is encountered.

public void setRollbackOnly()
标记当前的事务,使该事务最终只能被回滚。
ThrowsIllegalStateException: 如果 #isActive() 为 false。
英文文档:

setRollbackOnly

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

Throws:
IllegalStateException - if isActive() is false.

public boolean getRollbackOnly()
确定当前事务是否标记为回滚。
ThrowsIllegalStateException: 如果 #isActive() 为 false。
英文文档:

getRollbackOnly

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

Throws:
IllegalStateException - if isActive() is false.

public boolean isActive()
指示事务是否正在进行。
ThrowsPersistenceException: 如果遇到不可预料的错误情况。
英文文档:

isActive

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

Throws:
PersistenceException - if an unexpected error condition is encountered.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!