2016-03-08 82 views
0

我有一個需要寫入多個數據庫的需求。如果在寫入任何數據庫時發生異常,我想回滾所有內容。休眠時在單個事務中寫入多個數據庫

E.G.

Session userSession= a.getUserDBSession(); 
Session departmentSession= a.getDepartmentSession(); 
Session carSession= a.getCarSession(); 

//Do some work and write to User DB 
// Do some work and write to Department DB 
//Do some work and write to Car DB 
// commit everything. 

注:Session是Hibernate的Session 任何幫助將高度讚賞

回答