@Repository public class PersonRepository { @Autowired MongoTemplate mongoTemplate; public long countAllPersons() { return mongoTemplate.count(null, Person.class); } }
@Override public long count(final Query query, String collectionName) { return count(query, null, collectionName); }
@Override public long count(Query query, Class<?> entityClass) { Assert.notNull(entityClass, "Entity class must not be null!"); return count(query, entityClass, operations.determineCollectionName(entityClass)); }
@Override public long count() { return template.count(query, domainType, getCollectionName()); }
protected long count(Query query) { return mongoTemplate.count(query, getDocumentClass()); }
@Override public long count(final Query query, String collectionName) { return count(query, null, collectionName); }
baseQuery.addCriteria(new Criteria("transId").is(query.getTransId())); final long totalCount = mongoTemplate.count(baseQuery, mongoTableName); if (totalCount <= 0) { return voCommonPager;
baseQuery.addCriteria(new Criteria("retriedCount").lt(query.getRetry())); final long totalCount = mongoTemplate.count(baseQuery, mongoTableName); if (totalCount <= 0) { return voCommonPager;
baseQuery.addCriteria(new Criteria("retriedCount").lt(query.getRetry())); final long totalCount = mongoTemplate.count(baseQuery, mongoTableName); if (totalCount <= 0) { return voCommonPager;
@Override public int messageGroupSize(Object groupId) { long lCount = this.mongoTemplate.count(groupIdQuery(groupId), this.collectionName); Assert.isTrue(lCount <= Integer.MAX_VALUE, "Message count is out of Integer's range"); return (int) lCount; }
@Override public long count(Query query, Class<?> entityClass) { Assert.notNull(entityClass, "Entity class must not be null!"); return count(query, entityClass, operations.determineCollectionName(entityClass)); }
@Override public long count() { return template.count(query, domainType, getCollectionName()); }
@Override public int messageGroupSize(Object groupId) { long lCount = this.template.count(new Query(Criteria.where(GROUP_ID_KEY).is(groupId)), this.collectionName); Assert.isTrue(lCount <= Integer.MAX_VALUE, "Message count is out of Integer's range"); return (int) lCount; }
@Override public List<PersonEntity> findWithPageByParams(Map params) { Query query = new Query(); MongoDBPageable pageable = new MongoDBPageable(2); Iterator<String> iterator = params.keySet().iterator(); while (iterator.hasNext()) { String key = iterator.next(); query.addCriteria(Criteria.where(key).lt(params.get(key))); } Long allcount = mongoTemplate.count(query, PersonEntity.class); List<PersonEntity> list = mongoTemplate.find(query.with(pageable), PersonEntity.class); Page<PersonEntity> page = new PageImpl<PersonEntity>(list, pageable, allcount); return page.getContent(); } }
@Override @ManagedAttribute public int getMessageCountForAllMessageGroups() { Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true) .and(MessageDocumentFields.GROUP_ID).exists(true)); long count = this.mongoTemplate.count(query, this.collectionName); Assert.isTrue(count <= Integer.MAX_VALUE, "Message count is out of Integer's range"); return (int) count; }
@Override @ManagedAttribute public int getMessageCountForAllMessageGroups() { Query query = Query.query(Criteria.where(MessageDocumentFields.MESSAGE_ID).exists(true) .and(MessageDocumentFields.GROUP_ID).exists(true)); long count = this.template.count(query, this.collectionName); Assert.isTrue(count <= Integer.MAX_VALUE, "Message count is out of Integer's range"); return (int) count; }
@Override public Long countCriteria(CriteriaQuery query) { Query mongoQuery = buildQuery(query); return mongoTemplate.count(mongoQuery, ObservationCriterion.class); }
/** * Count the total number of objects in the collection * * @return the total number of objects */ @Override public long count() { long items = this.mongoTemplate.count(new Query(), this.entityClass); return items; }
@Override public int messageGroupSize(Object groupId) { long lCount = this.mongoTemplate.count(groupIdQuery(groupId), this.collectionName); Assert.isTrue(lCount <= Integer.MAX_VALUE, "Message count is out of Integer's range"); return (int) lCount; }
@Override public boolean hasLogs(Iterable<TestItem> items) { Query query = query(where(ITEM_REFERENCE).in(DbUtils.toIds(items))); return mongoTemplate.count(query, Log.class) > 0; }