From 20e1b6517b1c64a82cb52be8a2a2882c86b1318b Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Sun, 24 Feb 2019 10:42:15 -0500 Subject: Prevent race conditions on same distributionId. - Code to include optimistic lock to prevent race conditions on same distributionId. Change-Id: Ibe110b32f2472d991a4a3e03e3d15d5e4deefd65 Issue-ID: SO-1566 Signed-off-by: Benjamin, Max (mb388a) --- .../so/db/request/beans/WatchdogDistributionStatus.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'mso-api-handlers/mso-requests-db/src') diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java index 40c81b96e7..69d84b7679 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java @@ -31,6 +31,8 @@ import javax.persistence.PreUpdate; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import javax.persistence.Version; + import java.util.Objects; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -54,6 +56,9 @@ public class WatchdogDistributionStatus implements Serializable { @Column(name = "MODIFY_TIME") @Temporal(TemporalType.TIMESTAMP) private Date modifyTime; + @Version + @Column(name = "LOCK_VERSION") + private int version; public WatchdogDistributionStatus() { @@ -78,7 +83,15 @@ public class WatchdogDistributionStatus implements Serializable { public void setDistributionIdStatus(String distributionIdStatus) { this.distributionIdStatus = distributionIdStatus; } - + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } + public Date getCreateTime() { return createTime; } -- cgit 1.2.3-korg