Class ChangelogSupplier<T>

java.lang.Object
org.hibernate.audit.spi.ChangelogSupplier<T>
Type Parameters:
T - the type of the changeset identifier (the @ChangesetId property type)
All Implemented Interfaces:
ChangesetIdentifierSupplier<T>

public class ChangelogSupplier<T> extends Object implements ChangesetIdentifierSupplier<T>
A built-in ChangesetIdentifierSupplier that persists a user-defined changelog entity and returns the @Changelog.ChangesetId property value as the changeset id for audit rows.

An optional ChangesetListener callback can be configured for populating custom fields.

Since:
7.4
  • Constructor Details

    • ChangelogSupplier

      public ChangelogSupplier(Class<?> changelogClass, String changesetIdProperty, String timestampProperty, @Nullable String modifiedEntitiesProperty, @Nullable ChangesetListener listener)
      Parameters:
      changelogClass - the changelog entity class
      changesetIdProperty - the name of the @ChangesetId property
      timestampProperty - the name of the @Timestamp property
      modifiedEntitiesProperty - the name of the @ModifiedEntities property, or null if entity change tracking is not configured
      listener - optional callback for populating custom fields
  • Method Details

    • getChangelogClass

      public Class<?> getChangelogClass()
      The changelog entity class.
    • getChangesetIdProperty

      public String getChangesetIdProperty()
      The name of the @Changeset property.
    • getTimestampProperty

      public String getTimestampProperty()
      The name of the @Timestamp property.
    • getListener

      public @Nullable ChangesetListener getListener()
      The configured changeset listener, or null.
    • getModifiedEntitiesProperty

      public @Nullable String getModifiedEntitiesProperty()
      The name of the @ModifiedEntities property, or null if entity change tracking is not configured.
    • generateIdentifier

      public T generateIdentifier(SharedSessionContract session)
      Description copied from interface: ChangesetIdentifierSupplier
      Called once per transaction to obtain the changeset identifier
      Specified by:
      generateIdentifier in interface ChangesetIdentifierSupplier<T>
      Parameters:
      session - the current session
      Returns:
      the changeset identifier
    • resolve

      public static @Nullable ChangelogSupplier<?> resolve(ServiceRegistry registry)
      Resolve the ChangelogSupplier from the given service registry, or return null if no @Changelog is configured.