aboutsummaryrefslogtreecommitdiffstats
path: root/models-base/src/main/java/org
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-03-05 15:50:47 -0500
committerJim Hahn <jrh3@att.com>2021-03-08 10:26:56 -0500
commit3d4488f4b4cdfb4e890e654a2ab39a1558e0a22e (patch)
tree7e718bf70f5757f4c915f9cba4e84c56010f5b53 /models-base/src/main/java/org
parent4301496b538fcb10df92d53984ed2a05dade3d08 (diff)
Use Date instead of Timestamp
Use of Timestamp in JPA classes appears to cause EntityNotFoundException. Changed from Timestamp back to Date. Issue-ID: POLICY-3125 Change-Id: I3ee29675849e3feda2641e9b240207c96fd975d4 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-base/src/main/java/org')
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java28
-rw-r--r--models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java15
2 files changed, 25 insertions, 18 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java
index 06af688b0..1a29c8b01 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceTimestampKey.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,13 +21,15 @@
package org.onap.policy.models.base;
-import java.sql.Timestamp;
import java.time.Instant;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
@@ -41,15 +44,16 @@ import org.onap.policy.common.utils.validation.Assertions;
@Embeddable
@Data
-@EqualsAndHashCode
+@EqualsAndHashCode(callSuper = false)
public class PfReferenceTimestampKey extends PfKey {
private static final long serialVersionUID = 1130918285832617215L;
private static final String TIMESTAMP_TOKEN = "timeStamp";
@Column(name = TIMESTAMP_TOKEN)
+ @Temporal(TemporalType.TIMESTAMP)
@NotNull
- private Timestamp timeStamp;
+ private Date timeStamp;
@Embedded
@Column
@@ -60,7 +64,7 @@ public class PfReferenceTimestampKey extends PfKey {
*/
public PfReferenceTimestampKey() {
this.referenceKey = new PfReferenceKey();
- this.timeStamp = new Timestamp(0);
+ this.timeStamp = new Date(0);
}
/**
@@ -82,7 +86,7 @@ public class PfReferenceTimestampKey extends PfKey {
*/
public PfReferenceTimestampKey(final PfConceptKey pfConceptKey) {
this.referenceKey = new PfReferenceKey(pfConceptKey);
- this.timeStamp = new Timestamp(0);
+ this.timeStamp = new Date(0);
}
/**
@@ -97,7 +101,7 @@ public class PfReferenceTimestampKey extends PfKey {
*/
public PfReferenceTimestampKey(final PfConceptKey pfConceptKey, final String localName, final Instant instant) {
this.referenceKey = new PfReferenceKey(pfConceptKey, localName);
- this.timeStamp = Timestamp.from(instant);
+ this.timeStamp = Date.from(instant);
}
/**
@@ -113,7 +117,7 @@ public class PfReferenceTimestampKey extends PfKey {
public PfReferenceTimestampKey(final PfReferenceKey parentReferenceKey, final String localName,
final Instant instant) {
this.referenceKey = new PfReferenceKey(parentReferenceKey, localName);
- this.timeStamp = Timestamp.from(instant);
+ this.timeStamp = Date.from(instant);
}
/**
@@ -132,7 +136,7 @@ public class PfReferenceTimestampKey extends PfKey {
public PfReferenceTimestampKey(final PfConceptKey pfConceptKey, final String parentLocalName,
final String localName, final Instant instant) {
this.referenceKey = new PfReferenceKey(pfConceptKey, parentLocalName, localName);
- this.timeStamp = Timestamp.from(instant);
+ this.timeStamp = Date.from(instant);
}
/**
@@ -151,7 +155,7 @@ public class PfReferenceTimestampKey extends PfKey {
public PfReferenceTimestampKey(final String parentKeyName, final String parentKeyVersion, final String localName,
final Instant instant) {
this.referenceKey = new PfReferenceKey(parentKeyName, parentKeyVersion, PfKey.NULL_KEY_NAME, localName);
- this.timeStamp = Timestamp.from(instant);
+ this.timeStamp = Date.from(instant);
}
/**
@@ -172,7 +176,7 @@ public class PfReferenceTimestampKey extends PfKey {
public PfReferenceTimestampKey(final String parentKeyName, final String parentKeyVersion,
final String parentLocalName, final String localName, final Instant instant) {
this.referenceKey = new PfReferenceKey(parentKeyName, parentKeyVersion, parentLocalName, localName);
- this.timeStamp = Timestamp.from(instant);
+ this.timeStamp = Date.from(instant);
}
@@ -183,7 +187,7 @@ public class PfReferenceTimestampKey extends PfKey {
*/
public PfReferenceTimestampKey(final String id) {
this.referenceKey = new PfReferenceKey(id.substring(0, id.lastIndexOf(':')));
- this.timeStamp = new Timestamp(Long.parseLong(id.substring(id.lastIndexOf(':') + 1)));
+ this.timeStamp = new Date(Long.parseLong(id.substring(id.lastIndexOf(':') + 1)));
}
@@ -202,7 +206,7 @@ public class PfReferenceTimestampKey extends PfKey {
}
public void setInstant(final Instant instant) {
- setTimeStamp(Timestamp.from(instant));
+ setTimeStamp(Date.from(instant));
}
/**
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
index 22d29f745..6e2271846 100644
--- a/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
+++ b/models-base/src/main/java/org/onap/policy/models/base/PfTimestampKey.java
@@ -3,7 +3,7 @@
* ONAP Policy Model
* ================================================================================
* Copyright (C) 2019-2021 Nordix Foundation.
- * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,10 +23,12 @@
package org.onap.policy.models.base;
-import java.sql.Timestamp;
import java.time.Instant;
+import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Embeddable;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
@@ -50,8 +52,9 @@ public class PfTimestampKey extends PfKeyImpl {
private String version;
@Column(name = TIMESTAMP_TOKEN)
+ @Temporal(TemporalType.TIMESTAMP)
@NonNull
- private Timestamp timeStamp;
+ private Date timeStamp;
/**
@@ -81,7 +84,7 @@ public class PfTimestampKey extends PfKeyImpl {
public PfTimestampKey(@NonNull final String name, @NonNull final String version,
@NonNull final Instant instant) {
super(name, version);
- this.timeStamp = Timestamp.from(instant);
+ this.timeStamp = Date.from(instant);
}
/**
@@ -91,7 +94,7 @@ public class PfTimestampKey extends PfKeyImpl {
*/
public PfTimestampKey(final String id) {
super(id.substring(0, id.lastIndexOf(':')));
- this.timeStamp = new Timestamp(Long.parseLong(id.substring(id.lastIndexOf(':') + 1)));
+ this.timeStamp = new Date(Long.parseLong(id.substring(id.lastIndexOf(':') + 1)));
}
@Override
@@ -113,7 +116,7 @@ public class PfTimestampKey extends PfKeyImpl {
}
public void setInstant(final Instant instant) {
- setTimeStamp(Timestamp.from(instant));
+ setTimeStamp(Date.from(instant));
}
@Override