javax.persistence.Query.getMaxResults()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(458)

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

Query.getMaxResults介绍

[英]The maximum number of results the query object was set to retrieve. Returns Integer.MAX_VALUE if setMaxResults was not applied to the query object.
[中]查询对象设置为检索的最大结果数。如果setMaxResults未应用于查询对象,则返回Integer.MAX_VALUE

代码示例

代码示例来源:origin: spring-projects/spring-data-jpa

/**
 * Restricts the max results of the given {@link Query} if the current {@code tree} marks this {@code query} as
 * limited.
 */
private Query restrictMaxResultsIfNecessary(Query query) {
  if (tree.isLimiting()) {
    if (query.getMaxResults() != Integer.MAX_VALUE) {
      /*
       * In order to return the correct results, we have to adjust the first result offset to be returned if:
       * - a Pageable parameter is present
       * - AND the requested page number > 0
       * - AND the requested page size was bigger than the derived result limitation via the First/Top keyword.
       */
      if (query.getMaxResults() > tree.getMaxResults() && query.getFirstResult() > 0) {
        query.setFirstResult(query.getFirstResult() - (query.getMaxResults() - tree.getMaxResults()));
      }
    }
    query.setMaxResults(tree.getMaxResults());
  }
  if (tree.isExistsProjection()) {
    query.setMaxResults(1);
  }
  return query;
}

代码示例来源:origin: Impetus/Kundera

@Override
public int getMaxResults()
{
  return query.getMaxResults();
}

代码示例来源:origin: org.evolvis.bsi/kolab-ws

@Override
public int
getMaxResults()
{
  return delegate.getMaxResults();
}

代码示例来源:origin: com.kumuluz.ee/kumuluzee-jpa-common

@Override
public int getMaxResults() {
  return query.getMaxResults();
}

代码示例来源:origin: org.wildfly/wildfly-jpa

@Override
public int getMaxResults() {
  return underlyingQuery.getMaxResults();
}

代码示例来源:origin: org.jboss.eap/wildfly-jpa

@Override
public int getMaxResults() {
  return underlyingQuery.getMaxResults();
}

代码示例来源:origin: de.mhus.lib/mhu-lib-persistence

/** {@inheritDoc} */
@Override
public int getMaxResults() {
  return query.getMaxResults();
}

代码示例来源:origin: kumuluz/kumuluzee

@Override
public int getMaxResults() {
  return query.getMaxResults();
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-persistence-jpa20

@Override
public int getMaxResults() {
  return query.getMaxResults();
}

代码示例来源:origin: org.apache.openejb/openejb-core

public int getMaxResults() {
  return query.getMaxResults();
}

代码示例来源:origin: org.apache.tomee/openejb-core

public int getMaxResults() {
  return query.getMaxResults();
}

代码示例来源:origin: org.apache.geronimo.ext.openejb/openejb-core

public int getMaxResults() {
  return query.getMaxResults();
}

代码示例来源:origin: net.sf.tsl2nano/tsl2.nano.serviceaccess

/**
   * helper to log a query with its parameters
   * 
   * @param query query to analyse
   * @return informations of given query
   */
  public static String formatQuery(Query query) {
    final StringBuilder buf = new StringBuilder("\nQuery: ");
    buf.append("hints = " + query.getHints() + ", ");
    buf.append("lockmode = " + query.getLockMode() + ", ");
    buf.append("flushmode = " + query.getFlushMode() + ", ");
    buf.append("maxresults = " + query.getMaxResults()/* + ", "*/);
    //there is a illegalaccess problem on the parameters
//        buf.append("\nparameter:\n");
//        Set<Parameter<?>> parameters = query.getParameters();
//        for (Parameter<?> parameter : parameters) {
//            buf.append("    " + new Bean(parameter) + "\n");
//        }
    return buf.toString();
  }

代码示例来源:origin: org.springframework.data/spring-data-jpa

/**
 * Restricts the max results of the given {@link Query} if the current {@code tree} marks this {@code query} as
 * limited.
 */
private Query restrictMaxResultsIfNecessary(Query query) {
  if (tree.isLimiting()) {
    if (query.getMaxResults() != Integer.MAX_VALUE) {
      /*
       * In order to return the correct results, we have to adjust the first result offset to be returned if:
       * - a Pageable parameter is present
       * - AND the requested page number > 0
       * - AND the requested page size was bigger than the derived result limitation via the First/Top keyword.
       */
      if (query.getMaxResults() > tree.getMaxResults() && query.getFirstResult() > 0) {
        query.setFirstResult(query.getFirstResult() - (query.getMaxResults() - tree.getMaxResults()));
      }
    }
    query.setMaxResults(tree.getMaxResults());
  }
  if (tree.isExistsProjection()) {
    query.setMaxResults(1);
  }
  return query;
}

代码示例来源:origin: com.blazebit/blaze-persistence-integration-spring-data-base

/**
 * Restricts the max results of the given {@link Query} if the current {@code tree} marks this {@code query} as
 * limited.
 *
 * @param query
 * @return
 */
private Query restrictMaxResultsIfNecessary(Query query) {
  if (tree.isLimiting()) {
    if (query.getMaxResults() != Integer.MAX_VALUE) {
      /*
       * In order to return the correct results, we have to adjust the first result offset to be returned if:
       * - a Pageable parameter is present
       * - AND the requested page number > 0
       * - AND the requested page size was bigger than the derived result limitation via the First/Top keyword.
       */
      if (query.getMaxResults() > tree.getMaxResults() && query.getFirstResult() > 0) {
        query.setFirstResult(query.getFirstResult() - (query.getMaxResults() - tree.getMaxResults()));
      }
    }
    query.setMaxResults(tree.getMaxResults());
  }
  return query;
}

代码示例来源:origin: com.blazebit/blaze-persistence-integration-spring-data

/**
 * Restricts the max results of the given {@link Query} if the current {@code tree} marks this {@code query} as
 * limited.
 *
 * @param query
 * @return
 */
private Query restrictMaxResultsIfNecessary(Query query) {
  if (tree.isLimiting()) {
    if (query.getMaxResults() != Integer.MAX_VALUE) {
      /*
       * In order to return the correct results, we have to adjust the first result offset to be returned if:
       * - a Pageable parameter is present
       * - AND the requested page number > 0
       * - AND the requested page size was bigger than the derived result limitation via the First/Top keyword.
       */
      if (query.getMaxResults() > tree.getMaxResults() && query.getFirstResult() > 0) {
        query.setFirstResult(query.getFirstResult() - (query.getMaxResults() - tree.getMaxResults()));
      }
    }
    query.setMaxResults(tree.getMaxResults());
  }
  return query;
}

代码示例来源:origin: org.glassfish.main.common/container-common

public int getMaxResults() {
  try {
    if(callFlowAgent.isEnabled()) {
      callFlowAgent.entityManagerQueryStart(EntityManagerQueryMethod.GET_MAX_RESULTS);
    }
    return queryDelegate.getMaxResults();
  } finally {
    if(callFlowAgent.isEnabled()) {
      callFlowAgent.entityManagerQueryEnd();
    }
  }
}

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

public static QueryKey create(String queryString, boolean softDeletion, javax.persistence.Query jpaQuery) {
  return new QueryKey(queryString, jpaQuery.getFirstResult(), jpaQuery.getMaxResults(), softDeletion, false, getNamedParameters(jpaQuery), getPositionalParameters(jpaQuery));
}

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

public static QueryKey create(String queryString, boolean softDeletion, boolean singleResult, javax.persistence.Query jpaQuery) {
  return new QueryKey(queryString, jpaQuery.getFirstResult(), jpaQuery.getMaxResults(), softDeletion, singleResult, getNamedParameters(jpaQuery), getPositionalParameters(jpaQuery));
}

代码示例来源:origin: org.glassfish.common/container-common

public int getMaxResults() {
  try {
    if(callFlowAgent.isEnabled()) {
      callFlowAgent.entityManagerQueryStart(EntityManagerQueryMethod.GET_MAX_RESULTS);
    }
    Query delegate = getQueryDelegate();
    return delegate.getMaxResults();
  } finally {
    if(callFlowAgent.isEnabled()) {
      callFlowAgent.entityManagerQueryEnd();
    }
  }
}

相关文章