Class AbstractSyncEntitiesOperations<Ctx extends OperationContext,T,Exc extends java.lang.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 java.lang.Exception> extends SyncEntitiesOperations<T,Exc>
Abstract synchronous entities operations.- Since:
- 3.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractSyncEntitiesOperations.Data
-
Field Summary
Fields Modifier and Type Field Description protected SyncCascadeOperations<Ctx>cascadeOperationsprotected io.micronaut.core.convert.ConversionService<?>conversionServiceprotected Ctxctxprotected java.util.List<AbstractSyncEntitiesOperations.Data>entitiesprotected io.micronaut.data.event.EntityEventListener<java.lang.Object>entityEventListenerprotected booleanhasGeneratedIdprotected booleaninsertprotected io.micronaut.data.model.runtime.RuntimePersistentEntity<T>persistentEntity
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSyncEntitiesOperations(Ctx ctx, SyncCascadeOperations<Ctx> cascadeOperations, io.micronaut.core.convert.ConversionService<?> conversionService, io.micronaut.data.event.EntityEventListener<java.lang.Object> entityEventListener, io.micronaut.data.model.runtime.RuntimePersistentEntity<T> persistentEntity, java.lang.Iterable<T> entities, boolean insert)Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcascadePost(io.micronaut.data.annotation.Relation.Cascade cascadeType)Cascade post operation.protected voidcascadePre(io.micronaut.data.annotation.Relation.Cascade cascadeType)Cascade pre operation.protected voidcheckOptimisticLocking(long expected, long received)Compare the expected modifications and the received rows count.protected voidcollectAutoPopulatedPreviousValues()Collect auto-populated values before pre-triggers modifies them.voiddelete()Delete one operation.protected abstract voidexecute()Execute update.protected voidfailed(java.lang.Exception e, java.lang.String operation)java.util.List<T>getEntities()voidpersist()Persist one operation.protected voidtriggerPost(java.util.function.Consumer<io.micronaut.data.event.EntityEventContext<java.lang.Object>> fn)Trigger post-actions onEntityEventContext.protected voidtriggerPostPersist()Trigger the post persist event.protected voidtriggerPostRemove()Trigger the post remove event.protected voidtriggerPostUpdate()Trigger the post update event.protected booleantriggerPre(java.util.function.Function<io.micronaut.data.event.EntityEventContext<java.lang.Object>,java.lang.Boolean> fn)Trigger pre-actions onEntityEventContext.protected booleantriggerPrePersist()Trigger the pre persist event.protected booleantriggerPreRemove()Trigger the pre remove event.protected booleantriggerPreUpdate()Trigger the pre update event.voidupdate()Update one operation.protected TupdateEntityId(io.micronaut.core.beans.BeanProperty<T,java.lang.Object> identity, T entity, java.lang.Object id)Update entity id.voidveto(java.util.function.Predicate<T> predicate)Veto an entity.
-
-
-
Field Detail
-
ctx
protected final Ctx extends OperationContext ctx
-
cascadeOperations
protected final SyncCascadeOperations<Ctx extends OperationContext> cascadeOperations
-
conversionService
protected final io.micronaut.core.convert.ConversionService<?> conversionService
-
entities
protected final java.util.List<AbstractSyncEntitiesOperations.Data> entities
-
insert
protected final boolean insert
-
hasGeneratedId
protected final boolean hasGeneratedId
-
entityEventListener
protected final io.micronaut.data.event.EntityEventListener<java.lang.Object> entityEventListener
-
persistentEntity
protected final io.micronaut.data.model.runtime.RuntimePersistentEntity<T> persistentEntity
-
-
Constructor Detail
-
AbstractSyncEntitiesOperations
protected AbstractSyncEntitiesOperations(Ctx ctx, SyncCascadeOperations<Ctx> cascadeOperations, io.micronaut.core.convert.ConversionService<?> conversionService, io.micronaut.data.event.EntityEventListener<java.lang.Object> entityEventListener, io.micronaut.data.model.runtime.RuntimePersistentEntity<T> persistentEntity, java.lang.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 Detail
-
cascadePre
protected void cascadePre(io.micronaut.data.annotation.Relation.Cascade cascadeType)
Cascade pre operation.- Parameters:
cascadeType- The cascade type
-
cascadePost
protected void cascadePost(io.micronaut.data.annotation.Relation.Cascade cascadeType)
Cascade post operation.- Parameters:
cascadeType- The cascade type
-
collectAutoPopulatedPreviousValues
protected void collectAutoPopulatedPreviousValues()
Collect auto-populated values before pre-triggers modifies them.
-
veto
public void veto(java.util.function.Predicate<T> predicate)
Veto an entity.- Parameters:
predicate- The veto predicate
-
triggerPre
protected boolean triggerPre(java.util.function.Function<io.micronaut.data.event.EntityEventContext<java.lang.Object>,java.lang.Boolean> fn)
Trigger pre-actions onEntityEventContext.- Parameters:
fn- The entity context function- Returns:
- true if operation was vetoed
-
triggerPost
protected void triggerPost(java.util.function.Consumer<io.micronaut.data.event.EntityEventContext<java.lang.Object>> fn)
Trigger post-actions onEntityEventContext.- Parameters:
fn- The entity context function
-
getEntities
public java.util.List<T> getEntities()
- Specified by:
getEntitiesin classSyncEntitiesOperations<T,Exc extends java.lang.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
protected void failed(java.lang.Exception e, java.lang.String operation) throws io.micronaut.data.exceptions.DataAccessException- Throws:
io.micronaut.data.exceptions.DataAccessException
-
execute
protected abstract void execute() throws Exc extends java.lang.ExceptionExecute update.- Throws:
Exc- The exceptionExc extends java.lang.Exception
-
updateEntityId
protected T updateEntityId(io.micronaut.core.beans.BeanProperty<T,java.lang.Object> identity, T entity, java.lang.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.
-
-