87: Use Instant instead of Date & Remove deprecated @Temporal

This commit is contained in:
Tom Zhao 2025-04-23 10:39:51 +02:00
parent 25b87579eb
commit 5c36cd345d
4 changed files with 12 additions and 14 deletions

@ -23,8 +23,8 @@ import jakarta.persistence.MapKeyJoinColumn;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import java.time.Instant;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collection;
@ -125,8 +125,7 @@ public class Project extends DomainObject {
@Basic
@Column(name = "clone_timestamp")
@Temporal(TemporalType.TIMESTAMP)
private Date cloneTimestamp;
private Instant cloneTimestamp;
// ----------------------------------------------------------------------------------
// Embedded JPA-mapping
@ -396,11 +395,11 @@ public class Project extends DomainObject {
this.rootProjectId = rootProjectId;
}
public Date getCloneTimestamp() {
public Instant getCloneTimestamp() {
return cloneTimestamp;
}
public void setCloneTimestamp(Date cloneTimestamp) {
public void setCloneTimestamp(Instant cloneTimestamp) {
this.cloneTimestamp = cloneTimestamp;
}

@ -100,7 +100,7 @@ public class SplitOrRestartProjectServiceImpl implements SplitOrRestartProjectSe
childProject.setRootProjectId(
project.getRootProjectId() != null ? project.getRootProjectId() : project.getId()
);
childProject.setCloneTimestamp(Date.from(Instant.now()));
childProject.setCloneTimestamp(Instant.now());
childProject = projectService.save(childProject);

@ -13,8 +13,8 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.OrderBy;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
@ -42,8 +42,7 @@ public abstract class ReviewerApproval extends DomainObject {
@Basic
@Column(name = "clone_timestamp")
@Temporal(TemporalType.TIMESTAMP)
protected Date cloneTimestamp;
protected Instant cloneTimestamp;
// ----------------------------------------------------------------------------------
// JPA-mappings of foreign keys in this table (reviewer_approval) referencing other
@ -80,11 +79,11 @@ public abstract class ReviewerApproval extends DomainObject {
isCloned = cloned;
}
public Date getCloneTimestamp() {
public Instant getCloneTimestamp() {
return cloneTimestamp;
}
public void setCloneTimestamp(Date cloneDate) {
public void setCloneTimestamp(Instant cloneDate) {
this.cloneTimestamp = cloneDate;
}

@ -32,7 +32,7 @@ public class RoughDraftApproval extends ReviewerApproval {
this.decisions.forEach(decision -> rda.decisions.add(decision.cloneToReviewerApproval(rda)));
rda.isCloned = true;
rda.cloneTimestamp = Date.from(Instant.now());
rda.cloneTimestamp = Instant.now();
return rda;
}