﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-硬盘的BLOG-文章分类-JPA</title><link>http://www.blogjava.net/simen/category/33293.html</link><description>引导分区</description><language>zh-cn</language><lastBuildDate>Fri, 25 Jul 2008 16:53:52 GMT</lastBuildDate><pubDate>Fri, 25 Jul 2008 16:53:52 GMT</pubDate><ttl>60</ttl><item><title>JPA(Hibernate)+Spring+Struts2 中延迟加载的解决办法</title><link>http://www.blogjava.net/simen/articles/217595.html</link><dc:creator>我是一块硬盘</dc:creator><author>我是一块硬盘</author><pubDate>Fri, 25 Jul 2008 15:45:00 GMT</pubDate><guid>http://www.blogjava.net/simen/articles/217595.html</guid><wfw:comment>http://www.blogjava.net/simen/comments/217595.html</wfw:comment><comments>http://www.blogjava.net/simen/articles/217595.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/simen/comments/commentRss/217595.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/simen/services/trackbacks/217595.html</trackback:ping><description><![CDATA[在entity中的@OneToMany、@OneToOne等中设置fetch = FetchType.LAZY时，在Struts2的Action中进行相关操作出现错误信息如下<br />org.hibernate.LazyInitializationException: could not initialize proxy no session<br /><br />解决方法：<br />在web.xml中加入<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">SpringOpenEntityManagerInViewFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-class</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">SpringOpenEntityManagerInViewFilter</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-name</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />    </span><span style="color: rgb(0, 0, 255);">&lt;</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);">*.action</span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">url-pattern</span><span style="color: rgb(0, 0, 255);">&gt;</span><span style="color: rgb(0, 0, 0);"><br />  </span><span style="color: rgb(0, 0, 255);">&lt;/</span><span style="color: rgb(128, 0, 0);">filter-mapping</span><span style="color: rgb(0, 0, 255);">&gt;</span></div><br />更多其它时刻解决延迟加载错误的方法参见 <a target="_blank" title="http://www.javaeye.com/topic/129698" href="http://www.javaeye.com/topic/129698">http://www.javaeye.com/topic/129698</a><br /><img src ="http://www.blogjava.net/simen/aggbug/217595.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/simen/" target="_blank">我是一块硬盘</a> 2008-07-25 23:45 <a href="http://www.blogjava.net/simen/articles/217595.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>