public class TransactionManager
extends java.lang.Object
implements java.io.Serializable
Title: TransactionManager
Description: 实现数据库的事务框架
bboss workgroup
Copyright (c) 2007
| 限定符和类型 | 字段和说明 |
|---|---|
static com.frameworkset.orm.annotation.TransactionType |
MAYBE_TRANSACTION
有事务就加入事务,没有不创建事务,默认情况
|
static com.frameworkset.orm.annotation.TransactionType |
NEW_TRANSACTION
始终创建新事务
|
static com.frameworkset.orm.annotation.TransactionType |
NO_TRANSACTION
没有事务
|
static com.frameworkset.orm.annotation.TransactionType |
REQUIRED_TRANSACTION
如果没有事务创建新事务,有事务加入当前事务
|
static com.frameworkset.orm.annotation.TransactionType |
RW_TRANSACTION
读写事务
|
static com.frameworkset.orm.annotation.TransactionType |
UNKNOWN_TRANSACTION
未知事务
|
| 构造器和说明 |
|---|
TransactionManager() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
begin()
Starts a new transaction, and associate it with the calling thread.
|
void |
begin(com.frameworkset.orm.annotation.TransactionType tx_type)
Starts a new transaction, and associate it with the calling thread.
|
void |
commit()
Commit the transaction associated with the calling thread.
|
static boolean |
destroyTransaction()
如果成功销毁事务,则返回true
如果没有需要销毁的事务则返回false
|
com.frameworkset.orm.annotation.TransactionType |
getCurrenttxtype()
获取当前事务的类型
|
java.lang.String |
getCurrenttxtypeName()
获取当前事务的类型名称
|
int |
getStatus()
Get the status of the transaction associated with the calling thread.
|
static JDBCTransaction |
getTransaction()
Get the transaction associated with the calling thread.
|
void |
release()
在final方法中调用,用来在出现异常时对事务资源进行回收,首先对事务进行回滚,
然后回收资源,如果事务已经提交和回滚,则不做任何操作
|
void |
releasenolog()
在final方法中调用,用来在出现异常时对事务资源进行回收,首先对事务进行回滚,
然后回收资源,如果事务已经提交和回滚,则不做任何操作
|
void |
resume(JDBCTransaction tx)
Resume the association of the calling thread with the given transaction.
|
void |
rollback()
Rolls back the transaction associated with the calling thread.
|
protected void |
setTransaction(JDBCTransaction tx)
Just used for unit tests
|
void |
setTransactionTimeout(int seconds)
Change the transaction timeout for transactions started by the calling
thread with the
begin() method. |
JDBCTransaction |
suspend()
Suspend the association the calling thread has to a transaction, and
return the suspended transaction.
|
JDBCTransaction |
suspendAll()
Suspend the association the calling thread has to a transaction, and
return the suspended transaction.
|
public static final com.frameworkset.orm.annotation.TransactionType NEW_TRANSACTION
public static final com.frameworkset.orm.annotation.TransactionType REQUIRED_TRANSACTION
public static final com.frameworkset.orm.annotation.TransactionType MAYBE_TRANSACTION
public static final com.frameworkset.orm.annotation.TransactionType NO_TRANSACTION
public static final com.frameworkset.orm.annotation.TransactionType RW_TRANSACTION
public static final com.frameworkset.orm.annotation.TransactionType UNKNOWN_TRANSACTION
public void begin()
throws com.frameworkset.orm.transaction.TransactionException
TransactionExceptionjavax.transaction.NotSupportedException - If the calling thread is already associated with a
transaction, and nested transactions are not supported.javax.transaction.SystemException - If the transaction service fails in an unexpected way.public void begin(com.frameworkset.orm.annotation.TransactionType tx_type)
throws com.frameworkset.orm.transaction.TransactionException
int - tx_type (默认值为REQUIRED_TRANSACTION)
始终创建新事务
JDBCTransaction.public static final int NEW_TRANSACTION = 0;
如果没有事务创建新事务,有事务加入当前事务(默认值)
JDBCTransaction.public static final int REQUIRED_TRANSACTION = 2;
有事务就加入事务,没有不创建事务,默认情况
JDBCTransaction.public static final int MAYBE_TRANSACTION = 3;
没有事务
JDBCTransaction.public static final int NO_TRANSACTION = 4;TransactionExceptionjavax.transaction.NotSupportedException - If the calling thread is already associated with a
transaction, and nested transactions are not supported.javax.transaction.SystemException - If the transaction service fails in an unexpected way.public void commit()
throws javax.transaction.RollbackException
javax.transaction.RollbackException - If the transaction was marked for rollback only, the
transaction is rolled back and this exception is thrown.java.lang.IllegalStateException - If the calling thread is not associated with a transaction.javax.transaction.SystemException - If the transaction service fails in an unexpected way.javax.transaction.HeuristicMixedException - If a heuristic decision was made and some some parts of the
transaction have been committed while other parts have been
rolled back.javax.transaction.HeuristicRollbackException - If a heuristic decision to roll back the transaction was
made.java.lang.SecurityException - If the caller is not allowed to commit this transaction.public void rollback()
throws javax.transaction.RollbackException
java.lang.IllegalStateException - If the transaction is in a state where it cannot be rolled
back. This could be because the calling thread is not
associated with a transaction, or because it is in the
prepared state.java.lang.SecurityException - If the caller is not allowed to roll back this transaction.javax.transaction.SystemException - If the transaction service fails in an unexpected way.javax.transaction.RollbackExceptionpublic int getStatus()
Status constants. If no transaction is
associated with the calling thread,
Status.STATUS_NO_TRANSACTION is
returned.javax.transaction.SystemException - If the transaction service fails in an unexpected way.public static JDBCTransaction getTransaction()
null if the calling thread is not associated with
a transaction.javax.transaction.SystemException - If the transaction service fails in an unexpected way.public void setTransactionTimeout(int seconds)
throws javax.transaction.SystemException
begin() method.seconds - The new timeout value, in seconds. If this parameter is
0, the timeout value is reset to the default
value.javax.transaction.SystemException - If the transaction service fails in an unexpected way.public JDBCTransaction suspend() throws javax.transaction.SystemException
null if the calling thread was not associated with
a transaction.javax.transaction.SystemException - If the transaction service fails in an unexpected way.public JDBCTransaction suspendAll() throws javax.transaction.SystemException
null if the calling thread was not associated with
a transaction.javax.transaction.SystemException - If the transaction service fails in an unexpected way.public void resume(JDBCTransaction tx) throws javax.transaction.InvalidTransactionException, java.lang.IllegalStateException, javax.transaction.SystemException
tx - The transaction to be associated with the calling thread.javax.transaction.InvalidTransactionException - If the argument does not represent a valid transaction.java.lang.IllegalStateException - If the calling thread is already associated with a
transaction.javax.transaction.SystemException - If the transaction service fails in an unexpected way.protected void setTransaction(JDBCTransaction tx)
tx - public static boolean destroyTransaction()
public com.frameworkset.orm.annotation.TransactionType getCurrenttxtype()
public java.lang.String getCurrenttxtypeName()
public void release()
public void releasenolog()