Class SyncEntityOperations<T,​Exc extends java.lang.Exception>

  • Type Parameters:
    T - The entity type
    Exc - The exception
    Direct Known Subclasses:
    AbstractSyncEntityOperations

    @Internal
    public abstract class SyncEntityOperations<T,​Exc extends java.lang.Exception>
    extends EntityOperations<T,​Exc>
    The entity operations container.
    Since:
    3.3
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected io.micronaut.core.convert.ConversionService<?> conversionService  
      protected io.micronaut.data.event.EntityEventListener<java.lang.Object> entityEventListener  
      protected io.micronaut.data.model.runtime.RuntimePersistentEntity<T> persistentEntity  
    • Constructor Summary

      Constructors 
      Constructor Description
      SyncEntityOperations​(io.micronaut.data.event.EntityEventListener<java.lang.Object> entityEventListener, io.micronaut.data.model.runtime.RuntimePersistentEntity<T> persistentEntity, io.micronaut.core.convert.ConversionService<?> conversionService)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void cascadePost​(io.micronaut.data.annotation.Relation.Cascade cascadeType)
      Cascade post operation.
      protected abstract void cascadePre​(io.micronaut.data.annotation.Relation.Cascade cascadeType)
      Cascade pre operation.
      protected void checkOptimisticLocking​(long expected, long received)
      Compare the expected modifications and the received rows count.
      protected abstract void collectAutoPopulatedPreviousValues()
      Collect auto-populated values before pre-triggers modifies them.
      void delete()
      Delete one operation.
      protected abstract void execute()
      Execute update.
      protected void failed​(java.lang.Exception e, java.lang.String operation)  
      abstract T getEntity()  
      void persist()
      Persist one operation.
      protected abstract void triggerPost​(java.util.function.Consumer<io.micronaut.data.event.EntityEventContext<java.lang.Object>> fn)
      Trigger post-actions on EntityEventContext.
      protected void triggerPostPersist()
      Trigger the post persist event.
      protected void triggerPostRemove()
      Trigger the post remove event.
      protected void triggerPostUpdate()
      Trigger the post update event.
      protected abstract boolean triggerPre​(java.util.function.Function<io.micronaut.data.event.EntityEventContext<java.lang.Object>,​java.lang.Boolean> fn)
      Trigger pre-actions on EntityEventContext.
      protected boolean triggerPrePersist()
      Trigger the pre persist event.
      protected boolean triggerPreRemove()
      Trigger the pre remove event.
      protected boolean triggerPreUpdate()
      Trigger the pre update event.
      void update()
      Update one operation.
      protected T updateEntityId​(io.micronaut.core.beans.BeanProperty<T,​java.lang.Object> identity, T entity, java.lang.Object id)
      Update entity id.
      abstract void veto​(java.util.function.Predicate<T> predicate)
      Veto an entity.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • entityEventListener

        protected final io.micronaut.data.event.EntityEventListener<java.lang.Object> entityEventListener
      • persistentEntity

        protected final io.micronaut.data.model.runtime.RuntimePersistentEntity<T> persistentEntity
      • conversionService

        protected final io.micronaut.core.convert.ConversionService<?> conversionService
    • Constructor Detail

      • SyncEntityOperations

        public SyncEntityOperations​(io.micronaut.data.event.EntityEventListener<java.lang.Object> entityEventListener,
                                    io.micronaut.data.model.runtime.RuntimePersistentEntity<T> persistentEntity,
                                    io.micronaut.core.convert.ConversionService<?> conversionService)
    • Method Detail

      • getEntity

        public abstract T getEntity()
      • checkOptimisticLocking

        protected void checkOptimisticLocking​(long expected,
                                              long received)
        Compare the expected modifications and the received rows count. If not equals throw OptimisticLockException.
        Parameters:
        expected - The expected value
        received - 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
      • cascadePre

        protected abstract void cascadePre​(io.micronaut.data.annotation.Relation.Cascade cascadeType)
        Cascade pre operation.
        Parameters:
        cascadeType - The cascade type
      • cascadePost

        protected abstract void cascadePost​(io.micronaut.data.annotation.Relation.Cascade cascadeType)
        Cascade post operation.
        Parameters:
        cascadeType - The cascade type
      • collectAutoPopulatedPreviousValues

        protected abstract void collectAutoPopulatedPreviousValues()
        Collect auto-populated values before pre-triggers modifies them.
      • execute

        protected abstract void execute()
                                 throws Exc extends java.lang.Exception
        Execute update.
        Throws:
        Exc - The exception
        Exc extends java.lang.Exception
      • veto

        public abstract void veto​(java.util.function.Predicate<T> predicate)
        Veto an entity.
        Parameters:
        predicate - The veto predicate
      • 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 instance
        id - 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.
      • triggerPre

        protected abstract boolean triggerPre​(java.util.function.Function<io.micronaut.data.event.EntityEventContext<java.lang.Object>,​java.lang.Boolean> fn)
        Trigger pre-actions on EntityEventContext.
        Parameters:
        fn - The entity context function
        Returns:
        true if operation was vetoed
      • triggerPost

        protected abstract void triggerPost​(java.util.function.Consumer<io.micronaut.data.event.EntityEventContext<java.lang.Object>> fn)
        Trigger post-actions on EntityEventContext.
        Parameters:
        fn - The entity context function