Hibernate JPA @Source Example
@Source
The @Source annotation is used in conjunction with a @Version timestamp entity attribute indicating the SourceType of the timestamp value.The SourceType offers two options:
DB
Get the timestamp from the database.
VM
Get the timestamp from the current JVM.
Source optional annotation in conjunction with Version and timestamp version properties indicating the source of the timestamp value.
Database-generated version timestamp mapping
@Entity(name = "Person")public static class Person {
@Id
private Long id;
private String firstName;
private String lastName;
@Version
@Source(value = SourceType.DB)
private Date version;
}
Comments
Post a Comment