1

I am getting "org.springframework.orm.ObjectOptimisticLockingFailureException" and "org.hibernate.StaleStateException" exception.

My code is simple and i am running my code in transaction (@Transactional of spring). First it get user entity from database . Second time when i am going to get the same user entity, Exception is coming mentioned above.

Please find my code below- :

final UserEntity user = userRepo.findByUserRefId(userDataPayload.getUserDetails().getUserRefId());

when i am doing this second time Exception is coming

Darshan Mehta
  • 30,102
  • 11
  • 68
  • 102
sachin thakur
  • 75
  • 4
  • 10
  • You are possibly running long transactions and your entity has versioning, too. Check scope of your `@Transactional` method and also check if entity is modified before you are reading second time. – Harshit Mar 14 '19 at 08:43
  • Possible duplicate of [Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1](https://stackoverflow.com/questions/2743130/hibernate-batch-update-returned-unexpected-row-count-from-update-0-actual-row) – Filip123go Mar 14 '19 at 08:44

0 Answers0