Class AbstractHibernateOperations<S,Q>
java.lang.Object
io.micronaut.data.hibernate.operations.AbstractHibernateOperations<S,Q>
- Type Parameters:
S- The session typeQ- The query type
- All Implemented Interfaces:
HintsCapableRepository,PreparedQueryDecorator,StoredQueryDecorator
- Direct Known Subclasses:
HibernateJpaOperations
@Internal
public abstract class AbstractHibernateOperations<S,Q>
extends Object
implements HintsCapableRepository, PreparedQueryDecorator, StoredQueryDecorator
Abstract Hibernate operations shared between the synchronous and the reactive implementations.
- Since:
- 3.5.0
- Author:
- Denis Stepaov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classThe result collector. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final io.micronaut.core.convert.ConversionServiceprotected final RuntimeEntityRegistry -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractHibernateOperations(RuntimeEntityRegistry runtimeEntityRegistry, DataConversionService dataConversionService) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected <T,R> void bindParameters(Q q, PreparedQuery<T, R> preparedQuery) Bind parameters into query.protected final <R> voidcollectCountOf(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, Class<R> entity, Pageable pageable, AbstractHibernateOperations<S, Q>.ResultCollector<Long> resultCollector) protected <R> voidcollectFindAll(S session, PreparedQuery<?, R> preparedQuery, AbstractHibernateOperations<S, Q>.ResultCollector<R> collector) Collect all results.protected <R> voidcollectFindOne(S session, PreparedQuery<?, R> preparedQuery, AbstractHibernateOperations<S, Q>.ResultCollector<R> collector) Collect one result.protected final <T> voidcollectPagedResults(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, PagedQuery<T> pagedQuery, AbstractHibernateOperations<S, Q>.ResultCollector<T> resultCollector) protected abstract <T> jakarta.persistence.EntityGraph<T>createEntityGraph(S session, Class<T> entityType) Creates an entity graph.protected abstract QcreateNativeQuery(S session, String query, Class<?> resultType) Create a new native query.protected abstract QcreateQuery(S session, jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery) Create a native query.protected abstract QcreateQuery(S session, String query, Class<?> resultType) Create a new query.<E,R> PreparedQuery<E, R> decorate(PreparedQuery<E, R> preparedQuery) Decorate prepared query.<E,R> StoredQuery<E, R> decorate(StoredQuery<E, R> storedQuery) Decorate stored query.protected io.micronaut.context.ApplicationContextprotected io.micronaut.core.convert.ConversionServiceprotected abstract <T> RuntimePersistentEntity<T>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.FlushModeTypegetFlushModeType(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata) protected final ObjectgetParameterValue(String[] propertyPath, Object value) getQueryHints(StoredQuery<?, ?> storedQuery) Obtain any custom query hints for this method and repository implementation.protected abstract voidSets a hint.protected abstract voidsetMaxResults(Q query, int max) Sets the max results value.protected abstract voidSets the offset value.protected abstract voidsetParameter(Q query, String parameterName, Object value) Sets a parameter into query.protected abstract voidsetParameter(Q query, String parameterName, Object value, io.micronaut.core.type.Argument argument) Sets parameter into query.protected abstract voidsetParameterList(Q query, String parameterName, Collection<Object> value) Sets a list parameter into query.protected abstract voidsetParameterList(Q query, String parameterName, Collection<Object> value, io.micronaut.core.type.Argument argument) Sets a list parameter into query.
-
Field Details
-
dataConversionService
protected final io.micronaut.core.convert.ConversionService dataConversionService -
runtimeEntityRegistry
-
-
Constructor Details
-
AbstractHibernateOperations
protected AbstractHibernateOperations(RuntimeEntityRegistry runtimeEntityRegistry, DataConversionService dataConversionService) Default constructor.- Parameters:
runtimeEntityRegistry- The runtime entity registrydataConversionService- The data conversion service
-
-
Method Details
-
decorate
Description copied from interface:PreparedQueryDecoratorDecorate prepared query.- Specified by:
decoratein interfacePreparedQueryDecorator- Type Parameters:
E- The entity typeR- The result type- Parameters:
preparedQuery- The query to be decorated- Returns:
- decorated prepared query
-
decorate
Description copied from interface:StoredQueryDecoratorDecorate stored query.- Specified by:
decoratein interfaceStoredQueryDecorator- Type Parameters:
E- The entity typeR- 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
Gets the persistence entity.- Type Parameters:
T- The entity type- Parameters:
type- The entity type- Returns:
- The persistent entity
-
getQueryHints
Description copied from interface:HintsCapableRepositoryObtain any custom query hints for this method and repository implementation.- Specified by:
getQueryHintsin interfaceHintsCapableRepository- Parameters:
storedQuery- The stored query- Returns:
- THe query hints
-
setParameter
Sets a parameter into query.- Parameters:
query- The queryparameterName- The parameter namevalue- 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 queryparameterName- The parameter namevalue- The valueargument- The argument
-
setParameterList
Sets a list parameter into query.- Parameters:
query- The queryparameterName- The parameter namevalue- 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 queryparameterName- The parameter namevalue- The valueargument- The argument
-
setHint
Sets a hint.- Parameters:
query- The queryhintName- The hint namevalue- The value
-
setMaxResults
Sets the max results value.- Parameters:
query- The querymax- The max value
-
setOffset
Sets the offset value.- Parameters:
query- The queryoffset- 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 sessionentityType- The entity typegraphName- 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 sessionentityType- The entityType- Returns:
- The graph
-
createQuery
Create a new query.- Parameters:
session- The sessionquery- The queryresultType- The result type- Returns:
- new query
-
createNativeQuery
Create a new native query.- Parameters:
session- The sessionquery- The queryresultType- The result type- Returns:
- new query
-
createQuery
protected abstract Q createQuery(S session, jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery) Create a native query.- Parameters:
session- The sessioncriteriaQuery- The criteriaQuery- Returns:
- new query
-
collectFindOne
protected <R> void collectFindOne(S session, PreparedQuery<?, R> preparedQuery, AbstractHibernateOperations<S, Q>.ResultCollector<R> collector) Collect one result.- Type Parameters:
R- The result type- Parameters:
session- The sessionpreparedQuery- The prepared querycollector- The collector
-
collectFindAll
protected <R> void collectFindAll(S session, PreparedQuery<?, R> preparedQuery, AbstractHibernateOperations<S, Q>.ResultCollector<R> collector) Collect all results.- Type Parameters:
R- The result type- Parameters:
session- The sessionpreparedQuery- The prepared querycollector- The collector
-
bindParameters
Bind parameters into query.- Type Parameters:
T- The entity typeR- The result type- Parameters:
q- The querypreparedQuery- THe prepared query
-
getParameterValue
-
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>.ResultCollector<T> resultCollector) -
collectCountOf
protected final <R> void collectCountOf(jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, Class<R> entity, @Nullable Pageable pageable, AbstractHibernateOperations<S, Q>.ResultCollector<Long> resultCollector)
-