@Override protected Object getResults(Session s, boolean isSingleResult) { Query query = getQuery( s ).setCacheable( getQueryCacheMode() != CacheMode.IGNORE ).setCacheMode( getQueryCacheMode() ); return ( isSingleResult ? query.uniqueResult() : query.list() ); } }
@Override protected void applyCacheMode(CacheMode cacheMode) { query.setCacheMode( cacheMode ); }
public TypedQuery<T> setCacheMode(CacheMode cacheMode) { query.setCacheMode(cacheMode); return this; }
@Override public Query setCacheMode(final CacheMode cacheMode) { return query.setCacheMode(cacheMode); }
@Override public Query setCacheMode(CacheMode cacheMode) { return query.setCacheMode(cacheMode); }
/** * Sets the specified query cacheable with NORMAL cache mode. * * @param c */ protected void setCacheable(Query q) { q.setCacheable(true); q.setCacheMode(CacheMode.NORMAL); }
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 }
public Object doInHibernate(Session session) throws HibernateException, SQLException { Query q = session.getNamedQuery(QUERY_GET_SAKAI_PERSON); //see scalars in the hbm q.setFirstResult(start); q.setMaxResults(count); q.setResultTransformer(Transformers.aliasToBean(UserProfile.class)); q.setCacheMode(CacheMode.GET); return q.list(); } };
/** * crates a Stream with given {@link Query} q * * @param q * - given Query * @return new {@link Stream} with given ResultSet */ public <T> Stream<T> stream(Query q) { if(TransactionStatus.NOT_ACTIVE.equals(session.getTransaction().getStatus())) session.beginTransaction(); if (loggingEnabled) logQuery(false); return StreamSupport.<T> stream(Spliterators.spliteratorUnknownSize( new QueryIterator<T>(q.setCacheMode(CacheMode.IGNORE) .setFlushMode(FlushMode.MANUAL), this, false), Spliterator.ORDERED | Spliterator.DISTINCT), false); }
query.setCacheMode(cacheMode);
query.setCacheMode( ConfigurationHelper.getCacheMode( value ) );
query.setCacheMode( (CacheMode) value );
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() ); }
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() ); }
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() ); }