org.hibernate.Query.setCacheMode()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(172)

本文整理了Java中org.hibernate.Query.setCacheMode方法的一些代码示例,展示了Query.setCacheMode的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setCacheMode方法的具体详情如下:
包路径:org.hibernate.Query
类名称:Query
方法名:setCacheMode

Query.setCacheMode介绍

[英]Override the current session cache mode, just for this query.
[中]覆盖当前会话缓存模式,仅用于此查询。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

@Override
  protected Object getResults(Session s, boolean isSingleResult) {
    Query query = getQuery( s ).setCacheable( getQueryCacheMode() != CacheMode.IGNORE ).setCacheMode( getQueryCacheMode() );
    return ( isSingleResult ? query.uniqueResult() : query.list() );
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.ejb

@Override
protected void applyCacheMode(CacheMode cacheMode) {
  query.setCacheMode( cacheMode );
}

代码示例来源:origin: riotfamily/riot

public TypedQuery<T> setCacheMode(CacheMode cacheMode) {
  query.setCacheMode(cacheMode);
  return this;
}

代码示例来源:origin: ezbz/projectx

@Override
public Query setCacheMode(final CacheMode cacheMode) {
 return query.setCacheMode(cacheMode);
}

代码示例来源:origin: com.github.cafdataprocessing/corepolicy-hibernate

@Override
public Query setCacheMode(CacheMode cacheMode) {
  return query.setCacheMode(cacheMode);
}

代码示例来源:origin: com.github.mrstampy/hit

/**
 * Sets the specified query cacheable with NORMAL cache mode.
 * 
 * @param c
 */
protected void setCacheable(Query q) {
 q.setCacheable(true);
 q.setCacheMode(CacheMode.NORMAL);
}

代码示例来源: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: org.sakaiproject.profile2/profile2-impl

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();
  }
};

代码示例来源:origin: at.chrl/chrl-orm

/**
 * 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);
}

代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate

query.setCacheMode(cacheMode);

代码示例来源:origin: hibernate/hibernate-entitymanager

query.setCacheMode( ConfigurationHelper.getCacheMode( value ) );

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

query.setCacheMode( (CacheMode) value );

代码示例来源: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() );
}

相关文章

微信公众号

最新文章

更多