本文整理了Java中org.hibernate.ScrollableResults.first()
方法的一些代码示例,展示了ScrollableResults.first()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollableResults.first()
方法的具体详情如下:
包路径:org.hibernate.ScrollableResults
类名称:ScrollableResults
方法名:first
[英]Go to the first result.
[中]转到第一个结果。
代码示例来源:origin: hibernate/hibernate-orm
@Test
@SkipForDialect(value = AbstractHANADialect.class, comment = "HANA only supports forward-only cursors")
public void testScrollMethod() {
final String entityName = "expected";
insertTestEntity( entityName );
try (Session session = openSession()) {
final CriteriaQuery<TestEntity> query = createTestEntityCriteriaQuery(
entityName,
session
);
try (final ScrollableResults scroll = session.createQuery( query ).scroll()) {
assertThat( scroll.first(), is( true ) );
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
.scroll();
results.first();
Animal animal = ( Animal ) results.get( 0 );
assertEquals( "first() did not return expected row", data.root1Id, animal.getId() );
代码示例来源:origin: hibernate/hibernate-orm
assertTrue( iter.first() );
assertTrue( iter.scroll(3) );
Object f4 = iter.get(0);
assertTrue( f4!=null );
assertTrue( !iter.next() );
assertTrue( iter.first() );
assertTrue( iter.get(0)==f1 );
assertTrue( iter.last() );
assertTrue( iter.first() );
assertTrue( iter.scroll(3) );
f4 = iter.get(0);
assertTrue( f4!=null );
assertTrue( !iter.next() );
assertTrue( iter.first() );
assertTrue( iter.get(0)==f1 );
assertTrue( iter.last() );
代码示例来源:origin: hibernate/hibernate-orm
assertFalse( results.previous() );
assertTrue( results.first() );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
assertFalse( results.next() );
assertTrue( results.first() );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
代码示例来源:origin: hibernate/hibernate-orm
assertFalse( results.next() );
assertFalse( results.first() );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
代码示例来源:origin: org.geomajas.plugin/geomajas-layer-hibernate
/**
* Create a {@link ScrollIterator}.
*
* @param sr scrollable result set
*/
public ScrollIterator(ScrollableResults sr) {
this.sr = sr;
hasNext = sr.first();
}
代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter
@Override
public boolean first() throws HibernateException {
try {
return results.first();
} 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: 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: 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
hibQuery = fullTextSession.createFullTextQuery( query, Clock.class, Book.class );
ScrollableResults sr = hibQuery.scroll();
assertTrue( sr.first() );
assertNotNull( sr.get() );
assertFalse( sr.next() );
代码示例来源:origin: hibernate/hibernate-search
checkProjectionLast( projection, s );
projections.first();
projection = projections.get();
checkProjectionFirst( projection, s );
代码示例来源:origin: hibernate/hibernate-search
results.first();
Object[] result = results.get();
assertEquals( 1004, result[0] );
内容来源于网络,如有侵权,请联系作者删除!