org.springframework.data.mongodb.core.MongoTemplate.createCollection()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(253)

本文整理了Java中org.springframework.data.mongodb.core.MongoTemplate.createCollection()方法的一些代码示例,展示了MongoTemplate.createCollection()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MongoTemplate.createCollection()方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.MongoTemplate
类名称:MongoTemplate
方法名:createCollection

MongoTemplate.createCollection介绍

暂无

代码示例

代码示例来源: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> MongoCollection<Document> createCollection(Class<T> entityClass) {
  return createCollection(operations.determineCollectionName(entityClass));
}

代码示例来源:origin: spring-projects/spring-data-mongodb

mongoTemplate.createCollection(collName);

代码示例来源:origin: org.springframework.data/spring-data-mongodb

public <T> MongoCollection<Document> createCollection(Class<T> entityClass) {
  return createCollection(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: stackoverflow.com

SpringMongoConfig config = new SpringMongoConfig();
MongoTemplate template = config.mongoTemplate();
template.createCollection("someCollection");

代码示例来源: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: org.springframework.data/spring-data-mongodb-cross-store

mongoTemplate.createCollection(collName);

相关文章