Class AbstractRepositoryOperations

  • All Implemented Interfaces:
    io.micronaut.context.ApplicationContextProvider
    Direct Known Subclasses:
    AbstractSqlRepositoryOperations

    @Internal
    public abstract class AbstractRepositoryOperations
    extends java.lang.Object
    implements io.micronaut.context.ApplicationContextProvider
    Abstract repository implementation.
    Since:
    3.1.0
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractRepositoryOperations​(java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs, DateTimeProvider<java.lang.Object> dateTimeProvider, io.micronaut.data.model.runtime.RuntimeEntityRegistry runtimeEntityRegistry, DataConversionService<?> conversionService, io.micronaut.data.model.runtime.AttributeConverterRegistry attributeConverterRegistry)
      Default constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkOptimisticLocking​(int expected, java.lang.Number received)
      Compare the expected modifications and the received rows count.
      io.micronaut.context.ApplicationContext getApplicationContext()  
      DataConversionService<?> getConversionService()  
      <T> io.micronaut.data.model.runtime.RuntimePersistentEntity<T> getEntity​(java.lang.Class<T> type)  
      protected io.micronaut.data.model.runtime.RuntimePersistentProperty<java.lang.Object> getIdReader​(java.lang.Object o)
      Obtain an ID reader for the given object.
      protected boolean isOnlySingleEndedJoins​(io.micronaut.data.model.runtime.RuntimePersistentEntity<?> rootPersistentEntity, java.util.Set<io.micronaut.data.model.query.JoinPath> joinFetchPaths)
      Check if joined associated are all single ended (Can produce only one result).
      protected <T> T triggerPostLoad​(T entity, io.micronaut.data.model.runtime.RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
      Trigger the post load event.
      • Methods inherited from class java.lang.Object

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

      • jsonCodec

        protected final io.micronaut.http.codec.MediaTypeCodec jsonCodec
      • entityEventRegistry

        protected final io.micronaut.data.event.EntityEventListener<java.lang.Object> entityEventRegistry
      • runtimeEntityRegistry

        protected final io.micronaut.data.model.runtime.RuntimeEntityRegistry runtimeEntityRegistry
      • attributeConverterRegistry

        protected final io.micronaut.data.model.runtime.AttributeConverterRegistry attributeConverterRegistry
    • Constructor Detail

      • AbstractRepositoryOperations

        protected AbstractRepositoryOperations​(java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs,
                                               DateTimeProvider<java.lang.Object> dateTimeProvider,
                                               io.micronaut.data.model.runtime.RuntimeEntityRegistry runtimeEntityRegistry,
                                               DataConversionService<?> conversionService,
                                               io.micronaut.data.model.runtime.AttributeConverterRegistry attributeConverterRegistry)
        Default constructor.
        Parameters:
        codecs - The media type codecs
        dateTimeProvider - The date time provider
        runtimeEntityRegistry - The entity registry
        conversionService - The conversion service
        attributeConverterRegistry - The attribute converter registry
    • Method Detail

      • getConversionService

        public DataConversionService<?> getConversionService()
        Returns:
        the conversion service
      • getApplicationContext

        public io.micronaut.context.ApplicationContext getApplicationContext()
        Specified by:
        getApplicationContext in interface io.micronaut.context.ApplicationContextProvider
      • getEntity

        @NonNull
        public final <T> io.micronaut.data.model.runtime.RuntimePersistentEntity<T> getEntity​(@NonNull
                                                                                              java.lang.Class<T> type)
      • triggerPostLoad

        protected <T> T triggerPostLoad​(@NonNull
                                        T entity,
                                        io.micronaut.data.model.runtime.RuntimePersistentEntity<T> pe,
                                        io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
        Trigger the post load event.
        Type Parameters:
        T - The generic type
        Parameters:
        entity - The entity
        pe - The persistent entity
        annotationMetadata - The annotation metadata
        Returns:
        The entity, possibly modified
      • getIdReader

        @NonNull
        protected final io.micronaut.data.model.runtime.RuntimePersistentProperty<java.lang.Object> getIdReader​(@NonNull
                                                                                                                java.lang.Object o)
        Obtain an ID reader for the given object.
        Parameters:
        o - The object
        Returns:
        The ID reader
      • checkOptimisticLocking

        protected void checkOptimisticLocking​(int expected,
                                              java.lang.Number received)
        Compare the expected modifications and the received rows count. If not equals throw OptimisticLockException.
        Parameters:
        expected - The expected value
        received - THe received value
      • isOnlySingleEndedJoins

        protected boolean isOnlySingleEndedJoins​(io.micronaut.data.model.runtime.RuntimePersistentEntity<?> rootPersistentEntity,
                                                 java.util.Set<io.micronaut.data.model.query.JoinPath> joinFetchPaths)
        Check if joined associated are all single ended (Can produce only one result).
        Parameters:
        rootPersistentEntity - The root entity
        joinFetchPaths - The join paths
        Returns:
        true if there are no "many" joins