kitodo / kitodo-production

Kitodo.Production is a workflow management tool for mass digitization and is part of the Kitodo Digital Library Suite.
http://www.kitodo.org/software/kitodoproduction/
GNU General Public License v3.0
62 stars 63 forks source link

Creating a new template via migration causes double entries in project_x_template #4458

Open m-kotzyba opened 3 years ago

m-kotzyba commented 3 years ago

Only in Migration (System --> Migrieren --> Workflow erstellen --> Workflow anlegen):

If a new or an existing workflow is selected and than a new template (Neue Produktionsvorlage erstellen) is created, for the corresponding project, this new template is assigned twice to the project.

That is, the template it self is created correctly (only once in table kitodo.template) but listed twice in table kitodo.project_x_template. This can also be seen via the web interface: Projekte --> select the corresponding migrated project --> bearbeiten --> Productionsvorlagen.

double template entry

matthias-ronge commented 3 years ago

Resaon: The templates property of class Project is declared as List<Template>, however without a column indicating the sort order:

@ManyToMany(mappedBy = "projects", cascade = CascadeType.PERSIST)
private List<Template> templates;

This should be a Set<Template> to avoid duplicates.

This is a general issue for all many-to-many relationships in our application: No duplicates are wanted, so Set<…> should be used. (If order matters or duplicates are wanted to be allowed, List<…> should be used with a column indicating the sorting, but our data model doesn’t have such a case.)