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

Class InterceptReadWrite

java.lang.Object
io.ebean.bean.InterceptReadWrite
All Implemented Interfaces:
EntityBeanIntercept, Serializable

public final class InterceptReadWrite extends Object
This is the object added to every entity bean using byte code enhancement.

This provides the mechanisms to support deferred fetching of reference beans and oldValues generation for concurrency checking.

See Also:
  • Constructor Details

    • InterceptReadWrite

      public InterceptReadWrite(Object ownerBean)
      Create with a given entity.
    • InterceptReadWrite

      public InterceptReadWrite()
      EXPERIMENTAL - Constructor only for use by serialization frameworks.
  • Method Details

    • freeze

      public boolean freeze()
      Description copied from interface: EntityBeanIntercept
      Return true if this entity bean should be frozen. Used to handle recursive freezing.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • persistenceContext

      public PersistenceContext persistenceContext()
      Description copied from interface: EntityBeanIntercept
      Return the persistenceContext.
    • setPersistenceContext

      public void setPersistenceContext(PersistenceContext persistenceContext)
      Description copied from interface: EntityBeanIntercept
      Set the persistenceContext.
    • setNodeUsageCollector

      public void setNodeUsageCollector(NodeUsageCollector usageCollector)
      Description copied from interface: EntityBeanIntercept
      Turn on profile collection.
    • ownerId

      public Object ownerId()
      Description copied from interface: EntityBeanIntercept
      Return the ownerId (IdClass).
    • setOwnerId

      public void setOwnerId(Object ownerId)
      Description copied from interface: EntityBeanIntercept
      Set the ownerId (IdClass).
    • embeddedOwner

      public Object embeddedOwner()
      Description copied from interface: EntityBeanIntercept
      Return the owning bean for an embedded bean.
    • embeddedOwnerIndex

      public int embeddedOwnerIndex()
      Description copied from interface: EntityBeanIntercept
      Return the property index (for the parent) of this embedded bean.
    • clearGetterCallback

      public void clearGetterCallback()
      Description copied from interface: EntityBeanIntercept
      Clear the getter callback.
    • registerGetterCallback

      public void registerGetterCallback(PreGetterCallback getterCallback)
      Description copied from interface: EntityBeanIntercept
      Register the callback to be triggered when getter is called. This is used primarily to automatically flush the JDBC batch.
    • setEmbeddedOwner

      public void setEmbeddedOwner(EntityBean parentBean, int embeddedOwnerIndex)
      Description copied from interface: EntityBeanIntercept
      Set the embedded beans owning bean.
    • setBeanLoader

      public void setBeanLoader(BeanLoader beanLoader, PersistenceContext ctx)
      Description copied from interface: EntityBeanIntercept
      Set the BeanLoader with PersistenceContext.
    • setBeanLoader

      public void setBeanLoader(BeanLoader beanLoader)
      Description copied from interface: EntityBeanIntercept
      Set the BeanLoader.
    • isPartial

      public boolean isPartial()
      Description copied from interface: EntityBeanIntercept
      Return true if the bean is partially loaded.
    • isDirty

      public boolean isDirty()
      Description copied from interface: EntityBeanIntercept
      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

      public void setEmbeddedDirty(int embeddedProperty)
      Description copied from interface: EntityBeanIntercept
      Called by an embedded bean onto its owner.
    • setDirty

      public void setDirty(boolean dirty)
      Description copied from interface: EntityBeanIntercept
      Marks the bean as dirty.
    • isNew

      public boolean isNew()
      Description copied from interface: EntityBeanIntercept
      Return true if this entity bean is new and not yet saved.
    • isNewOrDirty

      public boolean isNewOrDirty()
      Description copied from interface: EntityBeanIntercept
      Return true if the entity bean is new or dirty (and should be saved).
    • hasIdOnly

      public boolean hasIdOnly(int idIndex)
      Description copied from interface: EntityBeanIntercept
      Return true if only the Id property has been loaded.
    • isReference

      public boolean isReference()
      Description copied from interface: EntityBeanIntercept
      Return true if the entity is a reference.
    • setReference

      public void setReference(int idPos)
      Description copied from interface: EntityBeanIntercept
      Set this as a reference object.
    • setLoadedFromCache

      public void setLoadedFromCache(boolean loadedFromCache)
      Description copied from interface: EntityBeanIntercept
      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

      public boolean isLoadedFromCache()
      Description copied from interface: EntityBeanIntercept
      Return true if this bean was loaded from L2 bean cache.
    • setForceUpdate

      public void setForceUpdate(boolean forceUpdate)
      Description copied from interface: EntityBeanIntercept
      Set the bean to be updated when persisted (for merge).
    • isUpdate

      public boolean isUpdate()
      Description copied from interface: EntityBeanIntercept
      Return true if the entity should be updated.
    • isLoaded

      public boolean isLoaded()
      Description copied from interface: EntityBeanIntercept
      Return true if the entity has been loaded.
    • setNew

      public void setNew()
      Description copied from interface: EntityBeanIntercept
      Set the bean into NEW state.
    • setLoaded

      public void setLoaded()
      Description copied from interface: EntityBeanIntercept
      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

      public void setLoadedLazy()
      Description copied from interface: EntityBeanIntercept
      When finished loading for lazy or refresh on an already partially populated bean.
    • setLazyLoadFailure

      public void setLazyLoadFailure(Object ownerId)
      Description copied from interface: EntityBeanIntercept
      Set lazy load failure flag.
    • isLazyLoadFailure

      public boolean isLazyLoadFailure()
      Description copied from interface: EntityBeanIntercept
      Return true if the bean is marked as having failed lazy loading.
    • isDisableLazyLoad

      public boolean isDisableLazyLoad()
      Description copied from interface: EntityBeanIntercept
      Return true if lazy loading is disabled.
    • setDisableLazyLoad

      public void setDisableLazyLoad(boolean disableLazyLoad)
      Description copied from interface: EntityBeanIntercept
      Set true to turn off lazy loading.
    • setEmbeddedLoaded

      public void setEmbeddedLoaded(Object embeddedBean)
      Description copied from interface: EntityBeanIntercept
      Set the loaded status for the embedded bean.
    • isEmbeddedNewOrDirty

      public boolean isEmbeddedNewOrDirty(Object embeddedBean)
      Description copied from interface: EntityBeanIntercept
      Return true if the embedded bean is new or dirty and hence needs saving.
    • origValue

      public Object origValue(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Return the original value that was changed via an update.
    • propertyLength

      public int propertyLength()
      Description copied from interface: EntityBeanIntercept
      Return the number of properties.
    • setPropertyLoaded

      public void setPropertyLoaded(String propertyName, boolean loaded)
      Description copied from interface: EntityBeanIntercept
      Set the loaded state of the property given it's name.
    • setPropertyUnloaded

      public void setPropertyUnloaded(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Set the property to be treated as unloaded. Used for properties initialised in default constructor.
    • setLoadedProperty

      public void setLoadedProperty(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Set the property to be loaded.
    • setLoadedPropertyAll

      public void setLoadedPropertyAll()
      Description copied from interface: EntityBeanIntercept
      Set all properties to be loaded (post insert).
    • isLoadedProperty

      public boolean isLoadedProperty(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Return true if the property is loaded.
    • isChangedProperty

      public boolean isChangedProperty(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Return true if the property is considered changed.
    • isDirtyProperty

      public boolean isDirtyProperty(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Return true if the property was changed or if it is embedded and one of its embedded properties is dirty.
    • markPropertyAsChanged

      public void markPropertyAsChanged(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Explicitly mark a property as having been changed.
    • setChangedProperty

      public void setChangedProperty(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Set the changed state for the given property.
    • setChangeLoaded

      public void setChangeLoaded(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Set the changed and loaded state for the given property.
    • setEmbeddedPropertyDirty

      public void setEmbeddedPropertyDirty(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Set that an embedded bean has had one of its properties changed.
    • setOriginalValue

      public void setOriginalValue(int propertyIndex, Object value)
      Description copied from interface: EntityBeanIntercept
      Set the original value for the property.
    • setOriginalValueForce

      public void setOriginalValueForce(int propertyIndex, Object value)
      Description copied from interface: EntityBeanIntercept
      Set old value but force it to be set regardless if it already has a value.
    • setNewBeanForUpdate

      public void setNewBeanForUpdate()
      Description copied from interface: EntityBeanIntercept
      For forced update on a 'New' bean set all the loaded properties to changed.
    • loadedPropertyNames

      public Set<String> loadedPropertyNames()
      Description copied from interface: EntityBeanIntercept
      Return the set of property names for a partially loaded bean.
    • dirtyProperties

      public boolean[] dirtyProperties()
      Description copied from interface: EntityBeanIntercept
      Return the array of flags indicating the dirty properties.
    • dirtyPropertyNames

      public Set<String> dirtyPropertyNames()
      Description copied from interface: EntityBeanIntercept
      Return the set of dirty properties.
    • addDirtyPropertyNames

      public void addDirtyPropertyNames(Set<String> props, String prefix)
      Description copied from interface: EntityBeanIntercept
      Recursively add dirty properties.
    • hasDirtyProperty

      public boolean hasDirtyProperty(Set<String> propertyNames)
      Description copied from interface: EntityBeanIntercept
      Return true if any of the given property names are dirty.
    • dirtyValues

      public Map<String,ValuePair> dirtyValues()
      Description copied from interface: EntityBeanIntercept
      Return a map of dirty properties with their new and old values.
    • addDirtyPropertyValues

      public void addDirtyPropertyValues(Map<String,ValuePair> dirtyValues, String prefix)
      Description copied from interface: EntityBeanIntercept
      Recursively add dirty properties.
    • addDirtyPropertyValues

      public void addDirtyPropertyValues(BeanDiffVisitor visitor)
      Description copied from interface: EntityBeanIntercept
      Recursively add dirty properties.
    • dirtyPropertyKey

      public StringBuilder dirtyPropertyKey()
      Description copied from interface: EntityBeanIntercept
      Return a dirty property hash taking into account embedded beans.
    • addDirtyPropertyKey

      public void addDirtyPropertyKey(StringBuilder sb)
      Description copied from interface: EntityBeanIntercept
      Add and return a dirty property hash.
    • loaded

      public boolean[] loaded()
      Description copied from interface: EntityBeanIntercept
      Return the loaded state for all the properties.
    • lazyLoadPropertyIndex

      public int lazyLoadPropertyIndex()
      Description copied from interface: EntityBeanIntercept
      Return the index of the property that triggered the lazy load.
    • lazyLoadProperty

      public String lazyLoadProperty()
      Description copied from interface: EntityBeanIntercept
      Return the property that triggered the lazy load.
    • loadBean

      public void loadBean(int loadProperty)
      Description copied from interface: EntityBeanIntercept
      Load the bean when it is a reference.
    • loadBeanInternal

      public void loadBeanInternal(int loadProperty, BeanLoader loader)
      Description copied from interface: EntityBeanIntercept
      Invoke the lazy loading. This method is synchronised externally.
    • initialisedMany

      public void initialisedMany(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Called when a BeanCollection is initialised automatically.
    • preGetterCallback

      public void preGetterCallback(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Invoke the PreGetterCallback if it has been set due to getter for the given property.
    • preGetId

      public void preGetId()
      Description copied from interface: EntityBeanIntercept
      Called prior to Id property getter.
    • preGetter

      public void preGetter(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Method that is called prior to a getter method on the actual entity.
    • preSetterMany

      public void preSetterMany(boolean interceptField, int propertyIndex, Object oldValue, Object newValue)
      Description copied from interface: EntityBeanIntercept
      OneToMany and ManyToMany only set loaded state.
    • setChangedPropertyValue

      public void setChangedPropertyValue(int propertyIndex, boolean setDirtyState, Object origValue)
      Description copied from interface: EntityBeanIntercept
      Set the property changed state, bean dirtyState and property original value.
    • setDirtyStatus

      public void setDirtyStatus()
      Description copied from interface: EntityBeanIntercept
      Set the dirty state on the bean.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, Object oldValue, Object newValue)
      Description copied from interface: EntityBeanIntercept
      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

      public void preSetter(boolean intercept, int propertyIndex, boolean oldValue, boolean newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive boolean.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, int oldValue, int newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive int.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, long oldValue, long newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive long.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, double oldValue, double newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive double.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, float oldValue, float newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive float.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, short oldValue, short newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive short.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, char oldValue, char newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive char.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, byte oldValue, byte newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive byte.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, char[] oldValue, char[] newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive char array.
    • preSetter

      public void preSetter(boolean intercept, int propertyIndex, byte[] oldValue, byte[] newValue)
      Description copied from interface: EntityBeanIntercept
      Check for primitive byte array.
    • setOldValue

      public void setOldValue(int propertyIndex, Object oldValue)
      Description copied from interface: EntityBeanIntercept
      Explicitly set an old value with force (the old value is forced even it is already set).
    • sortOrder

      public int sortOrder()
      Description copied from interface: EntityBeanIntercept
      Return the sort order value for an order column.
    • setSortOrder

      public void setSortOrder(int sortOrder)
      Description copied from interface: EntityBeanIntercept
      Set the sort order value for an order column.
    • setDeletedFromCollection

      public void setDeletedFromCollection(boolean deletedFromCollection)
      Description copied from interface: EntityBeanIntercept
      Set if the entity was deleted from a BeanCollection.
    • isOrphanDelete

      public boolean isOrphanDelete()
      Description copied from interface: EntityBeanIntercept
      Return true if the bean was orphan deleted from a collection.
    • setLoadError

      public void setLoadError(int propertyIndex, Exception t)
      Description copied from interface: EntityBeanIntercept
      Set the load error that happened on this property.
    • loadErrors

      public Map<String,Exception> loadErrors()
      Description copied from interface: EntityBeanIntercept
      Returns the loadErrors.
    • isChangedProp

      public boolean isChangedProp(int i)
      Description copied from interface: EntityBeanIntercept
      Return true if the property has its changed state set.
    • mutableInfo

      public MutableValueInfo mutableInfo(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Return the MutableValueInfo for the given property or null.
    • mutableInfo

      public void mutableInfo(int propertyIndex, MutableValueInfo info)
      Description copied from interface: EntityBeanIntercept
      Set the MutableValueInfo for the given property.
    • mutableNext

      public void mutableNext(int propertyIndex, MutableValueNext next)
      Description copied from interface: EntityBeanIntercept
      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

      public String mutableNext(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Update the 'next' mutable info returning the content that was obtained via dirty detection.
    • owner

      public final EntityBean owner()
      Description copied from interface: EntityBeanIntercept
      Return the 'owning' entity bean.
      Specified by:
      owner in interface EntityBeanIntercept
    • isFullyLoadedBean

      public final boolean isFullyLoadedBean()
      Description copied from interface: EntityBeanIntercept
      Return true if the bean is fully loaded (not a partial).
      Specified by:
      isFullyLoadedBean in interface EntityBeanIntercept
    • setFullyLoadedBean

      public final void setFullyLoadedBean(boolean fullyLoadedBean)
      Description copied from interface: EntityBeanIntercept
      Set true when the bean is fully loaded (not a partial).
      Specified by:
      setFullyLoadedBean in interface EntityBeanIntercept
    • property

      public final String property(int propertyIndex)
      Description copied from interface: EntityBeanIntercept
      Return the property name for the given property.
      Specified by:
      property in interface EntityBeanIntercept
    • findProperty

      public final int findProperty(String propertyName)
      Description copied from interface: EntityBeanIntercept
      Finds the index position of a given property. Returns -1 if the property can not be found.
      Specified by:
      findProperty in interface EntityBeanIntercept
    • loadedPropertyKey

      public final StringBuilder loadedPropertyKey()
      Description copied from interface: EntityBeanIntercept
      Return a loaded property hash.
      Specified by:
      loadedPropertyKey in interface EntityBeanIntercept