-
Notifications
You must be signed in to change notification settings - Fork 356
Changes to entity in BeforeSaveCallback not being applied to generated SQL #902
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
Comments
This is to be expected. When In order to set the id before an insert you should use I'll create an issue to fix the example which should use |
Thanks for clearing that up, much appreciated. One small related point, the documentation has the same "When It Is Published" description for both BeforeConvertCallback and BeforeSaveCallback. Is that as expected? Or could/should the text for BeforeConvertedCallback read something like "Before the aggregate is converted into a database change"? |
The documentation is wrong. I'll fix that. |
Great, thanks. |
Hi,
I'd tried to use a BeforeSaveCallback to change an immutable entity before saving to the database (specifically to set a String id attribute). However after returning a new version of the entity from a BeforeSaveCallback, the generated insert statement doesn't include the ID column:
INSERT INTO "LEGO_SET" ("MAX_AGE", "MIN_AGE", "NAME") VALUES...
I've reproduced the issue by modifying the LegoSet example to use a BeforeSaveCallback: alimac87/spring-data-examples@924e779
With these changes, running AggregateTests:exerciseSomewhatComplexEntity errors out on the first call to repository:save (I've made the ID columns NOT NULL to highlight the issue).
It may be that I'm mis-understanding and/or mis-using the BeforeSaveCallback in some way - apologies in advance if that's the case.
Some things I've tried:
Thanks,
Ali
The text was updated successfully, but these errors were encountered: