Spring can commit Transaction in finally block with RunTimeException in try block [migrated]
- by Chance Lai
The project used Spring + Hibernate
Sample code:
public void method(){
try{
dao.saveA(entityA);
throw RuntimeException;
dao.saveB(entityB);
}catch(RuntimeException e){
throw e;
}finally{
dao.saveC(entityC)
}
}
Finally, just entityC will be saved in database in test.
I think saveA,…