Skip to content

DataContext merge can duplicate owner collection on bidirectional graph with multiple java instances of same id #5331

@Flaurite

Description

@Flaurite

Environment

Jmix version: 2.8+

Bug Description

Reproduces only with not saved entities.

When we have association with bidirectional reference it causes recursion to reach the same managed entity again, DataContext#mergeList() re-enters and writes to the same dstList as the outer call, producing duplicate elements in the owner's collection.
For instance:

  • ProductSet with Product collection
  • Product with ProductSet link

Steps To Reproduce

  1. Download demo: datacontext-demo.zip
  2. Launch the application
  3. Open "Product sets"
  4. Create one, do no save
  5. Create Product 1, Product 2
  6. Edit Product 1, edit Product 2

Current Behavior

After saving editions in Product 2 there are 4 rows with duplications instead of 2 rows.

Expected Behavior

2 rows with changes we've made in editor.

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

Status
Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions