OptimisticLocking in Micronaut Data Hibernate #3041
Unanswered
Spellmaker
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I wanted to use OptimisticLocking with an updated at Timestamp in my hibernate entities, but couldn't get it to work.
Now I'm unsure if it should even work after reading the docs.
The section about optimistic locking is here: https://micronaut-projects.github.io/micronaut-data/latest/guide/#optimisticLocking
Which is structured beneath micronaut-data-jdbc, but according to some older issues (#1125) it shouldn't work for data-jdbc?
I attempted to create a minimal example here:
https://github.com/Spellmaker/bug-report-optimistic-locking
apart from the pregenerated test, the two "testOptimisticLocking" tests should actually fail and the hibernate sql should interact with the timestamps, but the tests succeeed and hibernate/micronaut-data seems to ignore the @Version annotation.
Looking into the micronaut-data code, the VersionGeneratingEntityEventListener which is responsible for managing the version fields (as far as I understand) skips handling the version field, as the EntityEventContext populated by the EventIntegrator class indicates it doesn't support the event system (public final boolean supportsEventSystem() {
return false;
})
Maybe someone can shed some light on this?
Beta Was this translation helpful? Give feedback.
All reactions