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
AbstractAuditingEntity not working for update for entities with dto #1774
Comments
What cleared out the 'createdBy' field? It should be there, when it's retrieved from the database. |
I mask these fields out in dto layer. It is normal not to pass these audit fields to dto and back. You dont want to update created_* fields with entity updates. So these fields should be marked as updatable=false and should not have @NotNull |
Yes, sure, you dont want to put that fields into a DTO, and blindly update it. It's the drawback for using the same DTO for sending to the client, and receiving from the client. |
But we will not update it accidentally, once we mark it as , updatable = false. No? |
yes, that would make sense |
So this is specific to using DTOs:
|
I don't think we should change the existing behavior, then this has been opened for a long time and I don't find this issue very clear -> this is why I'm closing this If you have something more detailed, with maybe a PR or some sample code that demonstrates your issue (including the mapping code), it would be most welcomed. |
I tried to use the generated AbstractAuditingEntity to add audit fields to one of the application's entity. The update use case did not work correctly. It was failing with a constraint violation error that createdBy cannot be null. This property is marked as @NotNull in the generated class. But this field will be null in the update mode.
I'd to change this class to modify the definitions of createdBy and createdAt to fix this issue.
If this is correct, please update the generator to work correctly.
The text was updated successfully, but these errors were encountered: