當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。