possibility of data loss using CrudRepository in case of nested entities as java Record #39435
Labels
for: external-project
For an external project and not something we can fix
status: invalid
An issue that we don't feel is valid
Uh oh!
There was an error while loading. Please reload this page.
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 without an engine to cause the id column in the engine table to always be different from the car id.
This is the repository that uses CrudRepository:
This code creates a new Car;
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.
The text was updated successfully, but these errors were encountered: