org.hibernate.Criteria.setTimeout()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(153)

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

Criteria.setTimeout介绍

[英]Set a timeout for the underlying JDBC query.
[中]为基础JDBC查询设置超时。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Set a timeout for the underlying JDBC query.
 *
 * @param timeout The timeout value to apply.
 * @return this (for method chaining)
 *
 * @see java.sql.Statement#setQueryTimeout
 */
public DetachedCriteria setTimeout(int timeout) {
  criteria.setTimeout( timeout );
  return this;
}

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

/**
 * Prepare the given Criteria object, applying cache settings and/or
 * a transaction timeout.
 * @param criteria the Criteria object to prepare
 * @see #setCacheQueries
 * @see #setQueryCacheRegion
 */
protected void prepareCriteria(Criteria criteria) {
  if (isCacheQueries()) {
    criteria.setCacheable(true);
    if (getQueryCacheRegion() != null) {
      criteria.setCacheRegion(getQueryCacheRegion());
    }
  }
  if (getFetchSize() > 0) {
    criteria.setFetchSize(getFetchSize());
  }
  if (getMaxResults() > 0) {
    criteria.setMaxResults(getMaxResults());
  }
  ResourceHolderSupport sessionHolder =
      (ResourceHolderSupport) TransactionSynchronizationManager.getResource(obtainSessionFactory());
  if (sessionHolder != null && sessionHolder.hasTimeout()) {
    criteria.setTimeout(sessionHolder.getTimeToLiveInSeconds());
  }
}

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

/**
 * Prepare the given Criteria object, applying cache settings and/or
 * a transaction timeout.
 * @param criteria the Criteria object to prepare
 * @see #setCacheQueries
 * @see #setQueryCacheRegion
 */
protected void prepareCriteria(Criteria criteria) {
  if (isCacheQueries()) {
    criteria.setCacheable(true);
    if (getQueryCacheRegion() != null) {
      criteria.setCacheRegion(getQueryCacheRegion());
    }
  }
  if (getFetchSize() > 0) {
    criteria.setFetchSize(getFetchSize());
  }
  if (getMaxResults() > 0) {
    criteria.setMaxResults(getMaxResults());
  }
  ResourceHolderSupport sessionHolder =
      (ResourceHolderSupport) TransactionSynchronizationManager.getResource(obtainSessionFactory());
  if (sessionHolder != null && sessionHolder.hasTimeout()) {
    criteria.setTimeout(sessionHolder.getTimeToLiveInSeconds());
  }
}

代码示例来源:origin: TGAC/miso-lims

@Override
public Criteria setTimeout(int timeout) {
 backingCriteria.setTimeout(timeout);
 return this;
}

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

@Override
public Criteria setTimeout(final int timeout) {
  criteria.setTimeout(timeout);
  return null;
}

代码示例来源:origin: ezbz/projectx

@Override
public Criteria setTimeout(final int timeout) {
 return criteria.setTimeout(timeout);
}

代码示例来源:origin: hibernate/hibernate-search

private void setCriteriaTimeout(Criteria criteria, TimeoutManager timeoutManager) {
  // not best effort so fail fast
  if ( timeoutManager.getType() != TimeoutManager.Type.LIMIT ) {
    Long timeLeftInSecond = timeoutManager.getTimeoutLeftInSeconds();
    if ( timeLeftInSecond != null ) {
      if ( timeLeftInSecond == 0 ) {
        timeoutManager.reactOnQueryTimeoutExceptionWhileExtracting( null );
      }
      criteria.setTimeout( timeLeftInSecond.intValue() );
    }
  }
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Apply the current transaction timeout, if any, to the given
 * Hibernate Criteria object.
 * @param criteria the Hibernate Criteria object
 * @param sessionFactory Hibernate SessionFactory that the Criteria was created for
 * @see org.hibernate.Criteria#setTimeout
 */
public static void applyTransactionTimeout(Criteria criteria, SessionFactory sessionFactory) {
  Assert.notNull(criteria, "No Criteria object specified");
  if (sessionFactory != null) {
    SessionHolder sessionHolder =
      (SessionHolder) TransactionSynchronizationManager.getResource(sessionFactory);
    if (sessionHolder != null && sessionHolder.hasTimeout()) {
      criteria.setTimeout(sessionHolder.getTimeToLiveInSeconds());
    }
  }
}

代码示例来源:origin: org.jspresso.framework/jspresso-hibernate

@SuppressWarnings("unchecked")
 @Override
 public List<T> doInTransaction(TransactionStatus status) {
  Criteria executableCriteria = criteria.getExecutableCriteria(getHibernateSession());
  if (firstResult >= 0) {
   executableCriteria.setFirstResult(firstResult);
  }
  if (maxResults > 0) {
   executableCriteria.setMaxResults(maxResults);
  }
  if (queryTimeout > 0) {
   executableCriteria.setTimeout(queryTimeout);
  }
  List<T> entities = executableCriteria.list();
  if (mergeMode != null) {
   entities = merge(entities, mergeMode);
  }
  return entities;
 }
});

代码示例来源:origin: org.grails/grails-datastore-gorm-hibernate-core

c.setTimeout(conversionService.convert(argMap.get(DynamicFinder.ARGUMENT_TIMEOUT),Integer.class));

代码示例来源:origin: org.grails/grails-hibernate

c.setTimeout(converter.convertIfNecessary(argMap.get(ARGUMENT_TIMEOUT),Integer.class));

代码示例来源:origin: org.jspresso.framework/jspresso-hibernate

Criteria executableCriteria = criteria.getExecutableCriteria(hibernateSession);
 if (queryComponent.getQueryTimeout() > 0) {
  executableCriteria.setTimeout(queryComponent.getQueryTimeout());
Criteria executableCriteria = criteria.getExecutableCriteria(hibernateSession);
if (queryComponent.getQueryTimeout() > 0) {
 executableCriteria.setTimeout(queryComponent.getQueryTimeout());
                       .getExecutableCriteria(hibernateSession);
 if (queryComponent.getQueryTimeout() > 0) {
  chunkExecutableCriteria.setTimeout(queryComponent.getQueryTimeout());
Criteria executableCriteria = criteria.getExecutableCriteria(hibernateSession);
if (queryComponent.getQueryTimeout() > 0) {
 executableCriteria.setTimeout(queryComponent.getQueryTimeout());

代码示例来源:origin: apache/servicemix-bundles

/**
 * Prepare the given Criteria object, applying cache settings and/or
 * a transaction timeout.
 * @param criteria the Criteria object to prepare
 * @see #setCacheQueries
 * @see #setQueryCacheRegion
 */
protected void prepareCriteria(Criteria criteria) {
  if (isCacheQueries()) {
    criteria.setCacheable(true);
    if (getQueryCacheRegion() != null) {
      criteria.setCacheRegion(getQueryCacheRegion());
    }
  }
  if (getFetchSize() > 0) {
    criteria.setFetchSize(getFetchSize());
  }
  if (getMaxResults() > 0) {
    criteria.setMaxResults(getMaxResults());
  }
  SessionHolder sessionHolder =
      (SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
  if (sessionHolder != null && sessionHolder.hasTimeout()) {
    criteria.setTimeout(sessionHolder.getTimeToLiveInSeconds());
  }
}

相关文章