Skip to content

DATAMONGO-2296 - Consistent use of getCollectionName(Class) throughout MongoTemplate. #768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.2.0.BUILD-SNAPSHOT</version>
<version>2.2.0.DATAMONGO-2296-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data MongoDB</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.2.0.BUILD-SNAPSHOT</version>
<version>2.2.0.DATAMONGO-2296-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.2.0.BUILD-SNAPSHOT</version>
<version>2.2.0.DATAMONGO-2296-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb-parent</artifactId>
<version>2.2.0.BUILD-SNAPSHOT</version>
<version>2.2.0.DATAMONGO-2296-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public MongoConverter getConverter() {
@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));
}

/*
Expand Down Expand Up @@ -565,7 +565,7 @@ public <T> T execute(DbCallback<T> action) {
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);
}

/*
Expand Down Expand Up @@ -643,7 +643,7 @@ public <T> MongoCollection<Document> createCollection(Class<T> entityClass,
() -> operations.forType(entityClass).getCollation()) //
.map(options::collation).orElse(options);

return doCreateCollection(operations.determineCollectionName(entityClass), convertToDocument(options, entityClass));
return doCreateCollection(getCollectionName(entityClass), convertToDocument(options, entityClass));
}

/*
Expand Down Expand Up @@ -685,7 +685,7 @@ public MongoCollection<Document> getCollection(final String collectionName) {
* @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));
}

/*
Expand Down Expand Up @@ -713,7 +713,7 @@ public boolean collectionExists(final String collectionName) {
* @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));
}

/*
Expand Down Expand Up @@ -749,7 +749,7 @@ public IndexOperations indexOps(String collectionName) {
* @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);
}

/*
Expand All @@ -765,7 +765,7 @@ public BulkOperations bulkOps(BulkMode bulkMode, String collectionName) {
* @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));
}

/*
Expand Down Expand Up @@ -800,7 +800,7 @@ public ScriptOperations scriptOps() {
@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
Expand All @@ -825,7 +825,7 @@ public <T> T findOne(Query query, Class<T> entityClass, String collectionName) {

@Override
public boolean exists(Query query, Class<?> entityClass) {
return exists(query, entityClass, operations.determineCollectionName(entityClass));
return exists(query, entityClass, getCollectionName(entityClass));
}

@Override
Expand Down Expand Up @@ -856,7 +856,7 @@ public boolean exists(Query query, @Nullable Class<?> entityClass, String collec
*/
@Override
public <T> List<T> find(Query query, Class<T> entityClass) {
return find(query, entityClass, operations.determineCollectionName(entityClass));
return find(query, entityClass, getCollectionName(entityClass));
}

/*
Expand All @@ -877,7 +877,7 @@ public <T> List<T> find(Query query, Class<T> entityClass, String collectionName
@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
Expand All @@ -899,7 +899,7 @@ public <T> T findById(Object id, Class<T> entityClass, String collectionName) {
*/
@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);
}

/*
Expand Down Expand Up @@ -986,7 +986,7 @@ private static Class<?> getMostSpecificConversionTargetType(Class<?> userType, C

@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
Expand All @@ -1008,7 +1008,7 @@ public <T> GeoResults<T> geoNear(NearQuery near, Class<?> domainType, String col
Assert.notNull(returnType, "ReturnType must not be null!");

String collection = StringUtils.hasText(collectionName) ? collectionName
: operations.determineCollectionName(domainType);
: getCollectionName(domainType);
String distanceField = operations.nearQueryDistanceFieldName(domainType);

Aggregation $geoNear = TypedAggregation.newAggregation(domainType, Aggregation.geoNear(near, distanceField))
Expand Down Expand Up @@ -1040,7 +1040,7 @@ public <T> GeoResults<T> geoNear(NearQuery near, Class<?> domainType, String col
@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
Expand All @@ -1052,7 +1052,7 @@ public <T> T findAndModify(Query query, Update update, Class<T> entityClass, Str
@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
Expand Down Expand Up @@ -1122,7 +1122,7 @@ public <S, T> T findAndReplace(Query query, S replacement, FindAndReplaceOptions
@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
Expand All @@ -1142,7 +1142,7 @@ public <T> T findAndRemove(Query query, Class<T> entityClass, String collectionN
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
Expand Down Expand Up @@ -1296,7 +1296,7 @@ public <T> Collection<T> insert(Collection<? extends T> batchToSave, Class<?> en

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);
}

Expand Down Expand Up @@ -1557,7 +1557,7 @@ public Object doInCollection(MongoCollection<Document> collection) throws MongoE

@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
Expand All @@ -1575,7 +1575,7 @@ public UpdateResult upsert(Query query, Update update, Class<?> entityClass, Str

@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
Expand All @@ -1593,7 +1593,7 @@ public UpdateResult updateFirst(Query query, Update update, Class<?> entityClass

@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
Expand Down Expand Up @@ -1692,7 +1692,7 @@ public DeleteResult remove(Object object) {

Assert.notNull(object, "Object must not be null!");

return remove(object, operations.determineCollectionName(object.getClass()));
return remove(object, getCollectionName(object.getClass()));
}

@Override
Expand All @@ -1713,7 +1713,7 @@ public DeleteResult remove(Query query, String collectionName) {

@Override
public DeleteResult remove(Query query, Class<?> entityClass) {
return remove(query, entityClass, operations.determineCollectionName(entityClass));
return remove(query, entityClass, getCollectionName(entityClass));
}

@Override
Expand Down Expand Up @@ -1785,7 +1785,7 @@ protected <T> DeleteResult doRemove(final String collectionName, final Query que

@Override
public <T> List<T> findAll(Class<T> entityClass) {
return findAll(entityClass, operations.determineCollectionName(entityClass));
return findAll(entityClass, getCollectionName(entityClass));
}

@Override
Expand Down Expand Up @@ -1988,7 +1988,7 @@ public <T> GroupByResults<T> group(@Nullable Criteria criteria, String inputColl
*/
@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)
Expand All @@ -2011,7 +2011,7 @@ public <O> AggregationResults<O> aggregate(TypedAggregation<?> aggregation, Stri
@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));
}

Expand Down Expand Up @@ -2042,7 +2042,7 @@ public <O> CloseableIterator<O> aggregateStream(TypedAggregation<?> aggregation,
*/
@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)
Expand All @@ -2051,7 +2051,7 @@ public <O> CloseableIterator<O> aggregateStream(TypedAggregation<?> aggregation,
@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));
}

Expand All @@ -2077,7 +2077,7 @@ public <T> List<T> findAllAndRemove(Query query, String collectionName) {
*/
@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)
Expand Down