Spring transaction savepoint savepoint

Savepoint savepoint = null; savepoint record the operating position, can be rolled back to a specified location after

try{

// get links

conn=。。。。

// open affairs

conn.setAutoCommit(false);

A Transaction
B Transaction

savepoint=conn.setpoint();

C Services

D Services

// commit the transaction

conn.commit (); in a single transaction, even if the CD abnormal, AB can submit save!

}catch(){

if (savepoint! = null) {// CD abnormal

// rollback to the previous CD

conn.rollback(savepoint);

// submit AB

conn.commit();

} Else {// AB abnormal

// rollback AB

conn.rollback();}

}

Guess you like

Origin www.cnblogs.com/chris3-29/p/11220420.html