From 46408739a86d9515fa35d75ce860265b9045e8b5 Mon Sep 17 00:00:00 2001 From: Jasper Kamerling Date: Mon, 30 Jan 2023 08:58:45 +0100 Subject: [PATCH] Move output setting to device table Signed-off-by: Jasper Kamerling --- .../domain/core/entities/Device.java | 13 +++++++++++++ .../domain/core/entities/Ssld.java | 7 ------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/entities/Device.java b/osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/entities/Device.java index aea747b5595..9e119068e60 100644 --- a/osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/entities/Device.java +++ b/osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/entities/Device.java @@ -24,7 +24,9 @@ import java.util.stream.Collectors; import javax.persistence.AttributeOverride; import javax.persistence.CascadeType; +import javax.persistence.CollectionTable; import javax.persistence.Column; +import javax.persistence.ElementCollection; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.EnumType; @@ -36,6 +38,8 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Transient; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.SortNatural; import org.hibernate.annotations.Type; import org.opensmartgridplatform.domain.core.valueobjects.Address; @@ -96,6 +100,15 @@ public class Device extends AbstractEntity { @Type(type = "org.opensmartgridplatform.shared.hibernate.InetAddressUserType") protected InetAddress networkAddress; + /** + * The output settings are only used in the ssld table but in the database it is linked to the + * Device Table. + */ + @LazyCollection(LazyCollectionOption.FALSE) + @ElementCollection() + @CollectionTable(name = "device_output_setting", joinColumns = @JoinColumn(name = "device_id")) + protected List outputSettings = new ArrayList<>(); + /** Cell ID on a Base Transceiver Station. */ @Column private Integer cellId; diff --git a/osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/entities/Ssld.java b/osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/entities/Ssld.java index 056efb04cf5..85a62ffbfad 100644 --- a/osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/entities/Ssld.java +++ b/osgp/platform/osgp-domain-core/src/main/java/org/opensmartgridplatform/domain/core/entities/Ssld.java @@ -15,9 +15,7 @@ import java.util.Map; import java.util.TreeMap; import javax.persistence.CascadeType; -import javax.persistence.CollectionTable; import javax.persistence.Column; -import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.JoinColumn; @@ -56,11 +54,6 @@ public class Ssld extends Device { @LazyCollection(LazyCollectionOption.FALSE) private final List eans = new ArrayList<>(); - @LazyCollection(LazyCollectionOption.FALSE) - @ElementCollection() - @CollectionTable(name = "device_output_setting", joinColumns = @JoinColumn(name = "device_id")) - private List outputSettings = new ArrayList<>(); - @OneToMany( mappedBy = "device", cascade = {CascadeType.MERGE, CascadeType.PERSIST},