prePersist: count=0

This commit is contained in:
insanity 2018-04-27 14:53:59 +09:00
parent c944ee2be7
commit 9c74f4ae76
3 changed files with 27 additions and 16 deletions

View File

@ -4,6 +4,8 @@ import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.member.Member; import com.loafle.overflow.model.member.Member;
import com.loafle.overflow.model.meta.MetaProbeStatus; import com.loafle.overflow.model.meta.MetaProbeStatus;
import org.hibernate.annotations.ColumnDefault;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
@ -25,8 +27,7 @@ public class Probe {
private String cidr; private String cidr;
private Date authorizeDate; private Date authorizeDate;
private Member authorizeMember; private Member authorizeMember;
private int targetCount = 0; private int targetCount;
public Probe() { public Probe() {
@ -37,7 +38,7 @@ public class Probe {
} }
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
public long getId() { public long getId() {
return id; return id;
} }
@ -56,7 +57,6 @@ public class Probe {
this.status = status; this.status = status;
} }
@Column(name = "DESCRIPTION", nullable = true, length = 50) @Column(name = "DESCRIPTION", nullable = true, length = 50)
public String getDescription() { public String getDescription() {
return description; return description;
@ -86,7 +86,6 @@ public class Probe {
this.domain = domain; this.domain = domain;
} }
@Column(name = "PROBE_KEY", nullable = false, unique = true) @Column(name = "PROBE_KEY", nullable = false, unique = true)
public String getProbeKey() { public String getProbeKey() {
return probeKey; return probeKey;
@ -96,7 +95,6 @@ public class Probe {
this.probeKey = probeKey; this.probeKey = probeKey;
} }
@Column(name = "ENCRYPTION_KEY", nullable = false, length = 100, unique = true) @Column(name = "ENCRYPTION_KEY", nullable = false, length = 100, unique = true)
public String getEncryptionKey() { public String getEncryptionKey() {
return encryptionKey; return encryptionKey;
@ -144,14 +142,18 @@ public class Probe {
this.authorizeMember = authorizeMember; this.authorizeMember = authorizeMember;
} }
@Column(name = "TARGET_COUNT", nullable = false) @Column(name = "TARGET_COUNT", nullable = false)
public int getTargetCount() { public int getTargetCount() {
return targetCount; return targetCount;
} }
public void setTargetCount(int targetCount) { public void setTargetCount(int targetCount) {
this.targetCount = targetCount; this.targetCount = targetCount;
}
@PrePersist
void preInsert() {
this.targetCount = 0;
} }
} }

View File

@ -115,8 +115,12 @@ public class Sensor {
public void setDisplayName(String displayName) { public void setDisplayName(String displayName) {
this.displayName = displayName; this.displayName = displayName;
} }
@PrePersist
void preInsert() {
this.itemCount = 0;
}
@Transient @Transient
public List<MetaSensorDisplayItem> getSensorItems() { public List<MetaSensorDisplayItem> getSensorItems() {

View File

@ -18,7 +18,7 @@ public class Target {
private Date createDate; private Date createDate;
private String displayName; private String displayName;
private String description; private String description;
private int sensorCount = 0; private int sensorCount;
// Transient property // Transient property
private List<Sensor> sensors; private List<Sensor> sensors;
@ -79,7 +79,12 @@ public class Target {
public void setSensors(List<Sensor> sensors) { public void setSensors(List<Sensor> sensors) {
this.sensors = sensors; this.sensors = sensors;
} }
@PrePersist
void preInsert() {
this.sensorCount = 0;
}
// @ManyToOne // @ManyToOne