-
Notifications
You must be signed in to change notification settings - Fork 349
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
When an aggregate root has no id we should throw an appropriate exception #1502
Comments
May I take this to try to contribute? |
Sure, go ahead. |
@schauder |
Yes. There is a check in place that after saving a new aggregate, i.e. inserting its aggregate root, the id is not null. This will obviously fail when there is no id property in the first place. See Line 453 in fbc3bf0
But this is not the place where we should check for the existence of an id. I think we should do that when constructing a repository, because then we know a entity is intended to be used as an aggregate root and therefore should have an id property. |
Hi, @schauder. I'm still here trying to fix this issue. Haha! in this method:
|
I would put this check in the Putting it in the
Here is how I would approach this:
|
Your explanations helped me a lot. I think I am done, but I don't know if it's right. Should I open a Merge Request for you to see if it's ok? Must I follow the steps in this document, https://github.com/spring-projects/spring-data-build/blob/main/CONTRIBUTING.adoc ? |
Yes, a PR would be the next step. And yes that is the correct document for guidance. But we are already did a lot of the stuff (like discussing changes in an issue) and other stuff does not apply (the stuff about security issues). So the stuff to look out for:
See also this section: https://github.com/spring-projects/spring-data-build/blob/main/CONTRIBUTING.adoc#quickstart Everything als I can and will fix in post. |
We now distinguish between an id not set during insert and a supposed aggregate root without id property. Closes #1502
Currently Spring Data JDBC complains that the id is still
null
after save.The text was updated successfully, but these errors were encountered: