devonfw/jump-the-queue

Prevent cyclic dependency

Opened this issue · 2 comments

The tutorial for building JumpTheQueue suggests build two entities that are both linking to each other:
https://github.com/oasp/oasp-tutorial-sources/wiki/OASP4jComponents#the-em-core-em-of-the-components

Such a cyclic relation is rather to be considered as an anti-pattern and is causing issues with JPA.
IMHO we should not propose such a design in our tutorial. Better decide which side is the "natural" side where to put the relation and if required to get it from the other side, create a query for that in DAO/repository.

Also references in a database are to be modeled as such using foreign key constraint.

idCode BIGINT

This will prevent referential integrity of the database. In very specific occasions that can be done on purpose (and should be commented/documented) so e.g. to be able to delete the referenced entity without updating references in linking entity.

Hi @hohwille,
I think the second issue has been addressed, since FK's are used here now.

I'm not sure however if the first issue was been addressed when the app was migrated from OASP to devonfw. The design documentation only shows a very simplified model of the application, which seems to indicate that there are no cyclic dependency anymore ...

Do you have any input on this?