Otpimistich Lock获取所有冲突实体

时间:2014-12-11 09:47:15

标签: java hibernate optimistic-locking

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

如何获取所有冲突的实体???

这个解决方案怎么样?

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

}catch(ObjectOptimisticLockingFailureException e){
  ids.add(e.getIdentifier());
}
if (!ids.isEmpty()){
  throw MyRuntimeException(ids);
}

0 个答案:

没有答案