Class AbstractHibernateOperations<S,Q,P extends Q>

java.lang.Object
io.micronaut.data.hibernate.operations.AbstractHibernateOperations<S,Q,P>
Type Parameters:
S - The session type
Q - The query type
P - The selection query type
All Implemented Interfaces:
HintsCapableRepository, PreparedQueryDecorator, StoredQueryDecorator

@Internal public abstract class AbstractHibernateOperations<S,Q,P extends Q> extends Object implements HintsCapableRepository, PreparedQueryDecorator, StoredQueryDecorator
Abstract Hibernate operations shared between the synchronous and the reactive implementations.
Since:
3.5.0
Author:
Denis Stepanov
  • Field Details

    • dataConversionService

      protected final io.micronaut.core.convert.ConversionService dataConversionService
    • runtimeEntityRegistry

      protected final RuntimeEntityRegistry runtimeEntityRegistry
  • Constructor Details

    • AbstractHibernateOperations

      protected AbstractHibernateOperations(RuntimeEntityRegistry runtimeEntityRegistry, DataConversionService dataConversionService)
      Default constructor.
      Parameters:
      runtimeEntityRegistry - The runtime entity registry
      dataConversionService - The data conversion service
  • Method Details

    • decorate

      public <E, R> PreparedQuery<E,R> decorate(PreparedQuery<E,R> preparedQuery)
      Description copied from interface: PreparedQueryDecorator
      Decorate prepared query.
      Specified by:
      decorate in interface PreparedQueryDecorator
      Type Parameters:
      E - The entity type
      R - The result type
      Parameters:
      preparedQuery - The query to be decorated
      Returns:
      decorated prepared query
    • decorate

      public <E, R> StoredQuery<E,R> decorate(StoredQuery<E,R> storedQuery)
      Description copied from interface: StoredQueryDecorator
      Decorate stored query.
      Specified by:
      decorate in interface StoredQueryDecorator
      Type Parameters:
      E - The entity type
      R - The result type
      Parameters:
      storedQuery - The query to be decorated
      Returns:
      decorated stored query
    • 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> @NonNull RuntimePersistentEntity<T> getEntity(@NonNull @NonNull 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 @NonNull Map<String,Object> getQueryHints(@NonNull @NonNull StoredQuery<?,?> storedQuery)
      Description copied from interface: HintsCapableRepository
      Obtain any custom query hints for this method and repository implementation.
      Specified by:
      getQueryHints in interface HintsCapableRepository
      Parameters:
      storedQuery - The stored query
      Returns:
      THe query hints
    • setParameter

      protected abstract void setParameter(Q query, String parameterName, 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, String parameterName, 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, String parameterName, Collection<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, String parameterName, Collection<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
    • setParameter

      protected abstract void setParameter(Q query, int parameterIndex, Object value)
      Sets a parameter into query.
      Parameters:
      query - The query
      parameterIndex - The parameter index
      value - The value
    • setParameter

      protected abstract void setParameter(Q query, int parameterIndex, Object value, io.micronaut.core.type.Argument<?> argument)
      Sets parameter into query.
      Parameters:
      query - The query
      parameterIndex - The parameter index
      value - The value
      argument - The argument
    • setParameterList

      protected abstract void setParameterList(Q query, int parameterIndex, Collection<Object> value)
      Sets a list parameter into query.
      Parameters:
      query - The query
      parameterIndex - The parameter index
      value - The value
    • setParameterList

      protected abstract void setParameterList(Q query, int parameterIndex, Collection<Object> value, io.micronaut.core.type.Argument<?> argument)
      Sets a list parameter into query.
      Parameters:
      query - The query
      parameterIndex - The parameter index
      value - The value
      argument - The argument
    • setHint

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

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

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

      protected abstract <T> jakarta.persistence.EntityGraph<T> getEntityGraph(S session, Class<T> entityType, 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> jakarta.persistence.EntityGraph<T> createEntityGraph(S session, 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 P createQuery(S session, String query, @Nullable @Nullable Class<?> resultType)
      Create a new query.
      Parameters:
      session - The session
      query - The query
      resultType - The result type
      Returns:
      new query
    • createNativeQuery

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

      protected abstract P createQuery(S session, jakarta.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, PreparedQuery<?,R> preparedQuery, AbstractHibernateOperations<S,Q,P>.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, PreparedQuery<?,R> preparedQuery, AbstractHibernateOperations<S,Q,P>.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 @NonNull PreparedQuery<T,R> preparedQuery, boolean bindNamed)
      Bind parameters into query.
      Type Parameters:
      T - The entity type
      R - The result type
      Parameters:
      q - The query
      preparedQuery - The prepared query
      bindNamed - If parameter should be bind by the name
    • bindParameters

      protected <T, R> void bindParameters(Q q, @NonNull @NonNull StoredQuery<T,R> storedQuery, io.micronaut.aop.InvocationContext<?,?> invocationContext, boolean bindNamed, T entity)
      Bind parameters into query.
      Type Parameters:
      T - The entity type
      R - The result type
      Parameters:
      q - The query
      storedQuery - The stored query
      invocationContext - The invocationContext
      bindNamed - If parameter should be bind by the name
      entity - The entity
    • getFlushModeType

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

      protected final <T> void collectPagedResults(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, PagedQuery<T> pagedQuery, AbstractHibernateOperations<S,Q,P>.ResultCollector<T> resultCollector)
    • collectCountOf

      protected final <R> void collectCountOf(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, Class<R> entity, @Nullable @Nullable Pageable pageable, AbstractHibernateOperations<S,Q,P>.ResultCollector<Long> resultCollector)