RS
- The result set typePS
- The prepared statement typepublic abstract class AbstractSqlRepositoryOperations<RS,PS> extends java.lang.Object implements RepositoryOperations
Modifier and Type | Class and Description |
---|---|
protected static interface |
AbstractSqlRepositoryOperations.StatementSupplier<PS>
Functional interface used to supply a statement.
|
protected class |
AbstractSqlRepositoryOperations.StoredInsert<T>
A stored insert statement.
|
Modifier and Type | Field and Description |
---|---|
protected ResultReader<RS,java.lang.Integer> |
columnIndexResultSetReader |
protected ResultReader<RS,java.lang.String> |
columnNameResultSetReader |
protected DateTimeProvider |
dateTimeProvider |
protected static SqlQueryBuilder |
DEFAULT_SQL_BUILDER |
protected EntityEventListener<java.lang.Object> |
entityEventRegistry |
protected io.micronaut.http.codec.MediaTypeCodec |
jsonCodec |
protected QueryStatement<PS,java.lang.Integer> |
preparedStatementWriter |
protected static org.slf4j.Logger |
QUERY_LOG |
protected java.util.Map<java.lang.Class,SqlQueryBuilder> |
queryBuilders |
Modifier | Constructor and Description |
---|---|
protected |
AbstractSqlRepositoryOperations(java.lang.String dataSourceName,
ResultReader<RS,java.lang.String> columnNameResultSetReader,
ResultReader<RS,java.lang.Integer> columnIndexResultSetReader,
QueryStatement<PS,java.lang.Integer> preparedStatementWriter,
java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs,
DateTimeProvider<java.lang.Object> dateTimeProvider,
io.micronaut.context.BeanContext beanContext)
|
protected |
AbstractSqlRepositoryOperations(java.lang.String dataSourceName,
ResultReader<RS,java.lang.String> columnNameResultSetReader,
ResultReader<RS,java.lang.Integer> columnIndexResultSetReader,
QueryStatement<PS,java.lang.Integer> preparedStatementWriter,
java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs,
DateTimeProvider<java.lang.Object> dateTimeProvider,
RuntimeEntityRegistry runtimeEntityRegistry,
io.micronaut.context.BeanContext beanContext)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
<T> RuntimePersistentEntity<T> |
getEntity(java.lang.Class<T> type)
Retrieves the entity for the given type.
|
protected RuntimePersistentProperty<java.lang.Object> |
getIdReader(java.lang.Object o)
Obtain an ID reader for the given object.
|
protected boolean |
isSqlServerWithoutOrderBy(java.lang.String query,
Dialect dialect)
In the dialect SQL server and is order by required.
|
protected <T,R> PS |
prepareStatement(AbstractSqlRepositoryOperations.StatementSupplier<PS> statementFunction,
PreparedQuery<T,R> preparedQuery,
boolean isUpdate,
boolean isSingleResult)
Prepare a statement for execution.
|
protected <T> java.lang.String |
resolveAssociationInsert(java.lang.Class repositoryType,
RuntimePersistentEntity<T> persistentEntity,
RuntimeAssociation<T> association)
Builds a join table insert.
|
protected <T> AbstractSqlRepositoryOperations.StoredInsert<T> |
resolveEntityInsert(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.Class<?> repositoryType,
java.lang.Class<?> rootEntity,
RuntimePersistentEntity<?> persistentEntity)
Resolves a stored insert for the given entity.
|
protected <T> AbstractSqlRepositoryOperations.StoredInsert<T> |
resolveEntityUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.Class<?> repositoryType,
java.lang.Class<?> rootEntity,
RuntimePersistentEntity<?> persistentEntity)
Resolves a stored update for the given entity.
|
protected <T> AbstractSqlRepositoryOperations.StoredInsert<T> |
resolveInsert(EntityOperation<T> operation)
Resolve the INSERT for the given
EntityOperation . |
protected <T> void |
setInsertParameters(AbstractSqlRepositoryOperations.StoredInsert<T> insert,
T entity,
PS stmt)
Sets the insert parameters for the given insert, entity and statement.
|
protected void |
setStatementParameter(PS preparedStatement,
int index,
DataType dataType,
java.lang.Object value,
Dialect dialect)
Set the parameter value on the given statement.
|
protected int |
shiftIndex(int i)
Used to define the index whether it is 1 based (JDBC) or 0 based (R2DBC).
|
protected int |
sizeOf(java.lang.Object value)
Compute the size of the given object.
|
protected <T> Sort |
sortById(RuntimePersistentEntity<T> persistentEntity)
Build a sort for ID for the given entity.
|
protected <T> T |
triggerPostLoad(T entity,
RuntimePersistentEntity<T> pe,
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Trigger the post load event.
|
protected <T> T |
triggerPostPersist(T entity,
RuntimePersistentEntity<T> pe,
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Trigger the post persist event.
|
protected <T> void |
triggerPostRemove(T entity,
RuntimePersistentEntity<T> pe,
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Trigger the post remove event.
|
protected <T> void |
triggerPostUpdate(T entity,
RuntimePersistentEntity<T> pe,
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Trigger the post update event.
|
protected <T> T |
triggerPrePersist(T entity,
RuntimePersistentEntity<T> pe,
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Trigger the pre persist event.
|
protected <T> T |
triggerPreRemove(T entity,
RuntimePersistentEntity<T> pe,
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Trigger the pre remove event.
|
protected <T> T |
triggerPreUpdate(T entity,
RuntimePersistentEntity<T> pe,
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Trigger the pre update event.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
count, delete, deleteAll, executeDelete, executeUpdate, exists, findAll, findAll, findOne, findOne, findPage, findStream, findStream, getQueryHints, persist, persistAll, update
protected static final org.slf4j.Logger QUERY_LOG
protected static final SqlQueryBuilder DEFAULT_SQL_BUILDER
protected final ResultReader<RS,java.lang.String> columnNameResultSetReader
protected final ResultReader<RS,java.lang.Integer> columnIndexResultSetReader
protected final QueryStatement<PS,java.lang.Integer> preparedStatementWriter
protected final java.util.Map<java.lang.Class,SqlQueryBuilder> queryBuilders
protected final io.micronaut.http.codec.MediaTypeCodec jsonCodec
protected final EntityEventListener<java.lang.Object> entityEventRegistry
protected final DateTimeProvider dateTimeProvider
@Deprecated protected AbstractSqlRepositoryOperations(java.lang.String dataSourceName, ResultReader<RS,java.lang.String> columnNameResultSetReader, ResultReader<RS,java.lang.Integer> columnIndexResultSetReader, QueryStatement<PS,java.lang.Integer> preparedStatementWriter, java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs, DateTimeProvider<java.lang.Object> dateTimeProvider, io.micronaut.context.BeanContext beanContext)
AbstractSqlRepositoryOperations(String, ResultReader, ResultReader, QueryStatement, List, DateTimeProvider, RuntimeEntityRegistry, BeanContext)
dataSourceName
- The datasource namecolumnNameResultSetReader
- The column name result readercolumnIndexResultSetReader
- The column index result readerpreparedStatementWriter
- The prepared statement writercodecs
- The media type codecsdateTimeProvider
- The date time providerbeanContext
- The bean contextprotected AbstractSqlRepositoryOperations(java.lang.String dataSourceName, ResultReader<RS,java.lang.String> columnNameResultSetReader, ResultReader<RS,java.lang.Integer> columnIndexResultSetReader, QueryStatement<PS,java.lang.Integer> preparedStatementWriter, java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs, DateTimeProvider<java.lang.Object> dateTimeProvider, RuntimeEntityRegistry runtimeEntityRegistry, io.micronaut.context.BeanContext beanContext)
dataSourceName
- The datasource namecolumnNameResultSetReader
- The column name result readercolumnIndexResultSetReader
- The column index result readerpreparedStatementWriter
- The prepared statement writercodecs
- The media type codecsdateTimeProvider
- The date time providerruntimeEntityRegistry
- The entity registrybeanContext
- The bean context@NonNull public final <T> RuntimePersistentEntity<T> getEntity(@NonNull java.lang.Class<T> type)
RepositoryOperations
getEntity
in interface RepositoryOperations
T
- The generic Typetype
- The typeprotected <T,R> PS prepareStatement(AbstractSqlRepositoryOperations.StatementSupplier<PS> statementFunction, @NonNull PreparedQuery<T,R> preparedQuery, boolean isUpdate, boolean isSingleResult)
T
- The query declaring typeR
- The query result typestatementFunction
- The statement functionpreparedQuery
- The prepared queryisUpdate
- Is this an updateisSingleResult
- Is it a single resultprotected final <T> void setInsertParameters(@NonNull AbstractSqlRepositoryOperations.StoredInsert<T> insert, @NonNull T entity, @NonNull PS stmt)
T
- The entity typeinsert
- The insertentity
- The entitystmt
- The statementprotected <T> T triggerPrePersist(@NonNull T entity, RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
T
- The generic typeentity
- The entitype
- The persistent entityannotationMetadata
- The annotation metadataprotected <T> T triggerPostPersist(@NonNull T entity, RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
T
- The generic typeentity
- The entitype
- The persistent entityannotationMetadata
- The annotation metadataprotected <T> T triggerPreRemove(@NonNull T entity, RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
T
- The generic typeentity
- The entitype
- The persistent entityannotationMetadata
- The annotation metadataprotected <T> void triggerPostRemove(@NonNull T entity, RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
T
- The generic typeentity
- The entitype
- The persistent entityannotationMetadata
- The annotation metadataprotected <T> T triggerPreUpdate(@NonNull T entity, RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
T
- The generic typeentity
- The entitype
- The persistent entityannotationMetadata
- The annotation metadataprotected <T> void triggerPostUpdate(@NonNull T entity, RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
T
- The generic typeentity
- The entitype
- The persistent entityannotationMetadata
- The annotation metadataprotected <T> T triggerPostLoad(@NonNull T entity, RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
T
- The generic typeentity
- The entitype
- The persistent entityannotationMetadata
- The annotation metadataprotected int shiftIndex(int i)
i
- The index to shift@NonNull protected final <T> AbstractSqlRepositoryOperations.StoredInsert<T> resolveInsert(@NonNull EntityOperation<T> operation)
EntityOperation
.T
- The entity typeoperation
- The operation@NonNull protected final RuntimePersistentProperty<java.lang.Object> getIdReader(@NonNull java.lang.Object o)
o
- The object@NonNull protected final <T> Sort sortById(RuntimePersistentEntity<T> persistentEntity)
T
- The entity typepersistentEntity
- The entityprotected final boolean isSqlServerWithoutOrderBy(java.lang.String query, Dialect dialect)
query
- The querydialect
- The dialectprotected final int sizeOf(java.lang.Object value)
value
- The valueprotected final void setStatementParameter(PS preparedStatement, int index, DataType dataType, java.lang.Object value, Dialect dialect)
preparedStatement
- The prepared statementindex
- The indexdataType
- The data typevalue
- The valuedialect
- The dialect@NonNull protected <T> AbstractSqlRepositoryOperations.StoredInsert<T> resolveEntityInsert(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.lang.Class<?> repositoryType, @NonNull java.lang.Class<?> rootEntity, @NonNull RuntimePersistentEntity<?> persistentEntity)
T
- The generic typeannotationMetadata
- The repository annotation metadatarepositoryType
- The repository typerootEntity
- The root entitypersistentEntity
- The persistent entity@NonNull protected <T> AbstractSqlRepositoryOperations.StoredInsert<T> resolveEntityUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.lang.Class<?> repositoryType, @NonNull java.lang.Class<?> rootEntity, @NonNull RuntimePersistentEntity<?> persistentEntity)
T
- The generic typeannotationMetadata
- The repository annotation metadatarepositoryType
- The repository typerootEntity
- The root entitypersistentEntity
- The persistent entityprotected <T> java.lang.String resolveAssociationInsert(java.lang.Class repositoryType, RuntimePersistentEntity<T> persistentEntity, RuntimeAssociation<T> association)
T
- The entity generic typerepositoryType
- The repository typepersistentEntity
- The entityassociation
- The association