Hibernate ehcache配置二级缓存

Hibernate二级缓存配置实战:深入解析ehcache.xml 元素允许开发者集成Terracotta服务器来实现分布式缓存。这对于需要跨多个应用服务器共享缓存数据的大型应用来说非常有用。Terracotta配置的一个基本示例如下:这里clustered属性指明了是否启用集群模式,而url属性指定了Terracotta服务器的地址。启用此配置后,Hibernate会将缓存数据分布式地存储在多个节点上。通过了解并熟练使用以上元素,开发者可以有效地管理Hibernate的二级缓存,以满足复杂和高性能的应用需求。 阅读详情

1、首先设置EhCache,建立配置文件ehcache.xml,默认的位置在class-path,可以放到你的src目录下:

<?xml version="1.0" encoding="UTF-8"?>
<ehcache>
 <diskStore path="java.io.tmpdir"/> 
  <defaultCache
   maxElementsInMemory="10000"<!-- 缓存最大数目 -->
   eternal="false"<!-- 缓存是否持久 -->

   overflowToDisk="true"<!-- 是否保存到磁盘,当系统当机时-->

   timeToIdleSeconds="300"<!-- 当缓存闲置n秒后销毁 -->
   timeToLiveSeconds="180"<!-- 当缓存存活n秒后销毁-->
   diskPersistent="false"
   diskExpiryThreadIntervalSeconds= "120"/> 
</ehcache>


  2、在Hibernate配置文件中设置:

<!-- 设置Hibernate的缓存接口类,这个类在Hibernate包中 -->
<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property> 
 <!-- 是否使用查询缓存 -->

 <property name="hibernate.cache.use_query_cache">true</property>
  如果使用spring调用Hibernate的sessionFactory的话,这样设置:
  <!--HibernateSession工厂管理 -->

   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="dataSource">
    <ref bean="datasource" />
   </property>
   <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
     <prop key="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.cache.use_query_cache">true</prop>
    <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
   </props>
 </property>
 <property name="mappingDirectoryLocations">
  <list>
   <value>/WEB-INF/classes/cn/rmic/manager/hibernate/</value>
  </list>
 </property> 
</bean> 

   说明一下:如果不设置“查询缓存”,那么hibernate只会缓存使用load()方法获得的单个持久化对象,如果想缓存使用findall()、 list()、Iterator()、createCriteria()、createQuery()等方法获得的数据结果集的话,就需要设置 hibernate.cache.use_query_cache true 才行

  3、在Hbm文件中添加<cache usage="read-only"/>


  4、如果需要“查询缓存”,还需要在使用Query或Criteria()时设置其setCacheable(true);属性

  5、实践出真知,给一段测试程序,如果成功的话第二次查询时不会读取数据库

package cn.rmic.hibernatesample;

import java.util.List;

import org.hibernate.CacheMode;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;

import cn.rmic.hibernatesample.hibernate.HibernateSessionFactory;
import cn.rmic.manager.po.Resources;

public class testCacheSelectList ...{

 public static void main(String[] args) ...{
  Session s=HibernateSessionFactory.getSession();
  Criteria c=s.createCriteria(Resources.class);
  c.setCacheable(true);
  List l=c.list();

  Resources resources=(Resources)l.get(0);
  System.out.println("-1-"+resources.getName());
  HibernateSessionFactory.closeSession();


  try ...{
   Thread.sleep(5000);
  } catch (InterruptedException e) ...{
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  s=HibernateSessionFactory.getSession();
  c=s.createCriteria(Resources.class);
  c.setCacheable(true);
  l=c.list();
  resources=(Resources)l.get(0);
  System.out.println("-2-"+resources.getName());
  HibernateSessionFactory.closeSession();
 }
}

 

1. 在Hibernate配置文件中设置:
    

 <!--  Hibernate SessionFactory  --> 
    
 < bean id = " sessionFactory "   class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean " > 
        
 < property name = " dataSource "  ref = " dataSource " /> 
        
 < property name = " mappingResources " > 
        
 < list > 
            
 < value > com / ouou / model / Videos.hbm.xml </ value >    
         
 </ list > 
         
 </ property > 
        
 < property name = " hibernateProperties " > 
            
 < props > 
                
 < prop key = " hibernate.dialect " > org.hibernate.dialect.MySQLDialect </ prop >
                
 < prop key = " hibernate.current_session_context_class " > thread </ prop > 
                
 < prop key = " hibernate.cglib.use_reflection_optimizer " > false </ prop > 
                
 < prop key = " hibernate.query.substitutions " > true   ' Y ' ,  false   ' N ' </ prop> 
                
 <!-- add ehcache --> 
                
 < prop key = " hibernate.cache.provider_class " >org.hibernate.cache.EhCacheProvider </ prop > 
                
 < prop key = " hibernate.cache.use_query_cache " > false </ prop ><!--  是否使用查询缓存  --> 
                
 <!-- 
                
 < prop key = " hibernate.cache.provider_configuration_file_resource_path " >/ehcache.xml </ prop > 
                
 < prop key = " hibernate.show_sql " > true </ prop > 
                
 --> 
                
 <!--< prop key = " hibernate.transaction.auto_close_session " > true </ prop >--> 
                
 < prop key = " connection.provider_class " >org.hibernate.connection.C3P0ConnectionProvider </ prop > 
                
 <!--  Create / update the database tables automatically when the JVM starts up
                 
 < prop key = " hibernate.hbm2ddl.auto " > update </ prop >   --> 
                
 <!--  Turn batching off  for  better error messages under PostgreSQL  --> 
                
 < prop key = " hibernate.jdbc.batch_size " > 25 </ prop > 
                
 <!-- 
                
 < prop key = " hibernate.connection.pool_size " > 10 </ prop > 
                
 --> 
            
 </ props > 
        
 </ property > 
    
 </ bean >


    如果不设置“查询缓存”,那么hibernate只会缓存使用load()方法获得的单个持久化对象,如果想缓存使用findall()、 list()、Iterator()、createCriteria()、createQuery()等方法获得的数据结果集的话,就需要设置 hibernate.cache.use_query_cache true 才行

2.首先设置EhCache,建立配置文件ehcache.xml,默认的位置在class-path,可以放到你的src目录下:

   < ehcache > 
 
    
 <!--  Sets the path to the directory where cache .data files are created.

     If the path is a Java System Property it is replaced by
     its value in the running VM.
     The following properties are translated:
     user.home 
 -  User ' s home directory 
 
     user.dir  -  User ' s current working directory 
 
     java.io.tmpdir  -  Default temp file path  --> 
     
 <!--< diskStore path = " java.io.tmpdir " />--> 
     
 < diskStore path = " /data/ehcache " /> 
 
    
 <!--Default Cache configuration. These will applied to caches programmatically created through
        the CacheManager.

        The following attributes are required:

        maxElementsInMemory            
 - Sets the maximum number of objects that will be created in memory
        eternal                                     
 - Sets whether elements are eternal. If eternal,  timeouts are 
                                                            ignored and the element is never expired.
        overflowToDisk                      
 - Sets whether elements can overflow to disk when the in - memory cache
                                                        has reached the maxInMemory limit.

        The following attributes are optional:
        timeToIdleSeconds            
-  Sets the time to idle  for  an element before it expires.
                                                        i.e. The maximum amount of time between accesses before an
                                                        element expires Is only used 
 if the element is not eternal.
                                                        Optional attribute. A value of 
 0 means that an Element can idle
                                                        
for  infinity.The  default  value is  0 .
        timeToLiveSeconds              
-  Sets the time to live  for  an element before it expires.
                                                         i.e. The maximum time between creation time and when an element 
                                                         expires.  Is only used 
 if  the element is not eternal.
                                                         Optional attribute. A value of 
 0 means that and Element can live
                                                         
for  infinity.
                                                        The 
 default  value is  0 .
        diskPersistent                           
 - Whether the disk store persists between restarts of the Virtual 
                                                             Machine.
                                                         The 
 default  value is  false .
        diskExpiryThreadIntervalSeconds   
 - The number of seconds between runs of the disk expiry thread. 
                                                         The 
 default  value  is  120  seconds.
        
 --> 
 
    
 < defaultCache
        maxElementsInMemory
 = " 10000 " 
        eternal
 = " false " 
        overflowToDisk
 = " true " 
        timeToIdleSeconds
 = " 120 " 
        timeToLiveSeconds
 = " 120 " 
        diskPersistent
 = " false " 
        diskExpiryThreadIntervalSeconds
 = " 120 " /> 
    
 < cache name = " org.hibernate.cache.UpdateTimestampsCache "  maxElementsInMemory= " 5000 "  
     eternal
 = " true "  overflowToDisk = " true " /> 
    
 < cache name = " org.hibernate.cache.StandardQueryCache "  maxElementsInMemory = "5 "  eternal = " false " 
    timeToLiveSeconds
 = " 120 "  overflowToDisk = " true " /> 
    
 < cache name = " userCache "  maxElementsInMemory = " 100000 "  eternal = " false " timeToIdleSeconds = 
        "
 600 "    timeToLiveSeconds = " 600 "  overflowToDisk = " false "  diskPersistent = " false" /> 
    
 < cache name = " com.ouou.webapp.util.OuouMethodIntecepter "  maxElementsInMemory= " 100000 "  
    eternal
 = " false "  timeToIdleSeconds = " 600 "  timeToLiveSeconds = " 600 " overflowToDisk = " false " 
    diskPersistent
 = " false " /> 
    
 < cache name = " bbcode "  maxElementsInMemory = " 100000 "  eternal = " false " timeToIdleSeconds = " 600 " 
    timeToLiveSeconds
 = " 600 "  
    overflowToDisk
 = " false "  diskPersistent = " false " /> 
    
 < cache name = " com.ouou.model.Videos "  maxElementsInMemory = " 10000 "   eternal= " false "  
    overflowToDisk
 = " false "  timeToIdleSeconds = " 120 "  timeToLiveSeconds = " 120 " diskPersistent = " false " /> 
    
 < cache name = " com.ouou.model.Tags "  maxElementsInMemory = " 10000 "   eternal =" false " 
    overflowToDisk
 = " false "  timeToIdleSeconds = " 120 "  timeToLiveSeconds = " 120 " diskPersistent = " false " /> 
 
</ ehcache >


以com.ouou.model.Videos为例子
在Videos.hbm.xml中配置:
<class name="Videos" table="TEST" lazy="false">
  <cache usage="read-write" region="ehcache.xml中的name的属性值"/>注意:这一句需要紧跟在class标签下面,其他位置无效。
hbm文件查找cache方法名的策略:如果不指定hbm文件中的region="ehcache.xml中的name的属性值",则使用name名为com.ouou.model.Videos的cache,
如果不存在与类名匹配的cache名称,则用defaultCache。
如果Videos包含set集合,则需要另行指定其cache
例如Videos包含Tags集合,则需要
添加如下配置到ehcache.xml中
<cache name="com.ouou.model.Tags"
        maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="120"
        timeToLiveSeconds="120" overflowToDisk="false" />
另,针对查询缓存的配置如下:
<cache name="org.hibernate.cache.UpdateTimestampsCache"
        maxElementsInMemory="5000"
        eternal="true"
        overflowToDisk="true"/>
<cache name="org.hibernate.cache.StandardQueryCache"
        maxElementsInMemory="10000"
        eternal="false"
        timeToLiveSeconds="120"
        overflowToDisk="true"/>

3、 选择缓存策略依据:

<cache  usage="transactional|read-write|nonstrict-read-write|read-only" (1)/>
ehcache不支持transactional,其他三种可以支持。
read-only:无需修改, 那么就可以对其进行只读 缓存,注意,在此策略下,如果直接修改数据库,即使能够看到前台显示效果,
但是将对象修改至cache中会报error,cache不会发生作用。另:删除记录会报错,因为不能在read-only模式的对象从cache中删除。
read-write:需要更新数据,那么使用读/写缓存 比较合适,前提:数据库不可以为serializable transaction isolation level
(序列化事务隔离级别)
nonstrict-read-write:只偶尔需要更新数据(也就是说,两个事务同时更新同一记录的情况很不常见),也不需要十分严格的事务隔离,
那么比较适合使用非严格读/写缓存策略。

4、 调试时候使用log4j的log4j.logger.org.hibernate.cache=debug,更方便看到ehcache的操作过程,主要用于调试过程,实际应用发布时候,请注释掉,以免影响性能。

5、 使用ehcache,打印sql语句是正常的,因为query cache设置为true将会创建两个缓存区域:一个用于保存查询结果集 (
org.hibernate.cache.StandardQueryCache);另一个则用于保存最近查询的一系列表的时间戳(org.hibernate.cache.UpdateTimestampsCache)。
请注意:在查询缓存中,它并不缓存结果集中所包含的实体的确切状态;它只缓存这些实体的标识符属性的值、以及各值类型的结果。
需要将打印sql语句与最近的cache内容相比较,将不同之处修改到cache中,所以查询缓存通常会和二级缓存一起使用。

 

Ehcache的配置说明 

<ehcache>
<!--
磁盘存储配置:
用来指定缓存在磁盘上的存储位置。可以使用JavaVM环境变量(user.home, user.dir, java.io.tmpdir)
-->
<diskStore path = "/var/apps/cache/" />
<!--
指定CacheManagerEventListenerFactory,这个对象在缓存添加的时候会得到相应的通知
CacheManagerEventListenerFactory的属性
*class - CacheManagerEventListenerFactory的一个实现类
*properties - CacheManagerEventListenerFactory的属性值,以逗号(,)分割多个属性
如果没有实现类被指定,则系统不创建CacheManager的监听器,没有默认值
-->
<cacheManagerEventListenerFactory class="" properties="" />
<!--
在进行分布式缓存的应用时候需要指定CacheManagerPeerProviderFactory,
用来生成CacheManagerPeerProvider的实例,以便和集群中的其他CacheManager通信。
*class -CacheManagerPeerProviderFactory的一个实现类
*properties - CacheManagerPeerProviderFactory的属性值,以逗号(,)分割多个属性
Ehcache内建了2种基于RMI分布系统的通信策略:
*automatic - 使用多播组。在一个节点加入或者推出集群的时候自动感应
*manual - 硬编码方式

目前的awf中不考虑分布缓存
-->
<cacheManagerPeerListenerFactory class="" properties="" />
<!--
缓存配置。
以下属性是必须的:
name - cache的标识符,在一个CacheManager中必须唯一
maxElementsInMemory - 在内存中缓存的element的最大数目
maxElementsOnDisk - 在磁盘上缓存的element的最大数目
eternal - 设定缓存的elements是否有有效期。如果为true,timeouts属性被忽略
overflowToDisk - 设定当内存缓存溢出的时候是否将过期的element缓存到磁盘上
以下属性是可选的:
timeToIdleSeconds - 缓存element在过期前的空闲时间。默认为0,表示可空闲无限时间.
        (如果指定了这个时间,是否在被hit的前超过了这个时间就会被remove?在内存缓存数目超限之前不会被remove)
timeToLiveSeconds - 缓存element的有效生命期。这个类似于timeouts,默认为0,不过期
        (是否通常情况下应该大于等于timeToIdleSeconds,小于会如何?idle时间也会减小和这个数值一样)
diskPersistent - 在VM重启的时候是否持久化磁盘缓存,默认是false。
        (测试一下true的情况?重载vm的时候会从磁盘进行序列化到对象)
diskExpiryThreadIntervalSeconds - 磁盘缓存的清理线程运行间隔,默认是120秒.
        (测试一下0的时候会如何)
memoryStoreEvictionPolicy - 当内存缓存达到最大,有新的element加入的时候,
        移除缓存中element的策略。默认是LRU,可选的有LFU和FIFO

可对缓存中的element配置诸如监听器和加载器。Ehcahe内建了一些
*cacheEventListenerFactory - 监听缓存中element的put, remove, update和expire事件
*bootstrapCacheLoaderFactory - 启动时加载缓存的element
每个用来做分布式缓存都必须设定element的事件监听器,用来在各个CacheManager节点复制消息。
Ehcache内建了基于RMI的实现 - RMICacheReplicatorFactory
    <cacheEventListenerFactory class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
        properties="replicateAsynchronouly=true,
        replicatePuts=true,
        replicateUpdates=true,
        replicateUpdateViaCopy=true,
        replicateRemovals=true" />

-->
<cache .... />
<!--
默认的Cache配置。用来实现CacheManager.add(String cacheName)创建的缓存
-->
<defaultCache maxElementsInMemory="10000" eternal="false"
        timeToIdleSeconds="120" timeToLiveSeconds="120"
        overflowToDisk="true" maxElementsOnDisk="1000000"
        diskPersistent="false" diskExpiryThreadIntervalSeconds="120"
        memoryStoreEvictionPolicy="LRU"
        />

</ehcache>

通义千问语言模型Qwen2.5架构详解 此外,将基于API的模型 Qwen-Plus 与领先的专有和开源模型进行了对比,包括 GPT4-o、Claude-3.5-Sonnet、Llama-3.1-405B和DeepSeek-V2.5。Qwen2.5-Math-72B-Instruct的整体性能超越了Qwen2-Math-72B-Instruct和GPT4-o,甚至是非常小的专业模型如 Qwen2.5-Math-1.5B-Instruct也能在与大型语言模型的竞争中取得高度竞争力的表现。近来也出现了明显的转向小型语言模型(SLMs)的趋势。 阅读详情

相关推荐

XC7K325T FPGA硬件设计实战:从板级原理图到高速接口优化

本文以XC7K325T FPGA为核心,详细阐述了从板级原理图设计到高速接口优化的完整硬件实战流程。内容涵盖芯片管脚与电源规划、时钟复位配置电路设计,并重点解析了DDR3内存子系统以及PCIe与光纤接口等高速电路的原理图与PCB设计要点,旨在帮助工程师构建稳定可靠的高性能硬件平台。

python9snake的博客 515

Ehcache缓存配置解读

<diskStore> : 当内存缓存中对象数量超过maxElementsInMemory时,将缓存对象写到磁盘缓存中(需对象实现序列化接口) <diskStore path=""> : 用来配置磁盘缓存使用的物理路径,Ehcache磁盘缓存使用的文件后缀名是*.data和*.index name : "缓存名称,cache的唯一标识(ehcache会...

荡剑江湖 1940

可视化大屏系列(5):设备状态面板与数据分析仪表盘

在这篇文章中,我们将重点讨论如何通过智能化手段提升工地设备的管理效率与维护质量。随着智能工地系统的不断发展,设备监控与维护管理变得尤为重要。本篇将从 设备状态实时监控、自动化维护提醒、设备管理与维修记录 三个方面入手,展示如何通过 Vue3 和 ECharts 构建一个智能化的设备管理平台,实时采集和展示设备运行状态、及时生成维护提醒并记录维修历史,以提高设备的使用效率与安全性。我们还将结合实际代码示例,详细讲解如何实现这些功能,帮助你在智能工地项目中实现设备管理的智能化、数字化和自动化。

一名热衷于技术的全栈开发者,专注于前端与后端的全面技术探索。在这里,我将分享我在技术领域的学习与成长,助力更多开发者的进步。 3365

Ehcache缓存

EhCache 是一个纯Java的进程内缓存框架,具有快速、精干等特点,是Hibernate中默认CacheProvider。Ehcache是一种广泛使用的开源Java分布式缓存。主要面向通用缓存,Java EE和轻量级容器。它具有内存和磁盘存储,缓存加载器,缓存扩展,缓存异常处理程序,一个gzip缓存servlet过滤器,支持REST和SOAP api等特点。

m0_61580275的博客 1451

C++动态规划详解

动态规划思想 一、动态规划概念: 动态规划(dp)是研究多步决策过程最优化问题的一种数学方法。在动态规划中,为了寻找一个问题的最优解(即最优决策过程),将整个问题划分成若干个相应的阶段,并在每个阶段都根据先前所作出的决策作出当前阶段最优决策,进而得出整个问题的最优解。即记住已知问题的答案,在已知的答案的基础上解决未知的问题。 在这类问题中,可能会有许多可行解。每一个解都对应于一个值,我们希望找到具有最优值的解。动态规划算法与分治法类似,其基本思想也是将待求解问题分解成若干个子问题,先求解子问题,然后

weixin_51951103的博客 2万+

大规模新闻聚合爬虫实战:Python爬取数百万新闻数据的完整指南

本文详细介绍了如何构建一个大规模新闻聚合爬虫,结合Python异步爬虫技术,实现高效、稳定的新闻数据采集。增加NLP模块对新闻内容做自动分类、情感分析。引入机器学习模型检测新闻真实性。使用分布式爬虫框架进一步提升规模。增加多媒体内容抓取与处理。

2201_76125261的博客 1557

EhCache初体验

一、简介   EhCache 是一个纯Java的进程内缓存框架,具有快速、精干等特点。Ehcache是一种广泛使用的开源Java分布式缓存。主要面向通用缓存,Java EE和轻量级容器。它具有内存和磁盘存储,缓存加载器,缓存扩展,缓存异常处理程序,一个gzip缓存servlet过滤器,支持REST和SOAP api等特点。     主要的特性有:  快速  简单  多种缓存策略 缓...

weixin_34306446的博客 954

字符编码——简体中文编码中区位码、国标码、内码、外码、字形码的区别及关系

目录区位码国标码(交换码)内码(机内码)区位码、国际码、内码的转换为什么要加上20H为什么加上80H 本文以GB2312为例,讲述区位码、国标码、内码、外码、字形码 区位码 整个GB2312字符集分成94个区,每区有94个位,每个区位上只有一个字符,即每区含有94个汉字或符号,用所在的区和位来对字符进行编码(实际上就是字符编号、码点编号),因此称为区位码。 换言之,GB2312将包括汉字在内的所有字符编入一个94 * 94的二维表,行就是“区”、列就是“位”,每个字符由区、位唯一定位,其对应的区、位编号合并

路人coder 5343

浅谈EhCache缓存框架

最近学习了EhCache,做一些必要的笔记,一来是对自己学习的知识的巩固,二来对有同样问题的人有参考作用 文章目录一 EhCache简介二 EhCache 常用配置项详解三 Ehcache配置持久化到硬盘举例四 总结 一 EhCache简介    EhCache 是一个纯Java的进程内缓存框架,具有快速、精干等特点,是Hibernate中默认的CacheProvider。hcache是一种广泛使用的开源Java分布式缓存。主要面向通用缓存,Java EE和轻量级容器。它具有内存.

ergouy's blog 445

嵌入式开发工程师笔试面试指南-Linux驱动

linux驱动

weixin_43491077的博客 476

数据分析必问:Pandas面试题及参考答案

DataFrame是Pandas库中的一个核心数据结构,它类似于Excel中的表格,可以存储不同类型的数据。在Pandas中,抽样操作通常很简单,但是需要根据数据的特点和分析的需求来选择合适的抽样方法。数据标准化和归一化是数据预处理中常用的技术,目的是将数据调整到一个合适的范围内,以消除不同特征量纲和数值范围的差异,从而保证模型训练的有效性。CSV文件是一种文本文件,其中的数据以逗号分隔。不平衡数据集指的是数据集中各类别样本的数量差异较大的情况,这可能导致模型训练出现偏差,影响模型的泛化能力。

大模型大数据攻城狮的专栏 3011

Hibernate二级缓存以及ehcache的搭建配置

Session级别的以及缓存总是有效的,当应用保持持久化实体、修改持久化实体时,Session并不会吧这种改变flush到数据库,而是缓存在当前Session的一级缓存中,除非程序显示调用session的flush方法,或者查询关闭session时,才会把这先改变一次性的flush到底层数据库,这样可以减少与数据库的交互,从而提高数据库的访问性能。 SessionFactory级别的二级缓存是全局的,应用的所有的Seeion都共享这个二级缓存,当Session需要抓取数据时,Session就会优

Andyの笔记 1万+

银河麒麟编译libjpeg库并配置qt环境

银河麒麟下编译libjpeg库并配置qt环境验证

小米的修行之路 1017

Spring+Hibernate下配置Hibernate二级缓存EhCache

假设类A为持久化对象,对应表为tableA,这里没有考虑A和其他表关联的情况。在spring下配置使用二级缓存:property name="hibernateProperties">props>........prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}prop>prop key

退步原来是向前 7175

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

maven工程中hibernate的二级缓存ehcache的配置

说到缓存对于新手来说可能是一件很头疼的事儿,做为新手的我,今天给大家分享下自己的学习过程。最近项目中用到了可配置参数,这类参数基本无需修改,除了新增,刚开始是自己写了一个mapCache,就是用ConcurrentHashMap在系统启动时将所有数据缓存到map中,这样避免了系统运行时频繁访问数据库查询。但是这里有个缺点,如果系统启动后在管理平台新增参数那么新增的参数不会在map中,业务系统必须重

qq_34636263的博客 1709

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Hibernate二级缓存以及ehcache的搭建配置(注解方式)

1、Hibernate二级缓存      Hibernate包括两个级别的缓存:         1、一级缓存:默认总是启用的session级别的。          2、二级缓存:可选的SessionFactory级别的。        Session级别的以及缓存总是有效的,当应用保持持久化实体、修改持久化实体时,Session并不会吧这种改变flush到数据库,而是缓

无怨无悔专栏 3976

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Hibernate4+EhCache配置二级缓存

本文主要讲一讲Hibernate+EhCache配置二级缓存的基本使用方法 (有关EhCache的基础介绍可参见:http://sjsky.iteye.com/blog/1288257 ) Cache的多种配置方法 Javabean cache的配置有三种,下面将一一介绍,具体如下:: (1)bean中注解配置的方式: @Cache(usage...

dielishang0645的博客 152

Hibernate+EhCache配置二级缓存

FROM:  http://sjsky.iteye.com/blog/1312132 本文主要讲一讲Hibernate+EhCache配置二级缓存的基本使用方法,主要分以下两个方面介绍:   (有关EhCache的基础介绍可参见:http://sjsky.iteye.com/blog/1288257 ) Cache的多种配置方法 Hibernate+EhCache集成demo [一...

C_sdn_000000的专栏 289

Hibernate4.x二级缓存详细配置步骤( EHCache)

Hibernate4.x : 二级缓存的详细配置: EHCache      Hibernate4.x中使用缓存的步骤为(EHCache);     1.  将相应的二级缓存组件jar包导入到classpath类路径下     2.在hibernate.cfg.xml文件中配置如下的信息:                   org.hibernate.dialect.MySQL5Di

地平线的专栏 2045

Hibernate-ORM:16.Hibernate中的二级缓存Ehcache的配置

------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客讲述Hibernate中的二级缓存的配置,作者将使用的是ehcache缓存 一,目录   1.二级缓存的具体配置     1.1  jar包的引用和注意事项     1.2  ehcache.xml的配置     1.3  集成到hib...

Qgee2013的博客 241

Hibernate JPA 中配置Ehcache二级缓存

在Hibernate3 JPA里配置了一下非分布式环境的二级缓存,效果不错。具体过程如下:   1, 需要引入的jar包       http://ehcache.org/downloads/catalog 下载的包里已经包含了简单的例子和javadoc         ehcache-core-2.4.6.jar (必需)       ehcache-terracotta-2.4...

dxp4598 322

Hibernate 二级缓存 ehcache.xml 的相关配置的几点问题

<br />先看一个示例文件<br /> <br /><?xml version="1.0" encoding="UTF-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"> <!-- maxElementsInMemory为缓存对象的最大数目, eternal设置是否永远不过期

天下无双 9899

hibernate二级缓存ehcache.xml文件配置的几条心得

ehcache.xml文件如何创建或生成。ehcache.xml文件配置注意事项。

cafebar123的专栏 2069

Hibernate 二级缓存的配置及使用_EhCache

在大多数的应用程序中都会添加缓存模块,以减少数据库访问次数,同时增加响应速度。下面介绍一下hibernate的二级缓存。默认情况下hibernate的二级缓存是不开启的,我们需要手动配置并启用。 注: (1)      本教程只是针对使用hibernate配置文件的情况,如果使用spring的orm则另行百度! (2)      本教程中实体类是xml的配置,如果实体类使用的是注解的形式,请

shuijinglei1988的专栏 1994

Hibernate ehcache配置二级缓存及说明

Cache简介: 缓存(Cache )是计算机领域非常通用的概念。它介于应用程序和永久性数据存储源(如硬盘上的文件或者数据库)之间,其作用是降低应用程序直接读写永久性数据存储源的频率,从而提高应用的运行性能。缓存中的数据是数据存储源中数据的拷贝,应用程序在运行时直接读写缓存中的数据,只在某些特定时刻按照缓存中的数据来同步更新数据存储源。 缓存的物理介质通常是内存,而永久性数据存储源的物理介质通常是

lidiansheng的专栏 4982

Hibernate配置EHCache二级缓存的步骤

一、配置ehcache的lib包 二、配置user library 三、构建路径添加ehcache的依赖包 四、找到Hibernate文件夹下的etc文件夹中的ehcache ...

chuanerhang5655的博客 138
上一篇: Android拍照,上传,预览综合
下一篇: hibernate的查询缓存
codepython
博客等级 码龄20年 125粉丝 6原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值