List of usage examples for org.hibernate ScrollMode FORWARD_ONLY
ScrollMode FORWARD_ONLY
To view the source code for org.hibernate ScrollMode FORWARD_ONLY.
Click Source Link
From source file:org.rhq.server.metrics.migrator.datasources.ScrollableDataSource.java
License:Open Source License
@Override public void initialize() { if (session != null || results != null) { close();// w ww . ja v a 2 s . c o m } session = ((Session) entityManager.getDelegate()).getSessionFactory().openStatelessSession(); this.prepareSQLSession(); if (log.isDebugEnabled()) { if (maxResults >= 0) { log.debug("Preparing the query with " + maxResults + " results."); } else { log.debug("Preparing the query with all the results."); } } Query query = session.createSQLQuery(selectNativeQuery); if (maxResults >= 0) { query.setMaxResults(maxResults); } query.setFetchSize(30000); query.setReadOnly(true); query.setTimeout(TIMEOUT); results = query.scroll(ScrollMode.FORWARD_ONLY); lastMigratedItemIndex = -1; if (log.isDebugEnabled()) { if (maxResults >= 0) { log.debug("Query prepared with " + maxResults + " results."); } else { log.debug("Query prepared with all the results."); } } }
From source file:org.shredzone.cilla.core.repository.impl.SearchDaoHibImpl.java
License:Open Source License
@Override public int count(Query query, Criteria crit) { assertCriteriaEntity(crit);//from w w w .jav a 2 s . c om int count = 0; FullTextSession fullTextSession = getFullTextSession(); FullTextQuery fq = fullTextSession.createFullTextQuery(query, Page.class); fq.setCriteriaQuery(crit != null ? crit : pageDao.criteria()); ScrollableResults sr = fq.scroll(ScrollMode.FORWARD_ONLY); if (sr.last()) { count = sr.getRowNumber(); } sr.close(); return count; }
From source file:org.smallmind.persistence.orm.hibernate.HibernateDao.java
License:Open Source License
public Iterable<D> scroll() { return new ScrollIterator<D>( getSession().getNativeSession().createCriteria(getManagedClass()).scroll(ScrollMode.FORWARD_ONLY), getManagedClass());// w w w .ja va2s . co m }
From source file:org.smallmind.persistence.orm.hibernate.HibernateDao.java
License:Open Source License
public Iterable<D> scroll(int fetchSize) { return new ScrollIterator<D>(getSession().getNativeSession().createCriteria(getManagedClass()) .setFetchSize(fetchSize).scroll(ScrollMode.FORWARD_ONLY), getManagedClass()); }
From source file:org.smallmind.persistence.orm.hibernate.HibernateDao.java
License:Open Source License
public Iterable<D> scrollBySQLQuery(SQLQueryDetails sqlQueryDetails) { return new ScrollIterator<D>( constructSQLQuery(sqlQueryDetails).addEntity(getManagedClass()).scroll(ScrollMode.FORWARD_ONLY), getManagedClass());/*from ww w . ja v a 2s . c om*/ }
From source file:org.smallmind.persistence.orm.hibernate.HibernateDao.java
License:Open Source License
public <T> Iterable<T> scrollByQuery(Class<T> returnType, QueryDetails queryDetails) { return new ScrollIterator<T>(constructQuery(queryDetails).scroll(ScrollMode.FORWARD_ONLY), returnType); }
From source file:org.smallmind.persistence.orm.hibernate.HibernateDao.java
License:Open Source License
public Iterable<D> scrollByQuery(QueryDetails queryDetails) { return new ScrollIterator<D>(constructQuery(queryDetails).scroll(ScrollMode.FORWARD_ONLY), getManagedClass());/*from w w w. jav a 2s . co m*/ }
From source file:org.smallmind.persistence.orm.hibernate.HibernateDao.java
License:Open Source License
public <T> Iterable<T> scrollByCriteria(Class<T> returnType, CriteriaDetails criteriaDetails) { return new ScrollIterator<T>(constructCriteria(criteriaDetails).scroll(ScrollMode.FORWARD_ONLY), returnType);//from ww w . j a v a 2 s.c o m }
From source file:org.smallmind.persistence.orm.hibernate.HibernateDao.java
License:Open Source License
public Iterable<D> scrollByCriteria(CriteriaDetails criteriaDetails) { return new ScrollIterator<D>(constructCriteria(criteriaDetails).scroll(ScrollMode.FORWARD_ONLY), getManagedClass());/*from w w w . j ava2s . co m*/ }
From source file:org.springframework.batch.item.database.Hibernate5ItemReaderHelper.java
License:Apache License
/** * 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} *///from w w w. jav a2 s. co m 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); }