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

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

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

Query.setCacheMode介绍

暂无

代码示例

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

  1. .setCacheMode( CacheMode.IGNORE )
  2. .scroll( ScrollMode.FORWARD_ONLY );

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

  1. @Test
  2. public void test_hql_api_basic_usage_example() {
  3. doInJPA( this::entityManagerFactory, entityManager -> {
  4. Session session = entityManager.unwrap( Session.class );
  5. //tag::hql-api-basic-usage-example[]
  6. org.hibernate.query.Query query = session.createQuery(
  7. "select p " +
  8. "from Person p " +
  9. "where p.name like :name" )
  10. // timeout - in seconds
  11. .setTimeout( 2 )
  12. // write to L2 caches, but do not read from them
  13. .setCacheMode( CacheMode.REFRESH )
  14. // assuming query cache was enabled for the SessionFactory
  15. .setCacheable( true )
  16. // add a comment to the generated SQL if enabled via the hibernate.use_sql_comments configuration property
  17. .setComment( "+ INDEX(p idx_person_name)" );
  18. //end::hql-api-basic-usage-example[]
  19. });
  20. }

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

  1. protected void setQueryProperties(Query query) {
  2. if ( maxResults != null ) {
  3. query.setMaxResults( maxResults );
  4. }
  5. if ( firstResult != null ) {
  6. query.setFirstResult( firstResult );
  7. }
  8. if ( cacheable != null ) {
  9. query.setCacheable( cacheable );
  10. }
  11. if ( cacheRegion != null ) {
  12. query.setCacheRegion( cacheRegion );
  13. }
  14. if ( comment != null ) {
  15. query.setComment( comment );
  16. }
  17. if ( flushMode != null ) {
  18. query.setFlushMode( flushMode );
  19. }
  20. if ( cacheMode != null ) {
  21. query.setCacheMode( cacheMode );
  22. }
  23. if ( timeout != null ) {
  24. query.setTimeout( timeout );
  25. }
  26. if ( lockOptions != null && lockOptions.getLockMode() != LockMode.NONE ) {
  27. query.setLockMode( REFERENCED_ENTITY_ALIAS, lockOptions.getLockMode() );
  28. }
  29. }

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

  1. .setCacheable(true)
  2. .setCacheRegion( "query.cache.person" )
  3. .setCacheMode( CacheMode.REFRESH )
  4. .list();
  5. "select p from Person p" )
  6. .setCacheable( true )
  7. .setCacheMode( CacheMode.REFRESH )
  8. .list();

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

  1. protected void initQueryFromNamedDefinition(Query query, NamedQueryDefinition nqd) {
  2. // todo : cacheable and readonly should be Boolean rather than boolean...
  3. query.setCacheable( nqd.isCacheable() );
  4. query.setCacheRegion( nqd.getCacheRegion() );
  5. query.setReadOnly( nqd.isReadOnly() );
  6. if ( nqd.getTimeout() != null ) {
  7. query.setTimeout( nqd.getTimeout() );
  8. }
  9. if ( nqd.getFetchSize() != null ) {
  10. query.setFetchSize( nqd.getFetchSize() );
  11. }
  12. if ( nqd.getCacheMode() != null ) {
  13. query.setCacheMode( nqd.getCacheMode() );
  14. }
  15. if ( nqd.getComment() != null ) {
  16. query.setComment( nqd.getComment() );
  17. }
  18. if ( nqd.getFirstResult() != null ) {
  19. query.setFirstResult( nqd.getFirstResult() );
  20. }
  21. if ( nqd.getMaxResults() != null ) {
  22. query.setMaxResults( nqd.getMaxResults() );
  23. }
  24. if ( nqd.getFlushMode() != null ) {
  25. query.setHibernateFlushMode( nqd.getFlushMode() );
  26. }
  27. }

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

  1. .setLockMode( LockModeType.NONE )
  2. .setHibernateFlushMode( FlushMode.MANUAL )
  3. .setCacheMode( cacheMode )
  4. .setFetchSize( entityFetchSize )

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

  1. query.setCacheMode( cacheMode );

相关文章