@EachBean(value=com.mongodb.client.MongoClient.class) @Internal public final class DefaultMongoRepositoryOperations extends AbstractRepositoryOperations<com.mongodb.client.ClientSession,java.lang.Object> implements MongoRepositoryOperations, AsyncCapableRepository, ReactiveCapableRepository, SyncCascadeOperations.SyncCascadeOperationsHelper<DefaultMongoRepositoryOperations.MongoOperationContext>
Modifier and Type | Class and Description |
---|---|
protected static class |
DefaultMongoRepositoryOperations.MongoOperationContext |
attributeConverterRegistry, conversionService, dateTimeProvider, entityEventRegistry, jsonCodec, runtimeEntityRegistry
Modifier | Constructor and Description |
---|---|
protected |
DefaultMongoRepositoryOperations(java.lang.String serverName,
io.micronaut.context.BeanContext beanContext,
java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs,
DateTimeProvider<java.lang.Object> dateTimeProvider,
RuntimeEntityRegistry runtimeEntityRegistry,
DataConversionService<?> conversionService,
AttributeConverterRegistry attributeConverterRegistry,
com.mongodb.client.MongoClient mongoClient,
java.util.concurrent.ExecutorService executorService)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
ExecutorAsyncOperations |
async() |
<T> long |
count(PagedQuery<T> pagedQuery)
Counts all results for the given query.
|
protected io.micronaut.core.convert.ConversionContext |
createTypeConversionContext(com.mongodb.client.ClientSession 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.
|
<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() |
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, 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 DefaultMongoRepositoryOperations(@Parameter java.lang.String serverName, io.micronaut.context.BeanContext beanContext, java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs, DateTimeProvider<java.lang.Object> dateTimeProvider, RuntimeEntityRegistry runtimeEntityRegistry, DataConversionService<?> conversionService, AttributeConverterRegistry attributeConverterRegistry, com.mongodb.client.MongoClient mongoClient, @Named(value="io") @Nullable java.util.concurrent.ExecutorService executorService)
serverName
- The server namebeanContext
- The bean contextcodecs
- The media type codecsdateTimeProvider
- The date time providerruntimeEntityRegistry
- The entity registryconversionService
- The conversion serviceattributeConverterRegistry
- The attribute converter registrymongoClient
- The Mongo clientexecutorService
- The executor servicepublic <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 queryprotected io.micronaut.core.convert.ConversionContext createTypeConversionContext(com.mongodb.client.ClientSession connection, RuntimePersistentProperty<?> property, io.micronaut.core.type.Argument<?> argument)
AbstractRepositoryOperations
createTypeConversionContext
in class AbstractRepositoryOperations<com.mongodb.client.ClientSession,java.lang.Object>
connection
- The connectionproperty
- The propertyargument
- The argumentConversionContext
public 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 dialectpublic <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