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:
io.micronaut.data.operations.HintsCapableRepository, io.micronaut.data.runtime.query.PreparedQueryDecorator, io.micronaut.data.runtime.query.StoredQueryDecorator

@Internal public abstract class AbstractHibernateOperations<S,Q,P extends Q> extends 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
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
    The result collector.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final io.micronaut.core.convert.ConversionService
     
    protected final io.micronaut.data.model.runtime.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

    Modifier and Type
    Method
    Description
    protected <T, R> void
    bindParameters(Q q, @NonNull io.micronaut.data.model.runtime.PreparedQuery<T,R> preparedQuery, boolean bindNamed)
    Bind parameters into query.
    protected final <R> void
    collectCountOf(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, Class<R> entity, @Nullable io.micronaut.data.model.Pageable pageable, AbstractHibernateOperations<S,Q,P>.ResultCollector<Long> resultCollector)
     
    protected <R> void
    collectFindAll(S session, io.micronaut.data.model.runtime.PreparedQuery<?,R> preparedQuery, AbstractHibernateOperations<S,Q,P>.ResultCollector<R> collector)
    Collect all results.
    protected <R> void
    collectFindOne(S session, io.micronaut.data.model.runtime.PreparedQuery<?,R> preparedQuery, AbstractHibernateOperations<S,Q,P>.ResultCollector<R> collector)
    Collect one result.
    protected final <T> void
    collectPagedResults(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, io.micronaut.data.model.runtime.PagedQuery<T> pagedQuery, AbstractHibernateOperations<S,Q,P>.ResultCollector<T> resultCollector)
     
    protected abstract <T> jakarta.persistence.EntityGraph<T>
    createEntityGraph(S session, Class<T> entityType)
    Creates an entity graph.
    protected abstract P
    createNativeQuery(S session, String query, Class<?> resultType)
    Create a new native query.
    protected abstract P
    createQuery(S session, jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery)
    Create a native query.
    protected abstract P
    createQuery(S session, String query, @Nullable Class<?> resultType)
    Create a new 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
     
    protected io.micronaut.core.convert.ConversionService
     
    protected abstract <T> @NonNull io.micronaut.data.model.runtime.RuntimePersistentEntity<T>
    getEntity(@NonNull Class<T> type)
    Gets the persistence entity.
    protected abstract <T> jakarta.persistence.EntityGraph<T>
    getEntityGraph(S session, Class<T> entityType, String graphName)
    Gets an entity graph.
    protected final jakarta.persistence.FlushModeType
    getFlushModeType(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
     
    protected final Object
    getParameterValue(String[] propertyPath, Object value)
     
    @NonNull Map<String,Object>
    getQueryHints(@NonNull io.micronaut.data.model.runtime.StoredQuery<?,?> storedQuery)
     
    protected abstract void
    setHint(P query, String hintName, Object value)
    Sets a hint.
    protected abstract void
    setMaxResults(P query, int max)
    Sets the max results value.
    protected abstract void
    setOffset(P query, int offset)
    Sets the offset value.
    protected abstract void
    setParameter(Q query, int parameterIndex, Object value)
    Sets a parameter into query.
    protected abstract void
    setParameter(Q query, int parameterIndex, Object value, io.micronaut.core.type.Argument<?> argument)
    Sets parameter into query.
    protected abstract void
    setParameter(Q query, String parameterName, Object value)
    Sets a parameter into query.
    protected abstract void
    setParameter(Q query, String parameterName, Object value, io.micronaut.core.type.Argument<?> argument)
    Sets parameter into query.
    protected abstract void
    setParameterList(Q query, int parameterIndex, Collection<Object> value)
    Sets a list parameter into query.
    protected abstract void
    setParameterList(Q query, int parameterIndex, Collection<Object> value, io.micronaut.core.type.Argument<?> argument)
    Sets a list parameter into query.
    protected abstract void
    setParameterList(Q query, String parameterName, Collection<Object> value)
    Sets a list parameter into query.
    protected abstract void
    setParameterList(Q query, String parameterName, Collection<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 Details

    • dataConversionService

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

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

    • 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 Details

    • 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> @NonNull io.micronaut.data.model.runtime.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 io.micronaut.data.model.runtime.StoredQuery<?,?> storedQuery)
      Specified by:
      getQueryHints in interface io.micronaut.data.operations.HintsCapableRepository
    • 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, io.micronaut.data.model.runtime.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, io.micronaut.data.model.runtime.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 io.micronaut.data.model.runtime.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
    • getParameterValue

      protected final Object getParameterValue(String[] propertyPath, Object value)
    • 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, io.micronaut.data.model.runtime.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 io.micronaut.data.model.Pageable pageable, AbstractHibernateOperations<S,Q,P>.ResultCollector<Long> resultCollector)