Class EntityDetails


public class EntityDetails
extends Object
Contains detailed information about the changes made to an entity during a transaction. This information is sent to an EntityLogger that is responsible for the actual logging.

NOTE! The information in this object is more or less drawn from what Hibernate reveals about the entity. It is recommended that no information is changed.

Last modified
$Date: 2023-06-05 09:18:49 +0200 (Mon, 05 Jun 2023) $
  • Field Details


      public static final DateFormatter DATE_FORMAT

      public static final DateFormatter DATETIME_FORMAT
    • entity

      private final Object entity
    • changeType

      private final ChangeType changeType
    • state

      private final Object[] state
    • previousState

      private final Object[] previousState
    • properties

      private final String[] properties
    • types

      private final Type[] types
    • dirty

      private final int[] dirty
    • logOptions

      private final EntityLogOptions logOptions
  • Constructor Details

  • Method Details

    • getEntity

      public Object getEntity()
      Get the entity that was changed.
    • getChangeType

      public ChangeType getChangeType()
      Was it a creation/update/deletion?
    • getState

      public Object[] getState()
      Get an array with the current state of the entity.
    • getPreviousState

      public Object[] getPreviousState()
      Get an array with the previous state of the entity. The array is null for new items and is identical to the array returned by getState() for delete events.
    • getProperties

      public String[] getProperties()
      Get an array with the names of all properties.
    • getTypes

      public Type[] getTypes()
      Get an array representing the data type for each property.
    • getDirty

      public int getDirty​(int index)
    • getIndex

      public int getIndex​(String property)
      Get the array index of the given property. Return -1 if not found.
    • setDirty

      public void setDirty​(int index, int value)
      Set the dirtyness for the property with the given index.
      index - The index number of the property
      value - The dirtyness (-1=not dirty, 0=not known, 1=dirty)
    • getModifiedProperties

      public String getModifiedProperties​(String prefix, String separator, String suffix)
      Get all modified properties as a string, separating each property name with the given separator.
      prefix - A string that is added first in the result, or null
      separator - A separator string (if null, comma is used)
      suffix - A string that is added last in the result, or null
      A string with the modified properties, or null if this is a CREATE or DELETE change or if no modified properties was found
    • isOnlyDirty

      public boolean isOnlyDirty​(String property)
      Checks if the given property is the only modified property.
      TRUE if the given property (but no other) is dirty, FALSE in all other cases
    • toChangeDetails

      public List<ChangeHistoryDetailData> toChangeDetails​(boolean detailedProperties, boolean oldPropertyValues)
      Create a list of ChangeHistoryDetailData objects from the information in this object assuming that the entity is a subclass of BasicData.
      detailedProperties - If TRUE, one log entry is generated for each modified property (UPDATE only), otherwise only a single log entry is created
      oldPropertyValues - If TRUE, the log entry will save the old and new value (ignored unless detailedProperties is also set)
      A list of ChangeHistoryDetailData object (may be empty)
    • toChangeDetails

      public List<ChangeHistoryDetailData> toChangeDetails​(Item itemType, int itemId, String propertyPrefix, ChangeType changeType, boolean detailedProperties, boolean oldPropertyValues)
      Create a list of ChangeHistoryDetailData objects using a mix of the information in this object, and the given parameters. This method can be used to attach log entries to a different item, than what the changes in this EntityDetails object are associated with. Typically used to record changes in a child object on the parent object.
      itemType - The type of the item the log entries should be attached to
      itemId - The id of the item the log entries should be attached
      propertyPrefix - A prefix that is added to the property description to indicate what child object that was modified
      changeType - The change type
      detailedProperties - If TRUE, the ChangeHistoryDetailData.getChangeInfo() is populated with a list of the names of the modified properties (only relevant for UPDATE changes)
      oldPropertyValues - If TRUE, the log entry will save the old and new value (ignored unless detailedProperties is also set)
      A list of ChangeHistoryDetailData object (may be empty)
    • initializeDirtynessForSomeProperties

      private void initializeDirtynessForSomeProperties()
      We must initialize "dirtyness" for collections and some other properties from the constructor. The "dirtyness" of a collection is reset after flush the SQL to the database, which is completed before the rest of the logging is done.
    • toLoggableString

      public static String toLoggableString​(Type type, Object value)
    • getDataClassName

      private static String getDataClassName​(Object value)