当前位置: 首页>>代码示例>>Java>>正文


Java Query.setFetchSize方法代码示例

本文整理汇总了Java中org.hibernate.Query.setFetchSize方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setFetchSize方法的具体用法?Java Query.setFetchSize怎么用?Java Query.setFetchSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.Query的用法示例。


在下文中一共展示了Query.setFetchSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processQuery

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public void processQuery(Query query)
{
	if( freetext != null )
	{
		query.setParameter("freetext", freetext); //$NON-NLS-1$
	}
	if( dates != null )
	{
		if( dates[0] != null )
		{
			query.setParameter("start", dates[0]); //$NON-NLS-1$
		}
		if( dates[1] != null )
		{
			query.setParameter("end", dates[1]); //$NON-NLS-1$
		}
	}
	query.setParameter("owner", userId);
	query.setParameter("institution", institution);

	query.setFirstResult(offset);
	query.setFetchSize(max);
	query.setMaxResults(max);
}
 
开发者ID:equella,项目名称:Equella,代码行数:26,代码来源:FavouriteSearchDaoImpl.java

示例2: prepareQuery

import org.hibernate.Query; //导入方法依赖的package包/类
/**
 * Prepare the given Query object, applying cache settings and/or
 * a transaction timeout.
 * @param queryObject the Query object to prepare
 * @see #setCacheQueries
 * @see #setQueryCacheRegion
 */
protected void prepareQuery(Query queryObject) {
	if (isCacheQueries()) {
		queryObject.setCacheable(true);
		if (getQueryCacheRegion() != null) {
			queryObject.setCacheRegion(getQueryCacheRegion());
		}
	}
	if (getFetchSize() > 0) {
		queryObject.setFetchSize(getFetchSize());
	}
	if (getMaxResults() > 0) {
		queryObject.setMaxResults(getMaxResults());
	}

	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
	if (sessionHolder != null && sessionHolder.hasTimeout()) {
		queryObject.setTimeout(sessionHolder.getTimeToLiveInSeconds());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:HibernateTemplate.java

示例3: prepareQuery

import org.hibernate.Query; //导入方法依赖的package包/类
/**
 * Prepare the given Query object, applying cache settings and/or
 * a transaction timeout.
 * @param queryObject the Query object to prepare
 * @see #setCacheQueries
 * @see #setQueryCacheRegion
 * @see SessionFactoryUtils#applyTransactionTimeout
 */
protected void prepareQuery(Query queryObject) {
	if (isCacheQueries()) {
		queryObject.setCacheable(true);
		if (getQueryCacheRegion() != null) {
			queryObject.setCacheRegion(getQueryCacheRegion());
		}
	}
	if (getFetchSize() > 0) {
		queryObject.setFetchSize(getFetchSize());
	}
	if (getMaxResults() > 0) {
		queryObject.setMaxResults(getMaxResults());
	}
	SessionFactoryUtils.applyTransactionTimeout(queryObject, getSessionFactory());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:HibernateTemplate.java

示例4: processQuery

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public void processQuery(Query query)
{
	if( freetext != null )
	{
		query.setParameter("freetext", freetext);
	}

	query.setFirstResult(offset);
	query.setFetchSize(max);
	query.setMaxResults(max);
}
 
开发者ID:equella,项目名称:Equella,代码行数:13,代码来源:AbstractEntityDaoImpl.java

示例5: processQuery

import org.hibernate.Query; //导入方法依赖的package包/类
@Override
public void processQuery(Query query)
{
	if( freetext != null )
	{
		query.setParameter("freetext", freetext);
	}

	if( !Check.isEmpty(owner) )
	{
		query.setParameter("owner", owner);
	}

	if( !Check.isEmpty(type) )
	{
		query.setParameter("type", type);
	}

	if( onlyInstWide != null )
	{
		query.setParameter("institutional", onlyInstWide);
	}

	if( offset >= 0 )
	{
		query.setFirstResult(offset);
	}
	if( max >= 0 )
	{
		query.setFetchSize(max);
		query.setMaxResults(max);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:34,代码来源:PortletDaoImpl.java

示例6: initQuery

import org.hibernate.Query; //导入方法依赖的package包/类
private void initQuery(Query query, NamedQueryDefinition nqd) {
	// todo : cacheable and readonly should be Boolean rather than boolean...
	query.setCacheable( nqd.isCacheable() );
	query.setCacheRegion( nqd.getCacheRegion() );
	query.setReadOnly( nqd.isReadOnly() );

	if ( nqd.getTimeout() != null ) {
		query.setTimeout( nqd.getTimeout() );
	}
	if ( nqd.getFetchSize() != null ) {
		query.setFetchSize( nqd.getFetchSize() );
	}
	if ( nqd.getCacheMode() != null ) {
		query.setCacheMode( nqd.getCacheMode() );
	}
	if ( nqd.getComment() != null ) {
		query.setComment( nqd.getComment() );
	}
	if ( nqd.getFirstResult() != null ) {
		query.setFirstResult( nqd.getFirstResult() );
	}
	if ( nqd.getMaxResults() != null ) {
		query.setMaxResults( nqd.getMaxResults() );
	}
	if ( nqd.getFlushMode() != null ) {
		query.setFlushMode( nqd.getFlushMode() );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:AbstractSessionImpl.java

示例7: getInstructors

import org.hibernate.Query; //导入方法依赖的package包/类
/**
   * Executes the query to retrieve instructors
   * @param request
   * @param clause
   * @throws Exception
   */
  private static void getInstructors(HttpServletRequest request, SessionContext context, StringBuffer clause) throws Exception {
      String instructorNameFormat = UserProperty.NameFormat.get(context.getUser());
      
      Long acadSessionId = context.getUser().getCurrentAcademicSessionId();

StringBuffer query = new StringBuffer();
query.append("select distinct i from DepartmentalInstructor i ");
query.append(" where i.department.session.uniqueId = :acadSessionId ");
query.append(clause);
      query.append(" order by upper(i.lastName), upper(i.firstName) ");
      
      DepartmentalInstructorDAO idao = new DepartmentalInstructorDAO();
org.hibernate.Session hibSession = idao.getSession();

Query q = hibSession.createQuery(query.toString());
q.setFetchSize(5000);
q.setCacheable(true);
q.setLong("acadSessionId", acadSessionId);
      
List result = q.list();
      Vector v = new Vector(result.size());
      Vector h = new Vector(result.size());
   for (Iterator i=result.iterator();i.hasNext();) {
          DepartmentalInstructor di = (DepartmentalInstructor)i.next();
          String name = di.getName(instructorNameFormat);
          v.addElement(new ComboBoxLookup(name, di.getUniqueId().toString()));
          if (di.hasPreferences())
              h.add(di.getUniqueId());
}
      
      request.setAttribute(DepartmentalInstructor.INSTR_LIST_ATTR_NAME, v);
      request.setAttribute(DepartmentalInstructor.INSTR_HAS_PREF_ATTR_NAME, h);
  }
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:40,代码来源:LookupTables.java

示例8: scroll

import org.hibernate.Query; //导入方法依赖的package包/类
/**
 * <p>Returns a List of <b>T</b> entities, where HQL clauses can be
 * specified.</p>
 * 
 * Note: This method is useful in read only. It can be use to delete or 
 * create <b>T</b> entities, but caution with <code>top</code> and 
 * <code>skip</code> arguments.
 * 
 * @param clauses query clauses (WHERE, ORDER BY, GROUP BY), if null no
 * clauses are apply.
 * @param skip number of entities to skip.
 * @param n  number of entities max returned.
 * @return a list of <b>T</b> entities.
 * @deprecated use of {@link #listCriteria(DetachedCriteria, int, int)}
 */
@Deprecated
@SuppressWarnings ("unchecked")
public List<T> scroll (final String clauses, final int skip, final int n)
{
   StringBuilder hql = new StringBuilder ();
   hql.append ("FROM ").append (entityClass.getName ());
   if (clauses != null)
      hql.append (" ").append (clauses);

   Session session;
   boolean newSession = false;
   try
   {
      session = getSessionFactory ().getCurrentSession ();
   }
   catch (HibernateException e)
   {
      session = getSessionFactory ().openSession ();
      newSession = true;
   }

   Query query = session.createQuery (hql.toString ());
   if (skip > 0) query.setFirstResult (skip);
   if (n > 0) 
   {
      query.setMaxResults (n);
      query.setFetchSize (n);
   }
   
   logger.info("Execution of HQL: " + hql.toString ());
   long start = System.currentTimeMillis ();

   List<T> result = (List<T>) query.list ();
   logger.info("HQL executed in " + 
      (System.currentTimeMillis() -start) + "ms.");

   if (newSession)
   {
      session.disconnect ();
   }

   return result;
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:59,代码来源:HibernateDao.java


注:本文中的org.hibernate.Query.setFetchSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。