Class DefaultJdbcRepositoryOperations
java.lang.Object
io.micronaut.data.runtime.operations.internal.AbstractRepositoryOperations
io.micronaut.data.runtime.operations.internal.sql.AbstractSqlRepositoryOperations<ResultSet,PreparedStatement,SQLException>
  
io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations
- All Implemented Interfaces:
- io.micronaut.context.ApplicationContextProvider,- io.micronaut.core.convert.ConversionServiceProvider,- JdbcRepositoryOperations,- JdbcOperations,- AsyncCapableRepository,- HintsCapableRepository,- ReactiveCapableRepository,- RepositoryOperations,- SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultJdbcRepositoryOperations.JdbcOperationContext>,- MethodContextAwareStoredQueryDecorator,- PreparedQueryDecorator,- AutoCloseable
@EachBean(javax.sql.DataSource.class)
@Internal
public final class DefaultJdbcRepositoryOperations
extends AbstractSqlRepositoryOperations<ResultSet,PreparedStatement,SQLException>
implements JdbcRepositoryOperations, AsyncCapableRepository, ReactiveCapableRepository, AutoCloseable, SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultJdbcRepositoryOperations.JdbcOperationContext>  
Implementation of 
JdbcRepositoryOperations.- Since:
- 1.0.0
- Author:
- graemerocher, Denis Stepanov
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classNested classes/interfaces inherited from class io.micronaut.data.runtime.operations.internal.sql.AbstractSqlRepositoryOperationsAbstractSqlRepositoryOperations.StatementSupplier<PS>
- 
Field SummaryFields inherited from class io.micronaut.data.runtime.operations.internal.sql.AbstractSqlRepositoryOperationscolumnIndexResultSetReader, columnNameResultSetReader, dataSourceName, jsonMapper, preparedStatementWriter, QUERY_LOG, queryBuilders, repositoriesWithHardcodedDataSource, sqlJsonColumnMapperProviderFields inherited from class io.micronaut.data.runtime.operations.internal.AbstractRepositoryOperationsattributeConverterRegistry, conversionService, dateTimeProvider, entityEventRegistry, runtimeEntityRegistry
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedDefaultJdbcRepositoryOperations(String dataSourceName, DataJdbcConfiguration jdbcConfiguration, DataSource dataSource, ConnectionOperations<Connection> connectionOperations, TransactionOperations<Connection> transactionOperations, @Nullable ExecutorService executorService, io.micronaut.context.BeanContext beanContext, @NonNull DateTimeProvider dateTimeProvider, RuntimeEntityRegistry entityRegistry, DataConversionService conversionService, AttributeConverterRegistry attributeConverterRegistry, @Nullable SchemaTenantResolver schemaTenantResolver, JdbcSchemaHandler schemaHandler, @Nullable io.micronaut.json.JsonMapper jsonMapper, SqlJsonColumnMapperProvider<ResultSet> sqlJsonColumnMapperProvider) Default constructor.
- 
Method SummaryModifier and TypeMethodDescription@NonNull ExecutorAsyncOperationsasync()voidclose()<T> longcount(PagedQuery<T> pagedQuery) Counts all results for the given query.<T> intdelete(@NonNull DeleteOperation<T> operation) Deletes the entity.deleteAll(@NonNull DeleteBatchOperation<T> operation) Deletes all the entities of the given type.<T> @NonNull Stream<T>entityStream(@NonNull ResultSet resultSet, @NonNull Class<T> rootEntity) Map a result set to a stream of the given type.<T> @NonNull Stream<T>entityStream(@NonNull ResultSet resultSet, @Nullable String prefix, @NonNull Class<T> rootEntity) Map a result set to a stream of the given type.<R> Rexecute(@NonNull ConnectionCallback<R> callback) Execute the given operation with the given callback.executeUpdate(@NonNull PreparedQuery<?, Number> pq) Executes an update for the given query and parameter values.<T> booleanexists(@NonNull PreparedQuery<T, Boolean> pq) Execute a query that checks for existence.<T> @NonNull Iterable<T>findAll(@NonNull PagedQuery<T> query) Finds all results for the given query.<T,R> @NonNull Iterable<R> findAll(@NonNull PreparedQuery<T, R> preparedQuery) Finds all results for the given query.<T,R> R findOne(@NonNull PreparedQuery<T, R> pq) Find one by Query.<T> TFind one by ID.<R> Page<R>findPage(@NonNull PagedQuery<R> query) Find a page for the given entity and pageable.<T> @NonNull Stream<T>findStream(@NonNull PagedQuery<T> query) Finds a stream for the given arguments.<T,R> @NonNull Stream<R> findStream(@NonNull PreparedQuery<T, R> preparedQuery) Finds all results for the given query.@NonNull ConnectionThis method will return the currently active connection for the current transaction or throw an exception if no transaction is present.@NonNull DataSourcebooleanisSupportsBatchInsert(DefaultJdbcRepositoryOperations.JdbcOperationContext jdbcOperationContext, RuntimePersistentEntity<?> persistentEntity) Is supports batch insert.<T> Tpersist(@NonNull InsertOperation<T> operation) Persist the operation returning a possibly new entity.<T> @NonNull Iterable<T>persistAll(@NonNull InsertBatchOperation<T> operation) Persist all the given entities.<T> List<T>persistBatch(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, Iterable<T> values, RuntimePersistentEntity<T> childPersistentEntity, Predicate<T> predicate) Persist multiple entities in batch during cascade.voidpersistManyAssociation(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, RuntimeAssociation runtimeAssociation, Object value, RuntimePersistentEntity<Object> persistentEntity, Object child, RuntimePersistentEntity<Object> childPersistentEntity) Persist JOIN table relationship.voidpersistManyAssociationBatch(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, RuntimeAssociation runtimeAssociation, Object value, RuntimePersistentEntity<Object> persistentEntity, Iterable<Object> child, RuntimePersistentEntity<Object> childPersistentEntity) Persist JOIN table relationships in batch.<T> TpersistOne(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Persist one entity during cascade.<R> RprepareStatement(@NonNull String sql, @NonNull PreparedStatementCallback<R> callback) Execute the given operation with the given callback.@NonNull ReactiveRepositoryOperationsreactive()<E,D> D readDTO(@NonNull String prefix, @NonNull ResultSet resultSet, @NonNull Class<E> rootEntity, @NonNull Class<D> dtoType) Read an entity using the given prefix to be passes to result set lookups.<E> EreadEntity(@NonNull String prefix, @NonNull ResultSet resultSet, @NonNull Class<E> type) Read an entity using the given prefix to be passes to result set lookups.<T> Tupdate(@NonNull UpdateOperation<T> operation) Updates the entity for the given operation.<T> @NonNull Iterable<T>updateAll(@NonNull UpdateBatchOperation<T> operation) Updates the entities for the given operation.<T> TupdateOne(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Update one entity during cascade.Methods inherited from class io.micronaut.data.runtime.operations.internal.sql.AbstractSqlRepositoryOperationscreateQueryResultMapper, decorate, decorate, getJsonColumn, getJsonDataType, getSqlPreparedQuery, getSqlStoredQuery, handleSqlException, isJsonEntityGeneratedId, isJsonResult, isSupportsBatchDelete, isSupportsBatchInsert, isSupportsBatchUpdate, mapQueryColumnResult, prepareStatement, resolveAssociationInsert, resolveEntityInsert, resolveEntityUpdate, resolveSqlInsertAssociation, setStatementParameterMethods inherited from class io.micronaut.data.runtime.operations.internal.AbstractRepositoryOperationscheckOptimisticLocking, getApplicationContext, getConversionService, getEntity, getIdReader, isOnlySingleEndedJoins, triggerPostLoadMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.context.ApplicationContextProvidergetApplicationContextMethods inherited from interface io.micronaut.core.convert.ConversionServiceProvidergetConversionServiceMethods inherited from interface io.micronaut.data.operations.HintsCapableRepositorygetQueryHintsMethods inherited from interface io.micronaut.data.jdbc.runtime.JdbcOperationsreadDTO, readEntityMethods inherited from interface io.micronaut.data.operations.RepositoryOperationsexecuteDelete, getEntityMethods inherited from interface io.micronaut.data.runtime.operations.internal.SyncCascadeOperations.SyncCascadeOperationsHelperisSupportsBatchDelete, isSupportsBatchUpdate
- 
Constructor Details- 
DefaultJdbcRepositoryOperations@Internal protected DefaultJdbcRepositoryOperations(@Parameter String dataSourceName, @Parameter DataJdbcConfiguration jdbcConfiguration, DataSource dataSource, @Parameter ConnectionOperations<Connection> connectionOperations, @Parameter TransactionOperations<Connection> transactionOperations, @Named("io") @Nullable @Nullable ExecutorService executorService, io.micronaut.context.BeanContext beanContext, @NonNull @NonNull DateTimeProvider dateTimeProvider, RuntimeEntityRegistry entityRegistry, DataConversionService conversionService, AttributeConverterRegistry attributeConverterRegistry, @Nullable @Nullable SchemaTenantResolver schemaTenantResolver, JdbcSchemaHandler schemaHandler, @Nullable @Nullable io.micronaut.json.JsonMapper jsonMapper, SqlJsonColumnMapperProvider<ResultSet> sqlJsonColumnMapperProvider) Default constructor.- Parameters:
- dataSourceName- The data source name
- jdbcConfiguration- The jdbcConfiguration
- dataSource- The datasource
- transactionOperations- The JDBC operations for the data source
- executorService- The executor service
- beanContext- The bean context
- dateTimeProvider- The dateTimeProvider
- entityRegistry- The entity registry
- conversionService- The conversion service
- attributeConverterRegistry- The attribute converter registry
- schemaTenantResolver- The schema tenant resolver
- schemaHandler- The schema handler
- jsonMapper- The JSON mapper
- sqlJsonColumnMapperProvider- The SQL JSON column mapper provider
- connectionOperations-
 
 
- 
- 
Method Details- 
persistOnepublic <T> T persistOne(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Description copied from interface:SyncCascadeOperations.SyncCascadeOperationsHelperPersist one entity during cascade.- Specified by:
- persistOnein interface- SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultJdbcRepositoryOperations.JdbcOperationContext>
- Type Parameters:
- T- The entity type
- Parameters:
- ctx- The context
- value- The entity value
- persistentEntity- The persistent entity
- Returns:
- The entity value
 
- 
persistBatchpublic <T> List<T> persistBatch(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, Iterable<T> values, RuntimePersistentEntity<T> childPersistentEntity, Predicate<T> predicate) Description copied from interface:SyncCascadeOperations.SyncCascadeOperationsHelperPersist multiple entities in batch during cascade.- Specified by:
- persistBatchin interface- SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultJdbcRepositoryOperations.JdbcOperationContext>
- Type Parameters:
- T- The entity type
- Parameters:
- ctx- The context
- values- The entity values
- childPersistentEntity- The persistent entity
- predicate- The veto predicate
- Returns:
- The entity values
 
- 
updateOnepublic <T> T updateOne(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity) Description copied from interface:SyncCascadeOperations.SyncCascadeOperationsHelperUpdate one entity during cascade.- Specified by:
- updateOnein interface- SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultJdbcRepositoryOperations.JdbcOperationContext>
- Type Parameters:
- T- The entity type
- Parameters:
- ctx- The context
- value- The entity value
- persistentEntity- The persistent entity
- Returns:
- The entity value
 
- 
persistManyAssociationpublic void persistManyAssociation(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, RuntimeAssociation runtimeAssociation, Object value, RuntimePersistentEntity<Object> persistentEntity, Object child, RuntimePersistentEntity<Object> childPersistentEntity) Description copied from interface:SyncCascadeOperations.SyncCascadeOperationsHelperPersist JOIN table relationship.- Specified by:
- persistManyAssociationin interface- SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultJdbcRepositoryOperations.JdbcOperationContext>
- Parameters:
- ctx- The context
- runtimeAssociation- The association
- value- The parent entity value
- persistentEntity- The parent persistent entity
- child- The child entity value
- childPersistentEntity- The child persistent entity
 
- 
persistManyAssociationBatchpublic void persistManyAssociationBatch(DefaultJdbcRepositoryOperations.JdbcOperationContext ctx, RuntimeAssociation runtimeAssociation, Object value, RuntimePersistentEntity<Object> persistentEntity, Iterable<Object> child, RuntimePersistentEntity<Object> childPersistentEntity) Description copied from interface:SyncCascadeOperations.SyncCascadeOperationsHelperPersist JOIN table relationships in batch.- Specified by:
- persistManyAssociationBatchin interface- SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultJdbcRepositoryOperations.JdbcOperationContext>
- Parameters:
- ctx- The context
- runtimeAssociation- The association
- value- The parent entity value
- persistentEntity- The parent persistent entity
- child- The child entity values
- childPersistentEntity- The child persistent entity
 
- 
async- Specified by:
- asyncin interface- AsyncCapableRepository
- Returns:
- The async operations.
 
- 
reactive- Specified by:
- reactivein interface- ReactiveCapableRepository
- Returns:
- The reactive operations instance.
 
- 
findOneDescription copied from interface:RepositoryOperationsFind one by Query.- Specified by:
- findOnein interface- RepositoryOperations
- Type Parameters:
- T- The generic resultType
- R- The result type
- Parameters:
- pq- The prepared query
- Returns:
- A result or null
 
- 
existsDescription copied from interface:RepositoryOperationsExecute a query that checks for existence.- Specified by:
- existsin interface- RepositoryOperations
- Type Parameters:
- T- The generic resultType
- Parameters:
- pq- The prepared query
- Returns:
- A result or null
 
- 
findStream@NonNull public <T,R> @NonNull Stream<R> findStream(@NonNull @NonNull PreparedQuery<T, R> preparedQuery) Description copied from interface:RepositoryOperationsFinds all results for the given query.- Specified by:
- findStreamin interface- RepositoryOperations
- Type Parameters:
- T- The entity type
- R- The result type
- Parameters:
- preparedQuery- The prepared query
- Returns:
- An iterable result
 
- 
findAll@NonNull public <T,R> @NonNull Iterable<R> findAll(@NonNull @NonNull PreparedQuery<T, R> preparedQuery) Description copied from interface:RepositoryOperationsFinds all results for the given query.- Specified by:
- findAllin interface- RepositoryOperations
- Type Parameters:
- T- The entity type
- R- The result type
- Parameters:
- preparedQuery- The prepared query
- Returns:
- An iterable result
 
- 
executeUpdate@NonNull public @NonNull Optional<Number> executeUpdate(@NonNull @NonNull PreparedQuery<?, Number> pq) Description copied from interface:RepositoryOperationsExecutes an update for the given query and parameter values. If it is possible to return the number of objects updated, then do so.- Specified by:
- executeUpdatein interface- RepositoryOperations
- Parameters:
- pq- The prepared query
- Returns:
- An optional number with the count of the number of records updated
 
- 
deleteAllDescription copied from interface:RepositoryOperationsDeletes all the entities of the given type.- Specified by:
- deleteAllin interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The operation
- Returns:
- The number of entities deleted
 
- 
deleteDescription copied from interface:RepositoryOperationsDeletes the entity.- Specified by:
- deletein interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The operation
- Returns:
- The number of entities deleted
 
- 
updateDescription copied from interface:RepositoryOperationsUpdates the entity for the given operation.- Specified by:
- updatein interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The operation
- Returns:
- The operation
 
- 
updateAll@NonNull public <T> @NonNull Iterable<T> updateAll(@NonNull @NonNull UpdateBatchOperation<T> operation) Description copied from interface:RepositoryOperationsUpdates the entities for the given operation.- Specified by:
- updateAllin interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The operation
- Returns:
- The updated entities
 
- 
persistDescription copied from interface:RepositoryOperationsPersist the operation returning a possibly new entity.- Specified by:
- persistin interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The operation
- Returns:
- The operation
 
- 
findOneDescription copied from interface:RepositoryOperationsFind one by ID.- Specified by:
- findOnein interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- type- The type
- id- The id
- Returns:
- A result or null
 
- 
findAllDescription copied from interface:RepositoryOperationsFinds all results for the given query.- Specified by:
- findAllin interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- query- The root entity
- Returns:
- An iterable result
 
- 
countDescription copied from interface:RepositoryOperationsCounts all results for the given query.- Specified by:
- countin interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- pagedQuery- The paged query
- Returns:
- An iterable result
 
- 
findStreamDescription copied from interface:RepositoryOperationsFinds a stream for the given arguments.- Specified by:
- findStreamin interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- query- The query
- Returns:
- The stream
 
- 
findPageDescription copied from interface:RepositoryOperationsFind a page for the given entity and pageable.- Specified by:
- findPagein interface- RepositoryOperations
- Type Parameters:
- R- The entity generic type
- Parameters:
- query- The query
- Returns:
- The page type
 
- 
persistAll@NonNull public <T> @NonNull Iterable<T> persistAll(@NonNull @NonNull InsertBatchOperation<T> operation) Description copied from interface:RepositoryOperationsPersist all the given entities.- Specified by:
- persistAllin interface- RepositoryOperations
- Type Parameters:
- T- The generic type
- Parameters:
- operation- The operation
- Returns:
- The entities, possibly mutated
 
- 
close@PreDestroy public void close()- Specified by:
- closein interface- AutoCloseable
 
- 
getDataSource- Specified by:
- getDataSourcein interface- JdbcOperations
- Returns:
- The backing data source.
 
- 
getConnectionDescription copied from interface:JdbcOperationsThis method will return the currently active connection for the current transaction or throw an exception if no transaction is present.- Specified by:
- getConnectionin interface- JdbcOperations
- Returns:
- The current connection for the active transaction.
 
- 
executeDescription copied from interface:JdbcOperationsExecute the given operation with the given callback.- Specified by:
- executein interface- JdbcOperations
- Type Parameters:
- R- The result type
- Parameters:
- callback- The callback
- Returns:
- The result
 
- 
prepareStatement@NonNull public <R> R prepareStatement(@NonNull @NonNull String sql, @NonNull @NonNull PreparedStatementCallback<R> callback) Description copied from interface:JdbcOperationsExecute the given operation with the given callback.- Specified by:
- prepareStatementin interface- JdbcOperations
- Type Parameters:
- R- The result type
- Parameters:
- sql- The SQL
- callback- The callback
- Returns:
- The result
 
- 
entityStream@NonNull public <T> @NonNull Stream<T> entityStream(@NonNull @NonNull ResultSet resultSet, @NonNull @NonNull Class<T> rootEntity) Description copied from interface:JdbcOperationsMap a result set to a stream of the given type.- Specified by:
- entityStreamin interface- JdbcOperations
- Type Parameters:
- T- The generic type
- Parameters:
- resultSet- The result set
- rootEntity- The entity type
- Returns:
- The stream
 
- 
readEntity@NonNull public <E> E readEntity(@NonNull @NonNull String prefix, @NonNull @NonNull ResultSet resultSet, @NonNull @NonNull Class<E> type) throws DataAccessException Description copied from interface:JdbcOperationsRead an entity using the given prefix to be passes to result set lookups.- Specified by:
- readEntityin interface- JdbcOperations
- Type Parameters:
- E- The entity generic type
- Parameters:
- prefix- The prefix
- resultSet- The result set
- type- The entity type
- Returns:
- The entity result
- Throws:
- DataAccessException- if it is not possible read the result from the result set.
 
- 
readDTO@NonNull public <E,D> D readDTO(@NonNull @NonNull String prefix, @NonNull @NonNull ResultSet resultSet, @NonNull @NonNull Class<E> rootEntity, @NonNull @NonNull Class<D> dtoType) throws DataAccessException Description copied from interface:JdbcOperationsRead an entity using the given prefix to be passes to result set lookups.- Specified by:
- readDTOin interface- JdbcOperations
- Type Parameters:
- E- The entity generic type
- D- The DTO generic type
- Parameters:
- prefix- The prefix
- resultSet- The result set
- rootEntity- The entity type
- dtoType- The DTO type. Must be annotated with- Introspected
- Returns:
- The entity result
- Throws:
- DataAccessException- if it is not possible read the result from the result set.
 
- 
entityStream@NonNull public <T> @NonNull Stream<T> entityStream(@NonNull @NonNull ResultSet resultSet, @Nullable @Nullable String prefix, @NonNull @NonNull Class<T> rootEntity) Description copied from interface:JdbcOperationsMap a result set to a stream of the given type.- Specified by:
- entityStreamin interface- JdbcOperations
- Type Parameters:
- T- The generic type
- Parameters:
- resultSet- The result set
- prefix- The prefix to use for each column name that is mapped
- rootEntity- The entity type
- Returns:
- The stream
 
- 
isSupportsBatchInsertpublic boolean isSupportsBatchInsert(DefaultJdbcRepositoryOperations.JdbcOperationContext jdbcOperationContext, RuntimePersistentEntity<?> persistentEntity) Description copied from interface:SyncCascadeOperations.SyncCascadeOperationsHelperIs supports batch insert.- Specified by:
- isSupportsBatchInsertin interface- SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultJdbcRepositoryOperations.JdbcOperationContext>
- Parameters:
- jdbcOperationContext- The context
- persistentEntity- The persistent entity
- Returns:
- True if supports
 
 
-