public class DBTransactionAOP extends AOPAdapter
This class provides database transaction support for the beans generated be a
BeanCenter. If you set a DBTransactionAOP to a
database transaction will be associated with the thread that is invoking a
method of a bean, automatically. If the invocation is finished without any
exception, the transaction will be committed automatically. Whereas if there
is an exception, the transaction will be rollbacked automatically.
User can invoke the
getConnection() method to get a database
connection which is associated with the current thread. He/she needn't to
invoke its rollback(), commit() and close() method, because this
DBTransactionAOP can do it for him/her automatically and properly. Please
throws an exception if there is an error to access the database or if the
user need to rollback the current transaction. Please do not write a logger
or process the exception locally. This is because this DBTransactionAOP need
to know there is an exception before it decides to rollback the associated
If a method of a bean invokes another method of the same bean, or invokes a method of another bean, this DBTransactionAOP can handle the transaction in a nest way: the transaction of the caller method can override that of the callee method. In other words, the callee method will reuse the caller's transaction. There is only one transaction any time when invoking a method, despite of whether or not it invokes other method.
|Constructor and Description|
|Modifier and Type||Method and Description|
This method is invoked just after a method of a base object is invoked.
This method is invoked just before a method of a base object is invoked.
Get the connection associated with the current thread.
This method is invoked only if a throwable object is catched when invoking a method over the base object.
public void before(Invocation inv)
public void after(Invocation inv) throws java.sql.SQLException
public void tryCatch(java.lang.Throwable e, Invocation inv)
public static java.sql.Connection getConnection() throws java.sql.SQLException
java.sql.SQLException- if there throws a sql exception.