本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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();
}