@ -436,12 +436,12 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # reactiveIndexOps ( java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # reactiveIndexOps ( java . lang . Class )
* /
* /
public ReactiveIndexOperations indexOps ( Class < ? > entityClass ) {
public ReactiveIndexOperations indexOps ( Class < ? > entityClass ) {
return new DefaultReactiveIndexOperations ( this , determine CollectionName( entityClass ) , this . queryMapper ,
return new DefaultReactiveIndexOperations ( this , get CollectionName( entityClass ) , this . queryMapper ,
entityClass ) ;
entityClass ) ;
}
}
public String getCollectionName ( Class < ? > entityClass ) {
public String getCollectionName ( Class < ? > entityClass ) {
return thi s. determineCollectionName ( entityClass ) ;
return operation s. determineCollectionName ( entityClass ) ;
}
}
/ *
/ *
@ -481,7 +481,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* /
* /
@Override
@Override
public < T > Flux < T > execute ( Class < ? > entityClass , ReactiveCollectionCallback < T > action ) {
public < T > Flux < T > execute ( Class < ? > entityClass , ReactiveCollectionCallback < T > action ) {
return createFlux ( determine CollectionName( entityClass ) , action ) ;
return createFlux ( get CollectionName( entityClass ) , action ) ;
}
}
/ *
/ *
@ -697,7 +697,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
( ) - > operations . forType ( entityClass ) . getCollation ( ) ) //
( ) - > operations . forType ( entityClass ) . getCollation ( ) ) //
. map ( options : : collation ) . orElse ( options ) ;
. map ( options : : collation ) . orElse ( options ) ;
return doCreateCollection ( determine CollectionName( entityClass ) ,
return doCreateCollection ( get CollectionName( entityClass ) ,
convertToCreateCollectionOptions ( options , entityClass ) ) ;
convertToCreateCollectionOptions ( options , entityClass ) ) ;
}
}
@ -738,7 +738,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # collectionExists ( java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # collectionExists ( java . lang . Class )
* /
* /
public < T > Mono < Boolean > collectionExists ( Class < T > entityClass ) {
public < T > Mono < Boolean > collectionExists ( Class < T > entityClass ) {
return collectionExists ( determine CollectionName( entityClass ) ) ;
return collectionExists ( get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -757,7 +757,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # dropCollection ( java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # dropCollection ( java . lang . Class )
* /
* /
public < T > Mono < Void > dropCollection ( Class < T > entityClass ) {
public < T > Mono < Void > dropCollection ( Class < T > entityClass ) {
return dropCollection ( determine CollectionName( entityClass ) ) ;
return dropCollection ( get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -794,7 +794,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findOne ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findOne ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* /
* /
public < T > Mono < T > findOne ( Query query , Class < T > entityClass ) {
public < T > Mono < T > findOne ( Query query , Class < T > entityClass ) {
return findOne ( query , entityClass , determine CollectionName( entityClass ) ) ;
return findOne ( query , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -817,7 +817,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # exists ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # exists ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* /
* /
public Mono < Boolean > exists ( Query query , Class < ? > entityClass ) {
public Mono < Boolean > exists ( Query query , Class < ? > entityClass ) {
return exists ( query , entityClass , determine CollectionName( entityClass ) ) ;
return exists ( query , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -860,7 +860,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # find ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # find ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* /
* /
public < T > Flux < T > find ( Query query , Class < T > entityClass ) {
public < T > Flux < T > find ( Query query , Class < T > entityClass ) {
return find ( query , entityClass , determine CollectionName( entityClass ) ) ;
return find ( query , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -882,7 +882,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findById ( java . lang . Object , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findById ( java . lang . Object , java . lang . Class )
* /
* /
public < T > Mono < T > findById ( Object id , Class < T > entityClass ) {
public < T > Mono < T > findById ( Object id , Class < T > entityClass ) {
return findById ( id , entityClass , determine CollectionName( entityClass ) ) ;
return findById ( id , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -901,7 +901,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findDistinct ( org . springframework . data . mongodb . core . query . Query , java . lang . String , java . lang . Class , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findDistinct ( org . springframework . data . mongodb . core . query . Query , java . lang . String , java . lang . Class , java . lang . Class )
* /
* /
public < T > Flux < T > findDistinct ( Query query , String field , Class < ? > entityClass , Class < T > resultClass ) {
public < T > Flux < T > findDistinct ( Query query , String field , Class < ? > entityClass , Class < T > resultClass ) {
return findDistinct ( query , field , determine CollectionName( entityClass ) , entityClass , resultClass ) ;
return findDistinct ( query , field , get CollectionName( entityClass ) , entityClass , resultClass ) ;
}
}
/ *
/ *
@ -998,7 +998,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* /
* /
@Override
@Override
public < O > Flux < O > aggregate ( TypedAggregation < ? > aggregation , Class < O > outputType ) {
public < O > Flux < O > aggregate ( TypedAggregation < ? > aggregation , Class < O > outputType ) {
return aggregate ( aggregation , determine CollectionName( aggregation . getInputType ( ) ) , outputType ) ;
return aggregate ( aggregation , get CollectionName( aggregation . getInputType ( ) ) , outputType ) ;
}
}
/ *
/ *
@ -1008,7 +1008,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
@Override
@Override
public < O > Flux < O > aggregate ( Aggregation aggregation , Class < ? > inputType , Class < O > outputType ) {
public < O > Flux < O > aggregate ( Aggregation aggregation , Class < ? > inputType , Class < O > outputType ) {
return aggregate ( aggregation , determine CollectionName( inputType ) , outputType ,
return aggregate ( aggregation , get CollectionName( inputType ) , outputType ,
new TypeBasedAggregationOperationContext ( inputType , mappingContext , queryMapper ) ) ;
new TypeBasedAggregationOperationContext ( inputType , mappingContext , queryMapper ) ) ;
}
}
@ -1077,7 +1077,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* /
* /
@Override
@Override
public < T > Flux < GeoResult < T > > geoNear ( NearQuery near , Class < T > entityClass ) {
public < T > Flux < GeoResult < T > > geoNear ( NearQuery near , Class < T > entityClass ) {
return geoNear ( near , entityClass , determine CollectionName( entityClass ) ) ;
return geoNear ( near , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -1101,7 +1101,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
throw new InvalidDataAccessApiUsageException ( "Entity class must not be null!" ) ;
throw new InvalidDataAccessApiUsageException ( "Entity class must not be null!" ) ;
}
}
String collection = StringUtils . hasText ( collectionName ) ? collectionName : determine CollectionName( entityClass ) ;
String collection = StringUtils . hasText ( collectionName ) ? collectionName : get CollectionName( entityClass ) ;
String distanceField = operations . nearQueryDistanceFieldName ( entityClass ) ;
String distanceField = operations . nearQueryDistanceFieldName ( entityClass ) ;
GeoNearResultDocumentCallback < T > callback = new GeoNearResultDocumentCallback < > ( distanceField ,
GeoNearResultDocumentCallback < T > callback = new GeoNearResultDocumentCallback < > ( distanceField ,
@ -1119,7 +1119,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findAndModify ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findAndModify ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , java . lang . Class )
* /
* /
public < T > Mono < T > findAndModify ( Query query , Update update , Class < T > entityClass ) {
public < T > Mono < T > findAndModify ( Query query , Update update , Class < T > entityClass ) {
return findAndModify ( query , update , new FindAndModifyOptions ( ) , entityClass , determine CollectionName( entityClass ) ) ;
return findAndModify ( query , update , new FindAndModifyOptions ( ) , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -1135,7 +1135,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findAndModify ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , org . springframework . data . mongodb . core . FindAndModifyOptions , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findAndModify ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , org . springframework . data . mongodb . core . FindAndModifyOptions , java . lang . Class )
* /
* /
public < T > Mono < T > findAndModify ( Query query , Update update , FindAndModifyOptions options , Class < T > entityClass ) {
public < T > Mono < T > findAndModify ( Query query , Update update , FindAndModifyOptions options , Class < T > entityClass ) {
return findAndModify ( query , update , options , entityClass , determine CollectionName( entityClass ) ) ;
return findAndModify ( query , update , options , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -1213,7 +1213,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findAndRemove ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findAndRemove ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* /
* /
public < T > Mono < T > findAndRemove ( Query query , Class < T > entityClass ) {
public < T > Mono < T > findAndRemove ( Query query , Class < T > entityClass ) {
return findAndRemove ( query , entityClass , determine CollectionName( entityClass ) ) ;
return findAndRemove ( query , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -1236,7 +1236,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
Assert . notNull ( entityClass , "Entity class must not be null!" ) ;
Assert . notNull ( entityClass , "Entity class must not be null!" ) ;
return count ( query , entityClass , determine CollectionName( entityClass ) ) ;
return count ( query , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -1315,7 +1315,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* /
* /
@Override
@Override
public < T > Flux < T > insertAll ( Mono < ? extends Collection < ? extends T > > batchToSave , Class < ? > entityClass ) {
public < T > Flux < T > insertAll ( Mono < ? extends Collection < ? extends T > > batchToSave , Class < ? > entityClass ) {
return insertAll ( batchToSave , determine CollectionName( entityClass ) ) ;
return insertAll ( batchToSave , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -1339,7 +1339,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
Assert . notNull ( objectToSave , "Object to insert must not be null!" ) ;
Assert . notNull ( objectToSave , "Object to insert must not be null!" ) ;
ensureNotIterable ( objectToSave ) ;
ensureNotIterable ( objectToSave ) ;
return insert ( objectToSave , determineEntityCollectionName ( objectToSave ) ) ;
return insert ( objectToSave , getCollectionName ( ClassUtils . getUserClass ( objectToSave ) ) ) ;
}
}
/ *
/ *
@ -1388,7 +1388,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # insert ( java . util . Collection , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # insert ( java . util . Collection , java . lang . Class )
* /
* /
public < T > Flux < T > insert ( Collection < ? extends T > batchToSave , Class < ? > entityClass ) {
public < T > Flux < T > insert ( Collection < ? extends T > batchToSave , Class < ? > entityClass ) {
return doInsertBatch ( determine CollectionName( entityClass ) , batchToSave , this . mongoConverter ) ;
return doInsertBatch ( get CollectionName( entityClass ) , batchToSave , this . mongoConverter ) ;
}
}
/ *
/ *
@ -1422,9 +1422,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
listToSave . forEach ( element - > {
listToSave . forEach ( element - > {
MongoPersistentEntity < ? > entity = mappingContext . getRequiredPersistentEntity ( element . getClass ( ) ) ;
String collection = getCollectionName ( element . getClass ( ) ) ;
String collection = entity . getCollection ( ) ;
List < T > collectionElements = elementsByCollection . computeIfAbsent ( collection , k - > new ArrayList < > ( ) ) ;
List < T > collectionElements = elementsByCollection . computeIfAbsent ( collection , k - > new ArrayList < > ( ) ) ;
collectionElements . add ( element ) ;
collectionElements . add ( element ) ;
@ -1507,7 +1505,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
public < T > Mono < T > save ( T objectToSave ) {
public < T > Mono < T > save ( T objectToSave ) {
Assert . notNull ( objectToSave , "Object to save must not be null!" ) ;
Assert . notNull ( objectToSave , "Object to save must not be null!" ) ;
return save ( objectToSave , determineEntityCollectionName ( objectToSave ) ) ;
return save ( objectToSave , getCollectionName ( ClassUtils . getUserClass ( objectToSave ) ) ) ;
}
}
/ *
/ *
@ -1681,7 +1679,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # upsert ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # upsert ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , java . lang . Class )
* /
* /
public Mono < UpdateResult > upsert ( Query query , Update update , Class < ? > entityClass ) {
public Mono < UpdateResult > upsert ( Query query , Update update , Class < ? > entityClass ) {
return doUpdate ( determine CollectionName( entityClass ) , query , update , entityClass , true , false ) ;
return doUpdate ( get CollectionName( entityClass ) , query , update , entityClass , true , false ) ;
}
}
/ *
/ *
@ -1705,7 +1703,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # updateFirst ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # updateFirst ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , java . lang . Class )
* /
* /
public Mono < UpdateResult > updateFirst ( Query query , Update update , Class < ? > entityClass ) {
public Mono < UpdateResult > updateFirst ( Query query , Update update , Class < ? > entityClass ) {
return doUpdate ( determine CollectionName( entityClass ) , query , update , entityClass , false , false ) ;
return doUpdate ( get CollectionName( entityClass ) , query , update , entityClass , false , false ) ;
}
}
/ *
/ *
@ -1729,7 +1727,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # updateMulti ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # updateMulti ( org . springframework . data . mongodb . core . query . Query , org . springframework . data . mongodb . core . query . Update , java . lang . Class )
* /
* /
public Mono < UpdateResult > updateMulti ( Query query , Update update , Class < ? > entityClass ) {
public Mono < UpdateResult > updateMulti ( Query query , Update update , Class < ? > entityClass ) {
return doUpdate ( determine CollectionName( entityClass ) , query , update , entityClass , false , true ) ;
return doUpdate ( get CollectionName( entityClass ) , query , update , entityClass , false , true ) ;
}
}
/ *
/ *
@ -1907,7 +1905,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # remove ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # remove ( org . springframework . data . mongodb . core . query . Query , java . lang . Class )
* /
* /
public Mono < DeleteResult > remove ( Query query , Class < ? > entityClass ) {
public Mono < DeleteResult > remove ( Query query , Class < ? > entityClass ) {
return remove ( query , entityClass , determine CollectionName( entityClass ) ) ;
return remove ( query , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -1977,7 +1975,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findAll ( java . lang . Class )
* @see org . springframework . data . mongodb . core . ReactiveMongoOperations # findAll ( java . lang . Class )
* /
* /
public < T > Flux < T > findAll ( Class < T > entityClass ) {
public < T > Flux < T > findAll ( Class < T > entityClass ) {
return findAll ( entityClass , determine CollectionName( entityClass ) ) ;
return findAll ( entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -2005,7 +2003,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* /
* /
@Override
@Override
public < T > Flux < T > findAllAndRemove ( Query query , Class < T > entityClass ) {
public < T > Flux < T > findAllAndRemove ( Query query , Class < T > entityClass ) {
return findAllAndRemove ( query , entityClass , determine CollectionName( entityClass ) ) ;
return findAllAndRemove ( query , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -2023,7 +2021,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* /
* /
@Override
@Override
public < T > Flux < T > tail ( Query query , Class < T > entityClass ) {
public < T > Flux < T > tail ( Query query , Class < T > entityClass ) {
return tail ( query , entityClass , determine CollectionName( entityClass ) ) ;
return tail ( query , entityClass , get CollectionName( entityClass ) ) ;
}
}
/ *
/ *
@ -2105,7 +2103,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
public < T > Flux < T > mapReduce ( Query filterQuery , Class < ? > domainType , Class < T > resultType , String mapFunction ,
public < T > Flux < T > mapReduce ( Query filterQuery , Class < ? > domainType , Class < T > resultType , String mapFunction ,
String reduceFunction , MapReduceOptions options ) {
String reduceFunction , MapReduceOptions options ) {
return mapReduce ( filterQuery , domainType , determine CollectionName( domainType ) , resultType , mapFunction ,
return mapReduce ( filterQuery , domainType , get CollectionName( domainType ) , resultType , mapFunction ,
reduceFunction , options ) ;
reduceFunction , options ) ;
}
}
@ -2742,25 +2740,6 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
return type = = null ? null : mappingContext . getPersistentEntity ( type ) ;
return type = = null ? null : mappingContext . getPersistentEntity ( type ) ;
}
}
private < T > String determineEntityCollectionName ( @Nullable T obj ) {
if ( null ! = obj ) {
return determineCollectionName ( obj . getClass ( ) ) ;
}
return null ;
}
String determineCollectionName ( @Nullable Class < ? > entityClass ) {
if ( entityClass = = null ) {
throw new InvalidDataAccessApiUsageException (
"No class parameter provided, entity collection can't be determined!" ) ;
}
return mappingContext . getRequiredPersistentEntity ( entityClass ) . getCollection ( ) ;
}
private static MappingMongoConverter getDefaultMongoConverter ( ) {
private static MappingMongoConverter getDefaultMongoConverter ( ) {
MongoCustomConversions conversions = new MongoCustomConversions ( Collections . emptyList ( ) ) ;
MongoCustomConversions conversions = new MongoCustomConversions ( Collections . emptyList ( ) ) ;