Java Code Examples for org.hibernate.Query#setCacheMode()

The following examples show how to use org.hibernate.Query#setCacheMode() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
/**
	 * {@inheritDoc}
	 */
@Override
public List<UserProfile> getUserProfiles(final int start, final int count) {
	
	//get fields directly from the sakaiperson table and use Transformers.aliasToBean to transform into UserProfile pojo
	//the idea is we *dont* want a SakaiPerson object
	final HibernateCallback<List<UserProfile>> hcb = session -> {
           final 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();
       };
  	
  	return getHibernateTemplate().execute(hcb);
}
 
Example 2
/**
	 * {@inheritDoc}
	 */
@Override
public List<UserProfile> getUserProfiles(final int start, final int count) {
	
	//get fields directly from the sakaiperson table and use Transformers.aliasToBean to transform into UserProfile pojo
	//the idea is we *dont* want a SakaiPerson object
	final HibernateCallback<List<UserProfile>> hcb = session -> {
           final 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();
       };
  	
  	return getHibernateTemplate().execute(hcb);
}
 
Example 3
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() );
}