本文整理了Java中org.hibernate.ScrollableResults.getRowNumber()
方法的一些代码示例,展示了ScrollableResults.getRowNumber()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollableResults.getRowNumber()
方法的具体详情如下:
包路径:org.hibernate.ScrollableResults
类名称:ScrollableResults
方法名:getRowNumber
[英]Get the current position in the results. The first position is number 0 (unlike JDBC).
[中]
代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter
@Override
public int getRowNumber() throws HibernateException {
try {
return results.getRowNumber();
} catch (final PersistenceException ex) {
throw HibernateExceptionAdapter.adapt(ex);
}
}
代码示例来源:origin: stackoverflow.com
ScrollableResults scrollable = criteria.scroll(ScrollMode.SCROLL_INSENSITIVE);
if(scrollable.last()){//returns true if there is a resultset
genericDTO.setTotalCount(scrollable.getRowNumber() + 1);
criteria.setFirstResult(command.getStart())
.setMaxResults(command.getLimit());
genericDTO.setLineItems(Collections.unmodifiableList(criteria.list()));
}
scrollable.close();
return genericDTO;
代码示例来源:origin: com.revolsys.open/com.revolsys.open.orm.hibernate
/**
* Construct a new HibernateQueryPager.
*
* @param query The Hibernate query.
*/
public HibernateQueryPager(final Query query) {
this.query = query;
final ScrollableResults scrollableResults = query.scroll();
scrollableResults.last();
this.numResults = scrollableResults.getRowNumber() + 1;
}
代码示例来源:origin: badqiu/rapid-framework
private static int queryTatalCountByScrollableResults(Query query) {
ScrollableResults scrollableResults = query.scroll();
scrollableResults.last();
return scrollableResults.getRowNumber() + 1;
}
代码示例来源:origin: com.revolsys.open/com.revolsys.open.orm.hibernate
/**
* Construct a new HibernateQueryPager.
*
* @param criteria The Hibernate criteria.
*/
public HibernateCriteriaPager(final Criteria criteria) {
this.criteria = criteria;
final ScrollableResults scrollableResults = criteria.scroll();
scrollableResults.last();
this.numResults = scrollableResults.getRowNumber() + 1;
}
代码示例来源:origin: stackoverflow.com
final Criteria criteria = session.createCriteria(clazz);
List<Criterion> restrictions = factory.assemble(command.getFilter());
for (Criterion restriction : restrictions)
criteria.add(restriction);
criteria.add(Restrictions.conjunction());
if(this.projections != null)
criteria.setProjection(factory.loadProjections(this.projections));
criteria.addOrder(command.getDir().equals("ASC")?Order.asc(command.getSort()):Order.desc(command.getSort()));
ScrollableResults scrollable = criteria.scroll(ScrollMode.SCROLL_INSENSITIVE);
if(scrollable.last()){//returns true if there is a resultset
genericDTO.setTotalCount(scrollable.getRowNumber() + 1);
criteria.setFirstResult(command.getStart())
.setMaxResults(command.getLimit());
genericDTO.setLineItems(Collections.unmodifiableList(criteria.list()));
}
scrollable.close();
return genericDTO;
代码示例来源:origin: org.andromda.samples.animalquiz/animal-quiz-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源:origin: org.andromda.samples.carrental/car-rental-system-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源:origin: org.andromda.samples.carrental/car-rental-system-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源:origin: org.andromda.samples.carrental/car-rental-system-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源:origin: org.andromda.samples.carrental/car-rental-system-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源:origin: org.andromda.samples.animalquiz/animal-quiz-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源:origin: org.andromda.samples.carrental/car-rental-system-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源:origin: org.andromda.samples.crud/crud-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源:origin: org.andromda.samples.carrental/car-rental-system-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源:origin: org.andromda.samples.animalquiz/animal-quiz-core
int totalCount = scrollableResults.getRowNumber();
totalCount = totalCount >= 0 ? totalCount + 1 : 0;
if (pageNumber > 0 && pageSize > 0)
代码示例来源: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
scrollableResults.beforeFirst();
assertEquals( -1, scrollableResults.getRowNumber() );
assertTrue( scrollableResults.last() );
int position = scrollableResults.getRowNumber();
assertEquals( 323, position );
while ( scrollableResults.previous() ) {
assertEquals( -1, scrollableResults.getRowNumber() );
scrollableResults.close();
tx.commit();
代码示例来源:origin: hibernate/hibernate-search
.setMaxResults( 111 )
.scroll();
assertEquals( -1, scrollableResults.getRowNumber() );
assertTrue( scrollableResults.last() );
assertEquals( 110, scrollableResults.getRowNumber() );
scrollableResults.beforeFirst();
int position = scrollableResults.getRowNumber();
while ( scrollableResults.next() ) {
position++;
int bookId = position + 20;
assertEquals( position, scrollableResults.getRowNumber() );
AlternateBook book = (AlternateBook) scrollableResults.get()[0];
assertEquals( bookId, book.getId().intValue() );
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!