Enum Class TemporalTableStrategy

java.lang.Object
java.lang.Enum<TemporalTableStrategy>
org.hibernate.temporal.TemporalTableStrategy
All Implemented Interfaces:
Serializable, Comparable<TemporalTableStrategy>, Constable

@Incubating public enum TemporalTableStrategy extends Enum<TemporalTableStrategy>
Enumerates the possible mapping strategies for temporal entities and collections.
Since:
7.4
See Also:
  • Enum Constant Details

    • NATIVE

      public static final TemporalTableStrategy NATIVE
      Use native ANSI SQL 2011-style temporal tables where they are supported (Maria, SQL Server, Db2).
    • SINGLE_TABLE

      public static final TemporalTableStrategy SINGLE_TABLE
      Store historical data together with current data in one table. The table does not have the usual foreign key constraints that would exist for any non-temporal entity, and so it is the responsibility of the application program to maintain and enforce referential integrity.
    • HISTORY_TABLE

      public static final TemporalTableStrategy HISTORY_TABLE
      Maintain two tables, one for current data and one for historical data. The table for current data has all the usual foreign key constraints that would exist for any non-temporal entity; the table for historical data has no foreign key constraints.
      • When a new entity instance is created, a row is inserted in both tables.
      • When the instance is updated, its row in the table for current data is updated; but in the table for historical data, a new revision row is inserted and the previous revision row is marked as superseded by setting its row end column to the current timestamp.
      • When an entity instance is removed, its row in the table for current data is deleted; and the current revision row in the table for historical data is marked as superseded by setting its row end column.

      Queries for current data are run against the table for current data. Queries for historical data (that is, any query in a session created using CommonBuilder.asOf(Instant)) are executed against the table for historical data.

    • AUTO

      public static final TemporalTableStrategy AUTO
      Let us choose a temporal table mapping strategy for you because YOLO. Selects HISTORY_TABLE except on databases with especially robust implementations of NATIVE temporal versioning. This is the default.
      See Also:
  • Method Details

    • values

      public static TemporalTableStrategy[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static TemporalTableStrategy valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null