本文整理了Java中org.springframework.data.mongodb.core.MongoTemplate.collectionExists()
方法的一些代码示例,展示了MongoTemplate.collectionExists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MongoTemplate.collectionExists()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.MongoTemplate
类名称:MongoTemplate
方法名:collectionExists
暂无
代码示例来源:origin: kaaproject/kaa
@Override
public void createCollection(String collectionName) {
try {
if (!mongoTemplate.collectionExists(collectionName)) {
mongoTemplate.createCollection(collectionName);
}
} catch (UncategorizedMongoDbException ex) {
LOG.warn("Failed to create collection {} due to", collectionName, ex);
}
}
代码示例来源:origin: spring-projects/spring-data-mongodb
public <T> boolean collectionExists(Class<T> entityClass) {
return collectionExists(operations.determineCollectionName(entityClass));
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
public <T> boolean collectionExists(Class<T> entityClass) {
return collectionExists(operations.determineCollectionName(entityClass));
}
代码示例来源:origin: 3zamn/kingMicro
@Override
public void createCollection(String collectionName) {
if (StringUtils.isEmpty(collectionName)) {
collectionName = clz.getSimpleName();
}
if (!mongoTemplate.collectionExists(collectionName)) {
mongoTemplate.createCollection(collectionName);
}
};
代码示例来源:origin: 3zamn/kingMicro
@Override
public void dropPersonCollection(String collectionName) {
if (StringUtils.isEmpty(collectionName)) {
collectionName = clz.getSimpleName();
}
if (mongoTemplate.collectionExists(collectionName)) {
mongoTemplate.dropCollection(collectionName);
}
};
代码示例来源:origin: bsinno/iot-things-examples
@PostConstruct
public void start() {
mongoTemplate.setWriteResultChecking(WriteResultChecking.EXCEPTION);
if (!mongoTemplate.collectionExists("history")) {
mongoTemplate.createCollection("history");
}
Thread thread = new Thread(this);
thread.start();
LOGGER.info("Historian collector started");
}
代码示例来源:origin: pl.edu.icm.polindex/polindex-tools
@PostConstruct
public void updateMongoSchema() {
Preconditions.checkState(StringUtils.isNotBlank(collectionName), "error starting Store, collectionName is null");
logger.info("updating Mongo schema ...");
if (!mongoTemplate.collectionExists(collectionName)) {
logger.info("create collection '"+collectionName+"'");
mongoTemplate.createCollection(collectionName);
}
//tags_idx
BasicDBObject keys = new BasicDBObject(F_TAGS, 1);
mongoTemplate.getCollection(collectionName).ensureIndex(keys,
collectionName+"_tags_idx",
false);
//hist collection
if (keepHistory) {
collectionNameHist = collectionName + "_hist";
if (!mongoTemplate.collectionExists(collectionNameHist)) {
logger.info("create collection '"+collectionNameHist+"'");
mongoTemplate.createCollection(collectionNameHist);
}
keys = new BasicDBObject(F_RECORD_FK_ID, 1);
mongoTemplate.getCollection(collectionNameHist).ensureIndex(keys,
collectionNameHist+"_record_fk_idx",
false);
}
}
代码示例来源:origin: pl.edu.icm.synat/synat-core-services-impl
@Override
public void initializeResources() {
if (!mongoTemplate.collectionExists(collectionName)) {
mongoTemplate.createCollection(collectionName);
}
hashingElementManager.upgrade();
upgradeIndexes();
}
代码示例来源:origin: pl.edu.icm.synat/synat-core-services-impl
@Override
public ResourcesValidationResult validateResources() {
RESULT result;
if (mongoTemplate.collectionExists(collectionName)) {
if (hashingElementManager.needsUpgrade() || needsUpgradeIndexes()) {
result = ResourcesValidationResult.RESULT.NEEDS_UPGRADE;
} else {
result = ResourcesValidationResult.RESULT.VALID;
}
} else {
result = ResourcesValidationResult.RESULT.NOT_INITIALIZED;
}
return new ResourcesValidationResult(result);
}
内容来源于网络,如有侵权,请联系作者删除!