Class AbstractSqlRepositoryOperations<RS,​PS,​Exc extends java.lang.Exception>

    • Field Detail

      • QUERY_LOG

        protected static final org.slf4j.Logger QUERY_LOG
      • DEFAULT_SQL_BUILDER

        protected static final SqlQueryBuilder DEFAULT_SQL_BUILDER
      • columnNameResultSetReader

        protected final ResultReader<RS,​java.lang.String> columnNameResultSetReader
      • columnIndexResultSetReader

        protected final ResultReader<RS,​java.lang.Integer> columnIndexResultSetReader
      • preparedStatementWriter

        protected final QueryStatement<PS,​java.lang.Integer> preparedStatementWriter
      • queryBuilders

        protected final java.util.Map<java.lang.Class,​SqlQueryBuilder> queryBuilders
    • Constructor Detail

      • AbstractSqlRepositoryOperations

        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.
        Parameters:
        dataSourceName - The datasource name
        columnNameResultSetReader - The column name result reader
        columnIndexResultSetReader - The column index result reader
        preparedStatementWriter - The prepared statement writer
        codecs - The media type codecs
        dateTimeProvider - The date time provider
        runtimeEntityRegistry - The entity registry
        beanContext - The bean context
        conversionService - The conversion service
        attributeConverterRegistry - The attribute converter registry
    • Method Detail

      • decorate

        public <E,​R> PreparedQuery<E,​R> decorate​(PreparedQuery<E,​R> preparedQuery)
        Description copied from interface: PreparedQueryDecorator
        Decorate prepared query.
        Specified by:
        decorate in interface PreparedQueryDecorator
        Type Parameters:
        E - The entity type
        R - The result type
        Parameters:
        preparedQuery - The query to be decorated
        Returns:
        decorated prepared query
      • prepareStatement

        protected <T,​R> PS prepareStatement​(AbstractSqlRepositoryOperations.StatementSupplier<PS> statementFunction,
                                                  @NonNull
                                                  PreparedQuery<T,​R> preparedQuery,
                                                  boolean isUpdate,
                                                  boolean isSingleResult)
                                           throws Exc extends java.lang.Exception
        Prepare a statement for execution.
        Type Parameters:
        T - The query declaring type
        R - The query result type
        Parameters:
        statementFunction - The statement function
        preparedQuery - The prepared query
        isUpdate - Is this an update
        isSingleResult - Is it a single result
        Returns:
        The prepared statement
        Throws:
        Exc extends java.lang.Exception
      • setStatementParameter

        protected void setStatementParameter​(PS preparedStatement,
                                             int index,
                                             DataType dataType,
                                             java.lang.Object value,
                                             Dialect dialect)
        Set the parameter value on the given statement.
        Parameters:
        preparedStatement - The prepared statement
        index - The index
        dataType - The data type
        value - The value
        dialect - The dialect
      • resolveEntityInsert

        @NonNull
        protected <E> SqlStoredQuery<E,​E> resolveEntityInsert​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
                                                                    java.lang.Class<?> repositoryType,
                                                                    @NonNull
                                                                    java.lang.Class<E> rootEntity,
                                                                    @NonNull
                                                                    RuntimePersistentEntity<E> persistentEntity)
        Resolves a stored insert for the given entity.
        Type Parameters:
        E - The entity type
        Parameters:
        annotationMetadata - The repository annotation metadata
        repositoryType - The repository type
        rootEntity - The root entity
        persistentEntity - The persistent entity
        Returns:
        The insert
      • resolveAssociationInsert

        protected <T> java.lang.String resolveAssociationInsert​(java.lang.Class repositoryType,
                                                                RuntimePersistentEntity<T> persistentEntity,
                                                                RuntimeAssociation<T> association)
        Builds a join table insert.
        Type Parameters:
        T - The entity generic type
        Parameters:
        repositoryType - The repository type
        persistentEntity - The entity
        association - The association
        Returns:
        The insert statement
      • resolveEntityUpdate

        @NonNull
        protected <E> SqlStoredQuery<E,​E> resolveEntityUpdate​(io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
                                                                    java.lang.Class<?> repositoryType,
                                                                    @NonNull
                                                                    java.lang.Class<E> rootEntity,
                                                                    @NonNull
                                                                    RuntimePersistentEntity<E> persistentEntity)
        Resolves a stored update for the given entity.
        Type Parameters:
        E - The entity type
        Parameters:
        annotationMetadata - The repository annotation metadata
        repositoryType - The repository type
        rootEntity - The root entity
        persistentEntity - The persistent entity
        Returns:
        The insert
      • resolveSqlInsertAssociation

        protected <T> SqlStoredQuery<T,​?> resolveSqlInsertAssociation​(java.lang.Class<?> repositoryType,
                                                                            RuntimeAssociation<T> association,
                                                                            RuntimePersistentEntity<T> persistentEntity,
                                                                            T entity)
        Resolve SQL insert association operation.
        Type Parameters:
        T - The entity type
        Parameters:
        repositoryType - The repository type
        association - The association
        persistentEntity - The persistent entity
        entity - The entity
        Returns:
        The operation
      • getSqlStoredQuery

        protected final <E,​R> SqlStoredQuery<E,​R> getSqlStoredQuery​(StoredQuery<E,​R> storedQuery)
      • isSupportsBatchInsert

        protected boolean isSupportsBatchInsert​(PersistentEntity persistentEntity,
                                                Dialect dialect)
        Does supports batch for update queries.
        Parameters:
        persistentEntity - The persistent entity
        dialect - The dialect
        Returns:
        true if supported
      • isSupportsBatchUpdate

        protected boolean isSupportsBatchUpdate​(PersistentEntity persistentEntity,
                                                Dialect dialect)
        Does supports batch for update queries.
        Parameters:
        persistentEntity - The persistent entity
        dialect - The dialect
        Returns:
        true if supported
      • isSupportsBatchDelete

        protected boolean isSupportsBatchDelete​(PersistentEntity persistentEntity,
                                                Dialect dialect)
        Does supports batch for delete queries.
        Parameters:
        persistentEntity - The persistent entity
        dialect - The dialect
        Returns:
        true if supported