List of usage examples for org.springframework.data.mongodb.core MongoTemplate count
@Override public long count(final Query query, String collectionName)
From source file:com.seajas.search.profiler.service.repository.RepositoryService.java
/** * Default constructor./*from w ww . j a v a 2s . c om*/ * * @param dbFactory */ @Autowired public RepositoryService(final MongoDbFactory dbFactory, final MongoTemplate mongoTemplate) { this.gridFs = new GridFS(dbFactory.getDb()); // Initialize the indexes only if there aren't too many documents in the store yet Long currentCount = mongoTemplate.count(new Query(), CompositeEntry.class); // Determine whether the given indexes have been created, and initialize them if necessary if (currentCount <= MAX_INDEX_CREATION_COUNT) for (String index : INDEXES) mongoTemplate.indexOps(CompositeEntry.class).ensureIndex(new Index().on(index, Order.ASCENDING)); this.mongoTemplate = mongoTemplate; }