hibernate的查询缓存

Java 领域 Hibernate 的查询缓存清理策略 Hibernate作为Java领域最流行的ORM框架之一,其缓存机制对应用性能有着至关重要的影响。深入理解查询缓存的工作原理掌握查询缓存的配置和使用方法了解查询缓存的失效机制学会优化查询缓存的使用策略本文讨论范围涵盖Hibernate 5.x版本的查询缓存机制,重点分析其清理策略的实现原理和最佳实践。背景介绍:概述Hibernate缓存体系核心概念:详细解析查询缓存机制清理策略算法:分析缓存清理的实现原理数学模型:建立缓存性能分析模型实战案例:展示查询缓存的实际应用。 阅读详情
在hibernate的使用中,大家多数时间都在讨论一级缓存和二级缓存,而往往忽略了查询缓存。其实hibernate的查询缓存在使用过程中也起着同样重要的作用。hibernate的查询缓存是主要是针对普通属性结果集的缓存, 而对于实体对象的结果集只缓存id。在一级缓存,二级缓存和查询缓存都打开的情况下作查询操作时这样的:查询普通属性,会先到查询缓存中取,如果没有,则查询数据库;查询实体,会先到查询缓存中取id,如果有,则根据id到缓存(一级/二级)中取实体,如果缓存中取不到实体,再查询数据库。
 
    和一级/二级缓存不同,查询缓存的生命周期 ,是不确定的,当前关联的表发生改变时,查询缓存的生命周期结束。
 
     查询缓存的配置和使用也是很简单的:
         1>查询缓存的启用不但要在配置文件中进行配置
             <property name="hibernate.cache.use_query_cache">true</property>
         2>还要在程序中显示的进行启用
             query.setCacheable(true);

1>查询缓存的启用不但要在配置文件中进行配置 -------换成spring配置
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>/WEB-INF/config/jdbc.properties</value>
            </list>
        </property>
    </bean>
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driverClassName}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="user" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <property name="autoCommitOnClose" value="true"/>
        <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/>
        <property name="initialPoolSize" value="${cpool.minPoolSize}"/>
        <property name="minPoolSize" value="${cpool.minPoolSize}"/>
        <property name="maxPoolSize" value="${cpool.maxPoolSize}"/>
        <property name="maxIdleTime" value="${cpool.maxIdleTime}"/>
        <property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
        <property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/>
    </bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>    
        <property name="mappingLocations">
            <list>
                <value>classpath*:/com/jeecms/core/entity/hbm/*.hbm.xml</value>
                <value>classpath*:/com/jeecms/cms/entity/main/hbm/*.hbm.xml</value>
                <value>classpath*:/com/jeecms/cms/entity/assist/hbm/*.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <value>
            hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
            hibernate.show_sql=false
            hibernate.format_sql=false
            hibernate.query.substitutions=true 1, false 0
            hibernate.jdbc.batch_size=20
            //查询缓存配置
            hibernate.cache.use_query_cache=true
            </value>
        </property>
        <property name="entityInterceptor">   
            <ref local="treeInterceptor"/>
        </property>
        <property name="cacheProvider">
            <ref local="cacheProvider"/>
        </property>
        <property name="lobHandler">
            <ref bean="lobHandler" />
        </property>
    </bean>

2>还要在程序中显示的进行启用
public List<CmsSite> getList(boolean cacheable) {
        String hql = "from CmsSite bean order by bean.id asc";
        return getSession().createQuery(hql).setCacheable(cacheable).list();
    }

 
1.实体类:
  Student.jsva
public class Student { 
  private Integer id; 
  private String name; 
  //一系列的setter.getter方法 
}
 
2.映射文件
  Student.hbm.xml
  <class name="com.sxt.hibernate.cache.entity.Student" table="sxt_hibernate_student"> 
         
    <!-- 指定本类的对象使用二级缓存(这也可以放在hibernate.cfg.xml中统一指定) --> 
    <!-- 
    <cache usage="read-only"/> 
     
--> 
    <id name="id" length="4"> 
      <generator class="native"></generator> 
    </id> 
    <property name="name" length="10"></property> 
  </class>
 
3.hibernate配置文件:
  hibernate.cfg.xml
<hibernate-configuration> 
  <session-factory> 
    <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:ORCL10</property>
    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property> 
    <property name="hibernate.connection.username">scott</property> 
    <property name="hibernate.connection.password">yf123</property> 
    <property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property> 
    <property name="hibernate.show_sql">true</property> 
     
    <!-- 开启二级缓存,其实hibernate默认就是开启的,这里显示的指定一下 --> 
    <property name="hibernate.cache.use_second_level_cache">true</property> 
    <!-- 指定二级缓存产品的提供商 --> 
    <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property> 
     
    <!-- 启用查询缓存 --> 
    <property name="hibernate.cache.use_query_cache">true</property> 
     
    <mapping resource="com/sxt/hibernate/cache/entity/Student.hbm.xml"/> 
     
    <!-- 指定那些类使用二级缓存 --> 
    <class-cache usage="read-only" class="com.sxt.hibernate.cache.entity.Student"/> 
  </session-factory> 
</hibernate-configuration>
 
4.测试方法:
  public static void main(String[] args) { 
    Session session = null; 
    Transaction t = null; 

    *//** 
     * 开启查询缓存,关闭二级缓存, 开启一个session,分别调用query.list 
     */ 
  //如果不用查询缓存的话,那两个都发出查询语句,这也是默认的情况. 
  /* 
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s.name from Student s"); 
      //启用查询缓存    
      query.setCacheable(true); 
      List<String> names = query.list(); 
      for (Iterator<String> it = names.iterator(); it.hasNext();) { 
        String name = it.next(); 
        System.out.println(name); 
      } 
      System.out.println("================================"); 
      query = session.createQuery("select s.name from Student s"); 
      //启用查询缓存 
      query.setCacheable(true); 
      //没有发出查询语句,因为这里使用的查询缓存 
      names = query.list(); 
      for (Iterator<String> it = names.iterator(); it.hasNext();) { 
        String name = it.next(); 
        System.out.println(name); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
  }*/ 
    
/*  @SuppressWarnings("unchecked") 
  public static void main(String[] args) { 
    Session session = null; 
    Transaction t = null; 

    *//** 
     * 开启查询缓存,关闭二级缓存, 开启两个session,分别调用query.list 
     *//* 
    //如果不用查询缓存的话,那两个都发出查询语句,这也是默认的情况. 
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s.name from Student s"); 
      //启用查询缓存    
      //query.setCacheable(true); 
      List<String> names = query.list(); 
      for (Iterator<String> it = names.iterator(); it.hasNext();) { 
        String name = it.next(); 
        System.out.println(name); 
      } 

      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
     
    System.out.println("================================"); 
     
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s.name from Student s"); 
      //启用查询缓存    
      //query.setCacheable(true); 
      //不会发出查询语句,因为查询缓存和session无关. 
      List<String> names = query.list(); 
      for (Iterator<String> it = names.iterator(); it.hasNext();) { 
        String name = it.next(); 
        System.out.println(name); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
  }*/ 
    
/*  @SuppressWarnings("unchecked") 
  public static void main(String[] args) { 
    Session session = null; 
    Transaction t = null; 

    *//** 
     * 开启查询缓存,关闭二级缓存, 开启两个session,分别调用query.iterate 
     *//* 
    //如果不用查询缓存的话,那两个都发出查询语句,这也是默认的情况. 
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s.name from Student s"); 
      //启用查询缓存    
      query.setCacheable(true); 
      for (Iterator<String> it = query.iterate(); it.hasNext();) { 
        String name = it.next(); 
        System.out.println(name); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
     
    System.out.println("================================"); 
     
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s.name from Student s"); 
      //启用查询缓存    
      query.setCacheable(true); 
      //会发出查询语句,因为query.iterate不使用查询缓存 
      for (Iterator<String> it = query.iterate(); it.hasNext();) { 
        String name = it.next(); 
        System.out.println(name); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
  }*/ 
    
/*    @SuppressWarnings("unchecked") 
  public static void main(String[] args) { 
    Session session = null; 
    Transaction t = null; 

    *//** 
     * 关闭查询缓存,关闭二级缓存, 开启两个session,分别调用query.list查询实体对象 
     *//* 
    //如果不用查询缓存的话,那两个都发出查询语句,这也是默认的情况. 
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s from Student s"); 
      //启用查询缓存    
      //query.setCacheable(true); 
      List<Student> students = query.list(); 
      for (Iterator<Student> it = students.iterator(); it.hasNext();) { 
        Student s = it.next(); 
        System.out.println(s.getName()); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
     
    System.out.println("================================"); 
     
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s from Student s"); 
      //启用查询缓存    
      //query.setCacheable(true); 
      //会发出查询语句,因为list默认每次都会发出sql语句 
      List<Student> students = query.list(); 
      for (Iterator<Student> it = students.iterator(); it.hasNext();) { 
        Student s = it.next(); 
        System.out.println(s.getName()); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
  }*/ 
    
/*  @SuppressWarnings("unchecked") 
  public static void main(String[] args) { 
    Session session = null; 
    Transaction t = null; 

    *//** 
     * 开启查询缓存,关闭二级缓存, 开启两个session,分别调用query.list查询实体对象 
     *//* 
    //如果不用查询缓存的话,那两个都发出查询语句,这也是默认的情况. 
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s from Student s"); 
      //启用查询缓存    
      query.setCacheable(true); 
      List<Student> students = query.list(); 
      for (Iterator<Student> it = students.iterator(); it.hasNext();) { 
        Student s = it.next(); 
        System.out.println(s.getName()); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
     
    System.out.println("================================"); 
     
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s from Student s"); 
      //启用查询缓存    
      query.setCacheable(true); 
      //会发出根据id查询实体的n条查询语句,因为这种情况下,查询过程是这样的: 
      // 在第一次执行list时,会把查询对象的id缓存到查询缓存里 
      // 第二次执行list时, 会遍历查询缓存里的id到缓存里去找实体对象,由于这里没找到实体对象, 
      //所以就发出n条查询语句到数据库中查询. 
      List<Student> students = query.list(); 
      for (Iterator<Student> it = students.iterator(); it.hasNext();) { 
        Student s = it.next(); 
        System.out.println(s.getName()); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
  }*/ 
    
  @SuppressWarnings("unchecked") 
  public static void main(String[] args) { 
    Session session = null; 
    Transaction t = null; 

    /** 
     * 开启查询缓存,开启二级缓存, 开启两个session,分别调用query.list查询实体对象 
     */ 
    //如果不用查询缓存的话,那两个都发出查询语句,这也是默认的情况. 
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s from Student s"); 
      //启用查询缓存    
      query.setCacheable(true); 
      List<Student> students = query.list(); 
      for (Iterator<Student> it = students.iterator(); it.hasNext();) { 
        Student s = it.next(); 
        System.out.println(s.getName()); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
     
    System.out.println("================================"); 
     
    try { 
      session = HibernateUtils.getSession(); 
      t = session.beginTransaction(); 
      Query query = session.createQuery("select s from Student s"); 
      //启用查询缓存    
      query.setCacheable(true); 
      //不会发出查询语句,因为这种情况下,查询过程是这样的: 
      // 在第一次执行list时,会把查询对象的id缓存到查询缓存里 
      // 第二次执行list时, 会遍历查询缓存里的id到缓存里去找实体对象,由于这里开启了二级缓存,可以找到目标实体对象, 
      //所以就不会再发出n条查询语句. 
      List<Student> students = query.list(); 
      for (Iterator<Student> it = students.iterator(); it.hasNext();) { 
        Student s = it.next(); 
        System.out.println(s.getName()); 
      } 
      t.commit(); 
    } catch (Exception e) { 
      e.printStackTrace(); 
      t.rollback(); 
    } finally { 
      HibernateUtils.closeSession(session); 
    } 
  }
hibernate开启二级缓存和查询缓存 NULL 博文链接:https://yizhaorong.iteye.com/blog/2119438 立即下载

相关推荐

hibernate一级缓存、二级缓存和查询缓存

NULL 博文链接:https://cdxs2.iteye.com/blog/1936594

hibernate的查询缓存机制

<br />原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://yangfei520.blog.51cto.com/1041581/287380    在hibernate的使用中,大家多数时间都在讨论一级缓存和二级缓存,而往往忽略了查询缓存。其实hibernate的查询缓存在使用过程中也起着同样重要的作用。hibernate的查询缓存是主要是针对普通属性结果集的缓存, 而对于实体对象的结果集只缓存id。在一级缓存,二级缓存和查询缓存都打开的

FG2006的专栏 1085

Hibernate-二级缓存总结 开发技术 - Java.zip

Hibernate_二级缓存总结 开发技术 - Java.zip

hibernate缓存相关问题排查

该问题无法稳定复现,而且由于对hibernate基本不了解,定位和排查也是比较困难。排查问题还是得大胆猜想,仔细验证,问题总能定位的。今天又学到了!

qq_24367757的博客 1006

hibernate查询与缓存

Hibernate查询首先介绍get()和load()方法的区别:get()方法和load()方法的区别主要在于对二级缓存的使用上。load()方法会使用二级缓存,而get()方法在一级缓存没有找到会直接查询数据库,不会去二级缓存中查找。 get():如果在数据库中没有记录会返回空,get()无论如何都会返回数据. load():如果数据库中没有记录会抛出异常,如果有数据返回的是一个代理对象。 get()方法默认不支持lazy(延迟加

hibernate查询缓存详细分析

主要介绍了hibernate查询缓存详细分析,包括查询缓存配置方法及关闭二级缓存的详细介绍,需要的朋友参考下本文吧

Hibernate的查询缓存是什么?

Hibernate的查询缓存是什么?

weixin_45428910的博客 383

Globus 数据下载

Globus 大数据下载流程~

weixin_43978558的博客 6645

hibernate查询缓存_Hibernate查询缓存如何工作

hibernate查询缓存 介绍 现在,我已经介绍了实体和集合缓存,现在该研究查询缓存的工作原理了。 查询缓存与实体严格相关,它在搜索条件和满足该特定查询过滤器的实体之间绘制关联。 像其他Hibernate功能一样,查询缓存也不像人们想象的那么琐碎。 实体模型 对于我们的测试用例,我们将使用以下域模型: Post实体与Author 具有多对一关联,并且两个实体都存储在第二级缓...

最佳 Java 编程 904

【Telephony】Telephony总纲!Phone进程流程(AOSP)

整个Framework层的Telephony框架运行在一个叫做Phone(com.android.phone)的进程中。 Phone进程启动的过程中,会初始化非常多的分支功能,SIM卡流程初始化就是其中之一,所以我觉得有必要写一下Phone进程的框架

weixin_44513784的博客 1979

自建邮局服务器| 批量邮件群发系统PowerMTA+oem(mumara,mailwizz, interspire)

世界顶级自建邮局服务器PowerMTA+oem(mumara,mailwizz, interspire) PowerMTA4.5(最好用的 群发邮件软件)是用于大批量多ip开发的邮件传递邮寄。可按每小时发送数近百万条电子邮件,发送IP地址和域可以详细配置,加上目前流行前端oem,mumara,mailwizz, interspire等,可定时发送,定时重复发送,实现全自动化 邮件群发 方案。 官网(powermta4.5下载) https://www.sparkpost.com/powermta/ 使用Po

ytrsexpo的博客 6506

Hibernate缓存——查询缓存

Hibernate缓存——查询缓存 默认情况下关闭设置的缓存对HQL和QBC查询时无效,需要打开查询缓存。 查询缓存依赖于二级缓存。 1.设置          true 2.在打开了查询缓存之后,需要注意,调用query.list()操作之前,必须显式调用query.setCachable(true)来标识某个查询使用缓存。   pu

fkngl的博客 1294

从安装到出图:一份给振动测试新手的LMS Test.Lab 2021完整避坑手册(含许可证更新和常见弹窗解决)

本文为振动测试新手提供LMS Test.Lab 2021的完整使用指南,涵盖安装配置、许可证更新、数据采集到频域后处理的全流程。特别针对常见弹窗错误提供解决方案,并详细讲解Colormap时频图分析技巧,帮助用户快速掌握振动数据分析核心技能。

weixin_29268331的博客 997

Hibernate缓存☞查询缓存

Hibernate缓存☞一级缓存 Hibernate缓存☞二级缓存 Hibernate缓存☞查询缓存 Hibernate缓存☞总结 网上说 query.setCacheable(true) 或criteria.setCacheable(true) 这两种方式的缓存命中率低,个人认为谈论这个“无卵用”; 我在测试的时候发现,上面的操作会受配置的限制,必须在配

Sucre 2933

【华为鸿蒙3.0/荣耀安卓12使用VMOS Pro的激活方式】

解压激活工具 →连接数据线 轻松搞定激活!

Amy_mumu的博客 142万+

杰理JL701N内置flash录音配置教程

本文详细介绍了内置Flash录音功能的配置方法。主要内容包括:1) 基础模式配置(开启音乐/录音模式、Flash录音宏定义);2) 录音参数设置(格式基准值、存储区域定义、容量配置);3) MP3编码特殊处理;4) 下载时的Flash格式化操作;5) 录音开关和播放接口的使用说明。配置过程涉及多个关键文件的修改,并强调存储容量的精确分配。

qq_42014563的博客 599

Hibernate的二级缓存之查询缓存

  查询缓存(Query Cache):对于经常使用的查询语句,如果启用了查询缓存,当第一次执行查询语句时,Hibernate会把查询结果存放在第二缓存中。以后再次执行该查询语句时,只需从缓存中获得查询结果,从而提高查询性能。     查询缓存适用于以下场合:l 在应用程序运行时经常使用的查询语句。l 很少对与查询语句关联的数据库数据进行插入、删除或更新操作。     Hibernate的Quer

DiscussQuestions的专栏 890

大模型选型实战:为OpenClaw匹配最优“大脑”的全维度考量

大模型不是越贵越好,也不是参数越高越好,适合自己的使用场景才是最好的。按照我的方法,先明确自己的需求,再选对应的模型,配置多模型自动路由,既能保证体验,又能最大限度降低成本。我自己用这套配置用了半年多,不管是写文章、写代码还是处理复杂问题,都完全够用,成本也很低,大家可以参考一下。如果不知道选什么模型,可以在评论区说一下你的使用场景。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 343

hibernate查询缓存_深入研究Hibernate的查询缓存

hibernate查询缓存 我已经很长时间没有使用过Hibernate了,甚至更久没有写过博客了 。 最近,我在建立常绿缓存的工作范围内撰写博客文章。 在编写演示代码时,我遇到了一些与Hibernate的查询缓存有关的问题:它没有按我预期的那样工作。 终于,一段时间后,我设法解决了这个问题。 这篇文章旨在更深入地研究Hibernate的Query Cache,以帮助遇到同样问题的其他开发人员...

dlz00001的博客 629

全志平台camera驱动开发(4)NVP6134芯片4路模拟视频BT656输入

前言 1. 调试平台: 全志V5/T7等有BT656或BT1120的并行接口,理论有DVP接口的一般都支持 2. NVP6134可使用多路视频同时输入 硬件连接 模拟camera1 模拟camera2 NVP6134 ------>NVCSI0 ...

jzwjzw19900922的博客 3534

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

hibernate二级缓存 和 查询缓存

<br />二级缓存和查询缓存都相当于一个map。 <br />二级缓存缓存的key为id,value为实体对象。一般load(),iterate()使用到二级缓存,list()需要结合查询缓存使用。iterate()和list()区别如下: <br />iterate()不需要开启查询缓存,它首先发出一个sql如”select s.id from Student s”去数据库把id属性列表取出来,然后再根据id列表一个一个load(),如果缓存有从缓存取,如果缓存没有就从数据库取:select s.id,

liu372267001的专栏 5031

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Hibernate缓存之查询缓存简述

Hibernate独有的查询缓存

SirouW的博客 587

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

Hibernate开启查询缓存

由于查询缓存,依赖于二级缓存,所以先必须开启二级缓存!! 步骤如下: 首先,通过配置文件开启查询缓存      情况一,项目有hibernate.cfg.xml文件                     通过修改hibernate.cfg.xml文件,开启查询缓存功能 true org.hibernate.cache.EhCacheProvider tru

yh_zeng2的博客 1457

Hibernate实战——查询缓存

一配置 <?xml version="1.0" encoding="GBK"?> <!-- 指定Hibernate配置文件的DTD信息 --> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://...

实践求真知 215

hibernate查询缓存_在Hibernate中启用实体和查询缓存

hibernate查询缓存 1.简介 在我执行过的与性能相关的任务中,这就是其中之一。 令人担心的是,如果对于特定实体每次都调用相同的查询,并且表数据在特定的时隙内不易更改,则我们可以使用Hibernate缓存查询结果。 这意味着,如果我们需要ID为1234的Student的详细信息,则查询将仅针对第一个请求执行并访问数据库。 后续请求与查询缓存中的结果一起提供。 这对我们注意到的响应时间产生...

最佳 Java 编程 354

hibernate二级缓存VS查询缓存

hibernate二级缓存VS查询缓存(Second cache VS query cache)这两个概念,因为对查询缓存重视度不够,容易混。从以下维度比较下: 1.处理时机 2.缓存格式 3.适用范围 4.稍微分析利弊 处理时机说明: 1.查询缓存在一二级缓存前,使能情况下,先去找查询缓存里面的东西; 2.所有的缓存一定是在调用HQL后发生的,代码一定得走到HQL那块,然后由hiberna

石权的博客 661
上一篇: Hibernate ehcache配置二级缓存
下一篇: android颜色对应的xml配置值,颜色表
codepython
博客等级 码龄20年 125粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值