-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
repository.save() does not update the returned entity when fields are marked updatable=false [DATAJPA-1421] #1735
Comments
Jens Schauder commented This behavior is not caused by the auditing feature setting values or not. You are essentially resetting the fields to Here is what is happening:
|
Jason Bodnar commented Then the docs need to be updated:
|
Jens Schauder commented
Yes, because you set them to While I see that the combination of merging instances and non-updatable fields can be confusing I don't see what is to be improved about the documentation of the |
Jens Schauder commented Batch closing resolved issue without a fix version and a resolution indicating that there is nothing to release (Won't fix, Invalid ...) |
My thought is that when a field is marked
|
I believe it'd be helpful to focus on this from a different perspective. Regardless of the reason why this issue occurs, the issue is still valid. The purpose of this library is as follows:
Extract from: https://docs.spring.io/spring-data/jpa/reference/auditing.html Created fields should not be allowed to be updated otherwise they are no longer fulfilling its purpose. I disagree with the following statement:
That being said, even if we assume that to be true. If this is not the way to achieve this functionality, I believe an alternative should be provided. If we have to either:
Then the library is no longer |
I agree with @agarcia-te. The primary purpose of auditing features is to ensure users see accurate timestamps when entities are created or updated. |
Jason Bodnar opened DATAJPA-1421 and commented
I'm using Spring Data's annotations to add auditing data to my entities when they are saved or updated. When I create the entity the createdBy, createdDate, lastModifiedBy and lastModifiedDate get set on the object returned by repository.save(). Unfortunately, when I call repository.save() to update an existing entity the object returned does not have the createdBy and createdDate set. All the fields are set correctly in the database though
Affects: 2.0.10 (Kay SR10)
Reference URL: https://github.com/jcbodnar/auditing-example
The text was updated successfully, but these errors were encountered: