Skip to content

repository.save() returns duplicate child-elements (at least w/ postgresql) [DATAJDBC-456] #680

@spring-projects-issues

Description

@spring-projects-issues

Clemens Hahn opened DATAJDBC-456 and commented

I will explain this behavior based on the [example-project|https://github.com/spring-projects/spring-data-examples/blob/master/jdbc/basics/README.adoc].

I added a new child-entity to the LegoSet-Entity of type Color. LegoSet references this entity via Set<Color> colors.

  • create a LegoSet
  • add one Color
  • call legoSetRepository.save(legoSet) and inspect the returned value
  • the Set<Color> colors contains 2 Colors.

This does not happen using the embedded H2-Database! To reproduce it you can use a Postgresql Database!

To (hopefully quickly) reproduce this bug please apply the attached patch-file to the example-repo and execute the following (manual) steps:

  • create a local postgresql-database: docker run --name spring-data-jdbc-kotlin-test -e POSTGRES_USER=integrationtest -e POSTGRES_PASSWORD=password -e POSTGRES_DB=spring-data-jdbc-kotlin -p 5438:5432 -d postgres:11
  • create the schema in that database with src/main/resources/schema.sql (using a database-tool)
  • start the test example.springdata.jdbc.basics.aggregate.AggregateTests#exerciseSomewhatComplexEntity
  • the test will fails with:
java.lang.AssertionError: 
 Expected size:<1> but was:<2> in:
 <[Color(lego_set=1, r=255, g=0, b=0), Color(lego_set=1, r=255, g=0, b=0)]>

Attachments:

Metadata

Metadata

Assignees

Labels

status: declinedA suggestion or change that we don't feel we should currently applytype: bugA general bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions