本文整理了Java中org.hibernate.ScrollableResults.beforeFirst()
方法的一些代码示例,展示了ScrollableResults.beforeFirst()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollableResults.beforeFirst()
方法的具体详情如下:
包路径:org.hibernate.ScrollableResults
类名称:ScrollableResults
方法名:beforeFirst
[英]Go to a location just before first result, This is the location of the cursor on a newly returned scrollable result.
[中]转到第一个结果之前的位置,这是光标在新返回的可滚动结果上的位置。
代码示例来源:origin: hibernate/hibernate-orm
assertTrue( results.isLast() );
results.beforeFirst();
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
代码示例来源:origin: hibernate/hibernate-orm
assertFalse( results.isLast() );
results.beforeFirst();
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter
@Override
public void beforeFirst() throws HibernateException {
try {
results.beforeFirst();
} catch (final PersistenceException ex) {
throw HibernateExceptionAdapter.adapt(ex);
}
}
代码示例来源:origin: sakaiproject/sakai
public Object doInHibernate(Session session) throws HibernateException{
ArrayList page = new ArrayList();
Query q = session.createQuery(queryString);
if (value != null) {
q.setInteger(0, value.intValue());
}
ScrollableResults assessmentList = q.scroll();
if (assessmentList.first()){ // check that result set is not empty
int first = pageSize * (pageNumber - 1);
int i = 0;
assessmentList.setRowNumber(first);
assessmentList.beforeFirst();
while ( (pageSize > i++) && assessmentList.next()){
log.debug("**** add "+i);
page.add(assessmentList.get(0));
}
}
return page;
}
};
代码示例来源:origin: org.sakaiproject.samigo/samigo-services
public Object doInHibernate(Session session) throws HibernateException{
ArrayList page = new ArrayList();
Query q = session.createQuery(queryString);
if (value != null) {
q.setInteger(0, value.intValue());
}
ScrollableResults assessmentList = q.scroll();
if (assessmentList.first()){ // check that result set is not empty
int first = pageSize * (pageNumber - 1);
int i = 0;
assessmentList.setRowNumber(first);
assessmentList.beforeFirst();
while ( (pageSize > i++) && assessmentList.next()){
log.debug("**** add "+i);
page.add(assessmentList.get(0));
}
}
return page;
}
};
代码示例来源: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: hibernate/hibernate-search
@Test
public void testScrollEmptyHits() throws Exception {
FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
Transaction tx = fullTextSession.beginTransaction();
QueryParser parser = new QueryParser( "dept", TestConstants.standardAnalyzer );
Query query = parser.parse( "dept:XXX" );
org.hibernate.search.FullTextQuery hibQuery = fullTextSession.createFullTextQuery( query, Employee.class );
ScrollableResults projections = hibQuery.scroll();
projections.beforeFirst();
projections.next();
Object[] projection = projections.get();
assertNull( projection );
hibQuery = fullTextSession.createFullTextQuery( query, Employee.class ).setFirstResult( 10 ).setMaxResults( 20 );
projections = hibQuery.scroll();
projections.beforeFirst();
projections.next();
projection = projections.get();
assertNull( projection );
tx.commit();
fullTextSession.close();
}
代码示例来源:origin: hibernate/hibernate-search
assertTrue( scrollableResults.last() );
assertEquals( 3, scrollableResults.getRowNumber() );
scrollableResults.beforeFirst();
assertTrue( scrollableResults.last() );
assertEquals( 1, scrollableResults.getRowNumber() );
scrollableResults.beforeFirst();
代码示例来源:origin: hibernate/hibernate-search
.setFetchSize( 10 )
.scroll();
scrollableResults.beforeFirst();
代码示例来源:origin: hibernate/hibernate-search
@Test
public void testDefaultFetchSize() 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.setProjection( "id", "lastname", "dept" );
ScrollableResults projections = hibQuery.scroll();
projections.beforeFirst();
Object[] projection = projections.get();
assertNull( projection );
projections.next();
assertTrue( projections.isFirst() );
tx.commit();
fullTextSession.close();
}
代码示例来源:origin: hibernate/hibernate-search
@Test
public void testFetchSizeNonDefaultFirstAndMaxNoHits() throws Exception {
FullTextSession fullTextSession = Search.getFullTextSession( openSession() );
Transaction tx = fullTextSession.beginTransaction();
QueryParser parser = new QueryParser( "dept", TestConstants.standardAnalyzer );
Query query = parser.parse( "dept:XXX" );
org.hibernate.search.FullTextQuery hibQuery = fullTextSession.createFullTextQuery( query, Employee.class );
hibQuery.setProjection( "id", "lastname", "dept" );
hibQuery.setFetchSize( 3 );
hibQuery.setFirstResult( 1 );
hibQuery.setMaxResults( 3 );
ScrollableResults results = hibQuery.scroll();
results.beforeFirst();
Object[] result = results.get();
assertNull( "non-null entity infos returned", result );
tx.commit();
fullTextSession.close();
}
代码示例来源:origin: hibernate/hibernate-search
assertTrue( scrollableResults.last() );
assertEquals( 110, scrollableResults.getRowNumber() );
scrollableResults.beforeFirst();
int position = scrollableResults.getRowNumber();
while ( scrollableResults.next() ) {
代码示例来源:origin: hibernate/hibernate-search
assertNotNull( projections );
projections.beforeFirst();
projections.next();
Object[] projection = projections.get();
代码示例来源:origin: hibernate/hibernate-search
@Test
public void testFetchSizeLargerThanHits() 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( 6 );
ScrollableResults results = hibQuery.scroll();
results.beforeFirst();
results.next();
Object[] result = results.get();
assertEquals( "incorrect entityInfo returned", 1000, result[0] );
tx.commit();
fullTextSession.close();
}
代码示例来源:origin: hibernate/hibernate-search
scrollableResults.last();
assertEquals( 132, scrollableResults.getRowNumber() );
scrollableResults.beforeFirst();
assertEquals( -1, scrollableResults.getRowNumber() );
int position = scrollableResults.getRowNumber();
代码示例来源: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.beforeFirst();
results.next();
Object[] result = results.get();
代码示例来源:origin: hibernate/hibernate-search
projections.beforeFirst();
projections.next();
Object[] projection = projections.get();
代码示例来源:origin: hibernate/hibernate-search
results.beforeFirst();
results.next();
assertTrue( "beforeFirst() pointer incorrect", results.isFirst() );
内容来源于网络,如有侵权,请联系作者删除!