Module io.ebean.api
Package io.ebean.bean

Interface EntityBeanIntercept

All Superinterfaces:
Serializable
All Known Implementing Classes:
InterceptReadOnly, InterceptReadWrite

public interface EntityBeanIntercept extends Serializable
This is the object associated to every entity bean using byte code enhancement.

This provides per property state such as loaded state, changed state, original values as well as bean level dirty state etc.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add and return a dirty property hash.
    void
    Recursively add dirty properties.
    void
    Recursively add dirty properties.
    void
    Recursively add dirty properties.
    void
    Clear the getter callback.
    boolean[]
    Return the array of flags indicating the dirty properties.
    Return a dirty property hash taking into account embedded beans.
    Return the set of dirty properties.
    Return a map of dirty properties with their new and old values.
    Return the owning bean for an embedded bean.
    int
    Return the property index (for the parent) of this embedded bean.
    int
    findProperty(String propertyName)
    Finds the index position of a given property.
    boolean
    hasDirtyProperty(Set<String> propertyNames)
    Return true if any of the given property names are dirty.
    boolean
    hasIdOnly(int idIndex)
    Return true if only the Id property has been loaded.
    void
    initialisedMany(int propertyIndex)
    Called when a BeanCollection is initialised automatically.
    boolean
    isChangedProp(int propertyIndex)
    Return true if the property has its changed state set.
    boolean
    isChangedProperty(int propertyIndex)
    Return true if the property is considered changed.
    boolean
    Return true if this bean has been directly modified (it has oldValues) or if any embedded beans are either new or dirty (and hence need saving).
    boolean
    isDirtyProperty(int propertyIndex)
    Return true if the property was changed or if it is embedded and one of its embedded properties is dirty.
    boolean
    Return true if lazy loading is disabled.
    boolean
    Return true if the embedded bean is new or dirty and hence needs saving.
    boolean
    Return true if the bean is fully loaded (not a partial).
    boolean
    Return true if the bean is marked as having failed lazy loading.
    boolean
    Return true if the entity has been loaded.
    boolean
    Return true if this bean was loaded from L2 bean cache.
    boolean
    isLoadedProperty(int propertyIndex)
    Return true if the property is loaded.
    boolean
    Return true if this entity bean is new and not yet saved.
    boolean
    Return true if the entity bean is new or dirty (and should be saved).
    boolean
    Return true if the bean was orphan deleted from a collection.
    boolean
    Return true if the bean is partially loaded.
    boolean
    Return true if the bean should be treated as readOnly.
    boolean
    Return true if the entity is a reference.
    boolean
    Return true if the entity should be updated.
    Return the property that triggered the lazy load.
    int
    Return the index of the property that triggered the lazy load.
    void
    loadBean(int loadProperty)
    Load the bean when it is a reference.
    void
    loadBeanInternal(int loadProperty, BeanLoader loader)
    Invoke the lazy loading.
    boolean[]
    Return the loaded state for all the properties.
    Return a loaded property hash.
    Return the set of property names for a partially loaded bean.
    Returns the loadErrors.
    void
    markPropertyAsChanged(int propertyIndex)
    Explicitly mark a property as having been changed.
    mutableInfo(int propertyIndex)
    Return the MutableValueInfo for the given property or null.
    void
    mutableInfo(int propertyIndex, MutableValueInfo info)
    Set the MutableValueInfo for the given property.
    mutableNext(int propertyIndex)
    Update the 'next' mutable info returning the content that was obtained via dirty detection.
    void
    mutableNext(int propertyIndex, MutableValueNext next)
    Dirty detection set the next mutable property content and info .
    origValue(int propertyIndex)
    Return the original value that was changed via an update.
    Return the 'owning' entity bean.
    Return the ownerId (IdClass).
    Return the persistenceContext.
    void
    Called prior to Id property getter.
    void
    preGetter(int propertyIndex)
    Method that is called prior to a getter method on the actual entity.
    void
    preGetterCallback(int propertyIndex)
    Invoke the PreGetterCallback if it has been set due to getter for the given property.
    void
    preSetter(boolean intercept, int propertyIndex, boolean oldValue, boolean newValue)
    Check for primitive boolean.
    void
    preSetter(boolean intercept, int propertyIndex, byte[] oldValue, byte[] newValue)
    Check for primitive byte array.
    void
    preSetter(boolean intercept, int propertyIndex, byte oldValue, byte newValue)
    Check for primitive byte.
    void
    preSetter(boolean intercept, int propertyIndex, char[] oldValue, char[] newValue)
    Check for primitive char array.
    void
    preSetter(boolean intercept, int propertyIndex, char oldValue, char newValue)
    Check for primitive char.
    void
    preSetter(boolean intercept, int propertyIndex, double oldValue, double newValue)
    Check for primitive double.
    void
    preSetter(boolean intercept, int propertyIndex, float oldValue, float newValue)
    Check for primitive float.
    void
    preSetter(boolean intercept, int propertyIndex, int oldValue, int newValue)
    Check for primitive int.
    void
    preSetter(boolean intercept, int propertyIndex, long oldValue, long newValue)
    Check for primitive long.
    void
    preSetter(boolean intercept, int propertyIndex, short oldValue, short newValue)
    Check for primitive short.
    void
    preSetter(boolean intercept, int propertyIndex, Object oldValue, Object newValue)
    Check to see if the values are not equal.
    void
    preSetterMany(boolean interceptField, int propertyIndex, Object oldValue, Object newValue)
    OneToMany and ManyToMany only set loaded state.
    property(int propertyIndex)
    Return the property name for the given property.
    int
    Return the number of properties.
    void
    Register the callback to be triggered when getter is called.
    void
    Set the BeanLoader.
    void
    Set the BeanLoader with PersistenceContext.
    void
    setChangedProperty(int propertyIndex)
    Set the changed state for the given property.
    void
    setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue)
    Set the property changed state, bean dirtyState and property original value.
    void
    setChangeLoaded(int propertyIndex)
    Set the changed and loaded state for the given property.
    void
    setDeletedFromCollection(boolean deletedFromCollection)
    Set if the entity was deleted from a BeanCollection.
    void
    setDirty(boolean dirty)
    Marks the bean as dirty.
    void
    Set the dirty state on the bean.
    void
    setDisableLazyLoad(boolean disableLazyLoad)
    Set true to turn off lazy loading.
    void
    setEmbeddedDirty(int embeddedProperty)
    Called by an embedded bean onto its owner.
    void
    setEmbeddedLoaded(Object embeddedBean)
    Set the loaded status for the embedded bean.
    void
    setEmbeddedOwner(EntityBean parentBean, int embeddedOwnerIndex)
    Set the embedded beans owning bean.
    void
    setEmbeddedPropertyDirty(int propertyIndex)
    Set that an embedded bean has had one of its properties changed.
    void
    setForceUpdate(boolean forceUpdate)
    Set the bean to be updated when persisted (for merge).
    void
    setFullyLoadedBean(boolean fullyLoadedBean)
    Set true when the bean is fully loaded (not a partial).
    void
    Set lazy load failure flag.
    void
    Set the loaded state to true.
    void
    setLoadedFromCache(boolean loadedFromCache)
    Set true when the bean has been loaded from L2 bean cache.
    void
    When finished loading for lazy or refresh on an already partially populated bean.
    void
    setLoadedProperty(int propertyIndex)
    Set the property to be loaded.
    void
    Set all properties to be loaded (post insert).
    void
    setLoadError(int propertyIndex, Exception t)
    Set the load error that happened on this property.
    void
    Set the bean into NEW state.
    void
    For forced update on a 'New' bean set all the loaded properties to changed.
    void
    Turn on profile collection.
    void
    setOldValue(int propertyIndex, Object oldValue)
    Explicitly set an old value with force (the old value is forced even it is already set).
    void
    setOriginalValue(int propertyIndex, Object value)
    Set the original value for the property.
    void
    setOriginalValueForce(int propertyIndex, Object value)
    Set old value but force it to be set regardless if it already has a value.
    void
    setOwnerId(Object ownerId)
    Set the ownerId (IdClass).
    void
    Set the persistenceContext.
    void
    setPropertyLoaded(String propertyName, boolean loaded)
    Set the loaded state of the property given it's name.
    void
    setPropertyUnloaded(int propertyIndex)
    Set the property to be treated as unloaded.
    void
    setReadOnly(boolean readOnly)
    Set the readOnly status.
    void
    setReference(int idPos)
    Set this as a reference object.
    void
    setSortOrder(int sortOrder)
    Set the sort order value for an order column.
    int
    Return the sort order value for an order column.
  • Method Details

    • owner

      EntityBean owner()
      Return the 'owning' entity bean.
    • persistenceContext

      PersistenceContext persistenceContext()
      Return the persistenceContext.
    • setPersistenceContext

      void setPersistenceContext(PersistenceContext persistenceContext)
      Set the persistenceContext.
    • setNodeUsageCollector

      void setNodeUsageCollector(NodeUsageCollector usageCollector)
      Turn on profile collection.
    • ownerId

      Object ownerId()
      Return the ownerId (IdClass).
    • setOwnerId

      void setOwnerId(Object ownerId)
      Set the ownerId (IdClass).
    • embeddedOwner

      Object embeddedOwner()
      Return the owning bean for an embedded bean.
    • embeddedOwnerIndex

      int embeddedOwnerIndex()
      Return the property index (for the parent) of this embedded bean.
    • clearGetterCallback

      void clearGetterCallback()
      Clear the getter callback.
    • registerGetterCallback

      void registerGetterCallback(PreGetterCallback getterCallback)
      Register the callback to be triggered when getter is called. This is used primarily to automatically flush the JDBC batch.
    • setEmbeddedOwner

      void setEmbeddedOwner(EntityBean parentBean, int embeddedOwnerIndex)
      Set the embedded beans owning bean.
    • setBeanLoader

      void setBeanLoader(BeanLoader beanLoader, PersistenceContext ctx)
      Set the BeanLoader with PersistenceContext.
    • setBeanLoader

      void setBeanLoader(BeanLoader beanLoader)
      Set the BeanLoader.
    • isFullyLoadedBean

      boolean isFullyLoadedBean()
      Return true if the bean is fully loaded (not a partial).
    • setFullyLoadedBean

      void setFullyLoadedBean(boolean fullyLoadedBean)
      Set true when the bean is fully loaded (not a partial).
    • isPartial

      boolean isPartial()
      Return true if the bean is partially loaded.
    • isDirty

      boolean isDirty()
      Return true if this bean has been directly modified (it has oldValues) or if any embedded beans are either new or dirty (and hence need saving).
    • setEmbeddedDirty

      void setEmbeddedDirty(int embeddedProperty)
      Called by an embedded bean onto its owner.
    • setDirty

      void setDirty(boolean dirty)
      Marks the bean as dirty.
    • isNew

      boolean isNew()
      Return true if this entity bean is new and not yet saved.
    • isNewOrDirty

      boolean isNewOrDirty()
      Return true if the entity bean is new or dirty (and should be saved).
    • hasIdOnly

      boolean hasIdOnly(int idIndex)
      Return true if only the Id property has been loaded.
    • isReference

      boolean isReference()
      Return true if the entity is a reference.
    • setReference

      void setReference(int idPos)
      Set this as a reference object.
    • setLoadedFromCache

      void setLoadedFromCache(boolean loadedFromCache)
      Set true when the bean has been loaded from L2 bean cache. The effect of this is that we should skip the cache if there is subsequent lazy loading (bean cache partially populated).
    • isLoadedFromCache

      boolean isLoadedFromCache()
      Return true if this bean was loaded from L2 bean cache.
    • isReadOnly

      boolean isReadOnly()
      Return true if the bean should be treated as readOnly. If a setter method is called when it is readOnly an Exception is thrown.
    • setReadOnly

      void setReadOnly(boolean readOnly)
      Set the readOnly status. If readOnly then calls to setter methods through an exception.
    • setForceUpdate

      void setForceUpdate(boolean forceUpdate)
      Set the bean to be updated when persisted (for merge).
    • isUpdate

      boolean isUpdate()
      Return true if the entity should be updated.
    • isLoaded

      boolean isLoaded()
      Return true if the entity has been loaded.
    • setNew

      void setNew()
      Set the bean into NEW state.
    • setLoaded

      void setLoaded()
      Set the loaded state to true.

      Calls to setter methods after the bean is loaded can result in 'Old Values' being created.

      Worth noting that this is also set after a insert/update. By doing so it 'resets' the bean for making further changes and saving again.

    • setLoadedLazy

      void setLoadedLazy()
      When finished loading for lazy or refresh on an already partially populated bean.
    • setLazyLoadFailure

      void setLazyLoadFailure(Object ownerId)
      Set lazy load failure flag.
    • isLazyLoadFailure

      boolean isLazyLoadFailure()
      Return true if the bean is marked as having failed lazy loading.
    • isDisableLazyLoad

      boolean isDisableLazyLoad()
      Return true if lazy loading is disabled.
    • setDisableLazyLoad

      void setDisableLazyLoad(boolean disableLazyLoad)
      Set true to turn off lazy loading.
    • setEmbeddedLoaded

      void setEmbeddedLoaded(Object embeddedBean)
      Set the loaded status for the embedded bean.
    • isEmbeddedNewOrDirty

      boolean isEmbeddedNewOrDirty(Object embeddedBean)
      Return true if the embedded bean is new or dirty and hence needs saving.
    • origValue

      Object origValue(int propertyIndex)
      Return the original value that was changed via an update.
    • findProperty

      int findProperty(String propertyName)
      Finds the index position of a given property. Returns -1 if the property can not be found.
    • property

      String property(int propertyIndex)
      Return the property name for the given property.
    • propertyLength

      int propertyLength()
      Return the number of properties.
    • setPropertyLoaded

      void setPropertyLoaded(String propertyName, boolean loaded)
      Set the loaded state of the property given it's name.
    • setPropertyUnloaded

      void setPropertyUnloaded(int propertyIndex)
      Set the property to be treated as unloaded. Used for properties initialised in default constructor.
    • setLoadedProperty

      void setLoadedProperty(int propertyIndex)
      Set the property to be loaded.
    • setLoadedPropertyAll

      void setLoadedPropertyAll()
      Set all properties to be loaded (post insert).
    • isLoadedProperty

      boolean isLoadedProperty(int propertyIndex)
      Return true if the property is loaded.
    • isChangedProperty

      boolean isChangedProperty(int propertyIndex)
      Return true if the property is considered changed.
    • isDirtyProperty

      boolean isDirtyProperty(int propertyIndex)
      Return true if the property was changed or if it is embedded and one of its embedded properties is dirty.
    • markPropertyAsChanged

      void markPropertyAsChanged(int propertyIndex)
      Explicitly mark a property as having been changed.
    • setChangedProperty

      void setChangedProperty(int propertyIndex)
      Set the changed state for the given property.
    • setChangeLoaded

      void setChangeLoaded(int propertyIndex)
      Set the changed and loaded state for the given property.
    • setEmbeddedPropertyDirty

      void setEmbeddedPropertyDirty(int propertyIndex)
      Set that an embedded bean has had one of its properties changed.
    • setOriginalValue

      void setOriginalValue(int propertyIndex, Object value)
      Set the original value for the property.
    • setOriginalValueForce

      void setOriginalValueForce(int propertyIndex, Object value)
      Set old value but force it to be set regardless if it already has a value.
    • setNewBeanForUpdate

      void setNewBeanForUpdate()
      For forced update on a 'New' bean set all the loaded properties to changed.
    • loadedPropertyNames

      Set<String> loadedPropertyNames()
      Return the set of property names for a partially loaded bean.
    • dirtyProperties

      boolean[] dirtyProperties()
      Return the array of flags indicating the dirty properties.
    • dirtyPropertyNames

      Set<String> dirtyPropertyNames()
      Return the set of dirty properties.
    • addDirtyPropertyNames

      void addDirtyPropertyNames(Set<String> props, String prefix)
      Recursively add dirty properties.
    • hasDirtyProperty

      boolean hasDirtyProperty(Set<String> propertyNames)
      Return true if any of the given property names are dirty.
    • dirtyValues

      Map<String,ValuePair> dirtyValues()
      Return a map of dirty properties with their new and old values.
    • addDirtyPropertyValues

      void addDirtyPropertyValues(Map<String,ValuePair> dirtyValues, String prefix)
      Recursively add dirty properties.
    • addDirtyPropertyValues

      void addDirtyPropertyValues(BeanDiffVisitor visitor)
      Recursively add dirty properties.
    • dirtyPropertyKey

      StringBuilder dirtyPropertyKey()
      Return a dirty property hash taking into account embedded beans.
    • addDirtyPropertyKey

      void addDirtyPropertyKey(StringBuilder sb)
      Add and return a dirty property hash.
    • loadedPropertyKey

      StringBuilder loadedPropertyKey()
      Return a loaded property hash.
    • loaded

      boolean[] loaded()
      Return the loaded state for all the properties.
    • lazyLoadPropertyIndex

      int lazyLoadPropertyIndex()
      Return the index of the property that triggered the lazy load.
    • lazyLoadProperty

      String lazyLoadProperty()
      Return the property that triggered the lazy load.
    • loadBean

      void loadBean(int loadProperty)
      Load the bean when it is a reference.
    • loadBeanInternal

      void loadBeanInternal(int loadProperty, BeanLoader loader)
      Invoke the lazy loading. This method is synchronised externally.
    • initialisedMany

      void initialisedMany(int propertyIndex)
      Called when a BeanCollection is initialised automatically.
    • preGetterCallback

      void preGetterCallback(int propertyIndex)
      Invoke the PreGetterCallback if it has been set due to getter for the given property.
    • preGetId

      void preGetId()
      Called prior to Id property getter.
    • preGetter

      void preGetter(int propertyIndex)
      Method that is called prior to a getter method on the actual entity.
    • preSetterMany

      void preSetterMany(boolean interceptField, int propertyIndex, Object oldValue, Object newValue)
      OneToMany and ManyToMany only set loaded state.
    • setChangedPropertyValue

      void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue)
      Set the property changed state, bean dirtyState and property original value.
    • setDirtyStatus

      void setDirtyStatus()
      Set the dirty state on the bean.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, Object oldValue, Object newValue)
      Check to see if the values are not equal. If they are not equal then create the old values for use with ConcurrencyMode.ALL.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, boolean oldValue, boolean newValue)
      Check for primitive boolean.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, int oldValue, int newValue)
      Check for primitive int.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, long oldValue, long newValue)
      Check for primitive long.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, double oldValue, double newValue)
      Check for primitive double.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, float oldValue, float newValue)
      Check for primitive float.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, short oldValue, short newValue)
      Check for primitive short.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, char oldValue, char newValue)
      Check for primitive char.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, byte oldValue, byte newValue)
      Check for primitive byte.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, char[] oldValue, char[] newValue)
      Check for primitive char array.
    • preSetter

      void preSetter(boolean intercept, int propertyIndex, byte[] oldValue, byte[] newValue)
      Check for primitive byte array.
    • setOldValue

      void setOldValue(int propertyIndex, Object oldValue)
      Explicitly set an old value with force (the old value is forced even it is already set).
    • sortOrder

      int sortOrder()
      Return the sort order value for an order column.
    • setSortOrder

      void setSortOrder(int sortOrder)
      Set the sort order value for an order column.
    • setDeletedFromCollection

      void setDeletedFromCollection(boolean deletedFromCollection)
      Set if the entity was deleted from a BeanCollection.
    • isOrphanDelete

      boolean isOrphanDelete()
      Return true if the bean was orphan deleted from a collection.
    • setLoadError

      void setLoadError(int propertyIndex, Exception t)
      Set the load error that happened on this property.
    • loadErrors

      Map<String,Exception> loadErrors()
      Returns the loadErrors.
    • isChangedProp

      boolean isChangedProp(int propertyIndex)
      Return true if the property has its changed state set.
    • mutableInfo

      MutableValueInfo mutableInfo(int propertyIndex)
      Return the MutableValueInfo for the given property or null.
    • mutableInfo

      void mutableInfo(int propertyIndex, MutableValueInfo info)
      Set the MutableValueInfo for the given property.
    • mutableNext

      void mutableNext(int propertyIndex, MutableValueNext next)
      Dirty detection set the next mutable property content and info .

      Set here as the mutable property dirty detection is based on json content comparison. We only want to perform the json serialisation once so storing it here as part of dirty detection so that we can get it back to bind in insert or update etc.

    • mutableNext

      String mutableNext(int propertyIndex)
      Update the 'next' mutable info returning the content that was obtained via dirty detection.