private DBCollection renameCollection(String oldCollection, String newCollection) { if (!mongoTemplate.collectionExists(oldCollection)) return null; if (mongoTemplate.collectionExists(newCollection)) mongoTemplate.dropCollection(newCollection); DB db = mongoTemplate.getDb(); DBCollection dbCollection = db.getCollection(oldCollection); return dbCollection.rename(newCollection, true); }