本文整理了Java中org.hibernate.Query.scroll
方法的一些代码示例,展示了Query.scroll
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.scroll
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:scroll
[英]Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.
You should call ScrollableResults#close() after processing the ScrollableResults so that the underlying resources are deallocated right away.
[中]将查询结果作为可滚动结果返回。返回结果的可滚动性取决于JDBC驱动程序对可滚动结果集的支持。
在处理ScrollableResults之后,应该调用ScrollableResults#close(),以便立即释放底层资源。
代码示例来源:origin: hibernate/hibernate-orm
public SyntaxChecker checkScroll() {
Session s = openSession();
s.beginTransaction();
Query query = s.createQuery( hql );
preparer.prepare( query );
query.scroll();
s.getTransaction().commit();
s.close();
return this;
}
代码示例来源:origin: spring-projects/spring-batch
/**
* Get a cursor over all of the results, with the forward-only flag set.
*
* @param fetchSize the fetch size to use retrieving the results
* @param parameterValues the parameter values to use (or null if none).
*
* @return a forward-only {@link ScrollableResults}
*/
public ScrollableResults getForwardOnlyCursor(int fetchSize, Map<String, Object> parameterValues) {
Query query = createQuery();
if (parameterValues != null) {
query.setProperties(parameterValues);
}
return query.setFetchSize(fetchSize).scroll(ScrollMode.FORWARD_ONLY);
}
代码示例来源:origin: hibernate/hibernate-orm
Query query = s.createQuery("from DataPoint dp order by dp.x asc");
s.setDefaultReadOnly( true );
ScrollableResults sr = query.scroll(ScrollMode.FORWARD_ONLY);
s.setDefaultReadOnly( false );
while ( sr.next() ) {
代码示例来源:origin: hibernate/hibernate-orm
getSelectNewQuery( session ).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).scroll();
fail("'select new' together with a resulttransformer should result in error!");
代码示例来源:origin: hibernate/hibernate-orm
s.setDefaultReadOnly( true );
assertTrue( s.isDefaultReadOnly() );
ScrollableResults sr = query.scroll(ScrollMode.FORWARD_ONLY);
assertFalse( query.isReadOnly() );
DataPoint dpLast = ( DataPoint ) s.get( DataPoint.class, dp.getId() );
代码示例来源:origin: hibernate/hibernate-orm
s.setDefaultReadOnly( false );
assertFalse( s.isDefaultReadOnly() );
ScrollableResults sr = query.scroll(ScrollMode.FORWARD_ONLY);
assertFalse( s.isDefaultReadOnly() );
assertTrue( query.isReadOnly() );
代码示例来源:origin: hibernate/hibernate-orm
.scroll(ScrollMode.FORWARD_ONLY);
代码示例来源:origin: hibernate/hibernate-orm
Query query = s.createQuery("select f, f.integer from Foo f");
assertTrue( query.getReturnTypes().length==2 );
ScrollableResults iter = query.scroll();
assertTrue( iter.next() );
assertTrue( iter.scroll(1) );
query = s.createQuery("select f, f.integer from Foo f");
assertTrue( query.getReturnTypes().length==2 );
iter = query.scroll();
assertTrue( iter.next() );
assertTrue( iter.scroll(1) );
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
// MIN_VALUE gives hint to JDBC driver to stream results
query.setFetchSize(Integer.MIN_VALUE);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to evict() as well
}
results.close();
代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate
@Override
public ScrollableResults scroll() {
return query.scroll();
}
代码示例来源: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.querydsl/querydsl-jpa
@Override
public CloseableIterator<T> iterate() {
try {
Query query = createQuery();
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
return new ScrollableResultsIterator<T>(results);
} finally {
reset();
}
}
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
setFetchSize(Integer.MIN_VALUE); //MUST use Integer.MIN_VALUE, other value=fetch all
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
}
results.close();
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
// MIN_VALUE gives hint to JDBC driver to stream results
query.setFetchSize(Integer.MIN_VALUE);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to evict() as well
}
results.close();
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
query.setFetchSize(Integer.MIN_VALUE);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to evict() as well
}
results.close();
代码示例来源:origin: stackoverflow.com
Query query = session.createQuery(query);
query.setReadOnly(true);
query.setFetchSize(50);
ScrollableResults results = query.scroll(ScrollMode.FORWARD_ONLY);
// iterate over results
while (results.next()) {
Object row = results.get();
// process row then release reference
// you may need to flush() as well
}
results.close();
代码示例来源:origin: com.mysema.querydsl/querydsl-jpa
@Test
public void Scroll() throws IOException{
CloseableIterator<Cat> cats = new ScrollableResultsIterator<Cat>(query().from(cat)
.createQuery(cat).scroll());
assertTrue(cats.hasNext());
while (cats.hasNext()) {
assertNotNull(cats.next());
}
cats.close();
}
代码示例来源:origin: com.querydsl/querydsl-jpa
@Test
public void scroll() throws IOException {
CloseableIterator<Cat> cats = new ScrollableResultsIterator<Cat>(query().from(cat)
.select(cat).createQuery().scroll());
assertTrue(cats.hasNext());
while (cats.hasNext()) {
assertNotNull(cats.next());
}
cats.close();
}
代码示例来源:origin: com.querydsl/querydsl-jpa
@Test
public void scrollTuple() throws IOException {
CloseableIterator<Tuple> rows = new ScrollableResultsIterator<Tuple>(query()
.from(cat)
.select(cat.name, cat.birthdate).createQuery().scroll());
assertTrue(rows.hasNext());
while (rows.hasNext()) {
Tuple row = rows.next();
assertEquals(2, row.size());
}
rows.close();
}
内容来源于网络,如有侵权,请联系作者删除!