我使用spring orm with hibernate.I有如下方法樂觀版本鎖定
對象具有版本列。@版本。
void processObject(){
Object obj = getObjectFromDB(int id);
//do lot of processing. Takes 15 min
//version number is not changed
//if some other object updates the same object , which
//exception is thrown when folloing code runs
updateObject(obj) ;
//
}
@Transactional
updateObject(Object object){
session.save(object)
}
@Transcational
Object getObjectFromDB(int id){
}
現在,如果我同時處理和保存對象的其他線程更新對象,然後將引發異常?
1)StaleStateException (hibernate)
2)StaleObjectstateException (hibernate)
3)ConcurrentFailureException (spring)
4)Any other?
爲什麼你不測試它? – 2015-01-04 16:36:51