Skip to content

Synchronization of bi-directional associations #825

@dennisvang

Description

@dennisvang

The hibernate docs suggest using helper methods to ensure proper synchronization of bi-directional associations (relations).

However, the current v2 development branch does not define any helper methods.
As a result, the in-memory state of entities is likely to get out of sync with the database.

For example, this already happens here:

In this case, because the in memory definition is not updated, the DTO that is returned does not include the related items:

This has gone unnoticed because these relations were not tested.

A quick-and-dirty workaround for this specific case is to move the refresh() call below the createDependents() call.

However, the fact that a manual refresh() call is necessary suggests that the design is not optimal, and there are probably more places where similar problems can occur.

We can prevent this type of problem by introducing add/remove helper methods to all the relevant entity classes.

Metadata

Metadata

Assignees

Labels

bugSomething's wrongdevRelated to development, e.g. code style, refactoring, github workflows, etc.improvementExisting functionality that can be improved

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions