org.hibernate.ScrollableResults.scroll()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(176)

本文整理了Java中org.hibernate.ScrollableResults.scroll()方法的一些代码示例,展示了ScrollableResults.scroll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollableResults.scroll()方法的具体详情如下:
包路径:org.hibernate.ScrollableResults
类名称:ScrollableResults
方法名:scroll

ScrollableResults.scroll介绍

[英]Scroll the specified number of positions from the current position.
[中]从当前位置滚动指定数量的位置。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

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() );

代码示例来源:origin: hibernate/hibernate-orm

ScrollableResults iter = query.scroll();
assertTrue( iter.next() );
assertTrue( iter.scroll(1) );
FooProxy f2 = (FooProxy) iter.get()[0];
assertTrue( f2!=null );
assertTrue( iter.scroll(-1) );
Object f1 = iter.get(0);
iter.next();
assertTrue( !iter.scroll(100) );
assertTrue( iter.first() );
assertTrue( iter.scroll(3) );
Object f4 = iter.get(0);
assertTrue( f4!=null );
iter = query.scroll();
assertTrue( iter.next() );
assertTrue( iter.scroll(1) );
f2 = (FooProxy) iter.get()[0];
assertTrue( f2!=null );
assertTrue( f2.getString()!=null  && f2.getComponent().getImportantDates().length > 0 );
assertTrue( iter.scroll(-1) );
f1 = iter.get(0);
iter.next();
assertTrue( !iter.scroll(100) );
assertTrue( iter.first() );
assertTrue( iter.scroll(3) );
f4 = iter.get(0);

代码示例来源:origin: hibernate/hibernate-orm

assertFalse( results.scroll( i ) );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
assertFalse( results.scroll( - i ) );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );

代码示例来源:origin: hibernate/hibernate-orm

assertTrue( results.isLast() );
assertFalse( results.scroll( i ) );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
assertTrue( results.isLast() );
assertFalse( results.scroll( - i ) );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );

代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter

@Override
public boolean scroll(final int i) throws HibernateException {
  try {
    return results.scroll(i);
  } catch (final PersistenceException ex) {
    throw HibernateExceptionAdapter.adapt(ex);
  }
}

代码示例来源:origin: stackoverflow.com

String hql = "SELECT l from LoanAccount l where l."+filterColumn +" LIKE :filterValue  and l.assignedBranchKey=:TaskID order by l." + orderByColumnID +" " + orrderByASC;
Query query = session.createQuery(hql);
query.setParameter("filterValue", "%"+filterValue+"%");
query.setParameter("TaskID", TaskID);
int pageSize = 10;

ScrollableResults resultScroll = query.scroll(ScrollMode.FORWARD_ONLY);
resultScroll.first();
resultScroll.scroll(0);
List<LoanAccount> loanAccountPage = Lists.newArrayList();
int i = 0;
while (pageSize > i++) {
  loanAccountPage .add((LoanAccount ) resultScroll.get(0));
  if (!resultScroll.next())
    break;
}

代码示例来源:origin: stackoverflow.com

Query q = sess.createQuery("select cat.name, cat from DomesticCat cat " +
              "order by cat.name");
ScrollableResults cats = q.scroll();
if ( cats.first() ) {

  // find the first name on each page of an alphabetical list of cats by name
  firstNamesOfPages = new ArrayList();
  do {
    String name = cats.getString(0);
    firstNamesOfPages.add(name);
  }
  while ( cats.scroll(PAGE_SIZE) );

  // Now get the first page of cats
  pageOfCats = new ArrayList();    
  cats.beforeFirst();    
  int i=0;    
  while( ( PAGE_SIZE > i++ ) && cats.next() ) pageOfCats.add( cats.get(1) );

}

cats.close()

代码示例来源:origin: stackoverflow.com

String hql = "FROM Foo f order by f.name";
Query query = session.createQuery(hql);
int pageSize = 10;

ScrollableResults resultScroll = query.scroll(ScrollMode.FORWARD_ONLY);
resultScroll.first();
resultScroll.scroll(0);
List<Foo> fooPage = Lists.newArrayList();
int i = 0;
while (pageSize > i++) {
  fooPage.add((Foo) resultScroll.get(0));
  if (!resultScroll.next())
    break;
}
//Total count
resultScroll.last();
int totalResults = resultScroll.getRowNumber() + 1;

代码示例来源:origin: hibernate/hibernate-search

while ( scroll.scroll( rowsPerPartition ) ) {
  lowerID = upperID;
  upperID = scroll.get( 0 );

代码示例来源:origin: hibernate/hibernate-search

assertEquals( "incorrect entityInfo returned", 1002, result[0] );
results.scroll( 2 );
result = results.get();
assertEquals( "incorrect entityInfo returned", 1004, result[0] );
assertNull( result );
results.scroll( -8 );
result = results.get();
assertNull( result );
results.scroll( 10 );
result = results.get();
assertNull( result );

代码示例来源:origin: hibernate/hibernate-search

@Test
public void testScrollableResultSet() throws Exception {
  FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
  Transaction tx = fullTextSession.beginTransaction();
  QueryParser parser = new QueryParser( "title", TestConstants.stopAnalyzer );
  Query query = parser.parse( "summary:noword" );
  org.hibernate.query.Query hibQuery = fullTextSession.createFullTextQuery( query, Clock.class, Book.class );
  ScrollableResults result = hibQuery.scroll();
  assertNotNull( result );
  assertEquals( -1, result.getRowNumber() );
  assertEquals( false, result.next() );
  result.close();
  query = parser.parse( "summary:Festina Or brand:Seiko" );
  hibQuery = fullTextSession.createFullTextQuery( query, Clock.class, Book.class );
  result = hibQuery.scroll();
  assertEquals( -1, result.getRowNumber() );
  result.beforeFirst();
  assertEquals( true, result.next() );
  assertTrue( result.isFirst() );
  assertTrue( result.scroll( 1 ) );
  assertTrue( result.isLast() );
  assertFalse( result.scroll( 1 ) );
  tx.commit();
  fullTextSession.close();
}

代码示例来源:origin: hibernate/hibernate-search

@Test
public void testFetchSizeDefaultFirstAndMax() throws Exception {
  FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
  Transaction tx = fullTextSession.beginTransaction();
  QueryParser parser = new QueryParser( "dept", TestConstants.standardAnalyzer );
  Query query = parser.parse( "dept:ITech" );
  org.hibernate.search.FullTextQuery hibQuery = fullTextSession.createFullTextQuery( query, Employee.class );
  hibQuery.setSort( new Sort( new SortField( "id", SortField.Type.STRING ) ) );
  hibQuery.setProjection( "id", "lastname", "dept" );
  hibQuery.setFetchSize( 3 );
  ScrollableResults results = hibQuery.scroll();
  results.beforeFirst();
  results.next();
  Object[] result = results.get();
  assertEquals( "incorrect entityInfo returned", 1000, result[0] );
  results.scroll( 2 );
  result = results.get();
  assertEquals( "incorrect entityInfo returned", 1003, result[0] );
  // check cache addition
  results.next();
  result = results.get();
  assertEquals( "incorrect entityInfo returned", 1004, result[0] );
  results.scroll( -2 );
  result = results.get();
  assertEquals( "incorrect entityInfo returned", 1002, result[0] );
  tx.commit();
  fullTextSession.close();
}

代码示例来源:origin: hibernate/hibernate-search

results.scroll( -8 );
results.next();
assertTrue( "large negative scroll() pointer incorrect", results.isFirst() );
results.scroll( 10 );
results.previous();
assertTrue( "large positive scroll() pointer incorrect", results.isLast() );

代码示例来源:origin: hibernate/hibernate-search

checkProjectionFirst( projection, s );
projections.scroll( 2 );
projection = projections.get();
checkProjection2( projection, s );
projections.scroll( -5 );
projection = projections.get();
assertNull( projection );

相关文章