Class DefaultCoherenceRepositoryOperations

  • All Implemented Interfaces:
    CoherenceRepositoryOperations, io.micronaut.context.ApplicationContextProvider, io.micronaut.data.operations.async.AsyncCapableRepository, io.micronaut.data.operations.HintsCapableRepository, io.micronaut.data.operations.RepositoryOperations

    @EachProperty("coherence.data")
    public class DefaultCoherenceRepositoryOperations
    extends java.lang.Object
    implements CoherenceRepositoryOperations
    A RepositoryOperations implementation for Coherence.
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultCoherenceRepositoryOperations​(java.lang.String mapName, io.micronaut.context.ApplicationContext applicationContext, io.micronaut.context.BeanContext beanContext)
      Constructs a new operations instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      io.micronaut.data.operations.async.AsyncRepositoryOperations async()  
      <T> long count​(io.micronaut.data.model.runtime.PagedQuery<T> pagedQuery)  
      protected java.util.Map<java.lang.String,​java.lang.Object> createBindingMap​(io.micronaut.data.model.runtime.PreparedQuery preparedQuery)
      Creates a map of binding parameters names and their values.
      <T> int delete​(io.micronaut.data.model.runtime.DeleteOperation<T> operation)  
      <T> java.util.Optional<java.lang.Number> deleteAll​(io.micronaut.data.model.runtime.DeleteBatchOperation<T> operation)  
      protected com.tangosol.net.Session ensureSession()
      Return the Session that should be used by this repository.
      java.util.Optional<java.lang.Number> executeUpdate​(io.micronaut.data.model.runtime.PreparedQuery<?,​java.lang.Number> preparedQuery)  
      <T> boolean exists​(io.micronaut.data.model.runtime.PreparedQuery<T,​java.lang.Boolean> preparedQuery)  
      <T> java.lang.Iterable<T> findAll​(io.micronaut.data.model.runtime.PagedQuery<T> query)  
      <T,​R>
      java.lang.Iterable<R>
      findAll​(io.micronaut.data.model.runtime.PreparedQuery<T,​R> preparedQuery)  
      <T,​R>
      R
      findOne​(io.micronaut.data.model.runtime.PreparedQuery<T,​R> preparedQuery)  
      <T> T findOne​(java.lang.Class<T> type, java.io.Serializable id)  
      <R> io.micronaut.data.model.Page<R> findPage​(io.micronaut.data.model.runtime.PagedQuery<R> query)  
      <T> java.util.stream.Stream<T> findStream​(io.micronaut.data.model.runtime.PagedQuery<T> query)  
      <T,​R>
      java.util.stream.Stream<R>
      findStream​(io.micronaut.data.model.runtime.PreparedQuery<T,​R> preparedQuery)  
      io.micronaut.context.ApplicationContext getApplicationContext()  
      <ID,​T>
      ID
      getId​(T entity)
      Return the id associated with the specified entity.
      <ID,​T>
      com.tangosol.net.NamedMap<ID,​T>
      getNamedMap()
      Obtain the NamedMap associated with this repository.
      protected void logQuery​(com.tangosol.coherence.dslquery.ExecutionContext ctx, com.tangosol.coherence.dslquery.Statement statement, java.lang.String query, java.util.Map<java.lang.String,​java.lang.Object> bindingParams)
      Logs the specified query and binding parameters.
      <T> T persist​(io.micronaut.data.model.runtime.InsertOperation<T> operation)  
      <T> java.lang.Iterable<T> persistAll​(io.micronaut.data.model.runtime.InsertBatchOperation<T> operation)  
      protected <T> java.lang.String replaceTarget​(java.lang.String query, java.lang.Class<? extends T> entityClass)
      Replaces the generated target of the statement with the name NamedMap associated with this RepositoryOperations instance.
      protected void setSession​(java.lang.String sessionName)
      Configure the name of the Session.
      <T> T update​(io.micronaut.data.model.runtime.UpdateOperation<T> operation)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.micronaut.data.operations.HintsCapableRepository

        getQueryHints
      • Methods inherited from interface io.micronaut.data.operations.RepositoryOperations

        executeDelete, getConversionService, getEntity, updateAll
    • Constructor Detail

      • DefaultCoherenceRepositoryOperations

        public DefaultCoherenceRepositoryOperations​(@Parameter
                                                    java.lang.String mapName,
                                                    io.micronaut.context.ApplicationContext applicationContext,
                                                    io.micronaut.context.BeanContext beanContext)
        Constructs a new operations instance.
        Parameters:
        mapName - the name of the NamedMap (from configuration)
        applicationContext - the ApplicationContext
        beanContext - the BeanContext used to look up a Session instance
    • Method Detail

      • getApplicationContext

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

        public <ID,​T> com.tangosol.net.NamedMap<ID,​T> getNamedMap()
        Description copied from interface: CoherenceRepositoryOperations
        Obtain the NamedMap associated with this repository.
        Specified by:
        getNamedMap in interface CoherenceRepositoryOperations
        Type Parameters:
        ID - the type of the entity id
        T - the entity type
        Returns:
        the NamedMap associated this this repository
      • getId

        public <ID,​T> ID getId​(T entity)
        Description copied from interface: CoherenceRepositoryOperations
        Return the id associated with the specified entity.
        Specified by:
        getId in interface CoherenceRepositoryOperations
        Type Parameters:
        ID - the type of the entity id
        T - the entity type
        Parameters:
        entity - the entity to interrogate
        Returns:
        the id associated with the specified entity
      • setSession

        protected void setSession​(java.lang.String sessionName)
        Configure the name of the Session. This is called during configuration.
        Parameters:
        sessionName - the name of the Session
      • async

        @NonNull
        public io.micronaut.data.operations.async.AsyncRepositoryOperations async()
        Specified by:
        async in interface io.micronaut.data.operations.async.AsyncCapableRepository
      • findOne

        @Nullable
        public <T> T findOne​(@NonNull
                             java.lang.Class<T> type,
                             @NonNull
                             java.io.Serializable id)
        Specified by:
        findOne in interface io.micronaut.data.operations.RepositoryOperations
      • findOne

        @Nullable
        public <T,​R> R findOne​(@NonNull
                                     io.micronaut.data.model.runtime.PreparedQuery<T,​R> preparedQuery)
        Specified by:
        findOne in interface io.micronaut.data.operations.RepositoryOperations
      • exists

        public <T> boolean exists​(@NonNull
                                  io.micronaut.data.model.runtime.PreparedQuery<T,​java.lang.Boolean> preparedQuery)
        Specified by:
        exists in interface io.micronaut.data.operations.RepositoryOperations
      • findAll

        @NonNull
        public <T> java.lang.Iterable<T> findAll​(@NonNull
                                                 io.micronaut.data.model.runtime.PagedQuery<T> query)
        Specified by:
        findAll in interface io.micronaut.data.operations.RepositoryOperations
      • count

        public <T> long count​(io.micronaut.data.model.runtime.PagedQuery<T> pagedQuery)
        Specified by:
        count in interface io.micronaut.data.operations.RepositoryOperations
      • findAll

        @NonNull
        public <T,​R> java.lang.Iterable<R> findAll​(@NonNull
                                                         io.micronaut.data.model.runtime.PreparedQuery<T,​R> preparedQuery)
        Specified by:
        findAll in interface io.micronaut.data.operations.RepositoryOperations
      • findStream

        @NonNull
        public <T,​R> java.util.stream.Stream<R> findStream​(@NonNull
                                                                 io.micronaut.data.model.runtime.PreparedQuery<T,​R> preparedQuery)
        Specified by:
        findStream in interface io.micronaut.data.operations.RepositoryOperations
      • findStream

        @NonNull
        public <T> java.util.stream.Stream<T> findStream​(@NonNull
                                                         io.micronaut.data.model.runtime.PagedQuery<T> query)
        Specified by:
        findStream in interface io.micronaut.data.operations.RepositoryOperations
      • findPage

        public <R> io.micronaut.data.model.Page<R> findPage​(@NonNull
                                                            io.micronaut.data.model.runtime.PagedQuery<R> query)
        Specified by:
        findPage in interface io.micronaut.data.operations.RepositoryOperations
      • persist

        @NonNull
        public <T> T persist​(@NonNull
                             io.micronaut.data.model.runtime.InsertOperation<T> operation)
        Specified by:
        persist in interface io.micronaut.data.operations.RepositoryOperations
      • update

        @NonNull
        public <T> T update​(@NonNull
                            io.micronaut.data.model.runtime.UpdateOperation<T> operation)
        Specified by:
        update in interface io.micronaut.data.operations.RepositoryOperations
      • executeUpdate

        @NonNull
        public java.util.Optional<java.lang.Number> executeUpdate​(@NonNull
                                                                  io.micronaut.data.model.runtime.PreparedQuery<?,​java.lang.Number> preparedQuery)
        Specified by:
        executeUpdate in interface io.micronaut.data.operations.RepositoryOperations
      • deleteAll

        public <T> java.util.Optional<java.lang.Number> deleteAll​(@NonNull
                                                                  io.micronaut.data.model.runtime.DeleteBatchOperation<T> operation)
        Specified by:
        deleteAll in interface io.micronaut.data.operations.RepositoryOperations
      • delete

        public <T> int delete​(@NonNull
                              io.micronaut.data.model.runtime.DeleteOperation<T> operation)
        Specified by:
        delete in interface io.micronaut.data.operations.RepositoryOperations
      • persistAll

        @NonNull
        public <T> java.lang.Iterable<T> persistAll​(@NonNull
                                                    io.micronaut.data.model.runtime.InsertBatchOperation<T> operation)
        Specified by:
        persistAll in interface io.micronaut.data.operations.RepositoryOperations
      • ensureSession

        protected com.tangosol.net.Session ensureSession()
        Return the Session that should be used by this repository.
        Returns:
        return the Session that should be used by this repository
      • replaceTarget

        protected <T> java.lang.String replaceTarget​(java.lang.String query,
                                                     java.lang.Class<? extends T> entityClass)
        Replaces the generated target of the statement with the name NamedMap associated with this RepositoryOperations instance.
        Type Parameters:
        T - the entity type
        Parameters:
        query - the query as provided by Micronaut
        entityClass - the entity type
        Returns:
        the modified query
      • createBindingMap

        protected java.util.Map<java.lang.String,​java.lang.Object> createBindingMap​(io.micronaut.data.model.runtime.PreparedQuery preparedQuery)
        Creates a map of binding parameters names and their values.
        Parameters:
        preparedQuery - the PreparedQuery to build the binding map from
        Returns:
        the parameters necessary to execute a CohQL statement
      • logQuery

        protected void logQuery​(com.tangosol.coherence.dslquery.ExecutionContext ctx,
                                com.tangosol.coherence.dslquery.Statement statement,
                                java.lang.String query,
                                java.util.Map<java.lang.String,​java.lang.Object> bindingParams)
        Logs the specified query and binding parameters.
        Parameters:
        ctx - the ExecutionContext
        statement - the Statement
        query - the query
        bindingParams - the binding parameters