Class AbstractSyncEntityOperations<Ctx extends OperationContext,T,Exc extends Exception>
java.lang.Object
io.micronaut.data.runtime.operations.internal.EntityOperations<T,Exc>
io.micronaut.data.runtime.operations.internal.SyncEntityOperations<T,Exc>
io.micronaut.data.runtime.operations.internal.AbstractSyncEntityOperations<Ctx,T,Exc>
- Type Parameters:
Ctx
- The operation contextT
- The entity typeExc
- The exception
@Internal
public abstract class AbstractSyncEntityOperations<Ctx extends OperationContext,T,Exc extends Exception>
extends SyncEntityOperations<T,Exc>
Abstract synchronous entity operations.
- Since:
- 3.3
- Author:
- Denis Stepanov
-
Field Summary
Modifier and TypeFieldDescriptionprotected SyncCascadeOperations<Ctx>
protected final io.micronaut.core.convert.ConversionService
protected final Ctx
protected T
protected final EntityEventListener<Object>
protected final boolean
protected final boolean
protected final RuntimePersistentEntity<T>
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractSyncEntityOperations
(Ctx ctx, SyncCascadeOperations<Ctx> cascadeOperations, EntityEventListener<Object> entityEventListener, RuntimePersistentEntity<T> persistentEntity, io.micronaut.core.convert.ConversionService conversionService, T entity, boolean insert) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cascadePost
(Relation.Cascade cascadeType) Cascade post operation.protected void
cascadePre
(Relation.Cascade cascadeType) Cascade pre operation.protected void
checkOptimisticLocking
(long expected, long received) Compare the expected modifications and the received rows count.protected void
Collect auto-populated values before pre-triggers modifies them.void
delete()
Delete one operation.protected abstract void
execute()
Execute update.protected void
void
persist()
Persist one operation.protected void
Trigger post-actions onEntityEventContext
.protected void
Trigger the post persist event.protected void
Trigger the post remove event.protected void
Trigger the post update event.protected boolean
Trigger pre-actions onEntityEventContext
.protected boolean
Trigger the pre persist event.protected boolean
Trigger the pre remove event.protected boolean
Trigger the pre update event.void
update()
Update one operation.protected T
updateEntityId
(io.micronaut.core.beans.BeanProperty<T, Object> identity, T entity, Object id) Update entity id.void
Veto an entity.
-
Field Details
-
cascadeOperations
-
ctx
-
insert
protected final boolean insert -
hasGeneratedId
protected final boolean hasGeneratedId -
entity
-
entityEventListener
-
persistentEntity
-
conversionService
protected final io.micronaut.core.convert.ConversionService conversionService
-
-
Constructor Details
-
AbstractSyncEntityOperations
protected AbstractSyncEntityOperations(Ctx ctx, SyncCascadeOperations<Ctx> cascadeOperations, EntityEventListener<Object> entityEventListener, RuntimePersistentEntity<T> persistentEntity, io.micronaut.core.convert.ConversionService conversionService, T entity, boolean insert) Default constructor.- Parameters:
ctx
- The contextcascadeOperations
- The cascade operationsconversionService
- The conversion serviceentityEventListener
- The entity event listenerpersistentEntity
- The persistent entityentity
- The entityinsert
- The insert
-
-
Method Details
-
cascadePre
Cascade pre operation.- Parameters:
cascadeType
- The cascade type
-
cascadePost
Cascade post operation.- Parameters:
cascadeType
- The cascade type
-
collectAutoPopulatedPreviousValues
protected void collectAutoPopulatedPreviousValues()Collect auto-populated values before pre-triggers modifies them. -
triggerPre
Trigger pre-actions onEntityEventContext
.- Parameters:
fn
- The entity context function- Returns:
- true if operation was vetoed
-
triggerPost
Trigger post-actions onEntityEventContext
.- Parameters:
fn
- The entity context function
-
veto
Veto an entity.- Parameters:
predicate
- The veto predicate
-
getEntity
- Specified by:
getEntity
in classSyncEntityOperations<T,
Exc extends Exception>
-
checkOptimisticLocking
protected void checkOptimisticLocking(long expected, long received) Compare the expected modifications and the received rows count. If not equals throwOptimisticLockException
.- Parameters:
expected
- The expected valuereceived
- THe received value
-
persist
public void persist()Persist one operation. -
delete
public void delete()Delete one operation. -
update
public void update()Update one operation. -
failed
- Throws:
DataAccessException
-
execute
Execute update. -
updateEntityId
protected T updateEntityId(io.micronaut.core.beans.BeanProperty<T, Object> identity, T entity, Object id) Update entity id.- Parameters:
identity
- The identity property.entity
- The entity instanceid
- The id instance- Returns:
- The entity instance
-
triggerPrePersist
protected boolean triggerPrePersist()Trigger the pre persist event.- Returns:
- true if operation was vetoed
-
triggerPreUpdate
protected boolean triggerPreUpdate()Trigger the pre update event.- Returns:
- true if operation was vetoed
-
triggerPreRemove
protected boolean triggerPreRemove()Trigger the pre remove event.- Returns:
- true if operation was vetoed
-
triggerPostUpdate
protected void triggerPostUpdate()Trigger the post update event. -
triggerPostRemove
protected void triggerPostRemove()Trigger the post remove event. -
triggerPostPersist
protected void triggerPostPersist()Trigger the post persist event.
-