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
- Direct Known Subclasses:
HibernateJpaOperations
@Internal public abstract class AbstractHibernateOperations<S,Q> extends java.lang.Object implements HintsCapableRepository
Abstract Hibernate operations shared between the synchronous and the reactive implementations.- Since:
- 3.5.0
- Author:
- Denis Stepaov
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractHibernateOperations.ResultCollector<R>The result collector.
-
Field Summary
Fields Modifier and Type Field Description protected io.micronaut.core.convert.ConversionService<?>dataConversionServiceprotected RuntimeEntityRegistryruntimeEntityRegistry
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHibernateOperations(RuntimeEntityRegistry runtimeEntityRegistry, DataConversionService<?> dataConversionService)Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected <T,R>
voidbindParameters(Q q, PreparedQuery<T,R> preparedQuery, java.lang.String query)Bind parameters into query.protected <R> voidcollectCountOf(javax.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, java.lang.Class<R> entity, Pageable pageable, AbstractHibernateOperations.ResultCollector<java.lang.Long> resultCollector)protected <R> voidcollectFindAll(S session, PreparedQuery<?,R> preparedQuery, AbstractHibernateOperations.ResultCollector<R> collector)Collect all results.protected <R> voidcollectFindOne(S session, PreparedQuery<?,R> preparedQuery, AbstractHibernateOperations.ResultCollector<R> collector)Collect one result.protected <T> voidcollectPagedResults(javax.persistence.criteria.CriteriaBuilder criteriaBuilder, S session, 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 QcreateNativeQuery(S session, java.lang.String query, java.lang.Class<?> resultType)Create a new native query.protected abstract QcreateQuery(S session, java.lang.String query, java.lang.Class<?> resultType)Create a new query.protected abstract QcreateQuery(S session, javax.persistence.criteria.CriteriaQuery<?> criteriaQuery)Create a native query.protected io.micronaut.context.ApplicationContextgetApplicationContext()protected io.micronaut.core.convert.ConversionService<?>getConversionService()protected abstract <T> 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.FlushModeTypegetFlushModeType(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)protected java.lang.ObjectgetParameterValue(java.lang.String[] propertyPath, java.lang.Object value)java.util.Map<java.lang.String,java.lang.Object>getQueryHints(StoredQuery<?,?> storedQuery)Obtain any custom query hints for this method and repository implementation.protected abstract voidsetHint(Q query, java.lang.String hintName, java.lang.Object value)Sets a hint.protected abstract voidsetMaxResults(Q query, int max)Sets the max results value.protected abstract voidsetOffset(Q query, int offset)Sets the offset value.protected abstract voidsetParameter(Q query, java.lang.String parameterName, java.lang.Object value)Sets a parameter into query.protected abstract voidsetParameter(Q query, java.lang.String parameterName, java.lang.Object value, io.micronaut.core.type.Argument argument)Sets parameter into query.protected abstract voidsetParameterList(Q query, java.lang.String parameterName, java.util.Collection<java.lang.Object> value)Sets a list parameter into query.protected abstract voidsetParameterList(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.
-
-
-
Field Detail
-
dataConversionService
protected final io.micronaut.core.convert.ConversionService<?> dataConversionService
-
runtimeEntityRegistry
protected final RuntimeEntityRegistry runtimeEntityRegistry
-
-
Constructor Detail
-
AbstractHibernateOperations
protected AbstractHibernateOperations(RuntimeEntityRegistry runtimeEntityRegistry, DataConversionService<?> dataConversionService)
Default constructor.- Parameters:
runtimeEntityRegistry- The runtime entity registrydataConversionService- The data conversion service
-
-
Method Detail
-
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> 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 StoredQuery<?,?> storedQuery)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
protected abstract void setParameter(Q query, java.lang.String parameterName, java.lang.Object value)
Sets a parameter into query.- Parameters:
query- The queryparameterName- The parameter namevalue- 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 queryparameterName- The parameter namevalue- The valueargument- 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 queryparameterName- The parameter namevalue- 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 queryparameterName- The parameter namevalue- The valueargument- The argument
-
setHint
protected abstract void setHint(Q query, java.lang.String hintName, java.lang.Object value)
Sets a hint.- Parameters:
query- The queryhintName- The hint namevalue- The value
-
setMaxResults
protected abstract void setMaxResults(Q query, int max)
Sets the max results value.- Parameters:
query- The querymax- The max value
-
setOffset
protected abstract void setOffset(Q query, int offset)
Sets the offset value.- Parameters:
query- The queryoffset- 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 sessionentityType- The entity typegraphName- 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 sessionentityType- 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 sessionquery- The queryresultType- 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 sessionquery- The queryresultType- 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 sessioncriteriaQuery- The criteriaQuery- Returns:
- new query
-
collectFindOne
protected <R> void collectFindOne(S session, PreparedQuery<?,R> preparedQuery, AbstractHibernateOperations.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.ResultCollector<R> collector)
Collect all results.- Type Parameters:
R- The result type- Parameters:
session- The sessionpreparedQuery- The prepared querycollector- The collector
-
bindParameters
protected <T,R> void bindParameters(Q q, @NonNull PreparedQuery<T,R> preparedQuery, java.lang.String query)
Bind parameters into query.- Type Parameters:
T- The entity typeR- The result type- Parameters:
q- The querypreparedQuery- THe prepared queryquery- The string 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, 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 Pageable pageable, AbstractHibernateOperations.ResultCollector<java.lang.Long> resultCollector)
-
-