本文整理了Java中org.hibernate.query.Query.setFetchSize
方法的一些代码示例,展示了Query.setFetchSize
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setFetchSize
方法的具体详情如下:
包路径:org.hibernate.query.Query
类名称:Query
方法名:setFetchSize
暂无
代码示例来源:origin: spring-projects/spring-batch
@Test
@SuppressWarnings("unchecked")
public void testStatefulClose(){
SessionFactory sessionFactory = mock(SessionFactory.class);
Session session = mock(Session.class);
Query<Foo> scrollableResults = mock(Query.class);
HibernateCursorItemReader<Foo> itemReader = new HibernateCursorItemReader<>();
itemReader.setSessionFactory(sessionFactory);
itemReader.setQueryString("testQuery");
itemReader.setUseStatelessSession(false);
when(sessionFactory.openSession()).thenReturn(session);
when(session.createQuery("testQuery")).thenReturn(scrollableResults);
when(scrollableResults.setFetchSize(0)).thenReturn(scrollableResults);
itemReader.open(new ExecutionContext());
itemReader.close();
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue(jiraKey = "HHH-10860")
public void testScrollableResults() {
final List params = new ArrayList();
params.add( 1L );
params.add( 2L );
try (Session s = openSession()) {
final Query query = s.createQuery( "from MyEntity e where e.id in (:ids)" )
.setParameter( "ids", params )
.setFetchSize( 10 );
try (ScrollableResults scroll = query.scroll( ScrollMode.FORWARD_ONLY )) {
int i = 0;
while ( scroll.next() ) {
if ( i == 0 ) {
assertThat( ((MyEntity) scroll.get()[0]).getDescription(), is( "entity_1" ) );
}
else {
assertThat( ((MyEntity) scroll.get()[0]).getDescription(), is( "entity_2" ) );
}
i++;
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
@TestForIssue(jiraKey = "HHH-10860")
public void testScrollableResults2() {
final List params = new ArrayList();
params.add( 1L );
params.add( 2L );
try (Session s = openSession()) {
final Query query = s.createQuery( "from MyEntity e where e.id in (:ids)" )
.setParameter( "ids", params )
.setFetchSize( 10 );
try (ScrollableResults scroll = query.scroll( )) {
int i = 0;
while ( scroll.next() ) {
if ( i == 0 ) {
assertThat( ((MyEntity) scroll.get()[0]).getDescription(), is( "entity_1" ) );
}
else {
assertThat( ((MyEntity) scroll.get()[0]).getDescription(), is( "entity_2" ) );
}
i++;
}
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
protected void initQueryFromNamedDefinition(Query query, NamedQueryDefinition nqd) {
// todo : cacheable and readonly should be Boolean rather than boolean...
query.setCacheable( nqd.isCacheable() );
query.setCacheRegion( nqd.getCacheRegion() );
query.setReadOnly( nqd.isReadOnly() );
if ( nqd.getTimeout() != null ) {
query.setTimeout( nqd.getTimeout() );
}
if ( nqd.getFetchSize() != null ) {
query.setFetchSize( nqd.getFetchSize() );
}
if ( nqd.getCacheMode() != null ) {
query.setCacheMode( nqd.getCacheMode() );
}
if ( nqd.getComment() != null ) {
query.setComment( nqd.getComment() );
}
if ( nqd.getFirstResult() != null ) {
query.setFirstResult( nqd.getFirstResult() );
}
if ( nqd.getMaxResults() != null ) {
query.setMaxResults( nqd.getMaxResults() );
}
if ( nqd.getFlushMode() != null ) {
query.setHibernateFlushMode( nqd.getFlushMode() );
}
}
代码示例来源:origin: jamesagnew/hapi-fhir
hibernateQuery.setFetchSize(myFetchSize);
ScrollableResults scroll = hibernateQuery.scroll(ScrollMode.FORWARD_ONLY);
myResultsIterator = new ScrollableResultsIterator<>(scroll);
代码示例来源:origin: jamesagnew/hapi-fhir
hibernateQuery.setFetchSize(myFetchSize);
ScrollableResults scrollableResults = hibernateQuery.scroll(ScrollMode.FORWARD_ONLY);
Iterator<TermConceptMapGroupElementTarget> scrollableResultsIterator = new ScrollableResultsIterator<>(scrollableResults);
代码示例来源:origin: jamesagnew/hapi-fhir
hibernateQuery.setFetchSize(myFetchSize);
ScrollableResults scrollableResults = hibernateQuery.scroll(ScrollMode.FORWARD_ONLY);
Iterator<TermConceptMapGroupElement> scrollableResultsIterator = new ScrollableResultsIterator<>(scrollableResults);
代码示例来源:origin: com.atlassian.hibernate/hibernate.adapter
@Override
public Query setFetchSize(final int fetchSize) {
if (queryV2ForCompare != null) {
queryV2ForCompare.setFetchSize(fetchSize);
}
query.setFetchSize(fetchSize);
return this;
}
代码示例来源:origin: dkpro/dkpro-jwpl
.setFirstResult(dataOffset)
.setMaxResults(maxBufferSize)
.setFetchSize(maxBufferSize)
.list();
session.getTransaction().commit();
代码示例来源:origin: ca.uhn.hapi.fhir/hapi-fhir-jpaserver-base
hibernateQuery.setFetchSize(myFetchSize);
ScrollableResults scroll = hibernateQuery.scroll(ScrollMode.FORWARD_ONLY);
myResultsIterator = new ScrollableResultsIterator<>(scroll);
代码示例来源:origin: ca.uhn.hapi.fhir/hapi-fhir-jpaserver-base
hibernateQuery.setFetchSize(myFetchSize);
ScrollableResults scrollableResults = hibernateQuery.scroll(ScrollMode.FORWARD_ONLY);
Iterator<TermConceptMapGroupElement> scrollableResultsIterator = new ScrollableResultsIterator<>(scrollableResults);
代码示例来源:origin: ca.uhn.hapi.fhir/hapi-fhir-jpaserver-base
hibernateQuery.setFetchSize(myFetchSize);
ScrollableResults scrollableResults = hibernateQuery.scroll(ScrollMode.FORWARD_ONLY);
Iterator<TermConceptMapGroupElementTarget> scrollableResultsIterator = new ScrollableResultsIterator<>(scrollableResults);
代码示例来源:origin: hibernate/hibernate-search
.setHibernateFlushMode( FlushMode.MANUAL )
.setCacheMode( cacheMode )
.setFetchSize( entityFetchSize )
内容来源于网络,如有侵权,请联系作者删除!