From 1afea3de2fa119b98e3b9efbd5273a22c95a0170 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 15 Jun 2018 12:16:24 +0900 Subject: [PATCH] ing --- pom.xml | 2 +- .../overflow/model/infra/InfraHost.java | 30 ++++++++++++------- .../overflow/model/infra/InfraHostIP.java | 3 ++ .../model/infra/InfraHostMachine.java | 12 -------- .../overflow/model/infra/InfraHostOS.java | 11 ------- .../overflow/model/infra/InfraHostPort.java | 12 ++++---- .../overflow/model/infra/InfraService.java | 11 ------- .../overflow/model/infra/InfraZone.java | 1 - 8 files changed, 29 insertions(+), 53 deletions(-) diff --git a/pom.xml b/pom.xml index 598c3fe..f2e028b 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.loafle.overflow commons-java jar - 1.0.71-SNAPSHOT + 1.0.72-SNAPSHOT com.loafle.overflow.commons-java diff --git a/src/main/java/com/loafle/overflow/model/infra/InfraHost.java b/src/main/java/com/loafle/overflow/model/infra/InfraHost.java index d230d85..a02807f 100644 --- a/src/main/java/com/loafle/overflow/model/infra/InfraHost.java +++ b/src/main/java/com/loafle/overflow/model/infra/InfraHost.java @@ -6,6 +6,10 @@ import javax.persistence.*; import com.loafle.overflow.model.meta.MetaTargetHostType; +import org.codehaus.jackson.annotate.JsonBackReference; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; + /** * Created by root on 17. 6. 22. */ @@ -18,8 +22,11 @@ public class InfraHost extends Infra { private InfraHostMachine infraHostMachine; private InfraHostOS infraHostOS; + + @JsonBackReference private List infraHostIPs; - private List infraHostPorts; + + private InfraHost containerInfraHost; public InfraHost() { super(); @@ -30,7 +37,7 @@ public class InfraHost extends Infra { } @ManyToOne - @JoinColumn(name = "INFRA_ZONE_ID", nullable = true) + @JoinColumn(name = "INFRA_ZONE_ID", nullable = false) public InfraZone getInfraZone() { return infraZone; } @@ -85,7 +92,7 @@ public class InfraHost extends Infra { * @return the infraHostIPs */ @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "infraHost") - @OrderColumn(name = "ID") + @Fetch(FetchMode.SELECT) public List getInfraHostIPs() { return infraHostIPs; } @@ -98,18 +105,19 @@ public class InfraHost extends Infra { } /** - * @return the infraHostPorts + * @return the containerInfraHost */ - @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "infraHost") - @OrderColumn(name = "PORT") - public List getInfraHostPorts() { - return infraHostPorts; + @ManyToOne + @JoinColumn(name = "CONTAINER_INFRA_HOST_ID", nullable = true) + public InfraHost getContainerInfraHost() { + return containerInfraHost; } /** - * @param infraHostPorts the infraHostPorts to set + * @param containerInfraHost the containerInfraHost to set */ - public void setInfraHostPorts(List infraHostPorts) { - this.infraHostPorts = infraHostPorts; + public void setContainerInfraHost(InfraHost containerInfraHost) { + this.containerInfraHost = containerInfraHost; } + } diff --git a/src/main/java/com/loafle/overflow/model/infra/InfraHostIP.java b/src/main/java/com/loafle/overflow/model/infra/InfraHostIP.java index 48f90d0..f12b610 100644 --- a/src/main/java/com/loafle/overflow/model/infra/InfraHostIP.java +++ b/src/main/java/com/loafle/overflow/model/infra/InfraHostIP.java @@ -4,6 +4,8 @@ import javax.persistence.*; import com.loafle.overflow.model.meta.MetaIPType; +import org.codehaus.jackson.annotate.JsonManagedReference; + import java.util.Date; /** @@ -13,6 +15,7 @@ import java.util.Date; @Table(name = "INFRA_HOST_IP", schema = "public") public class InfraHostIP { private Long id; + @JsonManagedReference private InfraHost infraHost; private MetaIPType metaIPType; private String address; diff --git a/src/main/java/com/loafle/overflow/model/infra/InfraHostMachine.java b/src/main/java/com/loafle/overflow/model/infra/InfraHostMachine.java index 172168b..c7450f6 100644 --- a/src/main/java/com/loafle/overflow/model/infra/InfraHostMachine.java +++ b/src/main/java/com/loafle/overflow/model/infra/InfraHostMachine.java @@ -11,7 +11,6 @@ import java.util.Date; @Table(name = "INFRA_HOST_MACHINE", schema = "public") public class InfraHostMachine { private Long id; - private InfraHost infraHost; private String meta; private Date createDate; @@ -25,16 +24,6 @@ public class InfraHostMachine { this.id = id; } - @OneToOne - @JoinColumn(name = "INFRA_HOST_ID", nullable = false) - public InfraHost getInfraHost() { - return infraHost; - } - - public void setInfraHost(InfraHost infraHost) { - this.infraHost = infraHost; - } - @Basic @Column(name = "META", nullable = true, length = 2000) public String getMeta() { @@ -45,7 +34,6 @@ public class InfraHostMachine { this.meta = meta; } - @Temporal(TemporalType.TIMESTAMP) @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) public Date getCreateDate() { diff --git a/src/main/java/com/loafle/overflow/model/infra/InfraHostOS.java b/src/main/java/com/loafle/overflow/model/infra/InfraHostOS.java index 9747542..3a6ffd5 100644 --- a/src/main/java/com/loafle/overflow/model/infra/InfraHostOS.java +++ b/src/main/java/com/loafle/overflow/model/infra/InfraHostOS.java @@ -11,7 +11,6 @@ import java.util.Date; @Table(name = "INFRA_HOST_OS", schema = "public") public class InfraHostOS { private Long id; - private InfraHost infraHost; private String name; private String os; private String platform; @@ -32,16 +31,6 @@ public class InfraHostOS { this.id = id; } - @OneToOne - @JoinColumn(name = "INFRA_HOST_ID", nullable = false) - public InfraHost getInfraHost() { - return infraHost; - } - - public void setInfraHost(InfraHost infraHost) { - this.infraHost = infraHost; - } - /** * @return the name */ diff --git a/src/main/java/com/loafle/overflow/model/infra/InfraHostPort.java b/src/main/java/com/loafle/overflow/model/infra/InfraHostPort.java index d3b34e6..30f8641 100644 --- a/src/main/java/com/loafle/overflow/model/infra/InfraHostPort.java +++ b/src/main/java/com/loafle/overflow/model/infra/InfraHostPort.java @@ -13,7 +13,7 @@ import java.util.Date; @Table(name = "INFRA_HOST_PORT", schema = "public") public class InfraHostPort { private Long id; - private InfraHost infraHost; + private InfraHostIP infraHostIP; private MetaPortType metaPortType; private Integer port; private Date createDate; @@ -29,13 +29,13 @@ public class InfraHostPort { } @ManyToOne - @JoinColumn(name = "INFRA_HOST_ID", nullable = false) - public InfraHost getInfraHost() { - return infraHost; + @JoinColumn(name = "INFRA_HOST_IP_ID", nullable = false) + public InfraHostIP getInfraHostIP() { + return infraHostIP; } - public void setInfraHost(InfraHost infraHost) { - this.infraHost = infraHost; + public void setInfraHostIP(InfraHostIP infraHostIP) { + this.infraHostIP = infraHostIP; } @ManyToOne diff --git a/src/main/java/com/loafle/overflow/model/infra/InfraService.java b/src/main/java/com/loafle/overflow/model/infra/InfraService.java index 7b715eb..4997db2 100644 --- a/src/main/java/com/loafle/overflow/model/infra/InfraService.java +++ b/src/main/java/com/loafle/overflow/model/infra/InfraService.java @@ -14,7 +14,6 @@ import com.loafle.overflow.model.meta.MetaTargetServiceType; public class InfraService extends Infra { private MetaTargetServiceType metaTargetServiceType; - private InfraHostIP infraHostIP; private InfraHostPort infraHostPort; private MetaCryptoType metaCryptoType; @@ -36,16 +35,6 @@ public class InfraService extends Infra { this.metaTargetServiceType = metaTargetServiceType; } - @ManyToOne - @JoinColumn(name = "INFRA_HOST_IP_ID", nullable = true) - public InfraHostIP getInfraHostIP() { - return infraHostIP; - } - - public void setInfraHostIP(InfraHostIP infraHostIP) { - this.infraHostIP = infraHostIP; - } - @OneToOne @JoinColumn(name = "INFRA_HOST_PORT_ID", nullable = true) public InfraHostPort getInfraHostPort() { diff --git a/src/main/java/com/loafle/overflow/model/infra/InfraZone.java b/src/main/java/com/loafle/overflow/model/infra/InfraZone.java index f51c5ae..1ad404e 100644 --- a/src/main/java/com/loafle/overflow/model/infra/InfraZone.java +++ b/src/main/java/com/loafle/overflow/model/infra/InfraZone.java @@ -38,7 +38,6 @@ public class InfraZone extends Infra { this.metaTargetZoneType = metaTargetZoneType; } - @Basic @Column(name = "NETWORK", nullable = true) public String getNetwork() {