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


Java ScrollableResults.first方法代码示例

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


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

示例1: testScrollingJoinFetchesPositioning

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
public void testScrollingJoinFetchesPositioning() {
	TestData data = new TestData();
	data.prepare();

	Session s = openSession();
	Transaction txn = s.beginTransaction();

	ScrollableResults results = s
	        .createQuery( "from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
	        .setString( "desc", "root%" )
	        .scroll();

	results.first();
	Animal animal = ( Animal ) results.get( 0 );
	assertEquals( "first() did not return expected row", data.root1Id, animal.getId() );

	results.scroll( 1 );
	animal = ( Animal ) results.get( 0 );
	assertEquals( "scroll(1) did not return expected row", data.root2Id, animal.getId() );

	results.scroll( -1 );
	animal = ( Animal ) results.get( 0 );
	assertEquals( "scroll(-1) did not return expected row", data.root1Id, animal.getId() );

	results.setRowNumber( 1 );
	animal = ( Animal ) results.get( 0 );
	assertEquals( "setRowNumber(1) did not return expected row", data.root1Id, animal.getId() );

	results.setRowNumber( 2 );
	animal = ( Animal ) results.get( 0 );
	assertEquals( "setRowNumber(2) did not return expected row", data.root2Id, animal.getId() );

	txn.commit();
	s.close();

	data.cleanup();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:38,代码来源:ScrollableCollectionFetchingTest.java

示例2: DBIterator

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
/**
 * @param type
 *            the type to iterate
 * @param result
 *            the results of the query
 */
public DBIterator(final Class<T> type, final ScrollableResults result) {
    this.result = result;
    this.type = type;
    this.hasAny = result.first();
    result.beforeFirst();
}
 
开发者ID:meraki-analytics,项目名称:orianna-hibernate,代码行数:13,代码来源:HibernateDB.java

示例3: 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

示例4: ScrollIterator

import org.hibernate.ScrollableResults; //导入方法依赖的package包/类
/**
 * Create a {@link ScrollIterator}.
 *
 * @param sr scrollable result set
 */
public ScrollIterator(ScrollableResults sr) {
	this.sr = sr;
	hasNext = sr.first();
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:10,代码来源:HibernateLayer.java


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