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.
|
Modifier and Type | Field and Description |
---|---|
protected ResultReader<RS,java.lang.Integer> |
columnIndexResultSetReader |
protected ResultReader<RS,java.lang.String> |
columnNameResultSetReader |
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 |
protected RuntimeEntityRegistry |
runtimeEntityRegistry |
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,
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,
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 boolean |
isSupportsBatchDelete(PersistentEntity persistentEntity,
Dialect dialect)
Does supports batch for delete queries.
|
protected boolean |
isSupportsBatchInsert(PersistentEntity persistentEntity,
Dialect dialect)
Does supports batch for update queries.
|
protected boolean |
isSupportsBatchUpdate(PersistentEntity persistentEntity,
Dialect dialect)
Does supports batch for update queries.
|
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 io.micronaut.data.jdbc.operations.AbstractSqlRepositoryOperations.SqlOperation |
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 io.micronaut.data.jdbc.operations.AbstractSqlRepositoryOperations.SqlOperation |
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 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> T |
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, updateAll
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 RuntimeEntityRegistry runtimeEntityRegistry
@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, io.micronaut.context.BeanContext beanContext)
AbstractSqlRepositoryOperations(String, ResultReader, ResultReader, QueryStatement, List, RuntimeEntityRegistry, BeanContext)
dataSourceName
- The datasource namecolumnNameResultSetReader
- The column name result readercolumnIndexResultSetReader
- The column index result readerpreparedStatementWriter
- The prepared statement writercodecs
- The media type codecsbeanContext
- 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, 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 codecsruntimeEntityRegistry
- 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) throws java.lang.Exception
T
- The query declaring typeR
- The query result typestatementFunction
- The statement functionpreparedQuery
- The prepared queryisUpdate
- Is this an updateisSingleResult
- Is it a single resultjava.lang.Exception
protected <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> T 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 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 io.micronaut.data.jdbc.operations.AbstractSqlRepositoryOperations.SqlOperation resolveEntityInsert(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.lang.Class<?> repositoryType, @NonNull java.lang.Class<?> rootEntity, @NonNull RuntimePersistentEntity<?> persistentEntity)
annotationMetadata
- The repository annotation metadatarepositoryType
- The repository typerootEntity
- The root entitypersistentEntity
- The persistent entity@NonNull protected io.micronaut.data.jdbc.operations.AbstractSqlRepositoryOperations.SqlOperation resolveEntityUpdate(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.lang.Class<?> repositoryType, @NonNull java.lang.Class<?> rootEntity, @NonNull RuntimePersistentEntity<?> persistentEntity)
annotationMetadata
- 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 associationprotected boolean isSupportsBatchInsert(PersistentEntity persistentEntity, Dialect dialect)
persistentEntity
- The persistent entitydialect
- The dialectprotected boolean isSupportsBatchUpdate(PersistentEntity persistentEntity, Dialect dialect)
persistentEntity
- The persistent entitydialect
- The dialectprotected boolean isSupportsBatchDelete(PersistentEntity persistentEntity, Dialect dialect)
persistentEntity
- The persistent entitydialect
- The dialect