Class PersistRequestBean<T>

All Implemented Interfaces:
PreGetterCallback, BeanPersistRequest<T>, SpiProfileTransactionEvent, TxnProfileEventCodes, BatchPostExecute

public final class PersistRequestBean<T> extends PersistRequest implements BeanPersistRequest<T>, PreGetterCallback, SpiProfileTransactionEvent
PersistRequest for insert update or delete of a bean.
  • Constructor Details

  • Method Details

    • initForSoftDelete

      public void initForSoftDelete()
      Init generated properties for soft delete (as it's an update).
    • addTimingBatch

      public void addTimingBatch(long startNanos, int batch)
      Description copied from interface: BatchPostExecute
      Add timing metrics for batch persist.
      Specified by:
      addTimingBatch in interface BatchPostExecute
      Overrides:
      addTimingBatch in class PersistRequest
    • addTimingNoBatch

      public void addTimingNoBatch(long startNanos)
      Overrides:
      addTimingNoBatch in class PersistRequest
    • profile

      public void profile(long offset, int flushCount)
      Add to profile as batched bean insert, update or delete.
      Specified by:
      profile in interface BatchPostExecute
    • isCascade

      public boolean isCascade()
      Specified by:
      isCascade in interface BeanPersistRequest<T>
    • setTrans

      public void setTrans(SpiTransaction transaction)
      Set the transaction from prior persist request. Only used when hard deleting draft invalid input: '&' associated live beans.
    • initTransIfRequiredWithBatchCascade

      public void initTransIfRequiredWithBatchCascade()
      Init the transaction and also check for batch on cascade escalation.
    • checkBatchEscalationOnCascade

      public void checkBatchEscalationOnCascade()
      Check for batch escalation on cascade.
    • flushBatchOnCascade

      public void flushBatchOnCascade()
      If using batch on cascade flush if required.
    • rollbackTransIfRequired

      public void rollbackTransIfRequired()
      Description copied from class: BeanRequest
      Rollback the transaction if it was created for this request.
      Overrides:
      rollbackTransIfRequired in class BeanRequest
    • isBatched

      public boolean isBatched()
      Return true is this request was added to the JDBC batch.
    • setBatched

      public void setBatched()
      Set when request is added to the JDBC batch.
    • preGetterTrigger

      public void preGetterTrigger(int propertyIndex)
      Specified by:
      preGetterTrigger in interface PreGetterCallback
    • setSkipBatchForTopLevel

      public void setSkipBatchForTopLevel()
    • isBatchThisRequest

      public boolean isBatchThisRequest()
      Description copied from class: PersistRequest
      Return true if this persist request should use JDBC batch.
      Overrides:
      isBatchThisRequest in class PersistRequest
    • isInsert

      public boolean isInsert()
      Return true if this is an insert request.
    • loadedProperties

      public Set<String> loadedProperties()
      Specified by:
      loadedProperties in interface BeanPersistRequest<T>
    • updatedProperties

      public Set<String> updatedProperties()
      Specified by:
      updatedProperties in interface BeanPersistRequest<T>
    • isChangedProperty

      public boolean isChangedProperty(int propertyIndex)
    • dirtyProperties

      public boolean[] dirtyProperties()
      Return the dirty properties on this request.
      Specified by:
      dirtyProperties in interface BeanPersistRequest<T>
    • hasDirtyProperty

      public boolean hasDirtyProperty(Set<String> propertyNames)
      Return true if any of the given property names are dirty.
      Specified by:
      hasDirtyProperty in interface BeanPersistRequest<T>
    • hasDirtyProperty

      public boolean hasDirtyProperty(int[] propertyPositions)
      Return true if any of the given properties are dirty.
    • updatedValues

      public Map<String,ValuePair> updatedValues()
      Specified by:
      updatedValues in interface BeanPersistRequest<T>
    • addToPersistMap

      public void addToPersistMap(BeanPersistIdMap beanPersistMap)
    • notifyLocalPersistListener

      public void notifyLocalPersistListener()
    • isParent

      public boolean isParent(Object o)
    • isRegisteredBean

      public boolean isRegisteredBean()
      Return true if this bean has been already been persisted (inserted or updated) in this transaction.
    • unRegisterBean

      public void unRegisterBean()
    • registerDeleteBean

      public void registerDeleteBean()
    • isRegisteredForDeleteBean

      public boolean isRegisteredForDeleteBean()
    • descriptor

      public BeanDescriptor<T> descriptor()
      Return the BeanDescriptor for the associated bean.
    • isDirty

      public boolean isDirty()
      Used to skip updates if we know the bean is not dirty. This is the case for EntityBeans that have not been modified.
    • concurrencyMode

      public ConcurrencyMode concurrencyMode()
      Return the concurrency mode used for this persist.
    • fullName

      public String fullName()
      Returns a description of the request. This is typically the bean class name or the base table for MapBeans.

      Used to determine common persist requests for queueing and statement batching.

    • bean

      public T bean()
      Return the bean associated with this request.
      Specified by:
      bean in interface BeanPersistRequest<T>
    • entityBean

      public EntityBean entityBean()
    • beanId

      public Object beanId()
      Return the Id value for the bean.
    • createReference

      public T createReference()
      Create and return a new reference bean matching this beans Id value.
    • isHardDeleteCascade

      public boolean isHardDeleteCascade()
      Return true if this was a hard/permanent delete request (and should cascade as such).
    • parentBean

      public Object parentBean()
      Return the parent bean for cascading save with unidirectional relationship.
    • intercept

      public EntityBeanIntercept intercept()
      Return the intercept if there is one.
    • isLoadedProperty

      public boolean isLoadedProperty(BeanProperty prop)
      Return true if this property is loaded (full bean or included in partial bean).
    • isDirtyProperty

      public boolean isDirtyProperty(BeanProperty prop)
      Return true if the property is dirty.
    • origValue

      public Object origValue(BeanProperty prop)
      Return the original / old value for the given property.
    • executeNow

      public int executeNow()
      Description copied from class: PersistRequest
      Execute the request right now.
      Specified by:
      executeNow in class PersistRequest
    • executeOrQueue

      public int executeOrQueue()
      Description copied from class: PersistRequest
      Execute a the request or queue/batch it for later execution.
      Specified by:
      executeOrQueue in class PersistRequest
    • setGeneratedKey

      public void setGeneratedKey(Object idValue)
      Set the generated key back to the bean. Only used for inserts with getGeneratedKeys.
      Specified by:
      setGeneratedKey in interface BatchPostExecute
    • setBoundId

      public void setBoundId(Object idValue)
      Set the Id value that was bound. Used for the purposes of logging summary information on this request.
    • checkRowCount

      public void checkRowCount(int rowCount)
      Check for optimistic concurrency exception.
      Specified by:
      checkRowCount in interface BatchPostExecute
    • removeFromPersistenceContext

      public void removeFromPersistenceContext()
      Remove deleted beans from the persistence context early.
    • postExecute

      public void postExecute()
      Post processing.
      Specified by:
      postExecute in interface BatchPostExecute
    • preElementCollectionUpdate

      public void preElementCollectionUpdate()
      Ensure the preUpdate event fires (for case where only element collection has changed).
    • isNotifyCache

      public boolean isNotifyCache()
    • isAddToUpdate

      public boolean isAddToUpdate(BeanProperty prop)
      Return true if the property should be included in the update.
    • deferredRelationship

      public void deferredRelationship(EntityBean assocBean, ImportedId importedId, EntityBean bean)
      Register the derived relationships to get executed later (on JDBC batch flush or commit).
    • isSkipReference

      public boolean isSkipReference()
      Return if persist can be skipped on the reference only bean.
    • isReference

      public boolean isReference()
    • setUpdatedMany

      public void setUpdatedMany()
    • addUpdatedManyForL2Cache

      public void addUpdatedManyForL2Cache(BeanPropertyAssocMany<?> many)
      This many property has potential L2 cache update for many Ids.
    • updatedManyForL2Cache

      public List<BeanPropertyAssocMany<?>> updatedManyForL2Cache()
      Return the list of updated many properties for L2 cache update (can be null).
    • complete

      public void complete()
      Completed insert or delete request. Do cache notify in non-batched case.
    • completeUpdate

      public void completeUpdate()
      Completed update request handling cases for element collection and where ONLY many properties were updated.
    • flags

      public int flags()
      Return the flags set on this persist request.
    • updatePlanHash

      public String updatePlanHash()
      Return the key for an update persist request.
    • updateTable

      public String updateTable()
      Return the table to update.
    • deleteMode

      public DeleteMode deleteMode()
      Return the delete mode - Soft or Hard.
    • version

      public long version()
      Return the version in long form (if set).
    • now

      public long now()
      Use a common 'now' value across both when created and when updated etc.
    • isStatelessUpdate

      public boolean isStatelessUpdate()
      Return true if this is a stateless update request (in which case it doesn't really have 'old values').
    • profile

      public void profile()
      Add to profile as single bean insert, update or delete (not batched).
      Specified by:
      profile in interface SpiProfileTransactionEvent
    • flagInsert

      public void flagInsert()
      Set the request flags indicating this is an insert.
    • flagUpdate

      public void flagUpdate()
      Unset the request insert flag indicating this is an update.
    • isInsertedParent

      public boolean isInsertedParent()
      Return true if this request is an insert.
    • addCollectionChange

      public void addCollectionChange(String name, Object value)
      Add an element collection change to L2 bean cache update.
    • addBeanUpdate

      public void addBeanUpdate(CacheChangeSet changeSet)
      Build the bean update for the L2 cache.
    • setImportedOrphanForRemoval

      public void setImportedOrphanForRemoval(BeanPropertyAssocOne<?> prop)
      Set an orphan bean that needs to be deleted AFTER the request has persisted.
    • importedOrphanForRemoval

      public EntityBean importedOrphanForRemoval()
    • selectLastInsertedId

      public String selectLastInsertedId()
      Return the SQL used to fetch the last inserted id value.
    • isQueueSaveMany

      public boolean isQueueSaveMany()
      Return true if the intersection table updates or element collection updates should be queued.
    • addSaveMany

      public void addSaveMany(SaveMany saveManyRequest)
      The intersection table updates or element collection to the batch executed later on postExecute.
    • isForcedUpdate

      public boolean isForcedUpdate()
    • setSaveRecurse

      public void setSaveRecurse()
      Set when this request is from cascading persist.
    • setInsertOptions

      public void setInsertOptions(InsertOptions insertOptions)
    • insertOptions

      public InsertOptions insertOptions()