-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Javers: Incorrect new last modified date stored in commit for UPDATEs #233
Comments
I figured out the mechanism mentioned above does work properly, if I'd change the generated
instead of
So now, I do wonder, why Seemingly having to do something with Hibernate. |
Could be related to spring-projects/spring-data-jpa#1735 - where it is explained it is an expected behaviour when using a completely new instance while wanting to actually update one that is already in the database. We also have updateable=false on these audit fields |
Ok, so the Default JpaRepository is checking, if an entity is new and if so, it immediately persists it. If it is not new (like in the update case) it just runs a merge on the entityManager, and only once the |
It will probably require to implement Persistable interface. |
Seems to work. |
I see now. We probably should change to saveAndFlush at update operation. |
I did this in my own application via a custom blueprint and noticed, the
Additionally, it is required, to turn off the default
|
Hi,
we have Javers configured in our application and use basically defaults for kind of everything related to this Blueprint. We noticed, that the LastModifiedDate, that is being set by Spring Data via the @LastModifiedDate is not reflected within the data stored within Javers tables for the new value of an existing Entity, so we get so see the following observations:
In Javers, it shows the values that the users has submitted from the Frontend form (which is the old/previous value actually, without seconds/milliseconds). This is kind of confusing....
I do assume, that Javers takes the response value from the Spring Data repository for the entity to store
values in its tables.
This happens before actually calculating the actual new value and especially for the actual update of the data, as visible in the following log excerpt, where the INSERT into the javers tables happens before the update within the entity table. Maybe it has something to do with how the
@Transactional
and the@LastModifiedDate
in combination works for Updates.I do assume, the actual calculation and commit of that value happens at the end of the
@Transactional
session and not when the JPA Repository returns a value... which may be the root cause here...Strangely, for initial INSERTs, it does work, i.e. for the very first commit in the Javers tables, the values are appropriate and also the INSERT into the Entity happens before the INSERT into the Javers table according to the logs.
We do have MySQL8, JHipster 8.1.0 (Spring Boot 3.2.0).
I'm still investigating deeper and hope to figure out the root cause (possibily nothing directly related to the Blueprint), but maybe, someone else made similar observations and needs a starting point for investigations.
The text was updated successfully, but these errors were encountered: