Skip to content

Cascade update does not remove existing link records #3722

@andriy-dmytruk

Description

@andriy-dmytruk

Expected Behavior

In the AssignedUuidManyToManyPersistSpec.groovy#L62 test, it seems like the update is not overwritting the courses, instead it adds courses again:

        c1.name = 'Mathematics'
        s3.courses = [c1]
        studentRepository.update(s3) // This does not remove old courses, but instead adds new ones.
        def found2 = studentRepository.findById(s3.id).orElse(null)

Despite calling update with the same course, the course gets added again and is duplicated.

We have added primary key to the join table columns and this test started failing because it wanted to add the same row twice breaking the primary key constraint.

Actual Behaviour

The test is breaking

Steps To Reproduce

Showed in this PR: #3632, as it adds primary key to mapping tables.

Environment Information

No response

Example Application

No response

Version

5.0.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions