0
try{
  ....
}catch(ObjectOptimisticLockingFailureException e){
   e.getIdentifier(); -> this is just one id of conflicting entity.
}

How to get all conflicting entities???

What about this solution ?

List<Long> ids = Lists.newArrayList();
try{

}catch(ObjectOptimisticLockingFailureException e){
  ids.add(e.getIdentifier());
}
if (!ids.isEmpty()){
  throw MyRuntimeException(ids);
}
idmitriev
  • 4,619
  • 4
  • 28
  • 44
  • Are you using optimistic locking for user operations, e.g a user edited a record ? Why not simply say >>Another user has now changed the data you wanted to change. Please try again...< – Gren Dec 11 '14 at 10:58
  • I want to show what excatly conflicting row and lets give him a chance change certain rows. User changed on UI plenty of entities, maybe 100. He has changed 100 entities and then I send him, sorry but something was wrong, try again ,it's very very annoying situation, and he will be angry to change 100 rows again )) – idmitriev Dec 11 '14 at 11:08
  • Yes, that may be a little bit annoying for the user. Please have look at this link: http://stackoverflow.com/a/16558116/4296831 – Gren Dec 11 '14 at 11:12
  • I have seen that, this actually what I wrote about solution with List ids = Lists.newArrayList(),... etc. – idmitriev Dec 11 '14 at 11:15

0 Answers0