<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>权记 &#187; JPA</title>
	<atom:link href="http://www.quanlei.com/tag/jpa/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quanlei.com</link>
	<description>一个关于我们生活点滴的网站，一个记录我们酸甜苦辣的日志。</description>
	<lastBuildDate>Thu, 02 Feb 2012 06:37:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Querying @ElementCollections</title>
		<link>http://www.quanlei.com/2011/11/querying-elementcollections/</link>
		<comments>http://www.quanlei.com/2011/11/querying-elementcollections/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 12:06:20 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[编程相关]]></category>
		<category><![CDATA[JPA]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=2861</guid>
		<description><![CDATA[在JPA 2.0中使用到注解 @ElementCollection 在@ElementCollection的属性中做查询 show sql：<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="[09/48周主题] – JPA" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258991.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/48周主题] – JPA</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="cannot simultaneously fetch multiple bags 问题的解决办法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">cannot simultaneously fetch multiple bags 问题的解决办法</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="周主题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">周主题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/01周主题] – Web 项目开发中的常见问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/01周主题] – Web 项目开发中的常见问题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="绿色公益" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2008%2F11%2F%25E7%25BB%25BF%25E8%2589%25B2%25E5%2585%25AC%25E7%259B%258A%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2260495.png" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">绿色公益</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>在JPA 2.0中使用到注解 @ElementCollection</p>
<pre class="brush: plain; title: ; notranslate">
public class Budget extends IdEntity {

@ElementCollection(fetch = FetchType.EAGER)
@Column(name = &quot;projectLeaderIDs&quot;)
private List&lt;String&gt; projectLeaderIDs;
}
</pre>
<p>在@ElementCollection的属性中做查询</p>
<pre class="brush: plain; title: ; notranslate">
String sql = &quot;select count(b) from &quot; + Budget.class.getSimpleName()
                + &quot; b,IN (b.projectLeaderIDs) s where :userID in s&quot;;
</pre>
<p>show sql：</p>
<pre class="brush: plain; title: ; notranslate">
Hibernate:
    select
        count(budget0_.id) as col_0_0_
    from
        budget budget0_
    inner join
        Budget_projectLeaderIDs projectlea1_
            on budget0_.id=projectlea1_.Budget_id
    where
        ? in (
            projectlea1_.projectLeaderIDs
        ) limit ?
</pre>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F&title=Querying+%40ElementCollections" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="[09/48周主题] – JPA" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258991.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/48周主题] – JPA</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="cannot simultaneously fetch multiple bags 问题的解决办法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">cannot simultaneously fetch multiple bags 问题的解决办法</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="周主题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">周主题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/01周主题] – Web 项目开发中的常见问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/01周主题] – Web 项目开发中的常见问题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="分享：Chrome插件-G Translate EX" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F12%2Fshare-chrome-plugin-g-translate-ex%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/12/07/12028011.png" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">分享：Chrome插件-G Translate EX</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2011/11/querying-elementcollections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>cannot simultaneously fetch multiple bags 问题的解决办法</title>
		<link>http://www.quanlei.com/2011/10/cannot-simultaneously-fetch-multiple-bags/</link>
		<comments>http://www.quanlei.com/2011/10/cannot-simultaneously-fetch-multiple-bags/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 11:15:15 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[编程相关]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[JPA]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=2817</guid>
		<description><![CDATA[完整的异常信息如下： 问题是什么时候出现的呢？ 当一个实体对象中包含多于一个non-lazy获取策略时，比如@OneToMany，@ManyToMany或者@ElementCollection时，获取策略为(fetch = FetchType.EAGER) 出现问题的原因： 当(fetch = FetchType.EAGER)多余一个时，持久框架抓取一方的对象时，同时又将多方的对象加载进容器中，多方又可能关联其它对象，Hibernate实现的JPA，默认最高抓取深度含本身级为四级(它有个属性配置是0-3),若多方(第二级)存在重复值，则第三级中抓取的值就无法映射，就会出现 multiple bags。 解决方法： 1、将(fetch = FetchType.EAGER)改为(fetch = FetchType.LAZY) 2、将List修改成Set集合，即推荐@ManyToMany或@OneToMany的Many方此时用Set容器来存放，而不用List集合。 3、改变FetchMode为@Fetch(FetchMode.SUBSELECT)，即发送另外一条select语句抓取前面查询到的所有实体对象的关联实体。 4、在对应的属性上添加@IndexColumn，该注解允许你指明存放索引值的字段，目的跟Set容器不允许重复元素的道理一样。 推荐的处理办法： 方法2; 方法3和方法4是Hibernate特有的，非JPA标准; 如果可以用方法1，那就不会出现这个问题。 参考： 1、http://blog.eyallupu.com/2010/06/hibernate-exception-simultaneously.html 2、http://dyldragon.iteye.com/blog/788385 3、http://howsun.blog.sohu.com/119020926.html<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="[09/48周主题] – JPA" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258991.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/48周主题] – JPA</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F12%2Fcaused-by-org-hibernate-hql-ast-querysyntaxexception-unexpected-end-of-subtree%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Querying @ElementCollections" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Querying @ElementCollections</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/01周主题] – Web 项目开发中的常见问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/01周主题] – Web 项目开发中的常见问题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="周主题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">周主题</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p class="btitle">完整的异常信息如下：</p>
<pre class="brush: plain; title: ; notranslate">
org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
	at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:94)
	at org.hibernate.loader.entity.EntityLoader.&lt;init&gt;(EntityLoader.java:119)
	at org.hibernate.loader.entity.EntityLoader.&lt;init&gt;(EntityLoader.java:71)
	at org.hibernate.loader.entity.EntityLoader.&lt;init&gt;(EntityLoader.java:54)
	at org.hibernate.loader.entity.BatchingEntityLoader.createBatchingEntityLoader(BatchingEntityLoader.java:133)
	at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1914)
	at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:1937)
	at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(AbstractEntityPersister.java:3205)
	at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:3191)
	at org.hibernate.impl.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:348)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:906)
	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
</pre>
<p class="btitle">问题是什么时候出现的呢？</p>
<blockquote><p>当一个实体对象中包含多于一个non-lazy获取策略时，比如@OneToMany，@ManyToMany或者@ElementCollection时，获取策略为(fetch = FetchType.EAGER)
</p></blockquote>
<p><span id="more-2817"></span></p>
<p class="btitle">出现问题的原因：</p>
<blockquote><p>
当(fetch = FetchType.EAGER)多余一个时，持久框架抓取一方的对象时，同时又将多方的对象加载进容器中，多方又可能关联其它对象，Hibernate实现的JPA，默认最高抓取深度含本身级为四级(它有个属性配置是0-3),若多方(第二级)存在重复值，则第三级中抓取的值就无法映射，就会出现 multiple bags。
</p></blockquote>
<p class="btitle">解决方法：</p>
<blockquote><p>1、将(fetch = FetchType.EAGER)改为(fetch = FetchType.LAZY)</p></blockquote>
<blockquote><p>2、将List修改成Set集合，即推荐@ManyToMany或@OneToMany的Many方此时用Set容器来存放，而不用List集合。</p></blockquote>
<blockquote><p>3、改变FetchMode为@Fetch(FetchMode.SUBSELECT)，即发送另外一条select语句抓取前面查询到的所有实体对象的关联实体。</p></blockquote>
<blockquote><p>4、在对应的属性上添加@IndexColumn，该注解允许你指明存放索引值的字段，目的跟Set容器不允许重复元素的道理一样。</p></blockquote>
<p class="btitle">推荐的处理办法：</p>
<blockquote><p>方法2;</p>
<p>方法3和方法4是Hibernate特有的，非JPA标准;</p>
<p>如果可以用方法1，那就不会出现这个问题。</p></blockquote>
<p class="btitle">参考：</p>
<blockquote><p>1、http://blog.eyallupu.com/2010/06/hibernate-exception-simultaneously.html<br />
2、http://dyldragon.iteye.com/blog/788385<br />
3、http://howsun.blog.sohu.com/119020926.html</p></blockquote>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F&title=cannot+simultaneously+fetch+multiple+bags+%E9%97%AE%E9%A2%98%E7%9A%84%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="[09/48周主题] – JPA" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258991.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/48周主题] – JPA</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F12%2Fcaused-by-org-hibernate-hql-ast-querysyntaxexception-unexpected-end-of-subtree%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Querying @ElementCollections" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Querying @ElementCollections</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/01周主题] – Web 项目开发中的常见问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/01周主题] – Web 项目开发中的常见问题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="周主题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">周主题</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2011/10/cannot-simultaneously-fetch-multiple-bags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[10/01周主题] – Web 项目开发中的常见问题</title>
		<link>http://www.quanlei.com/2010/01/1001-week-subject-web-project-problems/</link>
		<comments>http://www.quanlei.com/2010/01/1001-week-subject-web-project-problems/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 08:32:40 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[周主题]]></category>
		<category><![CDATA[编程相关]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JDBC]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[乱码]]></category>
		<category><![CDATA[测试]]></category>
		<category><![CDATA[浏览器]]></category>
		<category><![CDATA[表单]]></category>
		<category><![CDATA[项目]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=1149</guid>
		<description><![CDATA[这周来一直在赶一个Web项目，没多少时间focus到其他上面，于是这周的主题就干脆做个整理，整理下web项目开发时遇到的一些问题和解决办法。 本周主题：Web 项目开发中的常见问题 一、中文乱码 建议统一使用UTF8，或者全局做个filter处理。 二、表单校验 使用第三方校验框架， 而非自己去写，可以减少很多工作量。 三、Ajax的使用 首页尽量少用ajax，页面初次加载时常会加载不上来，尤其多个Ajax实例同时运行。 四、UI 规范 UI最好是出Demo，跟客户确认，定终稿，然后开发按最终效果图实现页面最好，否则没有页面或者效果图，即使有统一的规范，还是会浪费很多时间去调UI问题。 五、浏览器的兼容问题 虽然IE6基本上淘汰了，可老机器上使用IE6的还是不少的，Css 在处理兼容问题时，建议分开处理，在页面进行浏览器version判断，读取不同的css，这样管理和调整起来都方便。 六、比较完整的测试数据 页面框架搭完了，看着效果不错，可是填完数据后会发现和想象的不太一样。 七、用JPA Or JDBC 与数据库交互 JPA与JDBC相比之下，使用JPA大大减少了编程人员的工作量，因此还是偏向使用JPA，特殊环境下再选择JDBC<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="[10/17 周主题] – Axure入项目" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F05%2F1017-week-subject-axure-quick-start%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258330.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/17 周主题] – Axure入项目</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[09/48周主题] – JPA" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258991.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/48周主题] – JPA</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="在Swing中做更多web的事情" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F09%2Fswing-web-browser%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/09/20/32283483.png" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">在Swing中做更多web的事情</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="在web页面中提供打印功能" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F01%2Fweb-print%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">在web页面中提供打印功能</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="分享：web标准化交流会第二十期北京站总结" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F07%2Fshare-w3ctech-beijing-20th%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">分享：web标准化交流会第二十期北京站总结</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>这周来一直在赶一个Web项目，没多少时间focus到其他上面，于是这周的主题就干脆做个整理，整理下web项目开发时遇到的一些问题和解决办法。</p>
<h1>本周主题：Web 项目开发中的常见问题</h1>
<h3>一、中文乱码</h3>
<blockquote><p>建议统一使用UTF8，或者全局做个filter处理。</p></blockquote>
<h3>二、表单校验</h3>
<blockquote><p>使用第三方校验框架， 而非自己去写，可以减少很多工作量。</p></blockquote>
<h3>三、Ajax的使用</h3>
<blockquote><p>首页尽量少用ajax，页面初次加载时常会加载不上来，尤其多个Ajax实例同时运行。</p></blockquote>
<h3>四、UI 规范</h3>
<blockquote><p>UI最好是出Demo，跟客户确认，定终稿，然后开发按最终效果图实现页面最好，否则没有页面或者效果图，即使有统一的规范，还是会浪费很多时间去调UI问题。</p></blockquote>
<h3>五、浏览器的兼容问题</h3>
<blockquote><p>虽然IE6基本上淘汰了，可老机器上使用IE6的还是不少的，Css 在处理兼容问题时，建议分开处理，在页面进行浏览器version判断，读取不同的css，这样管理和调整起来都方便。</p></blockquote>
<h3>六、比较完整的测试数据</h3>
<blockquote><p>页面框架搭完了，看着效果不错，可是填完数据后会发现和想象的不太一样。</p></blockquote>
<h3>七、用JPA Or JDBC 与数据库交互</h3>
<blockquote><p>JPA与JDBC相比之下，使用JPA大大减少了编程人员的工作量，因此还是偏向使用JPA，特殊环境下再选择JDBC</p></blockquote>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F&title=%5B10%2F01%E5%91%A8%E4%B8%BB%E9%A2%98%5D+%E2%80%93+Web+%E9%A1%B9%E7%9B%AE%E5%BC%80%E5%8F%91%E4%B8%AD%E7%9A%84%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="[10/17 周主题] – Axure入项目" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F05%2F1017-week-subject-axure-quick-start%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258330.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/17 周主题] – Axure入项目</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[09/48周主题] – JPA" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258991.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/48周主题] – JPA</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="在Swing中做更多web的事情" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F09%2Fswing-web-browser%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/09/20/32283483.png" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">在Swing中做更多web的事情</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="在web页面中提供打印功能" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F01%2Fweb-print%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">在web页面中提供打印功能</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="分享：web标准化交流会第二十期北京站总结" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F07%2Fshare-w3ctech-beijing-20th%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">分享：web标准化交流会第二十期北京站总结</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2010/01/1001-week-subject-web-project-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[09/48周主题] &#8211; JPA</title>
		<link>http://www.quanlei.com/2009/11/0948-week-subject-jpa/</link>
		<comments>http://www.quanlei.com/2009/11/0948-week-subject-jpa/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 12:35:22 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[周主题]]></category>
		<category><![CDATA[编程相关]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[对象]]></category>
		<category><![CDATA[总结]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=879</guid>
		<description><![CDATA[这是本博客开始周主题的第一个主题，周主题计划按自然周为标记，记录一年内每周的关注主题，这样至少可以提醒自己哪个周的没有写了。 本期主题：JPA 对于JPA不熟悉的朋友可以先看看这里：百度百科之JPA 里面介绍了JPA的起源，优势，厂商等。 本文是由网上其他网友的经验和自己的经验总结而成，个人能力有限，不免有错误之处，如有误导之地恳请指正。欢迎大家提出宝贵意见，以便完善。 一、JPA中必须知道的4个状态 1. 新建态(New)：新创建的实例对象，没有持久化主键。 简单讲就是你刚new出来的对象，谁也管不着的。 2. 受控态(Managed)：在持久化上下文中受管理的对象； 先理解两个概念持久化主键和持久化上下文：持久化上下文是由与该上下文相关联的 EntityManager 实例管理的一组实体实例，关键词是EntityManager， 新创建的实体尚未被托管于持久化上下文中，EntityManager无法对它进行管理。EntityManager对持久化上下文中的实体进行管理，必然通过主键去查找实体对象，这个主键就是持久化主键。 3. 游离态(Detached)：游离于持久化上下文之外的实例对象； 4. 删除态(Removed)：被删除的实例对象。 这些状态通过调用EntityManager的接口方法进行相互迁移 二、EntityManager 的常用API void persist(Object entity) 通过persist()方法，新建状态将转换为受控状态。这意谓着当persist ()方法所在的事务提交时，实体的数据将保存到数据库中。 如果实体已经被持久化，那么再调用persist()操作，会抛出异常 Duplicate entry。 如果对一个已经删除的实体调用persist()操作，删除态的实体又转变为受控态，实体的数据将保存到数据库中。 如果persist的是一个游离实体（即上下文中没有它），而上下文中又没有它的受管版本，数据库却有这个实体，那么会抛出异常 Duplicate entry； 如果persist的是一个游离实体（即上下文中没有它），而上下文中却有它的受管版本，数据库中也有了这个实体，那么EntityManager在persist它的时候就会抛出异常：javax.persistence.EntityExistsException 在一个实体上调用persist()操作，将广播到和实体关联的其他实体上，执行相应的级联持久化操作； void remove(Object entity) 通过remove()方法删除一个受控的实体; 如果实体声明为级联删除(cascade=REMOVE 或者cascade=ALL )，被关联的实体也会被删除; 在一个新建状态的实体上调用remove()操作，将被忽略; 如果在游离实体上调用remove()操作，将抛出 IllegalArgumentException，相关的事务将回滚; 如果在已经删除的实体上执行remove()操作，也会被忽略 T merge(T entity) 将一个游离态的实体持久化到数据库中，并转换为受控态的实体； Merge一个游离版本，同时上下文中却有它的受管版本，那么返回的是受管版本，数据库中的数据更新 Query createQuery(String qlString) [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="周主题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">周主题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="转载:打造自己的Twitter API Proxy" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F09%2Ftwitter-api-proxy%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258224.png" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">转载:打造自己的Twitter API Proxy</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Querying @ElementCollections" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Querying @ElementCollections</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[09/51-52周主题] – Java Net and XML parser" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F12%2Fjava-net-and-xml-parser%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/51-52周主题] – Java Net and XML parser</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="cannot simultaneously fetch multiple bags 问题的解决办法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">cannot simultaneously fetch multiple bags 问题的解决办法</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #800000;"><span style="font-size: xx-large;">这</span></span>是本博客开始周主题的第一个主题，周主题计划按自然周为标记，记录一年内每周的关注主题，这样至少可以提醒自己哪个周的没有写了。</p>
<h2>本期主题：JPA</h2>
<blockquote><p>对于JPA不熟悉的朋友可以先看看这里：<a href="http://baike.baidu.com/view/1036852.htm?fr=ala0" target="_blank">百度百科之JPA</a> 里面介绍了JPA的起源，优势，厂商等。</p></blockquote>
<p><strong>本文是由网上其他网友的经验和自己的经验总结而成，个人能力有限，不免有错误之处，如有误导之地恳请指正。欢迎大家提出宝贵意见，以便完善。</strong><br />
<img class="aligncenter size-full wp-image-892" title="context" src="http://www.quanlei.com/wp-content/uploads/2009/11/context.jpg" alt="context" width="257" height="256" /></p>
<h3>一、JPA中必须知道的4个状态</h3>
<blockquote>
<h4>1. 新建态(New)：新创建的实例对象，没有持久化主键。</h4>
<blockquote><p>简单讲就是你刚new出来的对象，谁也管不着的。</p></blockquote>
<h4>2. 受控态(Managed)：在持久化上下文中受管理的对象；</h4>
<blockquote><p>先理解两个概念<strong>持久化主键</strong>和<strong>持久化上下文</strong>：持久化上下文是由与该上下文相关联的 EntityManager 实例管理的一组实体实例，关键词是EntityManager， 新创建的实体尚未被托管于持久化上下文中，EntityManager无法对它进行管理。EntityManager对持久化上下文中的实体进行管理，必然通过主键去查找实体对象，这个主键就是持久化主键。</p></blockquote>
<h4>3. 游离态(Detached)：游离于持久化上下文之外的实例对象；</h4>
<h4>4. 删除态(Removed)：被删除的实例对象。</h4>
</blockquote>
<p>这些状态通过调用EntityManager的接口方法进行相互迁移</p>
<h3>二、EntityManager 的常用API</h3>
<blockquote>
<h4>void persist(Object entity)</h4>
<blockquote>
<ul>
<li>通过persist()方法，新建状态将转换为受控状态。这意谓着当persist ()方法所在的事务提交时，实体的数据将保存到数据库中。</li>
<li>如果实体已经被持久化，那么再调用persist()操作，会抛出异常 Duplicate entry。</li>
<li>如果对一个已经删除的实体调用persist()操作，删除态的实体又转变为受控态，实体的数据将保存到数据库中。</li>
<li>如果persist的是一个游离实体（即上下文中没有它），而上下文中又没有它的受管版本，数据库却有这个实体，那么会抛出异常 Duplicate entry；</li>
<li>如果persist的是一个游离实体（即上下文中没有它），而上下文中却有它的受管版本，数据库中也有了这个实体，那么EntityManager在persist它的时候就会抛出异常：javax.persistence.EntityExistsException</li>
<li>在一个实体上调用persist()操作，将广播到和实体关联的其他实体上，执行相应的级联持久化操作；</li>
</ul>
</blockquote>
<h4>void remove(Object entity)</h4>
<blockquote>
<ul>
<li>通过remove()方法删除一个受控的实体;</li>
<li>如果实体声明为级联删除(cascade=REMOVE 或者cascade=ALL )，被关联的实体也会被删除;</li>
<li>在一个新建状态的实体上调用remove()操作，将被忽略;</li>
<li>如果在游离实体上调用remove()操作，将抛出 IllegalArgumentException，相关的事务将回滚;</li>
<li>如果在已经删除的实体上执行remove()操作，也会被忽略</li>
</ul>
</blockquote>
<h4>T merge(T entity)</h4>
<blockquote>
<ul>
<li>将一个游离态的实体持久化到数据库中，并转换为受控态的实体；</li>
<li>Merge一个游离版本，同时上下文中却有它的受管版本，那么返回的是受管版本，数据库中的数据更新</li>
</ul>
</blockquote>
<h4>Query createQuery(String qlString)</h4>
<blockquote>
<ul>
<li>根据JPA的查询语句创建一个查询对象Query</li>
</ul>
</blockquote>
<h4>T find(Class entityClass, Object primaryKey)</h4>
<blockquote>
<ul>
<li>以主键查询实体对象，entityClass是实体的类，primaryKey是主键值</li>
</ul>
</blockquote>
</blockquote>
<h3>三、使用时应注意的一些情况</h3>
<blockquote><p>1. EntityManager对象的事务管理方式有两种，分别为JTA和RESOURCE_LOCAL，即Java Transaction API方法和本地的事务管理。JPA中的事务类型通过persistence.xml文件中的“transaction-type”元素配置。JTA事务只能运行在J2EE的环境中，即EJB容器中和Web容器中；而在J2SE环境中只能使用RESOURCE_LOCAL管理事务。</p>
<p>2. 注意OneToMany,ManyToOne,ManyToMany三种关系时的参数配置.</p>
<p>3. Merge也有Persist的功能，数据库中有就merge，没有添加。</p>
<p>4. 注意Transaction的使用，不要一个方法中有几个Transaction。</p>
<p>5. 正确使用Eager和Lazy能显著提交效率。</p>
<p>6. 使用persist，只需注意操作的对象要么是new，要么是受管的，否则肯定出问题。</p>
<p>7. 使用merge，基本上无论如何都不会抛异常，但后续的操作必须针对该方法返回的新受管对象进行操作，否则肯定出问题。</p>
</blockquote>
<h3>四、参考资料</h3>
<blockquote><p>1. http://www.oracle.com/technology/products/ias/toplink/jpa/index.html</p>
<p>2. http://baike.baidu.com/view/1036852.htm?fr=ala0</p>
<p>3. http://java.sun.com/javaee/technologies/persistence.jsp</p>
<p>4. http://pz0513.blog.51cto.com/443986/113098</p></blockquote>
<p><span style="color: #800000;">==本文谢绝转载，谢谢==</span></p>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F&title=%5B09%2F48%E5%91%A8%E4%B8%BB%E9%A2%98%5D+-+JPA" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="周主题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">周主题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="转载:打造自己的Twitter API Proxy" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F09%2Ftwitter-api-proxy%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258224.png" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">转载:打造自己的Twitter API Proxy</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="Querying @ElementCollections" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F11%2Fquerying-elementcollections%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">Querying @ElementCollections</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[09/51-52周主题] – Java Net and XML parser" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F12%2Fjava-net-and-xml-parser%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/51-52周主题] – Java Net and XML parser</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="cannot simultaneously fetch multiple bags 问题的解决办法" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2011%2F10%2Fcannot-simultaneously-fetch-multiple-bags%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">cannot simultaneously fetch multiple bags 问题的解决办法</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2009/11/0948-week-subject-jpa/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>周主题</title>
		<link>http://www.quanlei.com/2009/11/week-subject/</link>
		<comments>http://www.quanlei.com/2009/11/week-subject/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 01:46:17 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[周主题]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[懒惰]]></category>
		<category><![CDATA[计划]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=862</guid>
		<description><![CDATA[本周开始实施“周主题”计划，就是每周都有一个关注的主题内容，了解，掌握，到熟知，可以是各方面的内容， 自己感兴趣的，好玩的等，不过应该会以技术应用居多，毕竟目前还属于技术型，有些内容一周不行可以两周， 甚至三周&#8230;。 推出此计划的目的是自己太懒惰了，习惯性的东西太多，长期计划执行没有持久性，这才决定推出短期的以周为 单位的任务计划，以鞭策自己，你需要快点涉猎各方面的东西，而且是持久的。 预告下本周的主题：JPA， 主要结合项目中的使用，比较系统的了解JPA的应用情况。<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="[09/48周主题] – JPA" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258991.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/48周主题] – JPA</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="周主题推迟一周" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F12%2Fweek-subject-delay-a-week%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">周主题推迟一周</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/03周主题] – 滑雪" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1003-week-subject-ski%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2259045.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/03周主题] – 滑雪</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/01周主题] – Web 项目开发中的常见问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/01周主题] – Web 项目开发中的常见问题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/02周主题] – 仿Gmail头像上传剪辑" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1002-week-subject-gmail-icon-cutter%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258471.png" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/02周主题] – 仿Gmail头像上传剪辑</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #333333;"><span style="color: #800000;"><span style="font-size: xx-large;">本</span></span>周开始实施“周主题”计划，就是每周都有一个关注的主题内容，了解，掌握，到熟知，可以是各方面的内容，</span></p>
<p><span style="color: #333333;">自己感兴趣的，好玩的等，不过应该会以技术应用居多，毕竟目前还属于技术型，有些内容一周不行可以两周，</span></p>
<p><span style="color: #333333;">甚至三周&#8230;。</span></p>
<p><span style="color: #333333;">推出此计划的目的是自己太懒惰了，习惯性的东西太多，长期计划执行没有持久性，这才决定推出短期的以周为</span></p>
<p><span style="color: #333333;">单位的</span><span style="color: #333333;">任务</span><span style="color: #333333;">计划，以鞭策自己，你需要快点涉猎各方面的东西，而且是持久的。</span></p>
<p><span style="color: #333333;">预告下本周的主题：JPA， 主要结合项目中的使用，比较系统的了解JPA的应用情况。</span></p>
<p style="margin:0;padding:0;height:1px;overflow:hidden;">
    <script type="text/javascript"><!--
        var wumiiSitePrefix = "http://www.quanlei.com";
        var wumiiEnableCustomPos = false;
        var wumiiParams = "&#038;num=6&#038;mode=3&#038;displayInFeed=1&#038;version=1.0.5.5&#038;pf=WordPress3.3.1";
    //--></script><script type="text/javascript" src="http://widget.wumii.com/ext/relatedItemsWidget.htm"></script><a href="http://www.wumii.com/widget/relatedItems.htm" style="border:0;"><img src="http://static.wumii.com/images/pixel.png" alt="无觅相关文章插件，快速提升流量" style="border:0;padding:0;margin:0;" /></a></p>
<p><a href="http://www.bshare.cn/share?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F&title=%E5%91%A8%E4%B8%BB%E9%A2%98" title="用bShare分享或收藏本文"><img src="http://static.bshare.cn/frame/images/button_custom1-zh.gif" alt="用bShare分享或收藏本文" /></a></p><table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="5"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">无觅猜您也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="[09/48周主题] – JPA" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2F0948-week-subject-jpa%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258991.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[09/48周主题] – JPA</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="周主题推迟一周" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2009%2F12%2Fweek-subject-delay-a-week%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">周主题推迟一周</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/03周主题] – 滑雪" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1003-week-subject-ski%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2259045.jpg" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/03周主题] – 滑雪</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/01周主题] – Web 项目开发中的常见问题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1001-week-subject-web-project-problems%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/01周主题] – Web 项目开发中的常见问题</font>
                    </a>
                </td>
                <td width="116" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="[10/02周主题] – 仿Gmail头像上传剪辑" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fwww.quanlei.com%2F2010%2F01%2F1002-week-subject-gmail-icon-cutter%2F&from=http%3A%2F%2Fwww.quanlei.com%2F2009%2F11%2Fweek-subject%2F">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 110px !important; height: 110px !important;" src="http://static.wumii.com/site_images/2011/01/21/2258471.png" width="110px" height="110px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 116px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">[10/02周主题] – 仿Gmail头像上传剪辑</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="5" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2009/11/week-subject/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

