java.lang.Object
io.ebeaninternal.server.core.BeanRequest
io.ebeaninternal.server.core.PersistRequest
io.ebeaninternal.server.core.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.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.ebeaninternal.server.core.PersistRequest
PersistRequest.Type -
Field Summary
Fields inherited from class io.ebeaninternal.server.core.PersistRequest
label, startNanos, typeFields inherited from class io.ebeaninternal.server.core.BeanRequest
createdTransaction, server, transactionFields inherited from interface io.ebeaninternal.api.TxnProfileEventCodes
EVT_CALLABLESQL, EVT_COMMIT, EVT_DELETE, EVT_DELETE_PERMANENT, EVT_DELETE_SOFT, EVT_INSERT, EVT_ORMUPDATE, EVT_ROLLBACK, EVT_UPDATE, EVT_UPDATESQL, FIND_ATTRIBUTE, FIND_ATTRIBUTE_SET, FIND_COUNT, FIND_DELETE, FIND_EXISTS, FIND_ID_LIST, FIND_ITERATE, FIND_MANY, FIND_MANY_LAZY, FIND_ONE, FIND_ONE_LAZY, FIND_SUBQUERY, FIND_UPDATE -
Constructor Summary
ConstructorsConstructorDescriptionPersistRequestBean(SpiEbeanServer server, T bean, Object parentBean, BeanManager<T> mgr, SpiTransaction t, PersistExecute persistExecute, PersistRequest.Type type, int flags) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBeanUpdate(CacheChangeSet changeSet) Build the bean update for the L2 cache.voidaddCollectionChange(String name, Object value) Add an element collection change to L2 bean cache update.voidaddSaveMany(SaveMany saveManyRequest) The intersection table updates or element collection to the batch executed later on postExecute.voidaddTimingBatch(long startNanos, int batch) Add timing metrics for batch persist.voidaddTimingNoBatch(long startNanos) voidaddToPersistMap(BeanPersistIdMap beanPersistMap) voidThis many property has potential L2 cache update for many Ids.bean()Return the bean associated with this request.beanId()Return the Id value for the bean.voidCheck for batch escalation on cascade.voidcheckRowCount(int rowCount) Check for optimistic concurrency exception.voidcomplete()Completed insert or delete request.voidCompleted update request handling cases for element collection and where ONLY many properties were updated.Return the concurrency mode used for this persist.Create and return a new reference bean matching this beans Id value.voiddeferredRelationship(EntityBean assocBean, ImportedId importedId, EntityBean bean) Register the derived relationships to get executed later (on JDBC batch flush or commit).Return the delete mode - Soft or Hard.Return the BeanDescriptor for the associated bean.boolean[]Return the dirty properties on this request.intExecute the request right now.intExecute a the request or queue/batch it for later execution.voidSet the request flags indicating this is an insert.intflags()Return the flags set on this persist request.voidUnset the request insert flag indicating this is an update.voidIf using batch on cascade flush if required.fullName()Returns a description of the request.booleanhasDirtyProperty(int[] propertyPositions) Return true if any of the given properties are dirty.booleanhasDirtyProperty(Set<String> propertyNames) Return true if any of the given property names are dirty.voidInit generated properties for soft delete (as it's an update).voidInit the transaction and also check for batch on cascade escalation.Return the intercept if there is one.booleanisAddToUpdate(BeanProperty prop) Return true if the property should be included in the update.booleanReturn true is this request was added to the JDBC batch.booleanReturn true if this persist request should use JDBC batch.booleanbooleanisChangedProperty(int propertyIndex) booleanisDirty()Used to skip updates if we know the bean is not dirty.booleanisDirtyProperty(BeanProperty prop) Return true if the property is dirty.booleanbooleanReturn true if this was a hard/permanent delete request (and should cascade as such).booleanisInsert()Return true if this is an insert request.booleanReturn true if this request is an insert.booleanisLoadedProperty(BeanProperty prop) Return true if this property is loaded (full bean or included in partial bean).booleanbooleanbooleanReturn true if the intersection table updates or element collection updates should be queued.booleanbooleanReturn true if this bean has been already been persisted (inserted or updated) in this transaction.booleanbooleanReturn if persist can be skipped on the reference only bean.booleanReturn true if this is a stateless update request (in which case it doesn't really have 'old values').voidlongnow()Use a common 'now' value across both when created and when updated etc.origValue(BeanProperty prop) Return the original / old value for the given property.Return the parent bean for cascading save with unidirectional relationship.voidPost processing.voidEnsure the preUpdate event fires (for case where only element collection has changed).voidpreGetterTrigger(int propertyIndex) voidprofile()Add to profile as single bean insert, update or delete (not batched).voidprofile(long offset, int flushCount) Add to profile as batched bean insert, update or delete.voidvoidRemove deleted beans from the persistence context early.voidRollback the transaction if it was created for this request.Return the SQL used to fetch the last inserted id value.voidSet when request is added to the JDBC batch.voidsetBoundId(Object idValue) Set the Id value that was bound.voidsetGeneratedKey(Object idValue) Set the generated key back to the bean.voidSet an orphan bean that needs to be deleted AFTER the request has persisted.voidsetInsertOptions(InsertOptions insertOptions) voidSet when this request is from cascading persist.voidvoidsetTrans(SpiTransaction transaction) Set the transaction from prior persist request.voidvoidReturn the list of updated many properties for L2 cache update (can be null).Return the key for an update persist request.Return the table to update.longversion()Return the version in long form (if set).Methods inherited from class io.ebeaninternal.server.core.PersistRequest
initTransIfRequired, isFlushQueue, isPersistCascade, logSql, logSummary, resetDepth, startBind, translateSqlException, typeMethods inherited from class io.ebeaninternal.server.core.BeanRequest
clearTransIfRequired, commitTransIfRequired, createImplicitTransIfRequired, database, dataTimeZone, server, transaction, transactionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.ebean.event.BeanPersistRequest
database, transaction
-
Constructor Details
-
PersistRequestBean
public PersistRequestBean(SpiEbeanServer server, T bean, Object parentBean, BeanManager<T> mgr, SpiTransaction t, PersistExecute persistExecute, PersistRequest.Type type, int flags)
-
-
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:BatchPostExecuteAdd timing metrics for batch persist.- Specified by:
addTimingBatchin interfaceBatchPostExecute- Overrides:
addTimingBatchin classPersistRequest
-
addTimingNoBatch
public void addTimingNoBatch(long startNanos) - Overrides:
addTimingNoBatchin classPersistRequest
-
profile
public void profile(long offset, int flushCount) Add to profile as batched bean insert, update or delete.- Specified by:
profilein interfaceBatchPostExecute
-
isCascade
public boolean isCascade()- Specified by:
isCascadein interfaceBeanPersistRequest<T>
-
setTrans
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:BeanRequestRollback the transaction if it was created for this request.- Overrides:
rollbackTransIfRequiredin classBeanRequest
-
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:
preGetterTriggerin interfacePreGetterCallback
-
setSkipBatchForTopLevel
public void setSkipBatchForTopLevel() -
isBatchThisRequest
public boolean isBatchThisRequest()Description copied from class:PersistRequestReturn true if this persist request should use JDBC batch.- Overrides:
isBatchThisRequestin classPersistRequest
-
isInsert
public boolean isInsert()Return true if this is an insert request. -
loadedProperties
- Specified by:
loadedPropertiesin interfaceBeanPersistRequest<T>
-
updatedProperties
- Specified by:
updatedPropertiesin interfaceBeanPersistRequest<T>
-
isChangedProperty
public boolean isChangedProperty(int propertyIndex) -
dirtyProperties
public boolean[] dirtyProperties()Return the dirty properties on this request.- Specified by:
dirtyPropertiesin interfaceBeanPersistRequest<T>
-
hasDirtyProperty
Return true if any of the given property names are dirty.- Specified by:
hasDirtyPropertyin interfaceBeanPersistRequest<T>
-
hasDirtyProperty
public boolean hasDirtyProperty(int[] propertyPositions) Return true if any of the given properties are dirty. -
updatedValues
- Specified by:
updatedValuesin interfaceBeanPersistRequest<T>
-
addToPersistMap
-
notifyLocalPersistListener
public void notifyLocalPersistListener() -
isParent
-
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
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
Return the concurrency mode used for this persist. -
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
Return the bean associated with this request.- Specified by:
beanin interfaceBeanPersistRequest<T>
-
entityBean
-
beanId
Return the Id value for the bean. -
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
Return the parent bean for cascading save with unidirectional relationship. -
intercept
Return the intercept if there is one. -
isLoadedProperty
Return true if this property is loaded (full bean or included in partial bean). -
isDirtyProperty
Return true if the property is dirty. -
origValue
Return the original / old value for the given property. -
executeNow
public int executeNow()Description copied from class:PersistRequestExecute the request right now.- Specified by:
executeNowin classPersistRequest
-
executeOrQueue
public int executeOrQueue()Description copied from class:PersistRequestExecute a the request or queue/batch it for later execution.- Specified by:
executeOrQueuein classPersistRequest
-
setGeneratedKey
Set the generated key back to the bean. Only used for inserts with getGeneratedKeys.- Specified by:
setGeneratedKeyin interfaceBatchPostExecute
-
setBoundId
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:
checkRowCountin interfaceBatchPostExecute
-
removeFromPersistenceContext
public void removeFromPersistenceContext()Remove deleted beans from the persistence context early. -
postExecute
public void postExecute()Post processing.- Specified by:
postExecutein interfaceBatchPostExecute
-
preElementCollectionUpdate
public void preElementCollectionUpdate()Ensure the preUpdate event fires (for case where only element collection has changed). -
isNotifyCache
public boolean isNotifyCache() -
isAddToUpdate
Return true if the property should be included in the update. -
deferredRelationship
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
This many property has potential L2 cache update for many Ids. -
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
Return the key for an update persist request. -
updateTable
Return the table to update. -
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:
profilein interfaceSpiProfileTransactionEvent
-
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
Add an element collection change to L2 bean cache update. -
addBeanUpdate
Build the bean update for the L2 cache. -
setImportedOrphanForRemoval
Set an orphan bean that needs to be deleted AFTER the request has persisted. -
importedOrphanForRemoval
-
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
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
-
insertOptions
-