@Override protected OfBizListIterator createListIterator() { return ofBizDelegator.findListIteratorByCondition(AttachmentConstants.ATTACHMENT_ENTITY_NAME, null, null, null, null, EntityFindOptions.findOptions().forwardOnly().readOnly()); }
/** * Public method used internally, not safe to override. */ @Override public boolean atLeastOneIssueExists() { OfBizListIterator iterator = null; try { iterator = ofBizDelegator.findListIteratorByCondition(Entity.Name.ISSUE, null, null, of("id"), of("id"), EntityFindOptions.findOptions().maxResults(1)); return iterator.next() != null; } finally { if (iterator != null) { iterator.close(); } } }
@Override public boolean hasUnassignedIssues() { OfBizListIterator unassignedIssuesIt = ofBizDelegator.findListIteratorByCondition(Entity.Name.ISSUE, new EntityFieldMap(unassignedCondition, EntityOperator.EQUALS), null, of("id"), of("id"), findOptions().maxResults(1)); try { return unassignedIssuesIt.next() != null; } finally { unassignedIssuesIt.close(); } }
/** * Get the update date of the most recently updated issue from the database * * @return the updated time stamp of the most recently updated issue, otherwise null */ @Nullable private Date getLatestDbDate(final String modifier) { OfBizListIterator iterator = delegator.findListIteratorByCondition( Entity.Name.ISSUE, null, null, null, asList(modifier + " DESC"), findOptions().maxResults(1)); try { for (GenericValue genericValue : iterator) { return genericValue.getTimestamp(modifier); } } finally { iterator.close(); } return null; }
@Override protected IssuesIterable computeNext() { if (maxIdNextBatch < 0) { return endOfData(); } // include up to BATCH_SIZE issues in the next batch EntityCondition idCondition = new EntityExpr("id", LESS_THAN_EQUAL_TO, maxIdNextBatch); EntityCondition where = condition == null ? idCondition : new EntityConditionList(ImmutableList.of(idCondition, condition), EntityOperator.AND); maxIdNextBatch -= batchSize; return new SpyingIssuesIterable(delegator, issueFactory, where, orderBy, findOptions().maxResults(batchSize), spy); } }
/** * Get the id of the latest message in the store for a node.. * That is the message with the highest id or null if there are no messages. * @param nodeId the id of the node. * @return the id of the latest message in the store. */ public Long getLatestMessageByNodeId(String nodeId) { OfBizListIterator iterator = ofBizDelegator.findListIteratorByCondition(ENTITY, new EntityExpr(SOURCE_NODE, EQUALS, nodeId), null, ImmutableList.of(ID), ImmutableList.of(ID + " DESC"), EntityFindOptions.findOptions().maxResults(1)); try { for (GenericValue gV : iterator) { return gV.getLong(ID); } return null; } finally { if (iterator != null) { iterator.close(); } } }
asList(CREATED + " DESC"), findOptions().maxResults(1));
EntityFindOptions getFindOptions() { final DatabaseConfig dbConfig = databaseConfigurationManager.getDatabaseConfiguration(); int fetchSize = getIntProperty(applicationProperties, APKeys.Export.FETCH_SIZE, -1); if (fetchSize == -1) { if (dbConfig.isMySql()) { // JRA-28591 Use streaming mode on MySQL to stop OOMEs. Nothing else seems to do any good. :( fetchSize = Integer.MIN_VALUE; } else { fetchSize = DEFAULT_FETCH_SIZE; } } return findOptions().fetchSize(fetchSize); }
private Collection<Long> findMostRecentlyUpdatedIssueIdsByUsers(Collection<Long> projects, @Nonnull Collection<String> userkeys, int maxResults) { final Set<Long> issueIds = new LinkedHashSet<Long>(); OfBizListIterator changeGroupIssueViewIt = null; OfBizListIterator actionIssueViewIt = null; try { // filter by project and username EntityCondition entityCondition = new EntityConditionList(ImmutableList.<EntityCondition>of( new EntityExpr("project", IN, projects), new EntityExpr("author", IN, userkeys) ), AND); EntityFindOptions entityFindOptions = findOptions().maxResults(maxResults); //Get changegroup history. changeGroupIssueViewIt = ofBizDelegator.findListIteratorByCondition("ChangeGroupIssueView", entityCondition, null, FIELDS_TO_SELECT, ImmutableList.of("created DESC"), entityFindOptions); issueIds.addAll(extractIssueIds(maxResults, changeGroupIssueViewIt)); //Get comment history. actionIssueViewIt = ofBizDelegator.findListIteratorByCondition("ActionIssueView", entityCondition, null, FIELDS_TO_SELECT, ImmutableList.of("created DESC"), entityFindOptions); issueIds.addAll(extractIssueIds(maxResults, actionIssueViewIt)); return issueIds; } finally { // close the iterators to avoid connection leaks if (actionIssueViewIt != null) { actionIssueViewIt.close(); } if (changeGroupIssueViewIt != null) { changeGroupIssueViewIt.close(); } } }
try rows = ofBizDelegator.findListIteratorByCondition(entityName, null, null, null, null, EntityFindOptions.findOptions().fetchSize(1)); for (GenericValue row : rows)
@Override public HealthStatus check() { // any SELECT will do, as long as we hit the database. try { final OfBizListIterator rows = ofBizDelegator.findListIteratorByCondition(ENTITY_NAME, null, null, null, null, EntityFindOptions.findOptions().fetchSize(1)); try { for (final GenericValue row : rows) { // make sure we consume all the results to keep all db drivers happy log.trace("addHealthCheckInfo: select from {} limit 1: {}", ENTITY_NAME, row); } } finally { rows.close(); } return healthStatusFactory.healthy(); } catch (DataAccessException e) { return healthStatusFactory.failed(e.getMessage()); } } }
final List<String> orderBy, final String lockFieldName, final Transformation transformation) throws GenericEntityException { final EntityFindOptions findOptions = EntityFindOptions.findOptions(); final ModelField lockField = modelEntity.getField(lockFieldName); try {