Update the entityVersion also for downgrades#9786
Conversation
|
As agreed this is a spike/proof of concept for using the I've tested it manually by updating the entityVersion in the database, then updating the entity and only attributes. In both instances the entityVersion is downgraded successfully. I'd like to get feedback to this approach before I apply it to more entities. The three remaining calls to updateEntityVersion() are necessary when updating child tables (here: attributes). This could be changed to Hibernate listener as shown in #9761 to avoid missing any call to that method. The downside is the additional technical obscurity of Hibernate listeners. While the effect used in #9761 couldn't be achieved in another way, calling this method three times per entity is IMHO tolerable. Therefore This needs to be applied to roles as well. To void repeating the JavaDoc of updateEntityVersion(), it could be pulled to a superclass/interface JpaRootEntity that will be introduced in #9761. |
|
Thanks you @ahus1 - this gets a +1 from me and in my opinion it is perfectly fine to explicitly call |
|
@hmlnarik - they solve two independent problems. While this solves the downgrading of the schema problem, the other PR solves a concurrent update of the row problem. |
6fdbc30 to
9c80579
Compare
9c80579 to
ee5c0bf
Compare
|
reverting to draft status, will rework to use Hibernate API to align implementation with #9894 |
|
On hold until #9894 is merged. |
ee5c0bf to
190183d
Compare
190183d to
8f6edc7
Compare
|
This PR is now updated to use the Hibernate SPI to update the entity version. I tested it manually locally and an entity version is downgraded successfully from 2 to 1 even if only an attribute was changed. I decided to keep the two listeners separate as they serve two different purposes. Please let me know if you want name changes on new methods and classes. As the listeners are hibernate specific, I moved the two listeners to the hibernate package. Please let me know what you think, @vramik and @sguilhen. Thanks! |
8f6edc7 to
5016996
Compare
There was a problem hiding this comment.
nitpick: this javadoc was prob copied over from the other listener and doesn't correspond to what the method does.
There was a problem hiding this comment.
Thanks, I updated that. The danger of writing comments: they might get out of date. I try to write comment why I do something or the intent, not necessarily how I do things. Think I got a bit off-track here. JavaDoc updated, please re-review.
5016996 to
1f05393
Compare
…e JSON and auxiliary tables. Will trigger also when changes to a child occur, like for example when attributes change. Closes keycloak#9716
1f05393 to
bca0db1
Compare
as it needs to match the JSON and auxiliary tables
Closes #9716