2015-01-04 3 views
0

최대 절전 모드에서 spring orm을 사용하고 있습니다. 다음과 같은 방법이 있습니다.낙관적 인 버전 잠금

개체에 버전 열 @ 버전이 있습니다.

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? 
+1

읽어 보시겠습니까? –

답변

0

기본이되는 ORM (최대 절전 모드),

org.hibernate.StaleObjectStateException 

그런 다음 스프링 데이터 액세스 계층이 그것을 잡을 것입니다 던져 그래서 스택 추적 당신이 얻을 것이다

org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException 

에 포장됩니다 것입니다 be :

org.springframework.orm.hibernate4.HibernateOptimisticLockingFailureException: 
    Caused by: org.hibernate.StaleObjectStateException: 

당신은 n 약 hibernate optimistic lockingspring exception translation

+0

이 예외가 throw 된시기는 http://docs.spring.io/spring-framework/docs/2.0.8/api/org/springframework/dao/ConcurrencyFailureException.html – user93796

+0

ConcurrencyFailureException은 HibernateOptimisticLockingFailureException에 대한 수퍼 클래스입니다. http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/orm/hibernate4/HibernateOptimisticLockingFailureException.html을 참조하십시오. – outdev

관련 문제