本文整理了Java中org.hibernate.Query.setFetchSize
方法的一些代码示例,展示了Query.setFetchSize
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setFetchSize
方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setFetchSize
[英]Set a fetch size for the underlying JDBC query.
[中]为基础JDBC查询设置获取大小。
代码示例来源: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: spring-projects/spring-batch
/**
* Read a page of data, clearing the existing session (if necessary) first,
* and creating a new session before executing the query.
*
* @param page the page to read (starting at 0)
* @param pageSize the size of the page or maximum number of items to read
* @param fetchSize the fetch size to use
* @param parameterValues the parameter values to use (if any, otherwise
* null)
* @return a collection of items
*/
public Collection<? extends T> readPage(int page, int pageSize, int fetchSize, Map<String, Object> parameterValues) {
clear();
Query query = createQuery();
if (parameterValues != null) {
query.setProperties(parameterValues);
}
@SuppressWarnings("unchecked")
List<T> result = query.setFetchSize(fetchSize).setFirstResult(page * pageSize).setMaxResults(pageSize).list();
return result;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Prepare the given Query object, applying cache settings and/or
* a transaction timeout.
* @param queryObject the Query object to prepare
* @see #setCacheQueries
* @see #setQueryCacheRegion
*/
@SuppressWarnings({"rawtypes", "deprecation"})
protected void prepareQuery(org.hibernate.Query queryObject) {
if (isCacheQueries()) {
queryObject.setCacheable(true);
if (getQueryCacheRegion() != null) {
queryObject.setCacheRegion(getQueryCacheRegion());
}
}
if (getFetchSize() > 0) {
queryObject.setFetchSize(getFetchSize());
}
if (getMaxResults() > 0) {
queryObject.setMaxResults(getMaxResults());
}
ResourceHolderSupport sessionHolder =
(ResourceHolderSupport) TransactionSynchronizationManager.getResource(obtainSessionFactory());
if (sessionHolder != null && sessionHolder.hasTimeout()) {
queryObject.setTimeout(sessionHolder.getTimeToLiveInSeconds());
}
}
代码示例来源:origin: org.springframework/spring-orm
/**
* Prepare the given Query object, applying cache settings and/or
* a transaction timeout.
* @param queryObject the Query object to prepare
* @see #setCacheQueries
* @see #setQueryCacheRegion
*/
@SuppressWarnings({"rawtypes", "deprecation"})
protected void prepareQuery(org.hibernate.Query queryObject) {
if (isCacheQueries()) {
queryObject.setCacheable(true);
if (getQueryCacheRegion() != null) {
queryObject.setCacheRegion(getQueryCacheRegion());
}
}
if (getFetchSize() > 0) {
queryObject.setFetchSize(getFetchSize());
}
if (getMaxResults() > 0) {
queryObject.setMaxResults(getMaxResults());
}
ResourceHolderSupport sessionHolder =
(ResourceHolderSupport) TransactionSynchronizationManager.getResource(obtainSessionFactory());
if (sessionHolder != null && sessionHolder.hasTimeout()) {
queryObject.setTimeout(sessionHolder.getTimeToLiveInSeconds());
}
}
代码示例来源: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: riotfamily/riot
public TypedQuery<T> setFetchSize(int fetchSize) {
query.setFetchSize(fetchSize);
return this;
}
代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate
@Override
public Query setFetchSize(int i) {
return query.setFetchSize(i);
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb
@Override
protected void applyFetchSize(int fetchSize) {
query.setFetchSize( fetchSize );
}
代码示例来源:origin: ezbz/projectx
@Override
public Query setFetchSize(final int fetchSize) {
return query.setFetchSize(fetchSize);
}
代码示例来源:origin: culturecommunication/ginco
@Override
public List<ThesaurusConcept> getConceptsWoNotes(String idThesaurus, int startIndex, int limit) {
Query query = getCurrentSession().createSQLQuery("select c.* "
+ "from thesaurus_concept c "
+ "left join note n on c.identifier = n.conceptid "
+ "where c.thesaurusid=:pthesaurusid"
+ " and n.identifier is null").addEntity(ThesaurusConcept.class);
query.setParameter("pthesaurusid", idThesaurus);
query.setFirstResult(startIndex);
query.setFetchSize(limit);
query.setMaxResults(limit);
return (List<ThesaurusConcept>) query.list();
}
代码示例来源:origin: stackoverflow.com
Query q = session.createCriteria(... no offset or limit ...);
q.setCacheMode(CacheMode.IGNORE);
q.setFetchSize(1000); // experiment with this to optimize performance vs. memory
ScrollableResults iterator = query.scroll(ScrollMode.FORWARD_ONLY);
while (iterator.next()) {
Product p = (Product)iterator.get();
...
// session.evict(p); // an alternative to setting the cache mode above
}
代码示例来源: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);
// 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 flush() 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: jboss.jboss-embeddable-ejb3/hibernate-all
private void initQuery(Query query, NamedQueryDefinition nqd) {
query.setCacheable( nqd.isCacheable() );
query.setCacheRegion( nqd.getCacheRegion() );
if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() );
if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() );
if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() );
query.setReadOnly( nqd.isReadOnly() );
if ( nqd.getComment() != null ) query.setComment( nqd.getComment() );
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
private void initQuery(Query query, NamedQueryDefinition nqd) {
query.setCacheable( nqd.isCacheable() );
query.setCacheRegion( nqd.getCacheRegion() );
if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() );
if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() );
if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() );
query.setReadOnly( nqd.isReadOnly() );
if ( nqd.getComment() != null ) query.setComment( nqd.getComment() );
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
private void initQuery(Query query, NamedQueryDefinition nqd) {
query.setCacheable( nqd.isCacheable() );
query.setCacheRegion( nqd.getCacheRegion() );
if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() );
if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() );
if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() );
query.setReadOnly( nqd.isReadOnly() );
if ( nqd.getComment() != null ) query.setComment( nqd.getComment() );
}
代码示例来源:origin: org.jboss.seam/jboss-seam
protected org.hibernate.Query createQuery()
{
parseEjbql();
evaluateAllParameters();
org.hibernate.Query query = getSession().createQuery( getRenderedEjbql() );
setParameters( query, getQueryParameterValues(), 0 );
setParameters( query, getRestrictionParameterValues(), getQueryParameterValues().size() );
if ( getFirstResult()!=null) query.setFirstResult( getFirstResult() );
if ( getMaxResults()!=null) query.setMaxResults( getMaxResults()+1 ); //add one, so we can tell if there is another page
if ( getCacheable()!=null ) query.setCacheable( getCacheable() );
if ( getCacheRegion()!=null ) query.setCacheRegion( getCacheRegion() );
if ( getFetchSize()!=null ) query.setFetchSize( getFetchSize() );
return query;
}
代码示例来源:origin: OpenNMS/opennms
private void prepareQuery(Query queryObject) {
if(getHibernateTemplate().isCacheQueries()) {
queryObject.setCacheable(true);
if(getHibernateTemplate().getQueryCacheRegion() != null) {
queryObject.setCacheRegion(getHibernateTemplate().getQueryCacheRegion());
}
}
if(getHibernateTemplate().getFetchSize() > 0) {
queryObject.setFetchSize(getHibernateTemplate().getFetchSize());
}
if(getHibernateTemplate().getMaxResults() > 0) {
queryObject.setMaxResults(getHibernateTemplate().getMaxResults());
}
}
内容来源于网络,如有侵权,请联系作者删除!