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