From 9b2d61340c9264168c7f7f050f994beb322f7934 Mon Sep 17 00:00:00 2001 From: Matthias Ronge Date: Mon, 9 Sep 2024 15:49:28 +0200 Subject: [PATCH] Fix problems --- .../src/main/java/org/kitodo/data/database/beans/Batch.java | 1 - .../src/main/java/org/kitodo/data/database/beans/Process.java | 4 ++++ .../src/main/java/org/kitodo/data/database/beans/Task.java | 3 +++ .../main/java/org/kitodo/data/database/beans/Template.java | 1 + .../java/org/kitodo/data/database/persistence/TaskDAO.java | 4 ++-- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Batch.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Batch.java index 527e364b537..93fb527049d 100644 --- a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Batch.java +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Batch.java @@ -64,7 +64,6 @@ public class Batch extends BaseBean { * Holds the processes that belong to the batch. */ @ManyToMany(cascade = CascadeType.PERSIST) - @IndexedEmbedded(includePaths = {"title"}) @JoinTable(name = "batch_x_process", joinColumns = { @JoinColumn(name = "batch_id", foreignKey = @ForeignKey(name = "FK_batch_x_process_batch_id")) }, inverseJoinColumns = { @JoinColumn(name = "process_id", foreignKey = @ForeignKey(name = "FK_batch_x_process_process_id")) }) diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java index 3703bbe4aba..eac663aace1 100644 --- a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java @@ -116,6 +116,7 @@ public class Process extends BaseTemplateBean { @Transient private boolean hasChildren = true; + @LazyCollection(LazyCollectionOption.FALSE) @OneToMany(mappedBy = "process", cascade = CascadeType.ALL, orphanRemoval = true) @IndexedEmbedded(includePaths = {"title", "id"}) @OrderBy("ordering") @@ -126,6 +127,7 @@ public class Process extends BaseTemplateBean { @IndexedEmbedded(includePaths = {"message"}) private List comments; + @LazyCollection(LazyCollectionOption.FALSE) @ManyToMany(cascade = CascadeType.ALL) @IndexedEmbedded(includePaths = {"id", "title", "value"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @@ -134,6 +136,7 @@ public class Process extends BaseTemplateBean { @JoinColumn(name = "property_id", foreignKey = @ForeignKey(name = "FK_process_x_property_property_id")) }) private List properties; + @LazyCollection(LazyCollectionOption.FALSE) @ManyToMany(cascade = CascadeType.ALL) @IndexedEmbedded(includePaths = {"id", "title", "value"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) @@ -142,6 +145,7 @@ public class Process extends BaseTemplateBean { @JoinColumn(name = "property_id", foreignKey = @ForeignKey(name = "FK_template_x_property_property_id")) }) private List templates; + @LazyCollection(LazyCollectionOption.FALSE) @ManyToMany(cascade = CascadeType.ALL) @IndexedEmbedded(includePaths = {"id", "title", "value"}) @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW) diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Task.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Task.java index fb6c2a34405..7f1c98efbbb 100644 --- a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Task.java +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Task.java @@ -30,6 +30,8 @@ import javax.persistence.Table; import javax.persistence.Transient; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.GenericField; import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed; @@ -173,6 +175,7 @@ public class Task extends BaseBean { * This field contains information about user's roles, which are allowed to * work on this task. */ + @LazyCollection(LazyCollectionOption.FALSE) @ManyToMany(cascade = CascadeType.PERSIST) @IndexedEmbedded(includePaths = {"id"}) @JoinTable(name = "task_x_role", joinColumns = { diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Template.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Template.java index c7d944ef7d8..3572f046ebe 100644 --- a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Template.java +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Template.java @@ -78,6 +78,7 @@ public class Template extends BaseTemplateBean { @IndexedEmbedded(includePaths = {"id", "title"}) private List tasks; + @LazyCollection(LazyCollectionOption.FALSE) @ManyToMany(cascade = CascadeType.PERSIST) @IndexedEmbedded(includePaths = {"id", "active", "title"}) @JoinTable(name = "project_x_template", joinColumns = { diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/persistence/TaskDAO.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/persistence/TaskDAO.java index 7281ccab11d..ede11c078db 100644 --- a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/persistence/TaskDAO.java +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/persistence/TaskDAO.java @@ -101,8 +101,8 @@ public List getAllTasksInBetween(Integer orderingMax, Integer orderingMin, parameters.put("orderingMax", orderingMax); parameters.put("orderingMin", orderingMin); parameters.put(KEY_PROCESS_ID, processId); - return getByQuery("FROM Task WHERE process_id = :processId AND ordering < :orderingMin" - + " AND ordering > :orderingMax ORDER BY ordering ASC", + return getByQuery("FROM Task WHERE process_id = :processId AND ordering > :orderingMin" + + " AND ordering < :orderingMax ORDER BY ordering ASC", parameters); }