First, note @Before (tx.class) Add things rollback
@Before (tx.class) public
void Pay () throws Exception {
//throws Exception;
}
The method body cannot catch exceptions, all exceptions are thrown, and things will roll back when an exception occurs
Advantages: Simple violence, do not need to deal with each exception, directly thrown can be;
Disadvantage: Can not be detailed to distinguish the return data, views, can only be generalized to report exceptions
Second, Db.tx (new Iatom () {})
public void Pay () {
final map<string,string> Map = new hashmap<string, string> ();
Boolean bl = Db.tx (new Iatom () {
@Override public
Boolean run () throws SQLException {
if (...) {
//...
return false;
} else {
...
return true;
}
return true;
}
});
This.rendjson (BL, Null,map.get ("Return_words"), null);
}
return False or an exception thrown will rollback the transaction, return True to commit the transaction, the Db.tx method is a return value True/false, can be changed to return the value of the business return, if you want the run method to pass the variable to the outer layer, you can define a final Modified container class object or definition map, two more comprehensive, processing more delicate, recommended to use two.