- 浏览: 115305 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (63)
- struts (7)
- spring (12)
- Hibernate (14)
- struts+spring+hibernate (11)
- Ajax (1)
- DWR (0)
- JSON (0)
- Junit (0)
- Lucene (15)
- Compass (0)
- Tomcat(Jsp) (0)
- MySql (0)
- JavaScript (0)
- Html (0)
- UML (0)
- Log4j (0)
- Ant (0)
- Acegi (0)
- (My)eclipse (0)
- java2 (0)
- Jakarta Commons (0)
- java Web (0)
- Ruby (0)
- Ruby On Rails (0)
- IBatis (0)
- 版本控制 (0)
- eXtremeComponents (0)
- SiteMesh (0)
- IT相关 (0)
- 电子商务 (0)
- 随笔 (0)
- 正则表达式 (0)
- 测试资料 (0)
- 个人收藏 (0)
- 开发经验 (0)
- 名词解释(java,j2ee) (1)
- 英语 (0)
- java规则引擎 (0)
- CMS系统 (0)
- XML操作 (0)
- jvm (0)
- 开源工具收集 (0)
- webService (2)
最新评论
-
锦毛鼠:
请问下您现在有没有这个demo啊?可以发我看看吗?
cxf webservice身份验证 -
z276356445t:
LZ,你写的类文件怎么和配置文件中的不一样呢,求解.
spring 定时器 -
j2eeli:
感谢共享!
spring 定时器 -
gimy:
写的很清楚,谢谢!
Spring-MultiActionController -
valgrind:
Exception in thread "main& ...
Lucene中文分词组件 JE-Analysis 1.4.0
代码: |
|
写了个保存的代码测试了一下,报如下的错误:
代码: |
|
在javaeye中搜索了一下,发现了Readonly的帖子,将web.xml修改为如下:
代码: |
|
保存的代码顺利通过测试,但是删除的代码却不能通过了.出现如下的错误:
代码: |
|
****************************************
首先要说明一下Open Session in View的作用,就是允许在每次的整个request的过程中使用同一个hibernate session,可以在这个request任
何时期lazy loading数据。
如果是singleSession=false的话,就不会在每次的整个request的过程中使用同一个hibernate session,而是每个数据访问都会产生各自的seesion,等于没有Open Session in View.
OpenSessionInViewFilter默认是不会对session 进行flush的,并且flush mode 是 never
代码: |
protected Session getSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException { |
看getSession的方式就知道,把flush mode 设为FlushMode.NEVER,这样就算是commit的时候也不会session flush,
如果想在完成request过程中更新数据的话, 那就需要先把flush model设为FlushMode.AUTO,再在更新完数据后flush.
********************************
嗯,是事务的问题,感谢差沙也感谢cac的回复.
OpenSessionInView默认的FlushMode为
代码: |
|
可以采用在写保存更新删除代码的时候手动更改FlushMode
代码: |
|
但是这样做太繁琐了,第二种方式是采用spring的事务声明
代码: |
|
<o:p> </o:p>
代码: |
|
来源:http://spring.jactiongroup.net/viewtopic.php?p=5791
谢谢各位<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></v:path><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype><v:shape id="_x0000_i1025" style="WIDTH: 11.25pt; HEIGHT: 11.25pt" type="#_x0000_t75" alt="Smile"><v:imagedata src="file:///C:\DOCUME~1\Q\LOCALS~1\Temp\msohtml1\01\clip_image001.gif" o:href="http://spring.jactiongroup.net/images/smiles/icon_smile.gif"></v:imagedata></v:shape>同样在论坛里面搜索到遇到这个问题的朋友,回帖说去掉singleSession!迷惑了<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></v:path><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype><v:shape id="_x0000_i1025" style="WIDTH: 11.25pt; HEIGHT: 11.25pt" type="#_x0000_t75" alt="Sad"><v:imagedata src="file:///C:\DOCUME~1\Q\LOCALS~1\Temp\msohtml1\01\clip_image001.gif" o:href="http://spring.jactiongroup.net/images/smiles/icon_sad.gif"></v:imagedata></v:shape>
发表评论
-
详解Hibernate配置文件中映射元素
2007-09-27 16:09 1335配置文件中映射元素详解 对象关系的映射是用一个XML ... -
Java开源项目Hibernate包作用详
2007-09-27 16:08 876Hibernate一共包括了23个jar包,令人眼花缭乱。本 ... -
Hibernate学习心得--软件设计阶段的模型
2007-09-27 16:07 1020来源:BlogJava∣原文地 ... -
HIbernate参数说明
2007-09-27 16:06 8480 推荐 set节点有以下 ... -
Hibernate 3.0批量更新与删除
2007-09-27 16:06 1535Hibernate 3.0中,Session接口中被废弃的方法 ... -
关于条件查询detachedCriteria的一点体会
2007-09-27 16:03 1253假设要通过stuName查询一个学生Student记录,可以 ... -
使用模板模式简化DAO操作Hibernate
2007-09-27 15:58 979原文出处:http://www.javaresearch.or ... -
Hibernate分页
2007-09-27 15:21 1113连续看了两篇robbin有关DetachedCriteria ... -
应用Hibernate3的DetachedCriteria实现分页查询
2007-09-27 15:19 955Hibernate3提供了DetachedCriteria, ... -
通过XDoclet(ant)生成Hibernate映射文件
2007-09-27 15:17 1121通过XDoclet可以我们的精力放在编写java源文件上。 ... -
利用Hibernate配置文件生成数据库
2007-09-27 15:07 1758前很多人使用Hibernate作为持久层,如果我们已经写了配置 ... -
Hibernate 3新增XML关系持久性介绍
2007-09-27 14:59 884Hibernate的易用性、高性能和对象关系持久性等高级特性给 ... -
配置Hibernate连接池
2007-09-27 14:54 2592Hibernate自带的连接池性能不高,而且还存在BUG,因此 ...
相关推荐
介绍Spring+hibernate opensessioninview问题
Spring提供的CharacterEncoding和OpenSessionInView功能
为了练手培训,给大家准备的 Open Session In View 的简单例子,纯代码,大家可以参考,其中主要说了六部分内容: 1.通过接口编程 2.通过spring注入dao到 action 3.通过 open session in view filter 支持 延迟加载...
OpenSessionInView项目整合jar包
在没有使用Spring提供的Open Session In View情况下,因需要在service(or Dao)层里把session关闭,所以lazy loading 为true的话,要在应用层内把关系集合都初始化,如 company.getEmployees(),否则Hibernate抛...
NULL 博文链接:https://8366.iteye.com/blog/472141
SSH项目整合示例【OpenSessionInView】所用到的jar包 包含Struts + Hibernate + Spring所有jar及其依赖的jar
NULL 博文链接:https://likenice.iteye.com/blog/290162
和Spring中OpenSessionInView由于org.springframework.web.struts.ContextLoaderPlugIn中保存同一个对象的名不同导致openSessionInView失效 稍微修改后在struts-config.xml中使用MyContextLoaderPlugIn.jar包中...
NULL 博文链接:https://yanzhenwei.iteye.com/blog/1701164
SSH项目整合示例【OpenSessionInView】源码
spring2.5学习PPT 传智博客 01_全面阐释Spring及其各项功能 ... 30.Spring提供的CharacterEncoding和OpenSessionInView功能 31.使用Spring集成JPA 32.Struts+Spring+JPA集成 33.使用Spring集成Struts2 34.所有源码
最新版SSH项目整合 实现了OpenSessionInView。 hibernate5.2.3+struts2.5.2+spring4.3.3
使用 AOC 拦截器而不是过滤器进行 OpenSessionInView 处理 列出一个国家的城市和添加城市的可能性(bean 验证和自动检索 lat 和 lng 坐标) 安全 安全的 REST Web 服务 使用 CSRF 令牌 角度父状态的问题 有用的链接 ...
3,在web.xml中配置 spring 的 OpenSessionInView 过滤器(解决抛LazyInitializationException的问题) 1,配置 <!-- 配置 spring 的 OpenSessionInView 过滤器 --> <filter-name>OpenSessionInView ...
...............................................................................................................................4 1.2.1 什么是 Spring:......................................................