DATAMONGO-2296 - Consistent use of getCollectionName(Class) throughout MongoTemplate.
Original pull request: #768.
This commit is contained in:
committed by
Mark Paluch
parent
676ee80434
commit
5f6291ed32
@@ -378,7 +378,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Override
|
||||
public <T> CloseableIterator<T> stream(final Query query, final Class<T> entityType) {
|
||||
|
||||
return stream(query, entityType, operations.determineCollectionName(entityType));
|
||||
return stream(query, entityType, getCollectionName(entityType));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -528,7 +528,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
public <T> T execute(Class<?> entityClass, CollectionCallback<T> callback) {
|
||||
|
||||
Assert.notNull(entityClass, "EntityClass must not be null!");
|
||||
return execute(operations.determineCollectionName(entityClass), callback);
|
||||
return execute(getCollectionName(entityClass), callback);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -599,7 +599,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Nullable CollectionOptions collectionOptions) {
|
||||
|
||||
Assert.notNull(entityClass, "EntityClass must not be null!");
|
||||
return doCreateCollection(operations.determineCollectionName(entityClass),
|
||||
return doCreateCollection(getCollectionName(entityClass),
|
||||
convertToDocument(collectionOptions, entityClass));
|
||||
}
|
||||
|
||||
@@ -645,7 +645,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#getCollection(java.lang.Class)
|
||||
*/
|
||||
public <T> boolean collectionExists(Class<T> entityClass) {
|
||||
return collectionExists(operations.determineCollectionName(entityClass));
|
||||
return collectionExists(getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -674,7 +674,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#dropCollection(java.lang.Class)
|
||||
*/
|
||||
public <T> void dropCollection(Class<T> entityClass) {
|
||||
dropCollection(operations.determineCollectionName(entityClass));
|
||||
dropCollection(getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -710,7 +710,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#indexOps(java.lang.Class)
|
||||
*/
|
||||
public IndexOperations indexOps(Class<?> entityClass) {
|
||||
return new DefaultIndexOperations(this, operations.determineCollectionName(entityClass), entityClass);
|
||||
return new DefaultIndexOperations(this, getCollectionName(entityClass), entityClass);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -726,7 +726,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
* @see org.springframework.data.mongodb.core.ExecutableInsertOperation#bulkOps(org.springframework.data.mongodb.core.BulkMode, java.lang.Class)
|
||||
*/
|
||||
public BulkOperations bulkOps(BulkMode bulkMode, Class<?> entityClass) {
|
||||
return bulkOps(bulkMode, entityClass, operations.determineCollectionName(entityClass));
|
||||
return bulkOps(bulkMode, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -761,7 +761,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T findOne(Query query, Class<T> entityClass) {
|
||||
return findOne(query, entityClass, operations.determineCollectionName(entityClass));
|
||||
return findOne(query, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -783,7 +783,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
@Override
|
||||
public boolean exists(Query query, Class<?> entityClass) {
|
||||
return exists(query, entityClass, operations.determineCollectionName(entityClass));
|
||||
return exists(query, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -813,7 +813,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> find(Query query, Class<T> entityClass) {
|
||||
return find(query, entityClass, operations.determineCollectionName(entityClass));
|
||||
return find(query, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -834,7 +834,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T findById(Object id, Class<T> entityClass) {
|
||||
return findById(id, entityClass, operations.determineCollectionName(entityClass));
|
||||
return findById(id, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -856,7 +856,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> findDistinct(Query query, String field, Class<?> entityClass, Class<T> resultClass) {
|
||||
return findDistinct(query, field, operations.determineCollectionName(entityClass), entityClass, resultClass);
|
||||
return findDistinct(query, field, getCollectionName(entityClass), entityClass, resultClass);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -939,7 +939,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
@Override
|
||||
public <T> GeoResults<T> geoNear(NearQuery near, Class<T> entityClass) {
|
||||
return geoNear(near, entityClass, operations.determineCollectionName(entityClass));
|
||||
return geoNear(near, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -962,7 +962,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
Assert.notNull(returnType, "ReturnType must not be null!");
|
||||
|
||||
String collection = StringUtils.hasText(collectionName) ? collectionName
|
||||
: operations.determineCollectionName(domainType);
|
||||
: getCollectionName(domainType);
|
||||
Document nearDocument = near.toDocument();
|
||||
|
||||
Document command = new Document("geoNear", collection);
|
||||
@@ -1016,7 +1016,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Override
|
||||
public <T> T findAndModify(Query query, Update update, Class<T> entityClass) {
|
||||
return findAndModify(query, update, new FindAndModifyOptions(), entityClass,
|
||||
operations.determineCollectionName(entityClass));
|
||||
getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1028,7 +1028,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T findAndModify(Query query, Update update, FindAndModifyOptions options, Class<T> entityClass) {
|
||||
return findAndModify(query, update, options, entityClass, operations.determineCollectionName(entityClass));
|
||||
return findAndModify(query, update, options, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1092,7 +1092,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T findAndRemove(Query query, Class<T> entityClass) {
|
||||
return findAndRemove(query, entityClass, operations.determineCollectionName(entityClass));
|
||||
return findAndRemove(query, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -1111,7 +1111,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
public long count(Query query, Class<?> entityClass) {
|
||||
|
||||
Assert.notNull(entityClass, "Entity class must not be null!");
|
||||
return count(query, entityClass, operations.determineCollectionName(entityClass));
|
||||
return count(query, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1255,7 +1255,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
Assert.notNull(batchToSave, "BatchToSave must not be null!");
|
||||
|
||||
return (Collection<T>) doInsertBatch(operations.determineCollectionName(entityClass), batchToSave,
|
||||
return (Collection<T>) doInsertBatch(getCollectionName(entityClass), batchToSave,
|
||||
this.mongoConverter);
|
||||
}
|
||||
|
||||
@@ -1511,7 +1511,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
@Override
|
||||
public UpdateResult upsert(Query query, Update update, Class<?> entityClass) {
|
||||
return doUpdate(operations.determineCollectionName(entityClass), query, update, entityClass, true, false);
|
||||
return doUpdate(getCollectionName(entityClass), query, update, entityClass, true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1529,7 +1529,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
@Override
|
||||
public UpdateResult updateFirst(Query query, Update update, Class<?> entityClass) {
|
||||
return doUpdate(operations.determineCollectionName(entityClass), query, update, entityClass, false, false);
|
||||
return doUpdate(getCollectionName(entityClass), query, update, entityClass, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1547,7 +1547,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
@Override
|
||||
public UpdateResult updateMulti(Query query, Update update, Class<?> entityClass) {
|
||||
return doUpdate(operations.determineCollectionName(entityClass), query, update, entityClass, false, true);
|
||||
return doUpdate(getCollectionName(entityClass), query, update, entityClass, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1667,7 +1667,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
@Override
|
||||
public DeleteResult remove(Query query, Class<?> entityClass) {
|
||||
return remove(query, entityClass, operations.determineCollectionName(entityClass));
|
||||
return remove(query, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1738,7 +1738,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
|
||||
@Override
|
||||
public <T> List<T> findAll(Class<T> entityClass) {
|
||||
return findAll(entityClass, operations.determineCollectionName(entityClass));
|
||||
return findAll(entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1935,7 +1935,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
*/
|
||||
@Override
|
||||
public <O> AggregationResults<O> aggregate(TypedAggregation<?> aggregation, Class<O> outputType) {
|
||||
return aggregate(aggregation, operations.determineCollectionName(aggregation.getInputType()), outputType);
|
||||
return aggregate(aggregation, getCollectionName(aggregation.getInputType()), outputType);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -1958,7 +1958,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Override
|
||||
public <O> AggregationResults<O> aggregate(Aggregation aggregation, Class<?> inputType, Class<O> outputType) {
|
||||
|
||||
return aggregate(aggregation, operations.determineCollectionName(inputType), outputType,
|
||||
return aggregate(aggregation, getCollectionName(inputType), outputType,
|
||||
new TypeBasedAggregationOperationContext(inputType, mappingContext, queryMapper));
|
||||
}
|
||||
|
||||
@@ -1989,7 +1989,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
*/
|
||||
@Override
|
||||
public <O> CloseableIterator<O> aggregateStream(TypedAggregation<?> aggregation, Class<O> outputType) {
|
||||
return aggregateStream(aggregation, operations.determineCollectionName(aggregation.getInputType()), outputType);
|
||||
return aggregateStream(aggregation, getCollectionName(aggregation.getInputType()), outputType);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -1998,7 +1998,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
@Override
|
||||
public <O> CloseableIterator<O> aggregateStream(Aggregation aggregation, Class<?> inputType, Class<O> outputType) {
|
||||
|
||||
return aggregateStream(aggregation, operations.determineCollectionName(inputType), outputType,
|
||||
return aggregateStream(aggregation, getCollectionName(inputType), outputType,
|
||||
new TypeBasedAggregationOperationContext(inputType, mappingContext, queryMapper));
|
||||
}
|
||||
|
||||
@@ -2024,7 +2024,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> findAllAndRemove(Query query, Class<T> entityClass) {
|
||||
return findAllAndRemove(query, entityClass, operations.determineCollectionName(entityClass));
|
||||
return findAllAndRemove(query, entityClass, getCollectionName(entityClass));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
Reference in New Issue
Block a user