1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package de.kaiserpfalzedv.commons.jpa;
19
20 import java.time.OffsetDateTime;
21
22 import org.hibernate.envers.RevisionEntity;
23 import org.hibernate.envers.RevisionNumber;
24 import org.hibernate.envers.RevisionTimestamp;
25
26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
27 import jakarta.persistence.Column;
28 import jakarta.persistence.GeneratedValue;
29 import jakarta.persistence.GenerationType;
30 import jakarta.persistence.MappedSuperclass;
31 import jakarta.persistence.SequenceGenerator;
32 import lombok.AllArgsConstructor;
33 import lombok.Getter;
34 import lombok.NoArgsConstructor;
35 import lombok.NonNull;
36 import lombok.Setter;
37 import lombok.experimental.SuperBuilder;
38
39 @SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "lombok provided superbuilder constructor.")
40 @MappedSuperclass
41 @RevisionEntity
42 @SuperBuilder(toBuilder = true)
43 @AllArgsConstructor
44 @NoArgsConstructor
45 @Getter
46 @Setter
47 public abstract class AbstractRevisionedJPAEntity extends AbstractJPAEntity {
48 @RevisionNumber
49 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "DbSequence")
50 @SequenceGenerator(name = "DbSequence", sequenceName = "hibernate_sequence")
51 @Column(name = "REVID", nullable = false, updatable = false)
52 protected int revId;
53
54 @RevisionTimestamp
55 @Column(name = "REVISIONED", insertable = true, updatable = false)
56 @NonNull
57 protected OffsetDateTime revisioned;
58
59
60 @Override
61 public AbstractRevisionedJPAEntity clone() throws CloneNotSupportedException {
62 final AbstractRevisionedJPAEntity result = (AbstractRevisionedJPAEntity) super.clone();
63
64 result.revId = this.revId;
65 result.revisioned = this.revisioned;
66
67 return result;
68 }
69 }