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.meta.MetaProbeStatus;
import org.hibernate.annotations.ColumnDefault;
import javax.persistence.*;
import java.util.Date;
@ -25,8 +27,7 @@ public class Probe {
private String cidr;
private Date authorizeDate;
private Member authorizeMember;
private int targetCount = 0;
private int targetCount;
public Probe() {
@ -56,7 +57,6 @@ public class Probe {
this.status = status;
}
@Column(name = "DESCRIPTION", nullable = true, length = 50)
public String getDescription() {
return description;
@ -86,7 +86,6 @@ public class Probe {
this.domain = domain;
}
@Column(name = "PROBE_KEY", nullable = false, unique = true)
public String getProbeKey() {
return probeKey;
@ -96,7 +95,6 @@ public class Probe {
this.probeKey = probeKey;
}
@Column(name = "ENCRYPTION_KEY", nullable = false, length = 100, unique = true)
public String getEncryptionKey() {
return encryptionKey;
@ -144,7 +142,6 @@ public class Probe {
this.authorizeMember = authorizeMember;
}
@Column(name = "TARGET_COUNT", nullable = false)
public int getTargetCount() {
return targetCount;
@ -154,4 +151,9 @@ public class Probe {
this.targetCount = targetCount;
}
@PrePersist
void preInsert() {
this.targetCount = 0;
}
}

View File

@ -117,6 +117,10 @@ public class Sensor {
this.displayName = displayName;
}
@PrePersist
void preInsert() {
this.itemCount = 0;
}
@Transient
public List<MetaSensorDisplayItem> getSensorItems() {

View File

@ -18,7 +18,7 @@ public class Target {
private Date createDate;
private String displayName;
private String description;
private int sensorCount = 0;
private int sensorCount;
// Transient property
private List<Sensor> sensors;
@ -81,6 +81,11 @@ public class Target {
this.sensors = sensors;
}
@PrePersist
void preInsert() {
this.sensorCount = 0;
}
// @ManyToOne
// @JoinColumn(name = "PROBE_ID", nullable = false)