@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, triggerPostLoad
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getConversionService, getEntity
getQueryHints
getApplicationContext
isSupportsBatchDelete, isSupportsBatchInsert, isSupportsBatchUpdate
protected 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)
RepositoryOperations
findOne
in interface RepositoryOperations
T
- The generic typetype
- The typeid
- The idpublic <T,R> R findOne(PreparedQuery<T,R> preparedQuery)
RepositoryOperations
findOne
in interface RepositoryOperations
T
- The generic resultTypeR
- The result typepreparedQuery
- The prepared querypublic <T> boolean exists(PreparedQuery<T,java.lang.Boolean> preparedQuery)
RepositoryOperations
exists
in interface RepositoryOperations
T
- The generic resultTypepreparedQuery
- The prepared querypublic <T> java.lang.Iterable<T> findAll(PagedQuery<T> query)
RepositoryOperations
findAll
in interface RepositoryOperations
T
- The generic typequery
- The root entitypublic <T> long count(PagedQuery<T> pagedQuery)
RepositoryOperations
count
in interface RepositoryOperations
T
- The generic typepagedQuery
- The paged querypublic <T> java.util.stream.Stream<T> findStream(PagedQuery<T> query)
RepositoryOperations
findStream
in interface RepositoryOperations
T
- The generic typequery
- The querypublic <R> Page<R> findPage(PagedQuery<R> query)
RepositoryOperations
findPage
in interface RepositoryOperations
R
- The entity generic typequery
- The querypublic <T,R> java.lang.Iterable<R> findAll(PreparedQuery<T,R> preparedQuery)
RepositoryOperations
findAll
in interface RepositoryOperations
T
- The entity typeR
- The result typepreparedQuery
- The prepared querypublic <T,R> java.util.stream.Stream<R> findStream(PreparedQuery<T,R> preparedQuery)
RepositoryOperations
findStream
in interface RepositoryOperations
T
- The entity typeR
- The result typepreparedQuery
- The prepared querypublic <T> T persist(InsertOperation<T> operation)
RepositoryOperations
persist
in interface RepositoryOperations
T
- The generic typeoperation
- The operationpublic <T> java.lang.Iterable<T> persistAll(InsertBatchOperation<T> operation)
RepositoryOperations
persistAll
in interface RepositoryOperations
T
- The generic typeoperation
- The operationpublic <T> T update(UpdateOperation<T> operation)
RepositoryOperations
update
in interface RepositoryOperations
T
- The generic typeoperation
- The operationpublic <T> java.lang.Iterable<T> updateAll(UpdateBatchOperation<T> operation)
RepositoryOperations
updateAll
in interface RepositoryOperations
T
- The generic typeoperation
- The operationpublic <T> int delete(DeleteOperation<T> operation)
RepositoryOperations
delete
in interface RepositoryOperations
T
- The generic typeoperation
- The operationpublic <T> java.util.Optional<java.lang.Number> deleteAll(DeleteBatchOperation<T> operation)
RepositoryOperations
deleteAll
in interface RepositoryOperations
T
- The generic typeoperation
- The operationpublic java.util.Optional<java.lang.Number> executeUpdate(PreparedQuery<?,java.lang.Number> preparedQuery)
RepositoryOperations
executeUpdate
in interface RepositoryOperations
preparedQuery
- The prepared querypublic java.util.Optional<java.lang.Number> executeDelete(PreparedQuery<?,java.lang.Number> preparedQuery)
RepositoryOperations
executeDelete
in interface RepositoryOperations
preparedQuery
- The prepared querypublic void setStatementParameter(java.lang.Object preparedStatement, int index, DataType dataType, java.lang.Object value, Dialect dialect)
OpContext
setStatementParameter
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.SyncCascadeOperationsHelper
persistOne
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.SyncCascadeOperationsHelper
persistBatch
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.SyncCascadeOperationsHelper
updateOne
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.SyncCascadeOperationsHelper
persistManyAssociation
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.SyncCascadeOperationsHelper
persistManyAssociationBatch
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 ReactiveCapableRepository
protected <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)
PreparedQueryResolver
resolveQuery
in interface PreparedQueryResolver
E
- 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)
PreparedQueryResolver
resolveCountQuery
in interface PreparedQueryResolver
E
- 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)
StoredQueryResolver
resolveQuery
in interface StoredQueryResolver
E
- 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)
StoredQueryResolver
resolveCountQuery
in interface StoredQueryResolver
E
- 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)
StoredQueryResolver
createStoredQuery
in interface StoredQueryResolver
E
- 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)
StoredQueryResolver
createCountStoredQuery
in interface StoredQueryResolver
executableMethod
- 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)
AbstractRepositoryOperations
createTypeConversionContext
in class AbstractRepositoryOperations<Cnt,PS>
connection
- The connectionproperty
- The propertyargument
- The argumentConversionContext
protected void logFind(MongoFind find)
protected void logAggregate(MongoAggregation aggregation)