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

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

本文整理了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

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

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

  1. @Override
  2. protected void applyCacheMode(CacheMode cacheMode) {
  3. query.setCacheMode( cacheMode );
  4. }

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

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

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

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

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

  1. @Override
  2. public Query setCacheMode(CacheMode cacheMode) {
  3. return query.setCacheMode(cacheMode);
  4. }

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

  1. /**
  2. * Sets the specified query cacheable with NORMAL cache mode.
  3. *
  4. * @param c
  5. */
  6. protected void setCacheable(Query q) {
  7. q.setCacheable(true);
  8. q.setCacheMode(CacheMode.NORMAL);
  9. }

代码示例来源:origin: stackoverflow.com

  1. Query q = session.createCriteria(... no offset or limit ...);
  2. q.setCacheMode(CacheMode.IGNORE);
  3. q.setFetchSize(1000); // experiment with this to optimize performance vs. memory
  4. ScrollableResults iterator = query.scroll(ScrollMode.FORWARD_ONLY);
  5. while (iterator.next()) {
  6. Product p = (Product)iterator.get();
  7. ...
  8. // session.evict(p); // an alternative to setting the cache mode above
  9. }

代码示例来源:origin: org.sakaiproject.profile2/profile2-impl

  1. public Object doInHibernate(Session session) throws HibernateException, SQLException {
  2. Query q = session.getNamedQuery(QUERY_GET_SAKAI_PERSON);
  3. //see scalars in the hbm
  4. q.setFirstResult(start);
  5. q.setMaxResults(count);
  6. q.setResultTransformer(Transformers.aliasToBean(UserProfile.class));
  7. q.setCacheMode(CacheMode.GET);
  8. return q.list();
  9. }
  10. };

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

  1. /**
  2. * crates a Stream with given {@link Query} q
  3. *
  4. * @param q
  5. * - given Query
  6. * @return new {@link Stream} with given ResultSet
  7. */
  8. public <T> Stream<T> stream(Query q) {
  9. if(TransactionStatus.NOT_ACTIVE.equals(session.getTransaction().getStatus()))
  10. session.beginTransaction();
  11. if (loggingEnabled)
  12. logQuery(false);
  13. return StreamSupport.<T> stream(Spliterators.spliteratorUnknownSize(
  14. new QueryIterator<T>(q.setCacheMode(CacheMode.IGNORE)
  15. .setFlushMode(FlushMode.MANUAL), this, false),
  16. Spliterator.ORDERED | Spliterator.DISTINCT), false);
  17. }

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

  1. query.setCacheMode(cacheMode);

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

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

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

  1. query.setCacheMode( (CacheMode) value );

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

  1. private void initQuery(Query query, NamedQueryDefinition nqd) {
  2. query.setCacheable( nqd.isCacheable() );
  3. query.setCacheRegion( nqd.getCacheRegion() );
  4. if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() );
  5. if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() );
  6. if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() );
  7. query.setReadOnly( nqd.isReadOnly() );
  8. if ( nqd.getComment() != null ) query.setComment( nqd.getComment() );
  9. }

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

  1. private void initQuery(Query query, NamedQueryDefinition nqd) {
  2. query.setCacheable( nqd.isCacheable() );
  3. query.setCacheRegion( nqd.getCacheRegion() );
  4. if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() );
  5. if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() );
  6. if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() );
  7. query.setReadOnly( nqd.isReadOnly() );
  8. if ( nqd.getComment() != null ) query.setComment( nqd.getComment() );
  9. }

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

  1. private void initQuery(Query query, NamedQueryDefinition nqd) {
  2. query.setCacheable( nqd.isCacheable() );
  3. query.setCacheRegion( nqd.getCacheRegion() );
  4. if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() );
  5. if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() );
  6. if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() );
  7. query.setReadOnly( nqd.isReadOnly() );
  8. if ( nqd.getComment() != null ) query.setComment( nqd.getComment() );
  9. }

相关文章