Package org.hibernate.annotations
Annotation Type CurrentTimestamp
-
@Retention(RUNTIME) @Target({FIELD,METHOD,ANNOTATION_TYPE}) public @interface CurrentTimestamp
Specifies that the annotated field of property is a generated timestamp, and also specifies the timing of the timestamp generation, and whether it is generated in Java or by the database:source = VM
indicates that the virtual machine current instant is used, andsource = DB
indicates that the databasecurrent_timestamp
function should be used.
By default, the timestamp is generated by the database, which requires an extra round trip to the database to fetch the generated value.
This annotation may be used in combination with the JPA-defined
Version
annotation.The annotated property may be of any one of the following types:
Date
,Calendar
,Date
,Time
,Timestamp
,Instant
,LocalDate
,LocalDateTime
,LocalTime
,MonthDay
,OffsetDateTime
,OffsetTime
,Year
,YearMonth
, orZonedDateTime
.- Since:
- 6.0
- See Also:
UpdateTimestamp
,CreationTimestamp
,CurrentTimestampGeneration
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description EventType[]
event
Determines when the timestamp is generated.SourceType
source
Specifies how the timestamp is generated.@Remove GenerationTiming
timing
Deprecated.This was introduced in error
-
-
-
Element Detail
-
event
EventType[] event
Determines when the timestamp is generated. But default, it is updated when any SQLinsert
orupdate
statement is executed. If it should be generated just once, on the initial SQLinsert
, explicitly specifyevent = INSERT
.- Default:
- {org.hibernate.generator.EventType.INSERT, org.hibernate.generator.EventType.UPDATE}
-
-
-
timing
@Deprecated(since="6.2") @Remove @Remove GenerationTiming timing
Deprecated.This was introduced in errorDetermines when the timestamp is generated. But default, it is updated when any SQLinsert
orupdate
statement is executed. If it should be generated just once, on the initial SQLinsert
, explicitly specifytiming = INSERT
.- Default:
- org.hibernate.tuple.GenerationTiming.ALWAYS
-
-
-
source
SourceType source
Specifies how the timestamp is generated. By default, it is generated by the database, and fetched using a subsequentselect
statement.- Default:
- org.hibernate.annotations.SourceType.DB
-
-