Class AbstractSyncEntitiesOperations<Ctx extends OperationContext,T,Exc extends Exception>
java.lang.Object
io.micronaut.data.runtime.operations.internal.SyncEntitiesOperations<T,Exc>
io.micronaut.data.runtime.operations.internal.AbstractSyncEntitiesOperations<Ctx,T,Exc>
- Type Parameters:
Ctx- The operation contextT- The entity typeExc- The exception
@Internal
public abstract class AbstractSyncEntitiesOperations<Ctx extends OperationContext,T,Exc extends Exception>
extends SyncEntitiesOperations<T,Exc>
Abstract synchronous entities operations.
- Since:
- 3.3
- Author:
- Denis Stepanov
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final SyncCascadeOperations<Ctx>protected final io.micronaut.core.convert.ConversionServiceprotected final Ctxprotected final EntityEventListener<Object>protected final booleanprotected final booleanprotected final RuntimePersistentEntity<T> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSyncEntitiesOperations(Ctx ctx, SyncCascadeOperations<Ctx> cascadeOperations, io.micronaut.core.convert.ConversionService conversionService, EntityEventListener<Object> entityEventListener, RuntimePersistentEntity<T> persistentEntity, Iterable<T> entities, boolean insert) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcascadePost(Relation.Cascade cascadeType) Cascade post operation.protected voidcascadePre(Relation.Cascade cascadeType) Cascade pre operation.protected voidcheckOptimisticLocking(long expected, long received) Compare the expected modifications and the received rows count.protected voidCollect auto-populated values before pre-triggers modifies them.voiddelete()Delete one operation.protected abstract voidexecute()Execute update.protected voidvoidpersist()Persist one operation.protected voidTrigger post-actions onEntityEventContext.protected voidTrigger the post persist event.protected voidTrigger the post remove event.protected voidTrigger the post update event.protected booleanTrigger pre-actions onEntityEventContext.protected booleanTrigger the pre persist event.protected booleanTrigger the pre remove event.protected booleanTrigger the pre update event.voidupdate()Update one operation.protected TupdateEntityId(io.micronaut.core.beans.BeanProperty<T, Object> identity, T entity, Object id) Update entity id.voidVeto an entity.
-
Field Details
-
ctx
-
cascadeOperations
-
conversionService
protected final io.micronaut.core.convert.ConversionService conversionService -
entities
protected final List<AbstractSyncEntitiesOperations<Ctx extends OperationContext,T, entitiesExc extends Exception>.Data> -
insert
protected final boolean insert -
hasGeneratedId
protected final boolean hasGeneratedId -
entityEventListener
-
persistentEntity
-
-
Constructor Details
-
AbstractSyncEntitiesOperations
protected AbstractSyncEntitiesOperations(Ctx ctx, SyncCascadeOperations<Ctx> cascadeOperations, io.micronaut.core.convert.ConversionService conversionService, EntityEventListener<Object> entityEventListener, RuntimePersistentEntity<T> persistentEntity, Iterable<T> entities, boolean insert) Default constructor.- Parameters:
ctx- The contextcascadeOperations- The cascade operationsconversionService- The conversion serviceentityEventListener- The entity event listenerpersistentEntity- The persistent entityentities- The entitiesinsert- 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. -
veto
Veto an entity.- Parameters:
predicate- The veto predicate
-
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
-
getEntities
- Specified by:
getEntitiesin classSyncEntitiesOperations<T,Exc extends Exception> - Returns:
- The entities
-
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.
-