Annotation Interface Synchronize


@Target({TYPE,FIELD,METHOD}) @Retention(RUNTIME) public @interface Synchronize
Specifies a table or tables that hold state mapped by the annotated entity or collection.

If Hibernate is not aware that a certain table holds state mapped by an entity class or collection, then modifications might not be automatically synchronized with the database before a query is executed against that table, and the query might return stale data.

Ordinarily, Hibernate knows the tables containing the state of an entity or collection. This annotation might be necessary if:

  • an entity or collection maps a database view,
  • an entity or collection is persisted using handwritten SQL, that is, using @SQLSelect and friends, or
  • an entity is mapped using @Subselect.

By default, the table names specified by this annotation are interpreted as logical names, and are processed by PhysicalNamingStrategy.toPhysicalTableName(org.hibernate.boot.model.naming.Identifier, org.hibernate.engine.jdbc.env.spi.JdbcEnvironment). But if logical=false, the table names will be treated as physical names, and will not be processed by the naming strategy.

See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Names of tables that hold state mapped by the annotated entity.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Specifies whether the table names given by value() should be interpreted as logical or physical names.
  • Element Details

    • value

      String[] value
      Names of tables that hold state mapped by the annotated entity. Updates to these tables must be flushed to the database before execution of any query which refers to the annotated entity.
    • logical

      boolean logical
      Specifies whether the table names given by value() should be interpreted as logical or physical names.
      Returns:
      true if they are logical names
      Default:
      true