-
Notifications
You must be signed in to change notification settings - Fork 356
possibility of data loss using CrudRepository in case of nested entities as java Record #1739
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
Thank you for getting in touch - it would be great if you could take the time to provide the above code snippets as a complete minimal sample (something that we can unzip or git clone, build, and deploy) that reproduces the problem. |
ofcourse, I already have a project, but I have to check if it needs to be cleaned a bit more before I can send it. |
Hi, I've created a repository for you: https://github.com/ljpeters/engine-trouble The main code is in I hope you can simply load it into intellij and make it work. The test should fail, and you should see an ERROR in the application log. |
Thank you @ljpeters for the reproducer - I moved the issue to spring-data-relational the home of the data jdbc project used in the sample. |
Duplicate of #1692 |
Hi,
I have encountered an issue that occurs in spring-boot-starter-parent 3.2.0 - 3.2.2.
It worked fine in 3.1.8 and 2.7.18.
I have the following structure:
Create a Car in the database without an engine to cause the id column in the engine table to always be different from the car id.
The Repository that extends CrudRepository:
Creates a new Car in code;
Next, I use a
find
to lookup the same Car. The save causes the pistons to be deleted.I think this happens:
the findByReference does a SELECT on Car, and subsequently on Engine. When selecting pistons, it takes the Car.id, instead of the Engine.id. The resulting Engine object does not have Pistons, and when doing the save(), al the pistons in the database get deleted.
In the root pom:
root pom snippet
These are the included spring dependencies, it does NOT use/include Hibernate:
pom snippet
I moved this issue from the spring-boot repository.
The text was updated successfully, but these errors were encountered: