/** * Sets the limit to apply. * * @param limit the limit, which may be null * @return this * @mongodb.driver.manual reference/method/cursor.limit/#cursor.limit Limit */ public FindOptions limit(final int limit) { options.limit(limit); return this; }
/** * Limits the number of elements returned. Note: parameter {@code limit} should be positive, although a negative value is * supported for legacy reason. Passing a negative value will call {@link DBCursor#batchSize(int)} which is the preferred method. * * @param limit the number of elements to return * @return a cursor to iterate the results * @mongodb.driver.manual reference/method/cursor.limit Limit */ public DBCursor limit(final int limit) { findOptions.limit(limit); return this; }
/** * Copy this DBCollectionFindOptions instance into a new instance. * * @return the new DBCollectionFindOptions with the same settings as this instance. */ public DBCollectionFindOptions copy() { DBCollectionFindOptions copiedOptions = new DBCollectionFindOptions(); copiedOptions.batchSize(batchSize); copiedOptions.limit(limit); copiedOptions.modifiers(modifiers); copiedOptions.projection(projection); copiedOptions.maxTime(maxTimeMS, TimeUnit.MILLISECONDS); copiedOptions.maxAwaitTime(maxAwaitTimeMS, TimeUnit.MILLISECONDS); copiedOptions.skip(skip); copiedOptions.sort(sort); copiedOptions.cursorType(cursorType); copiedOptions.noCursorTimeout(noCursorTimeout); copiedOptions.oplogReplay(oplogReplay); copiedOptions.partial(partial); copiedOptions.readPreference(readPreference); copiedOptions.readConcern(readConcern); copiedOptions.collation(collation); copiedOptions.comment(comment); copiedOptions.hint(hint); copiedOptions.max(max); copiedOptions.min(min); copiedOptions.returnKey(returnKey); copiedOptions.showRecordId(showRecordId); return copiedOptions; }
/** * Limits the number of elements returned. Note: parameter {@code limit} should be positive, although a negative value is * supported for legacy reason. Passing a negative value will call {@link DBCursor#batchSize(int)} which is the preferred method. * * @param limit the number of elements to return * @return a cursor to iterate the results * @mongodb.driver.manual reference/method/cursor.limit Limit */ public DBCursor limit(final int limit) { findOptions.limit(limit); return this; }
/** * Sets the limit to apply. * * @param limit the limit, which may be null * @return this * @mongodb.driver.manual reference/method/cursor.limit/#cursor.limit Limit */ public FindOptions limit(final int limit) { options.limit(limit); return this; }
@Override public List<T> results(){ DBObject projection; if(fieldsSpecified){ projection = fields; }else{ projection = dao.getKeyFields(); } DBCollectionFindOptions options = new DBCollectionFindOptions(); options.projection(projection); if(maxTimeMS > 0){ options.maxTime(maxTimeMS, TimeUnit.MILLISECONDS); } if(orderBy != null){ options.sort(SortUtil.getSort(orderBy)); } if(pageNumber>0 && pageSize>0){ options.skip((pageNumber-1) * pageSize); options.limit(pageSize); } DBCollection coll = dao.getCollection(); DBCursor cursor = coll.find(condition, options); return MapperUtil.toList(dao.getEntityClass(), cursor, withoutCascade); }
/** * Copy this DBCollectionFindOptions instance into a new instance. * * @return the new DBCollectionFindOptions with the same settings as this instance. */ public DBCollectionFindOptions copy() { DBCollectionFindOptions copiedOptions = new DBCollectionFindOptions(); copiedOptions.batchSize(batchSize); copiedOptions.limit(limit); copiedOptions.modifiers(modifiers); copiedOptions.projection(projection); copiedOptions.maxTime(maxTimeMS, TimeUnit.MILLISECONDS); copiedOptions.maxAwaitTime(maxAwaitTimeMS, TimeUnit.MILLISECONDS); copiedOptions.skip(skip); copiedOptions.sort(sort); copiedOptions.cursorType(cursorType); copiedOptions.noCursorTimeout(noCursorTimeout); copiedOptions.oplogReplay(oplogReplay); copiedOptions.partial(partial); copiedOptions.readPreference(readPreference); copiedOptions.readConcern(readConcern); copiedOptions.collation(collation); copiedOptions.comment(comment); copiedOptions.hint(hint); copiedOptions.max(max); copiedOptions.min(min); copiedOptions.returnKey(returnKey); copiedOptions.showRecordId(showRecordId); return copiedOptions; }