2012-07-25 67 views
0

我想創建一個使用mongoTemplate進行日誌記錄的封頂集合。但是,我的收藏數量正在超出我作爲參數傳遞的大小。任何人都可以請幫忙。使用MongoDB和SpringData封頂的集合

public synchronized MongoTemplate getTemplate() { 

    if (template == null) { 
     Mongo mongo = null; 
     mongo = new Mongo(addrs); 
     template = new MongoTemplate(mongo, this.dbName); 

     if(!template.collectionExists(HttpRequestEntity.class)){ 
      CollectionOptions options = new CollectionOptions(4,4,true); 
      template.createCollection(HttpRequestEntity.class, options); 
     } 
    } 

    return template; 
} 

爲了節省我打電話保存此模板實例

getTemplate().save(entity); 

回答

1

得到它的工作後,我刪除了蒙戈控制檯集合。我想這是使用舊元數據template.collectionExists(HttpRequestEntity.class)返回true。