当前位置: 首页>>代码示例>>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;未经允许,请勿转载。