Liran Zelkha has uploaded a new change for review. Change subject: core: Fix cascade delete with Job/Step ......................................................................
core: Fix cascade delete with Job/Step Job/Step had an incorrect behavior of cascade delete, causing exception to be thrown. This patch aims to fix it. Change-Id: I53021c91c138059816e58c4f25bb2851f6c29800 Signed-off-by: lzel...@redhat.com <lzel...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Job.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Step.java 2 files changed, 8 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/41912/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Job.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Job.java index 9486caf..ae95ce3 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Job.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Job.java @@ -21,10 +21,9 @@ import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; +import javax.persistence.OrderColumn; import javax.persistence.Table; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.Type; import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.VdcActionType; @@ -145,7 +144,7 @@ /** * A collection which holds the entities associated with the Job */ - @ElementCollection(fetch = FetchType.LAZY) + @ElementCollection(fetch = FetchType.EAGER) @MapKey(name = "entity_id") @CollectionTable(schema = "jpa", name = "job_subject_entity", joinColumns = @JoinColumn(name = "job_id")) @@ -155,8 +154,8 @@ * A collection which stores the steps of the Job */ - @LazyCollection(LazyCollectionOption.FALSE) - @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "jobId", orphanRemoval = true) + @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "jobId", orphanRemoval = true, fetch = FetchType.EAGER) + @OrderColumn(name = "step_number") private List<Step> steps; /** diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Step.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Step.java index e829a9e..cdda4e2 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Step.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/job/Step.java @@ -12,15 +12,15 @@ import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; +import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.OrderBy; +import javax.persistence.OrderColumn; import javax.persistence.Table; -import org.hibernate.annotations.LazyCollection; -import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.Type; import org.ovirt.engine.core.common.businessentities.BusinessEntity; import org.ovirt.engine.core.common.businessentities.IVdcQueryable; @@ -147,9 +147,9 @@ /** * The successors steps */ - @LazyCollection(LazyCollectionOption.FALSE) - @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "parentStepId", orphanRemoval = true) + @OneToMany(cascade = { CascadeType.ALL }, mappedBy = "parentStepId", orphanRemoval = true, fetch = FetchType.EAGER) @OrderBy("stepNumber") + @OrderColumn(name = "step_number") private List<Step> steps; public Step() { -- To view, visit https://gerrit.ovirt.org/41912 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I53021c91c138059816e58c4f25bb2851f6c29800 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liran Zelkha <lzel...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches