Class AbstractHibernateOperations<S,​Q>

  • Type Parameters:
    S - The session type
    Q - The query type
    All Implemented Interfaces:
    io.micronaut.data.operations.HintsCapableRepository, io.micronaut.data.runtime.query.PreparedQueryDecorator, io.micronaut.data.runtime.query.StoredQueryDecorator
    Direct Known Subclasses:
    HibernateJpaOperations

    @Internal
    public abstract class AbstractHibernateOperations<S,​Q>
    extends java.lang.Object
    implements io.micronaut.data.operations.HintsCapableRepository, io.micronaut.data.runtime.query.PreparedQueryDecorator, io.micronaut.data.runtime.query.StoredQueryDecorator
    Abstract Hibernate operations shared between the synchronous and the reactive implementations.
    Since:
    3.5.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected io.micronaut.core.convert.ConversionService<?> dataConversionService  
      protected io.micronaut.data.model.runtime.RuntimeEntityRegistry runtimeEntityRegistry  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractHibernateOperations​(io.micronaut.data.model.runtime.RuntimeEntityRegistry runtimeEntityRegistry, io.micronaut.data.runtime.convert.DataConversionService<?> dataConversionService)
      Default constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected <T,​R>
      void
      bindParameters​(Q q, io.micronaut.data.model.runtime.PreparedQuery<T,​R> preparedQuery)
      Bind parameters into query.
      protected <R> void collectCountOf​(javax.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, java.lang.Class<R> entity, io.micronaut.data.model.Pageable pageable, AbstractHibernateOperations.ResultCollector<java.lang.Long> resultCollector)  
      protected <R> void collectFindAll​(S session, io.micronaut.data.model.runtime.PreparedQuery<?,​R> preparedQuery, AbstractHibernateOperations.ResultCollector<R> collector)
      Collect all results.
      protected <R> void collectFindOne​(S session, io.micronaut.data.model.runtime.PreparedQuery<?,​R> preparedQuery, AbstractHibernateOperations.ResultCollector<R> collector)
      Collect one result.
      protected <T> void collectPagedResults​(javax.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, io.micronaut.data.model.runtime.PagedQuery<T> pagedQuery, AbstractHibernateOperations.ResultCollector<T> resultCollector)  
      protected abstract <T> javax.persistence.EntityGraph<T> createEntityGraph​(S session, java.lang.Class<T> entityType)
      Creates an entity graph.
      protected abstract Q createNativeQuery​(S session, java.lang.String query, java.lang.Class<?> resultType)
      Create a new native query.
      protected abstract Q createQuery​(S session, java.lang.String query, java.lang.Class<?> resultType)
      Create a new query.
      protected abstract Q createQuery​(S session, javax.persistence.criteria.CriteriaQuery<?> criteriaQuery)
      Create a native query.
      <E,​R>
      io.micronaut.data.model.runtime.PreparedQuery<E,​R>
      decorate​(io.micronaut.data.model.runtime.PreparedQuery<E,​R> preparedQuery)  
      <E,​R>
      io.micronaut.data.model.runtime.StoredQuery<E,​R>
      decorate​(io.micronaut.data.model.runtime.StoredQuery<E,​R> storedQuery)  
      protected io.micronaut.context.ApplicationContext getApplicationContext()  
      protected io.micronaut.core.convert.ConversionService<?> getConversionService()  
      protected abstract <T> io.micronaut.data.model.runtime.RuntimePersistentEntity<T> getEntity​(java.lang.Class<T> type)
      Gets the persistence entity.
      protected abstract <T> javax.persistence.EntityGraph<T> getEntityGraph​(S session, java.lang.Class<T> entityType, java.lang.String graphName)
      Gets an entity graph.
      protected javax.persistence.FlushModeType getFlushModeType​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)  
      protected java.lang.Object getParameterValue​(java.lang.String[] propertyPath, java.lang.Object value)  
      java.util.Map<java.lang.String,​java.lang.Object> getQueryHints​(io.micronaut.data.model.runtime.StoredQuery<?,​?> storedQuery)  
      protected abstract void setHint​(Q query, java.lang.String hintName, java.lang.Object value)
      Sets a hint.
      protected abstract void setMaxResults​(Q query, int max)
      Sets the max results value.
      protected abstract void setOffset​(Q query, int offset)
      Sets the offset value.
      protected abstract void setParameter​(Q query, java.lang.String parameterName, java.lang.Object value)
      Sets a parameter into query.
      protected abstract void setParameter​(Q query, java.lang.String parameterName, java.lang.Object value, io.micronaut.core.type.Argument argument)
      Sets parameter into query.
      protected abstract void setParameterList​(Q query, java.lang.String parameterName, java.util.Collection<java.lang.Object> value)
      Sets a list parameter into query.
      protected abstract void setParameterList​(Q query, java.lang.String parameterName, java.util.Collection<java.lang.Object> value, io.micronaut.core.type.Argument argument)
      Sets a list parameter into query.
      • Methods inherited from class java.lang.Object

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

      • dataConversionService

        protected final io.micronaut.core.convert.ConversionService<?> dataConversionService
      • runtimeEntityRegistry

        protected final io.micronaut.data.model.runtime.RuntimeEntityRegistry runtimeEntityRegistry
    • Constructor Detail

      • AbstractHibernateOperations

        protected AbstractHibernateOperations​(io.micronaut.data.model.runtime.RuntimeEntityRegistry runtimeEntityRegistry,
                                              io.micronaut.data.runtime.convert.DataConversionService<?> dataConversionService)
        Default constructor.
        Parameters:
        runtimeEntityRegistry - The runtime entity registry
        dataConversionService - The data conversion service
    • Method Detail

      • decorate

        public <E,​R> io.micronaut.data.model.runtime.PreparedQuery<E,​R> decorate​(io.micronaut.data.model.runtime.PreparedQuery<E,​R> preparedQuery)
        Specified by:
        decorate in interface io.micronaut.data.runtime.query.PreparedQueryDecorator
      • decorate

        public <E,​R> io.micronaut.data.model.runtime.StoredQuery<E,​R> decorate​(io.micronaut.data.model.runtime.StoredQuery<E,​R> storedQuery)
        Specified by:
        decorate in interface io.micronaut.data.runtime.query.StoredQueryDecorator
      • getApplicationContext

        protected io.micronaut.context.ApplicationContext getApplicationContext()
        Returns:
        The application context
      • getConversionService

        protected io.micronaut.core.convert.ConversionService<?> getConversionService()
        Returns:
        The conversion service
      • getEntity

        @NonNull
        protected abstract <T> io.micronaut.data.model.runtime.RuntimePersistentEntity<T> getEntity​(@NonNull
                                                                                                    java.lang.Class<T> type)
        Gets the persistence entity.
        Type Parameters:
        T - The entity type
        Parameters:
        type - The entity type
        Returns:
        The persistent entity
      • getQueryHints

        @NonNull
        public java.util.Map<java.lang.String,​java.lang.Object> getQueryHints​(@NonNull
                                                                                    io.micronaut.data.model.runtime.StoredQuery<?,​?> storedQuery)
        Specified by:
        getQueryHints in interface io.micronaut.data.operations.HintsCapableRepository
      • setParameter

        protected abstract void setParameter​(Q query,
                                             java.lang.String parameterName,
                                             java.lang.Object value)
        Sets a parameter into query.
        Parameters:
        query - The query
        parameterName - The parameter name
        value - The value
      • setParameter

        protected abstract void setParameter​(Q query,
                                             java.lang.String parameterName,
                                             java.lang.Object value,
                                             io.micronaut.core.type.Argument argument)
        Sets parameter into query.
        Parameters:
        query - The query
        parameterName - The parameter name
        value - The value
        argument - The argument
      • setParameterList

        protected abstract void setParameterList​(Q query,
                                                 java.lang.String parameterName,
                                                 java.util.Collection<java.lang.Object> value)
        Sets a list parameter into query.
        Parameters:
        query - The query
        parameterName - The parameter name
        value - The value
      • setParameterList

        protected abstract void setParameterList​(Q query,
                                                 java.lang.String parameterName,
                                                 java.util.Collection<java.lang.Object> value,
                                                 io.micronaut.core.type.Argument argument)
        Sets a list parameter into query.
        Parameters:
        query - The query
        parameterName - The parameter name
        value - The value
        argument - The argument
      • setHint

        protected abstract void setHint​(Q query,
                                        java.lang.String hintName,
                                        java.lang.Object value)
        Sets a hint.
        Parameters:
        query - The query
        hintName - The hint name
        value - The value
      • setMaxResults

        protected abstract void setMaxResults​(Q query,
                                              int max)
        Sets the max results value.
        Parameters:
        query - The query
        max - The max value
      • setOffset

        protected abstract void setOffset​(Q query,
                                          int offset)
        Sets the offset value.
        Parameters:
        query - The query
        offset - The offset value
      • getEntityGraph

        protected abstract <T> javax.persistence.EntityGraph<T> getEntityGraph​(S session,
                                                                               java.lang.Class<T> entityType,
                                                                               java.lang.String graphName)
        Gets an entity graph.
        Type Parameters:
        T - The entity type
        Parameters:
        session - The session
        entityType - The entity type
        graphName - The graph name
        Returns:
        The graph
      • createEntityGraph

        protected abstract <T> javax.persistence.EntityGraph<T> createEntityGraph​(S session,
                                                                                  java.lang.Class<T> entityType)
        Creates an entity graph.
        Type Parameters:
        T - The entityType
        Parameters:
        session - The session
        entityType - The entityType
        Returns:
        The graph
      • createQuery

        protected abstract Q createQuery​(S session,
                                         java.lang.String query,
                                         @Nullable
                                         java.lang.Class<?> resultType)
        Create a new query.
        Parameters:
        session - The session
        query - The query
        resultType - The result type
        Returns:
        new query
      • createNativeQuery

        protected abstract Q createNativeQuery​(S session,
                                               java.lang.String query,
                                               java.lang.Class<?> resultType)
        Create a new native query.
        Parameters:
        session - The session
        query - The query
        resultType - The result type
        Returns:
        new query
      • createQuery

        protected abstract Q createQuery​(S session,
                                         javax.persistence.criteria.CriteriaQuery<?> criteriaQuery)
        Create a native query.
        Parameters:
        session - The session
        criteriaQuery - The criteriaQuery
        Returns:
        new query
      • collectFindOne

        protected <R> void collectFindOne​(S session,
                                          io.micronaut.data.model.runtime.PreparedQuery<?,​R> preparedQuery,
                                          AbstractHibernateOperations.ResultCollector<R> collector)
        Collect one result.
        Type Parameters:
        R - The result type
        Parameters:
        session - The session
        preparedQuery - The prepared query
        collector - The collector
      • collectFindAll

        protected <R> void collectFindAll​(S session,
                                          io.micronaut.data.model.runtime.PreparedQuery<?,​R> preparedQuery,
                                          AbstractHibernateOperations.ResultCollector<R> collector)
        Collect all results.
        Type Parameters:
        R - The result type
        Parameters:
        session - The session
        preparedQuery - The prepared query
        collector - The collector
      • bindParameters

        protected <T,​R> void bindParameters​(Q q,
                                                  @NonNull
                                                  io.micronaut.data.model.runtime.PreparedQuery<T,​R> preparedQuery)
        Bind parameters into query.
        Type Parameters:
        T - The entity type
        R - The result type
        Parameters:
        q - The query
        preparedQuery - THe prepared query
      • getParameterValue

        protected final java.lang.Object getParameterValue​(java.lang.String[] propertyPath,
                                                           java.lang.Object value)
      • getFlushModeType

        protected final javax.persistence.FlushModeType getFlushModeType​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
      • collectPagedResults

        protected final <T> void collectPagedResults​(javax.persistence.criteria.CriteriaBuilder criteriaBuilder,
                                                     S session,
                                                     io.micronaut.data.model.runtime.PagedQuery<T> pagedQuery,
                                                     AbstractHibernateOperations.ResultCollector<T> resultCollector)
      • collectCountOf

        protected final <R> void collectCountOf​(javax.persistence.criteria.CriteriaBuilder criteriaBuilder,
                                                S session,
                                                java.lang.Class<R> entity,
                                                @Nullable
                                                io.micronaut.data.model.Pageable pageable,
                                                AbstractHibernateOperations.ResultCollector<java.lang.Long> resultCollector)