Hello,
My application uses Spring with Hibernate, the current design works absolutely fine for single users. However when the multiple users are involved on a distributed cluster based servers, many times user's face 'Optimistic Locking/Stale Object' exception occurs.
The exception is particularly thrown at "findbyId(id).." method. The structure is as below..
Outermethod(){
saveDetails(destinationObject);--This method is non-Transactional and performs update with No flush... storeinDB(destinationObject.getID()); --This method is transactional. } @Transactional(noRolebackFor...) storeinDB(ID){ destinationObject.findbyId(ID);---here the optimistic is thrown few lines of business logic; gethibernateTemplate().update(); }
Please help me understand:
1) does findbyID() look in cache or DB ? 2) What is the possible to change or suggestions to avoid optimistic loc?
Thanks in advance. Deepti
|