0
我正面臨以下版本問題(樂觀鎖)。 版本檢查沒有發生,並且異常陳舊狀態當我使用下面的查詢時,不會引發異常。 用戶詳細信息和版本沒有正確遞增,但版本號不相等時不會引發異常。版本檢查不能與executeUpdate一起使用
try{
Query query= getSessionFactory().getCurrentSession().createQuery("update versioned User u set u.userName=:userName,u.DOB=:DOB where u.userID= :id ");
query.setString("userName", usrName);
query.setString("DOB",dob);
query.executeUpdate()
getSessionFactory().getCurrentSession().flush();
}catch(StaleStateException e){
return "some msg return to notify user "
}
Same thing working fine if use below query.
try{
getSessionFactory().getCurrentSession().update(user);
getSessionFactory().getCurrentSession().flush();
}catch(StaleStateException e){
return "some msg return to notify user "
}
any suggestion in this regard will be much helpfull