Skip to content

Commit

Permalink
Disable lazy loading where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-ronge committed May 29, 2024
1 parent 7741046 commit 1089266
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
import javax.persistence.Transient;

import org.apache.commons.collections.CollectionUtils;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.kitodo.data.database.enums.TaskStatus;
import org.kitodo.data.database.persistence.HibernateUtil;
import org.kitodo.data.database.persistence.ProcessDAO;
import org.kitodo.data.elasticsearch.index.converter.ProcessConverter;
import org.kitodo.data.interfaces.BatchInterface;
import org.kitodo.data.interfaces.ClientInterface;
import org.kitodo.data.interfaces.DocketInterface;
import org.kitodo.data.interfaces.ProcessInterface;
import org.kitodo.data.interfaces.ProjectInterface;
Expand Down Expand Up @@ -92,13 +93,15 @@ public class Process extends BaseTemplateBean implements ProcessInterface {
@JoinColumn(name = "parent_id", foreignKey = @ForeignKey(name = "FK_process_parent_id"))
private Process parent;

@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy = "parent", cascade = CascadeType.PERSIST)
private List<Process> children;

@OneToMany(mappedBy = "process", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("ordering")
private List<Task> tasks;

@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy = "process", cascade = CascadeType.PERSIST, orphanRemoval = true)
private List<Comment> comments;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public class Project extends BaseIndexedBean implements ProjectInterface, Compar
@ManyToMany(mappedBy = "projects", cascade = CascadeType.PERSIST)
private List<User> users;

@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy = "project", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Process> processes;

Expand Down

0 comments on commit 1089266

Please sign in to comment.