The exception occurs because latest version is not updated with domain Object. So JPA throwing this exception.
When we have relationship between table, while updating data in that table we have to update the most recent version in domain Object. Its always best practice to fetch the data from database and get the version before the update call.
In some scenarios, one-to-many relationship the child entity version will be increment, but hibernate does not increment parent entity version. To resolve this we need to call LockModeType.OPTIMISTIC_FORCE_INCREMENT to update the version.
getEntityManager().lock(formTemplate, LockModeType.OPTIMISTIC_FORCE_INCREMENT);
No comments:
Post a Comment