當前位置: 首頁>>代碼示例>>Java>>正文


Java ScrollableResults.getRowNumber方法代碼示例

本文整理匯總了Java中org.hibernate.ScrollableResults.getRowNumber方法的典型用法代碼示例。如果您正苦於以下問題:Java ScrollableResults.getRowNumber方法的具體用法?Java ScrollableResults.getRowNumber怎麽用?Java ScrollableResults.getRowNumber使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hibernate.ScrollableResults的用法示例。


在下文中一共展示了ScrollableResults.getRowNumber方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRowNumber

import org.hibernate.ScrollableResults; //導入方法依賴的package包/類
/**
 * Computes the row number of a record which has the id which is passed in as a parameter. The
 * rownumber computation takes into account the filter and sorting settings of the the OBQuery
 * object.
 * 
 * @param targetId
 *          the record id
 * @return the row number or -1 if not found
 */
public int getRowNumber(String targetId) {
  String qryStr = createQueryString();
  if (qryStr.toLowerCase().contains(FROM_SPACED)) {
    final int index = qryStr.indexOf(FROM_SPACED) + FROM_SPACED.length();
    qryStr = qryStr.substring(index);
  }
  final Query qry = getSession()
      .createQuery("select " + usedAlias + "id " + FROM_SPACED + qryStr);
  setParameters(qry);

  final ScrollableResults results = qry.scroll(ScrollMode.FORWARD_ONLY);
  try {
    while (results.next()) {
      final String id = results.getString(0);
      if (id.equals(targetId)) {
        return results.getRowNumber();
      }
    }
  } finally {
    results.close();
  }
  return -1;
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:33,代碼來源:OBQuery.java

示例2: getStoppedCollectionsCount

import org.hibernate.ScrollableResults; //導入方法依賴的package包/類
@Override
public Long getStoppedCollectionsCount(String terms) {
	Criteria criteria = getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria(Collection.class);
	criteria.setProjection(Projections.projectionList()
			.add(Projections.property("id"), "id"));
	
	LogicalExpression or = Restrictions.or(
			Restrictions.eq("status", CollectionStatus.STOPPED),
			Restrictions.eq("status", CollectionStatus.NOT_RUNNING)
			);
	
	LogicalExpression orAll = Restrictions.or(
			or,
			Restrictions.eq("status", CollectionStatus.FATAL_ERROR)
			);
	
	criteria.add(orAll);
	addCollectionSearchCriteria(terms, criteria);

	ScrollableResults scroll = criteria.scroll();
	int i = scroll.last() ? scroll.getRowNumber() + 1 : 0;
	return Long.valueOf(i);
}
 
開發者ID:qcri-social,項目名稱:AIDR,代碼行數:24,代碼來源:CollectionRepositoryImpl.java

示例3: getGroupedCount

import org.hibernate.ScrollableResults; //導入方法依賴的package包/類
protected int getGroupedCount(Query countQuery) {
  int nRows = -1;
  ScrollableResults scrollableResults = countQuery.scroll();
  if (scrollableResults.last()) {
    nRows = scrollableResults.getRowNumber();
  }
  scrollableResults.close();
  return nRows + 1;
}
 
開發者ID:mauyr,項目名稱:openbravo-brazil,代碼行數:10,代碼來源:HQLDataSourceService.java

示例4: getRowCountOfDCRst

import org.hibernate.ScrollableResults; //導入方法依賴的package包/類
public Integer getRowCountOfDCRst(DetachedCriteria dc) {
	Session session = (Session) this.em.getDelegate();
	boolean needClose = false;
	if (!session.isOpen()) {
		session = session.getSessionFactory().openSession();
		needClose = true;
	}

	ScrollableResults sc = null;
	try {
		Criteria c = dc.getExecutableCriteria(session);
		sc = c.scroll(ScrollMode.FORWARD_ONLY);
		sc.last();
		int count = sc.getRowNumber() + 1;

		return count;
	} finally {
		if (sc != null) {
			sc.close();
			sc = null;
		}

		if (needClose) {
			session.close();
			session = null;
		}

	}
}
 
開發者ID:dynamo2,項目名稱:tianma,代碼行數:30,代碼來源:AbstractBaseDAO.java

示例5: getUsersCount

import org.hibernate.ScrollableResults; //導入方法依賴的package包/類
@Override
   public Long getUsersCount(String query) {
	Criteria criteria = getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria(UserAccount.class);
       criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

       if (StringUtils.hasText(query)){
           String wildcard ='%'+ URLDecoder.decode(query.trim())+'%';
           criteria.add(Restrictions.ilike("userName", wildcard));
       }

       ScrollableResults scroll = criteria.scroll();
       int i = scroll.last() ? scroll.getRowNumber() + 1 : 0;
       return Long.valueOf(i);
}
 
開發者ID:qcri-social,項目名稱:AIDR,代碼行數:15,代碼來源:UserAccountRepositoryImpl.java

示例6: getRunningCollectionsCount

import org.hibernate.ScrollableResults; //導入方法依賴的package包/類
@Override
public Long getRunningCollectionsCount(String terms) {
	Criteria criteria = getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria(Collection.class);
	criteria.setProjection(Projections.projectionList()
			.add(Projections.property("id"), "id"));

	LogicalExpression or = Restrictions.or(
			Restrictions.eq("status", CollectionStatus.RUNNING),
			Restrictions.eq("status", CollectionStatus.RUNNING_WARNING)
			);

	LogicalExpression or2 = Restrictions.or(
			or,
			Restrictions.eq("status", CollectionStatus.INITIALIZING)
			);
	
	LogicalExpression orAll = Restrictions.or(
			or2,
			Restrictions.eq("status", CollectionStatus.WARNING)
			);

	LogicalExpression andAll = Restrictions.and(
			orAll,
			Restrictions.ne("status", CollectionStatus.TRASHED)
			);

	criteria.add(andAll);
	addCollectionSearchCriteria(terms, criteria);

	ScrollableResults scroll = criteria.scroll();
	int i = scroll.last() ? scroll.getRowNumber() + 1 : 0;
	return Long.valueOf(i);
}
 
開發者ID:qcri-social,項目名稱:AIDR,代碼行數:34,代碼來源:CollectionRepositoryImpl.java

示例7: QueryDataModel

import org.hibernate.ScrollableResults; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public QueryDataModel(String jpql) {
    this.jpql = jpql;

    QueryImpl<T> query = (QueryImpl<T>) JPAUtil.getEntityManager().createQuery(jpql);
    ScrollableResults scroll = query.getHibernateQuery().scroll();
    scroll.last();
    int count = scroll.getRowNumber();
    setRowCount(count);
}
 
開發者ID:joedayz,項目名稱:javaee7-samples,代碼行數:11,代碼來源:QueryDataModel.java

示例8: doRebuildIndex

import org.hibernate.ScrollableResults; //導入方法依賴的package包/類
protected int doRebuildIndex() throws Exception {
	FullTextSession fullTextSession = (FullTextSession) entityManager.getDelegate();
	fullTextSession.setFlushMode(org.hibernate.FlushMode.MANUAL);
	fullTextSession.setCacheMode(org.hibernate.CacheMode.IGNORE);
	fullTextSession.purgeAll(NodeDocumentVersion.class);
	fullTextSession.getSearchFactory().optimize(NodeDocumentVersion.class);

	String query = "select ndv from NodeDocumentVersion ndv";
	ScrollableResults cursor = fullTextSession.createQuery(query).scroll();
	cursor.last();
	int count = cursor.getRowNumber() + 1;
	log.warn("Re-building Wine index for " + count + " objects.");

	if (count > 0) {
		int batchSize = 300;
		cursor.first(); // Reset to first result row
		int i = 0;

		while (true) {
			fullTextSession.index(cursor.get(0));

			if (++i % batchSize == 0) {
				fullTextSession.flushToIndexes();
				fullTextSession.clear(); // Clear persistence context for each batch
				log.info("Flushed index update " + i + " from Thread "
						+ Thread.currentThread().getName());
			}

			if (cursor.isLast()) {
				break;
			}

			cursor.next();
		}
	}

	cursor.close();
	fullTextSession.flushToIndexes();
	fullTextSession.clear(); // Clear persistence context for each batch
	fullTextSession.getSearchFactory().optimize(NodeDocumentVersion.class);

	return count;
}
 
開發者ID:openkm,項目名稱:document-management-system,代碼行數:44,代碼來源:IndexHelper.java


注:本文中的org.hibernate.ScrollableResults.getRowNumber方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。