@RequiresSyncMongo @EachBean(value=com.mongodb.client.MongoClient.class) @Internal public final class DefaultMongoRepositoryOperations extends AbstractRepositoryOperations<Cnt,PS> implements MongoRepositoryOperations, AsyncCapableRepository, ReactiveCapableRepository, SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultMongoRepositoryOperations.MongoOperationContext>
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DefaultMongoRepositoryOperations.MongoOperationContext |
| Modifier and Type | Field and Description |
|---|---|
protected static org.bson.BsonDocument |
EMPTY |
protected static org.slf4j.Logger |
QUERY_LOG |
protected java.util.Map<java.lang.Class,java.lang.String> |
repoDatabaseConfig |
attributeConverterRegistry, conversionService, dateTimeProvider, entityEventRegistry, jsonCodec, runtimeEntityRegistry| Modifier and Type | Method and Description |
|---|---|
protected org.bson.BsonDocument |
association(org.bson.codecs.configuration.CodecRegistry codecRegistry,
java.lang.Object value,
RuntimePersistentEntity<java.lang.Object> persistentEntity,
java.lang.Object child,
RuntimePersistentEntity<java.lang.Object> childPersistentEntity) |
ExecutorAsyncOperations |
async() |
protected <R> R |
convertResult(org.bson.codecs.configuration.CodecRegistry codecRegistry,
java.lang.Class<R> resultType,
org.bson.BsonDocument result,
boolean isDtoProjection) |
<T> long |
count(PagedQuery<T> pagedQuery)
Counts all results for the given query.
|
StoredQuery<java.lang.Object,java.lang.Long> |
createCountStoredQuery(io.micronaut.inject.ExecutableMethod<?,?> executableMethod,
DataMethod.OperationType operationType,
java.lang.String name,
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.Class<java.lang.Object> rootEntity,
java.lang.String query,
java.lang.String[] queryParts,
java.util.List<QueryParameterBinding> queryParameters)
Create count stored query from provided values.
|
<E,QR> StoredQuery<E,QR> |
createStoredQuery(io.micronaut.inject.ExecutableMethod<?,?> executableMethod,
DataMethod.OperationType operationType,
java.lang.String name,
io.micronaut.core.annotation.AnnotationMetadata annotationMetadata,
java.lang.Class<java.lang.Object> rootEntity,
java.lang.String query,
java.lang.String update,
java.lang.String[] queryParts,
java.util.List<QueryParameterBinding> queryParameters,
boolean hasPageable,
boolean isSingleResult)
Create stored query from provided values.
|
protected io.micronaut.core.convert.ConversionContext |
createTypeConversionContext(Cnt connection,
RuntimePersistentProperty<?> property,
io.micronaut.core.type.Argument<?> argument)
Creates implementation specific conversion context.
|
<T> int |
delete(DeleteOperation<T> operation)
Deletes the entity.
|
<T> java.util.Optional<java.lang.Number> |
deleteAll(DeleteBatchOperation<T> operation)
Deletes all the entities of the given type.
|
java.util.Optional<java.lang.Number> |
executeDelete(PreparedQuery<?,java.lang.Number> preparedQuery)
Executes a delete for the given query and parameter values.
|
java.util.Optional<java.lang.Number> |
executeUpdate(PreparedQuery<?,java.lang.Number> preparedQuery)
Executes an update for the given query and parameter values.
|
<T> boolean |
exists(PreparedQuery<T,java.lang.Boolean> preparedQuery)
Execute a query that checks for existence.
|
<T> java.lang.Iterable<T> |
findAll(PagedQuery<T> query)
Finds all results for the given query.
|
<T,R> java.lang.Iterable<R> |
findAll(PreparedQuery<T,R> preparedQuery)
Finds all results for the given query.
|
<T> T |
findOne(java.lang.Class<T> type,
java.io.Serializable id)
Find one by ID.
|
<T,R> R |
findOne(PreparedQuery<T,R> preparedQuery)
Find one by Query.
|
<R> Page<R> |
findPage(PagedQuery<R> query)
Find a page for the given entity and pageable.
|
<T> java.util.stream.Stream<T> |
findStream(PagedQuery<T> query)
Finds a stream for the given arguments.
|
<T,R> java.util.stream.Stream<R> |
findStream(PreparedQuery<T,R> preparedQuery)
Finds all results for the given query.
|
protected org.bson.codecs.configuration.CodecRegistry |
getCodecRegistry(com.mongodb.client.MongoDatabase mongoDatabase) |
protected com.mongodb.client.MongoDatabase |
getDatabase(RuntimePersistentEntity<?> persistentEntity,
java.lang.Class<?> repositoryClass) |
protected <E,R> MongoPreparedQuery<E,R,Dtb> |
getMongoPreparedQuery(PreparedQuery<E,R> preparedQuery) |
protected <E,R> MongoStoredQuery<E,R,Dtb> |
getMongoStoredQuery(StoredQuery<E,R> storedQuery) |
protected void |
logAggregate(MongoAggregation aggregation) |
protected void |
logFind(MongoFind find) |
<T> T |
persist(InsertOperation<T> operation)
Persist the operation returning a possibly new entity.
|
<T> java.lang.Iterable<T> |
persistAll(InsertBatchOperation<T> operation)
Persist all the given entities.
|
<T> java.util.List<T> |
persistBatch(DefaultMongoRepositoryOperations.MongoOperationContext ctx,
java.lang.Iterable<T> values,
RuntimePersistentEntity<T> persistentEntity,
java.util.function.Predicate<T> predicate)
Persist multiple entities in batch during cascade.
|
void |
persistManyAssociation(DefaultMongoRepositoryOperations.MongoOperationContext ctx,
RuntimeAssociation runtimeAssociation,
java.lang.Object value,
RuntimePersistentEntity<java.lang.Object> persistentEntity,
java.lang.Object child,
RuntimePersistentEntity<java.lang.Object> childPersistentEntity)
Persist JOIN table relationship.
|
void |
persistManyAssociationBatch(DefaultMongoRepositoryOperations.MongoOperationContext ctx,
RuntimeAssociation runtimeAssociation,
java.lang.Object value,
RuntimePersistentEntity<java.lang.Object> persistentEntity,
java.lang.Iterable<java.lang.Object> child,
RuntimePersistentEntity<java.lang.Object> childPersistentEntity)
Persist JOIN table relationships in batch.
|
<T> T |
persistOne(DefaultMongoRepositoryOperations.MongoOperationContext ctx,
T value,
RuntimePersistentEntity<T> persistentEntity)
Persist one entity during cascade.
|
ReactiveRepositoryOperations |
reactive() |
<E,R> StoredQuery<E,R> |
resolveCountQuery(io.micronaut.aop.MethodInvocationContext<?,?> context,
java.lang.Class<E> entityClass,
java.lang.Class<R> resultType)
Stored count query resolved from the method context.
|
<E,R> PreparedQuery<E,R> |
resolveCountQuery(io.micronaut.aop.MethodInvocationContext<?,?> context,
StoredQuery<E,R> storedQuery,
Pageable pageable)
Prepared count query resolved from the method context.
|
<E,R> StoredQuery<E,R> |
resolveQuery(io.micronaut.aop.MethodInvocationContext<?,?> context,
java.lang.Class<E> entityClass,
java.lang.Class<R> resultType)
Stored query resolved from the method context.
|
<E,R> PreparedQuery<E,R> |
resolveQuery(io.micronaut.aop.MethodInvocationContext<?,?> context,
StoredQuery<E,R> storedQuery,
Pageable pageable)
Prepared query resolved from the method context.
|
void |
setStatementParameter(java.lang.Object preparedStatement,
int index,
DataType dataType,
java.lang.Object value,
Dialect dialect)
Set the parameter value on the given statement.
|
<T> T |
update(UpdateOperation<T> operation)
Updates the entity for the given operation.
|
<T> java.lang.Iterable<T> |
updateAll(UpdateBatchOperation<T> operation)
Updates the entities for the given operation.
|
<T> T |
updateOne(DefaultMongoRepositoryOperations.MongoOperationContext ctx,
T value,
RuntimePersistentEntity<T> persistentEntity)
Update one entity during cascade.
|
checkOptimisticLocking, convert, convert, getApplicationContext, getConversionService, getEntity, getIdReader, getRuntimeEntityRegistry, isOnlySingleEndedJoins, shiftIndex, triggerPostLoadclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetConversionService, getEntitygetQueryHintsgetApplicationContextisSupportsBatchDelete, isSupportsBatchInsert, isSupportsBatchUpdateprotected static final org.slf4j.Logger QUERY_LOG
protected static final org.bson.BsonDocument EMPTY
protected final java.util.Map<java.lang.Class,java.lang.String> repoDatabaseConfig
public <T> T findOne(java.lang.Class<T> type,
java.io.Serializable id)
RepositoryOperationsfindOne in interface RepositoryOperationsT - The generic typetype - The typeid - The idpublic <T,R> R findOne(PreparedQuery<T,R> preparedQuery)
RepositoryOperationsfindOne in interface RepositoryOperationsT - The generic resultTypeR - The result typepreparedQuery - The prepared querypublic <T> boolean exists(PreparedQuery<T,java.lang.Boolean> preparedQuery)
RepositoryOperationsexists in interface RepositoryOperationsT - The generic resultTypepreparedQuery - The prepared querypublic <T> java.lang.Iterable<T> findAll(PagedQuery<T> query)
RepositoryOperationsfindAll in interface RepositoryOperationsT - The generic typequery - The root entitypublic <T> long count(PagedQuery<T> pagedQuery)
RepositoryOperationscount in interface RepositoryOperationsT - The generic typepagedQuery - The paged querypublic <T> java.util.stream.Stream<T> findStream(PagedQuery<T> query)
RepositoryOperationsfindStream in interface RepositoryOperationsT - The generic typequery - The querypublic <R> Page<R> findPage(PagedQuery<R> query)
RepositoryOperationsfindPage in interface RepositoryOperationsR - The entity generic typequery - The querypublic <T,R> java.lang.Iterable<R> findAll(PreparedQuery<T,R> preparedQuery)
RepositoryOperationsfindAll in interface RepositoryOperationsT - The entity typeR - The result typepreparedQuery - The prepared querypublic <T,R> java.util.stream.Stream<R> findStream(PreparedQuery<T,R> preparedQuery)
RepositoryOperationsfindStream in interface RepositoryOperationsT - The entity typeR - The result typepreparedQuery - The prepared querypublic <T> T persist(InsertOperation<T> operation)
RepositoryOperationspersist in interface RepositoryOperationsT - The generic typeoperation - The operationpublic <T> java.lang.Iterable<T> persistAll(InsertBatchOperation<T> operation)
RepositoryOperationspersistAll in interface RepositoryOperationsT - The generic typeoperation - The operationpublic <T> T update(UpdateOperation<T> operation)
RepositoryOperationsupdate in interface RepositoryOperationsT - The generic typeoperation - The operationpublic <T> java.lang.Iterable<T> updateAll(UpdateBatchOperation<T> operation)
RepositoryOperationsupdateAll in interface RepositoryOperationsT - The generic typeoperation - The operationpublic <T> int delete(DeleteOperation<T> operation)
RepositoryOperationsdelete in interface RepositoryOperationsT - The generic typeoperation - The operationpublic <T> java.util.Optional<java.lang.Number> deleteAll(DeleteBatchOperation<T> operation)
RepositoryOperationsdeleteAll in interface RepositoryOperationsT - The generic typeoperation - The operationpublic java.util.Optional<java.lang.Number> executeUpdate(PreparedQuery<?,java.lang.Number> preparedQuery)
RepositoryOperationsexecuteUpdate in interface RepositoryOperationspreparedQuery - The prepared querypublic java.util.Optional<java.lang.Number> executeDelete(PreparedQuery<?,java.lang.Number> preparedQuery)
RepositoryOperationsexecuteDelete in interface RepositoryOperationspreparedQuery - The prepared querypublic void setStatementParameter(java.lang.Object preparedStatement,
int index,
DataType dataType,
java.lang.Object value,
Dialect dialect)
OpContextsetStatementParameter in interface OpContext<com.mongodb.client.ClientSession,java.lang.Object>preparedStatement - The prepared statementindex - The indexdataType - The data typevalue - The valuedialect - The dialectprotected com.mongodb.client.MongoDatabase getDatabase(RuntimePersistentEntity<?> persistentEntity, java.lang.Class<?> repositoryClass)
protected org.bson.codecs.configuration.CodecRegistry getCodecRegistry(com.mongodb.client.MongoDatabase mongoDatabase)
public <T> T persistOne(DefaultMongoRepositoryOperations.MongoOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity)
SyncCascadeOperations.SyncCascadeOperationsHelperpersistOne in interface SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultMongoRepositoryOperations.MongoOperationContext>T - The entity typectx - The contextvalue - The entity valuepersistentEntity - The persistent entitypublic <T> java.util.List<T> persistBatch(DefaultMongoRepositoryOperations.MongoOperationContext ctx, java.lang.Iterable<T> values, RuntimePersistentEntity<T> persistentEntity, java.util.function.Predicate<T> predicate)
SyncCascadeOperations.SyncCascadeOperationsHelperpersistBatch in interface SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultMongoRepositoryOperations.MongoOperationContext>T - The entity typectx - The contextvalues - The entity valuespersistentEntity - The persistent entitypredicate - The veto predicatepublic <T> T updateOne(DefaultMongoRepositoryOperations.MongoOperationContext ctx, T value, RuntimePersistentEntity<T> persistentEntity)
SyncCascadeOperations.SyncCascadeOperationsHelperupdateOne in interface SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultMongoRepositoryOperations.MongoOperationContext>T - The entity typectx - The contextvalue - The entity valuepersistentEntity - The persistent entitypublic void persistManyAssociation(DefaultMongoRepositoryOperations.MongoOperationContext ctx, RuntimeAssociation runtimeAssociation, java.lang.Object value, RuntimePersistentEntity<java.lang.Object> persistentEntity, java.lang.Object child, RuntimePersistentEntity<java.lang.Object> childPersistentEntity)
SyncCascadeOperations.SyncCascadeOperationsHelperpersistManyAssociation in interface SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultMongoRepositoryOperations.MongoOperationContext>ctx - The contextruntimeAssociation - The associationvalue - The parent entity valuepersistentEntity - The parent persistent entitychild - The child entity valuechildPersistentEntity - The child persistent entitypublic void persistManyAssociationBatch(DefaultMongoRepositoryOperations.MongoOperationContext ctx, RuntimeAssociation runtimeAssociation, java.lang.Object value, RuntimePersistentEntity<java.lang.Object> persistentEntity, java.lang.Iterable<java.lang.Object> child, RuntimePersistentEntity<java.lang.Object> childPersistentEntity)
SyncCascadeOperations.SyncCascadeOperationsHelperpersistManyAssociationBatch in interface SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultMongoRepositoryOperations.MongoOperationContext>ctx - The contextruntimeAssociation - The associationvalue - The parent entity valuepersistentEntity - The parent persistent entitychild - The child entity valueschildPersistentEntity - The child persistent entity@NonNull public ExecutorAsyncOperations async()
async in interface AsyncCapableRepository@NonNull public ReactiveRepositoryOperations reactive()
reactive in interface ReactiveCapableRepositoryprotected <E,R> MongoStoredQuery<E,R,Dtb> getMongoStoredQuery(StoredQuery<E,R> storedQuery)
protected <E,R> MongoPreparedQuery<E,R,Dtb> getMongoPreparedQuery(PreparedQuery<E,R> preparedQuery)
public <E,R> PreparedQuery<E,R> resolveQuery(io.micronaut.aop.MethodInvocationContext<?,?> context, StoredQuery<E,R> storedQuery, Pageable pageable)
PreparedQueryResolverresolveQuery in interface PreparedQueryResolverE - The entity typeR - The result typecontext - The method contextstoredQuery - The stored querypageable - The pageablepublic <E,R> PreparedQuery<E,R> resolveCountQuery(io.micronaut.aop.MethodInvocationContext<?,?> context, StoredQuery<E,R> storedQuery, Pageable pageable)
PreparedQueryResolverresolveCountQuery in interface PreparedQueryResolverE - The entity typeR - The result typecontext - The method contextstoredQuery - The stored querypageable - The pageablepublic <E,R> StoredQuery<E,R> resolveQuery(io.micronaut.aop.MethodInvocationContext<?,?> context, java.lang.Class<E> entityClass, java.lang.Class<R> resultType)
StoredQueryResolverresolveQuery in interface StoredQueryResolverE - The entity typeR - The result typecontext - The method contextentityClass - The entity typeresultType - The result typepublic <E,R> StoredQuery<E,R> resolveCountQuery(io.micronaut.aop.MethodInvocationContext<?,?> context, java.lang.Class<E> entityClass, java.lang.Class<R> resultType)
StoredQueryResolverresolveCountQuery in interface StoredQueryResolverE - The entity typeR - The result typecontext - The method contextentityClass - The entity typeresultType - The result typepublic <E,QR> StoredQuery<E,QR> createStoredQuery(io.micronaut.inject.ExecutableMethod<?,?> executableMethod, DataMethod.OperationType operationType, java.lang.String name, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.lang.Class<java.lang.Object> rootEntity, java.lang.String query, java.lang.String update, java.lang.String[] queryParts, java.util.List<QueryParameterBinding> queryParameters, boolean hasPageable, boolean isSingleResult)
StoredQueryResolvercreateStoredQuery in interface StoredQueryResolverE - The entity typeQR - The result typeexecutableMethod - The executableMethodoperationType - The operationTypename - The nameannotationMetadata - The annotation metadatarootEntity - The root entityquery - The queryupdate - The update queryqueryParts - The query partsqueryParameters - The query parametershasPageable - Has pageableisSingleResult - Is single resultpublic StoredQuery<java.lang.Object,java.lang.Long> createCountStoredQuery(io.micronaut.inject.ExecutableMethod<?,?> executableMethod, DataMethod.OperationType operationType, java.lang.String name, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata, java.lang.Class<java.lang.Object> rootEntity, java.lang.String query, java.lang.String[] queryParts, java.util.List<QueryParameterBinding> queryParameters)
StoredQueryResolvercreateCountStoredQuery in interface StoredQueryResolverexecutableMethod - The executableMethodoperationType - The operationTypename - The nameannotationMetadata - The annotation metadatarootEntity - The root entityquery - The queryqueryParts - The query partsqueryParameters - The query parametersprotected <R> R convertResult(org.bson.codecs.configuration.CodecRegistry codecRegistry,
java.lang.Class<R> resultType,
org.bson.BsonDocument result,
boolean isDtoProjection)
protected org.bson.BsonDocument association(org.bson.codecs.configuration.CodecRegistry codecRegistry,
java.lang.Object value,
RuntimePersistentEntity<java.lang.Object> persistentEntity,
java.lang.Object child,
RuntimePersistentEntity<java.lang.Object> childPersistentEntity)
protected io.micronaut.core.convert.ConversionContext createTypeConversionContext(Cnt connection,
RuntimePersistentProperty<?> property,
io.micronaut.core.type.Argument<?> argument)
AbstractRepositoryOperationscreateTypeConversionContext in class AbstractRepositoryOperations<Cnt,PS>connection - The connectionproperty - The propertyargument - The argumentConversionContextprotected void logFind(MongoFind find)
protected void logAggregate(MongoAggregation aggregation)