Cnt
- The connection typeRS
- The result set typePS
- The prepared statement typeExc
- The exception type@Internal public abstract class AbstractSqlRepositoryOperations<Cnt,RS,PS,Exc extends java.lang.Exception> extends AbstractRepositoryOperations<Cnt,PS> implements io.micronaut.context.ApplicationContextProvider, OpContext<Cnt,PS>
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 QueryStatement<PS,java.lang.Integer> |
preparedStatementWriter |
protected static org.slf4j.Logger |
QUERY_LOG |
protected java.util.Map<java.lang.Class,SqlQueryBuilder> |
queryBuilders |
attributeConverterRegistry, conversionService, dateTimeProvider, entityEventRegistry, jsonCodec, 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,
DateTimeProvider<java.lang.Object> dateTimeProvider,
RuntimeEntityRegistry runtimeEntityRegistry,
io.micronaut.context.BeanContext beanContext,
DataConversionService<?> conversionService,
AttributeConverterRegistry attributeConverterRegistry)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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(Cnt connection,
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 DBOperation |
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 DBOperation |
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> DBOperation |
resolveSqlInsertAssociation(java.lang.Class<?> repositoryType,
Dialect dialect,
RuntimeAssociation<T> association,
RuntimePersistentEntity<T> persistentEntity,
T entity)
Resolve SQL insert association operation.
|
void |
setStatementParameter(PS preparedStatement,
int index,
DataType dataType,
java.lang.Object value,
Dialect dialect)
Set the parameter value on the given statement.
|
checkOptimisticLocking, convert, convert, createTypeConversionContext, getApplicationContext, getEntity, getIdReader, getRuntimeEntityRegistry, isOnlySingleEndedJoins, shiftIndex, triggerPostLoad
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getApplicationContext
convert, convert, getEntity, getRuntimeEntityRegistry, shiftIndex
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 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, DataConversionService<?> conversionService, AttributeConverterRegistry attributeConverterRegistry)
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 contextconversionService
- The conversion serviceattributeConverterRegistry
- The attribute converter registryprotected <T,R> PS prepareStatement(Cnt connection, AbstractSqlRepositoryOperations.StatementSupplier<PS> statementFunction, @NonNull PreparedQuery<T,R> preparedQuery, boolean isUpdate, boolean isSingleResult) throws Exc extends java.lang.Exception
T
- The query declaring typeR
- The query result typeconnection
- The connectionstatementFunction
- The statement functionpreparedQuery
- The prepared queryisUpdate
- Is this an updateisSingleResult
- Is it a single resultExc extends java.lang.Exception
public void setStatementParameter(PS preparedStatement, int index, DataType dataType, java.lang.Object value, Dialect dialect)
setStatementParameter
in interface OpContext<Cnt,PS>
preparedStatement
- The prepared statementindex
- The indexdataType
- The data typevalue
- The valuedialect
- The dialect@NonNull protected DBOperation 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 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@NonNull protected DBOperation 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> DBOperation resolveSqlInsertAssociation(java.lang.Class<?> repositoryType, Dialect dialect, RuntimeAssociation<T> association, RuntimePersistentEntity<T> persistentEntity, T entity)
T
- The entity typerepositoryType
- The repository typedialect
- The dialectassociation
- The associationpersistentEntity
- The persistent entityentity
- The entityprotected 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