Package org.hibernate.annotations

Annotation Interface CurrentTimestamp


@Retention(RUNTIME)@Target({FIELD,METHOD,ANNOTATION_TYPE})public @interfaceCurrentTimestamp
Specifies that the annotated field of property is a generated timestamp, and also specifies thetiming of the timestamp generation, and whether it is generated in Java or by the database:

By default, the timestamp is generated by the database, which might require an extra round trip to the database to fetch the generated value, depending on the capabilities of thedatabase anddriver.

This annotation may be used in combination with the JPA-definedVersion 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.

A field annotated@CurrentTimestamp may not be directly set by the application program.

Since:
6.0
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Determines when the timestamp is generated.
    Specifies how the timestamp is generated.
  • Element Details

    • 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:
      {INSERT, UPDATE}
    • source

      SourceType source
      Specifies how the timestamp is generated. By default, it is generated by the database. Depending on the capabilities of the database and JDBC driver, this might require that the value be fetched using a subsequentselect statement. Settingsource = VM guarantees that this additionalselect never occurs.
      Default:
      DB