com.haulmont.cuba.core.Query.setMaxResults()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(254)

本文整理了Java中com.haulmont.cuba.core.Query.setMaxResults方法的一些代码示例,展示了Query.setMaxResults的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setMaxResults方法的具体详情如下:
包路径:com.haulmont.cuba.core.Query
类名称:Query
方法名:setMaxResults

Query.setMaxResults介绍

[英]Set the maximum number of results to retrieve.
[中]设置要检索的最大结果数。

代码示例

代码示例来源:origin: com.haulmont.cuba/cuba-core

query.setMaxResults(maxResults);

代码示例来源:origin: com.haulmont.cuba/cuba-core

protected boolean referenceExists(String entityName, MetaProperty property) {
  String template = property.getRange().getCardinality().isMany() ?
      "select count(e) from %s e join e.%s c where c." + primaryKeyName + "= ?1" :
      "select count(e) from %s e where e.%s." + primaryKeyName + " = ?1";
  String qstr = String.format(template, entityName, property.getName());
  Query query = entityManager.createQuery(qstr);
  query.setParameter(1, entity.getId());
  query.setMaxResults(1);
  Long count = (Long) query.getSingleResult();
  return count > 0;
}

代码示例来源:origin: com.haulmont.cuba/cuba-core

protected boolean isCollectionEmpty(MetaProperty property) {
  MetaProperty inverseProperty = property.getInverse();
  if (inverseProperty == null) {
    log.warn("Inverse property not found for property {}", property);
    Collection<Entity> value = entity.getValue(property.getName());
    return value == null || value.isEmpty();
  }
  String invPropName = inverseProperty.getName();
  String collectionPkName = metadata.getTools().getPrimaryKeyName(property.getRange().asClass());
  String qlStr = "select e." + collectionPkName + " from " + property.getRange().asClass().getName() +
      " e where e." + invPropName + "." + primaryKeyName + " = ?1";
  Query query = entityManager.createQuery(qlStr);
  query.setParameter(1, entity.getId());
  query.setMaxResults(1);
  List<Entity> list = query.getResultList();
  return list.isEmpty();
}

代码示例来源:origin: com.haulmont.fts/fts-core

List loadingResult = storeEm.createQuery(getQueryString())
        .setParameter("ids", loadingIds)
        .setMaxResults(ftsConfig.getReindexBatchSize())
        .getResultList();
    result.addAll(loadingResult);
if (excludeFromQueue) {
  query.setParameter("entityName", metaClass.getName());
  query.setMaxResults(ftsConfig.getReindexBatchSize());

代码示例来源:origin: com.haulmont.reports/reports-core

query.setMaxResults(parameterPrototype.getMaxResults());
} else {
  Configuration configuration = AppBeans.get(Configuration.NAME);
  ReportingConfig config = configuration.getConfig(ReportingConfig.class);
  query.setMaxResults(config.getParameterPrototypeQueryLimit());

代码示例来源:origin: com.haulmont.cuba/cuba-core

query.setFirstResult(contextQuery.getFirstResult());
if (contextQuery.getMaxResults() != 0)
  query.setMaxResults(contextQuery.getMaxResults());

代码示例来源:origin: com.haulmont.cuba/cuba-core

protected Query createQuery(EntityManager em, LoadContext context, boolean singleResult) {
  LoadContext.Query contextQuery = context.getQuery();
  RdbmsQueryBuilder queryBuilder = AppBeans.get(RdbmsQueryBuilder.NAME);
  queryBuilder.init(
      contextQuery == null ? null : contextQuery.getQueryString(),
      contextQuery == null ? null : contextQuery.getCondition(),
      contextQuery == null ? null : contextQuery.getSort(),
      contextQuery == null ? null : contextQuery.getParameters(),
      contextQuery == null ? null : contextQuery.getNoConversionParams(),
      context.getId(), context.getMetaClass()
  );
  queryBuilder.setSingleResult(singleResult);
  if (!context.getPrevQueries().isEmpty()) {
    log.debug("Restrict query by previous results");
    queryBuilder.restrictByPreviousResults(userSessionSource.getUserSession().getId(), context.getQueryKey());
  }
  Query query = queryBuilder.getQuery(em);
  if (contextQuery != null) {
    if (contextQuery.getFirstResult() != 0)
      query.setFirstResult(contextQuery.getFirstResult());
    if (contextQuery.getMaxResults() != 0)
      query.setMaxResults(contextQuery.getMaxResults());
    if (contextQuery.isCacheable()) {
      query.setCacheable(contextQuery.isCacheable());
    }
  }
  return query;
}

相关文章