在spring中配置hibernate的二级缓…

spring整合hibernate中的配置文件hibernate.cfg.xml的详解总结 applicationContext.xml配置文件 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi: 阅读详情

1.首先,在spring的hibernate配置里(我的是applicationContext-hibernate.xml) 加上如下属性:

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">         
  <property name="dataSource">
   <ref bean="dataSource"/>
  </property>
  <property name="mappingResources">
   <list>
    <value>org/appfteaching/model/TArticleclass.hbm.xml</value>
   </list>
  </property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
          <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
          <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
          <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
          <prop key="hibernate.cache.use_query_cache">true</prop>
          <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
   </props>   
  </property>  
 </bean> 

2.其次,在src目录下的ehcache.xml中配置如下信息(如果是默认ehcache.xml则会有<cache name="sampleCache1">和<cache name="sampleCache2>",去掉)

<cache name="org.hibernate.cache.StandardQueryCache"
        maxElementsInMemory="10000"
        eternal="false"
        timeToIdleSeconds="300"
        timeToLiveSeconds="4200"
        overflowToDisk="true"
        />

    <!-- Sample cache named sampleCache2
        This cache contains 1000 elements. Elements will always be held in memory.
        They are not expired. -->

    <cache name="org.hibernate.cache.UpdateTimestampsCache"
        maxElementsInMemory="5000"
        eternal="true"
        timeToIdleSeconds="0"
        timeToLiveSeconds="0"
        overflowToDisk="false"
        />

3.将你要缓存的model加进ehcache.xml里

<cache name="org.appfteaching.model.TArticleclass"
     maxElementsInMemory="1000"
        eternal="false"
        timeToIdleSeconds="100"
        timeToLiveSeconds="4200"
        overflowToDisk="true"
     />  

4.最后一步,在TArticleclass.hbm.xml里加上

<cache usage="read-write"/>

启动Tomcat,如发现如下错误

Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults.
Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults.

则是第二步没有做,加上即可.配置完毕

 

转自:http://www.blogjava.net/WshmAndLily/articles/137244.html


                               By:lsfhack Email:lsfhack@163.com QQ:858084865

spring配置hibernate事务aop不生效的问题 最近学习spring框架,在spring+hibernate整合中,配置事务遇到了麻烦,头疼了两天,最终豁然开朗。 后来才发现:是因为数据库操作对应的类没有配置对应的导致。 事务配置分声明式和注解式,我用的是声明式(xml),两者核心配置原理相同。 spring整合hinernate方式: 1、定义DAO,继承HibernateTemplate, 2、配置数据库资源datasourc 阅读详情

相关推荐

Android Display Graphics #1 整体框架介绍一

手机屏上显示的内容,2D或3D ,如果是 3D 的,不管是 App 还是游戏,或者简单的图片界面,底层都是通过 GPU、 通过 OpenGL(ES)绘制出来的。是Java层的一个类,提供了一系列API,使用这些API可以实现各种的产品经理要求的效果。显示的不同阶段对这块内存的叫法不同,在上层可以是Window、ANnativeWindow、Surface、SurfaceView、layer、buffer,这些本质上没啥区别,可以广泛意义上理解为用于显示内容的那块内存,只不过各个阶段的操作接口不同。

oDwyane03的博客 1387

hibernate3学习笔记(四)|增删改查

测试代码: package com.hb3.pack_01;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.hibernate.Transaction;import org.hibernate.cfg.Configuration;import com.hb3.pack_01.model

531

手把手复现金蝶云星空V8.1文件上传漏洞(附完整POC与修复方案)

本文深度解析金蝶云星空V8.1文件上传漏洞,提供详细的漏洞复现步骤与完整POC,涵盖技术原理、测试环境搭建及验证流程。同时给出多维防护方案,包括官方补丁部署、临时缓解措施和长期安全加固建议,帮助企业有效防范任意文件上传风险。

weixin_30505225的博客 182

No configuration found. Configuring ehcache from ehcache-failsafe.xml 警告的解决方案

No configuration found. Configuring ehcache from ehcache-failsafe.xml 警告的解决方案 No configuration found. Configuring ehcache from ehcache-failsafe.xml 解决方案 No configuration ...

weixin_30827565的博客 1912

ISO15118-20协议测试实战:用Efficient XML库验证26条命令编解码(附完整代码)

本文分享了ISO15118-20协议测试实战经验,重点探讨了使用Efficient XML库对26条命令进行EXI编解码验证的过程。通过搭建测试环境、编写自动化程序并与官方工具链进行交叉比对,文章深入分析了4条命令编码结果不一致的原因,并提供了完整的排查思路与C代码示例,旨在帮助开发者确保电动汽车充电通信的协议一致性。

weixin_29284657的博客 108

SpringBoot如何正确连接SqlServer(亲测可用)

对于SpringBoot连接SqlServer的方式和常见的错误的汇总。1、驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。2、com.microsoft.sqlserver.jdbc.SQLServerException: 对象名 ‘DUAL‘ 无效。

黄团团的个人博客 2万+

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

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

gruhgd的博客 273

【WRF模拟】如何查看 WPS 的输入静态地理数据(二进制格式)?

如何查看 WPS 的输入静态地理数据(二进制格式)?

WW、forever的博客 633

Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults

Could not find configuration[org.hibernate.cache.UpdateTimestampsCache]; using defaults         Noconfiguration found. Configuring ehcache from ehcache-failsafe.xml 。ehcache-failsafe.xml是来自于ehcac

莎莎的专栏 1979

Claude Code 实战 从零教你用 Claude Code 干活

Claude Code 实用指南:AI 编程助手的核心功能与使用技巧 Claude Code 是 Anthropic 推出的智能编程助手,可直接在本地环境中执行操作,相比传统 AI 对话工具具有显著优势:能直接读取项目文件、自动执行修改、记忆项目规则,并支持连接外部服务。本文详解其安装配置、三大核心场景(资料搜索、网页抓取、文章撰写)及进阶功能(Skills、MCP协议、斜杠命令)。特别提供了工作模式切换、CLAUDE.md配置文件等实用技巧,并附常见问题解决方案,帮助用户高效利用这一"坐在身边的

2401_84052244的博客 7496

1、符号回归:原理、应用与实践

本文全面介绍了符号回归(Symbolic Regression)的原理、发展历程、核心算法及其在科学与工程领域的广泛应用。文章从基本概念出发,详细阐述了基于遗传编程的符号回归机制,并探讨了其在游艇水动力学、化学过程、锂离子电池、生物医学等多个领域的实际应用。同时,博文还涵盖了高级技术如知识集成、系数优化、预测区间计算及微分方程发现等内容,对比了开源与商业软件工具,并展望了未来发展趋势,旨在为研究人员和从业者提供一本实用的符号回归指南。

ipfs8storage的博客 248

FLEX与SPRING HIBERNATE 的配置应用

最近一直在研究FLEX,由于项目的需要自己构建了一个FLEX+SPRING+HIBERNATE 的WEB开发框架。在网上找到了一些相关资料,帮助最大的http://coenraets.org/flex-spring/ 。下面说一下我的配置过程,希望能给大家一些帮助:1)创建自己的工程,例如 :springtest (project)  -> flex(Package),将相关的JAR包放在

yangzx_study的专栏 1469

【人脸识别/轻量级模型】MobileFaceNet:适用于人脸识别的轻量级网络模型(文末附pytorch代码)

MobileFaceNet:用于人脸识别的轻量级网络模型

Roaddd的博客 6988

Hibernate:hibernate.cfg.xml 和 Spring配置中引入hibernate 的配置详解

hiberante.cfg.xml配置 <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

zzjvslove的博客 2344

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

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

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

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

退步原来是向前 7174

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

spring hibernate listener 简单配置

一、springXML配置文件 &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans     xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:p="

ebi1714的博客 600

蓝牙模块HM-10手册

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

spring配置hibernate的sessionFactory的几种方法

网上看到几种spring配置hibernate的sessionFactory的方法,这里做下总结,同时自己也归纳了一种比较符合自己习惯的配置,以此记录,方便以后做配置的时候可以拿来用。 1.通过配置dataSource来配置sessionFactory applicationContext.xml

记录成长的点点滴滴 4842

在Spring中配置Hibernate事务的方法

纵观以上四种在Spring中配置Hibernate事务的方法,其核心都是一样的,不同的只是实现的方式而已。所以看到这,这篇博文中你只需要记住4句话,就可以轻松理解在Spring中配置Hibernate事务的核心: 1.配置SessionFactory 2.配置事务容器 3.配置事务规则 4.配置事务入口 ![在这里插入图片描述]...

weiwjacsdn的博客 1542

hibernate监听器的配置,在spring中

在hibernate3.x中,如果需要使用hibernate的监听器,在hibernate.cfg.xml中进行配置即可,在spring中也有对应的设置属性;在hibernate4.x版本中, listener从以前的Configuration中移除,因此在org.springframework.orm.hibernate4.LocalSessionFactoryBean中也找不到对应的<property name="eventListeners"> 所以在使用时,spring集成hibernate4的时候

ScottLiu_的专栏 2962

spring管理hibernate的SessionFactory-多种配置方法

其实很简单第一种方式使用hiberante.cfg.xml:hiberante.cfg.xml配置如下: "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

9795

Struts2 Hibernate Spring 整合的基本流程和步骤及其相关配置细节

配置Hibernate环境 1、 把Hibernate的相关jar包复制到lib目录下: ① HIBERNATE_HOME/lib 下的相关的依赖的第三方包 ② HIBERNATE_HOME/hibernate3.jar Hibernate的核心实现 ③ 引入入相关的JDBC驱动 2、 在src目录下创建相关的配置文件:hibernate.cfg.xml 可以从以下

xyjikl 500

[Hibernate]spring与Hibernate整合配置文件

Hibernate框架与spring整合相关配置: 文件名:applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSc...

朱同学的博客 865

spring中加入hibernate配置文件

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.spri...

anwenzhao0749的博客 302

spring+hibernate注解配置实例

简单的spring3.2.9和hibernate3的集成配置,有demo供下载。shTest下载 第一步 jdbc.properties配置 driverClassName=com.mysql.jdbc.Driver url=jdbc\:mysql\://localhost\:3306/shtest username=root password=123456 prototypeCount

黎明踏浪的专栏 2671

spring hibernate 的二级绶存配置

.首先,在spring的hibernate配置里(我的是applicationContext-hibernate.xml) 加上如下属性:                          org/appfteaching/model/TArticleclass.hbm.xml              ${hibernate.dialect}          ${hibernate.sho

yxpjx的专栏 1114
上一篇: ZK&nbsp;使用&nbsp;ZK&nbsp;JspTags&nbsp;Q&amp;A
下一篇: BeanPropertyRowMapper类详解
jarry.liu
博客等级 码龄16年 36粉丝 304原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jarry.liu

如果对您有帮助,鼓励下博主吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值