﻿<?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-兴趣与爱好-文章分类-Hibernate</title><link>http://www.blogjava.net/kennyr/category/32971.html</link><description>学习交流</description><language>zh-cn</language><lastBuildDate>Wed, 10 Sep 2008 19:03:58 GMT</lastBuildDate><pubDate>Wed, 10 Sep 2008 19:03:58 GMT</pubDate><ttl>60</ttl><item><title>hibernate3</title><link>http://www.blogjava.net/kennyr/articles/227584.html</link><dc:creator>-南风</dc:creator><author>-南风</author><pubDate>Sun, 07 Sep 2008 12:39:00 GMT</pubDate><guid>http://www.blogjava.net/kennyr/articles/227584.html</guid><wfw:comment>http://www.blogjava.net/kennyr/comments/227584.html</wfw:comment><comments>http://www.blogjava.net/kennyr/articles/227584.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kennyr/comments/commentRss/227584.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kennyr/services/trackbacks/227584.html</trackback:ping><description><![CDATA[http://www.blogjava.net/sterning/archive/2007/09/30/149772.html
<img src ="http://www.blogjava.net/kennyr/aggbug/227584.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kennyr/" target="_blank">-南风</a> 2008-09-07 20:39 <a href="http://www.blogjava.net/kennyr/articles/227584.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何把HIBERNATE2.1升级到HIBERNATE3.0？</title><link>http://www.blogjava.net/kennyr/articles/214410.html</link><dc:creator>-南风</dc:creator><author>-南风</author><pubDate>Sat, 12 Jul 2008 04:28:00 GMT</pubDate><guid>http://www.blogjava.net/kennyr/articles/214410.html</guid><wfw:comment>http://www.blogjava.net/kennyr/comments/214410.html</wfw:comment><comments>http://www.blogjava.net/kennyr/articles/214410.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kennyr/comments/commentRss/214410.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kennyr/services/trackbacks/214410.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1 Hibernate API </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">变化</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> 1.1.1 </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">包名</span>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.2</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> org.hibernate.classic</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">包</span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.3</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">所依赖的第三方软件包</span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.4</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">异常模型</span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.5</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口</span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.6</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> createSQLQuery() </span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.7</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Lifecycle </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Validatable </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口</span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.8</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Interceptor</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口</span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.9</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> UserType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">CompositeUserType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口</span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.10</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> FetchMode</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">类</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> 1.1.11 PersistentEnum</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">类</span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.12</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">对</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Blob </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Clob</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的支持</span></p>
<p style="text-indent: 16.5pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.13</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中供扩展的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">API</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的变化</span></p>
<p style="line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.2 </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">元数据的变化</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">检索策略</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.2.2</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">对象标识符的映射</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.2.3</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">集合映射</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.2.4</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> DTD </span></p>
<p style="line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.3 </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">查询语句的变化</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.3.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> indices()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">elements()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">函数</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">尽管</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate 3.0 </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">与</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的源代码是不兼容的，但是当</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">开发小组在设计</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">时，为简化升级</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">版本作了周到的考虑。对于现有的基于</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Java</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">项目，可以很方便的把它升级到</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">本文描述了</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">版本的新变化，</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">版本的变化包括三个方面：</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">（</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">）</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">API</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的变化，它将影响到</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Java</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">程序代码。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">（</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">2</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">）元数据，它将影响到对象</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">-</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">关系映射文件。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">（</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">3</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">）</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">HQL</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">查询语句。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">值得注意的是，</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">并不会完全取代</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。在同一个应用程序中，允许</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">并存。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">&nbsp;1.1 Hibernate API </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">变化</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">包名</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的包的根路径为</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">: &#8220;org.hibernate&#8221; </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">，而在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中为</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">&#8220;net.sf.hibernate&#8221;</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。这一命名变化使得</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">能够同时在同一个应用程序中运行。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">如果希望把已有的应用升级到</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">，那么升级的第一步是把</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Java</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">源程序中的所有</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">&#8220;net.sf.hibernate&#8221;</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">替换为</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">&#8220;org.hibernate&#8221;</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">&#8220;net.sf.hibernate.expression&#8221;</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">包被改名为</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">&#8220;org.hibernate.criterion&#8221;</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。假如应用程序使用了</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Criteria API</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">，那么在升级的过程中，必须把</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Java</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">源程序中的所有</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">&#8220;net.sf.hibernate.expression&#8221;</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">替换为</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">&#8220;org.hibernate.criterion&#8221;</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">如果应用使用了除</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">以外的其他外部软件，而这个外部软件又引用了</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的接口，那么在升级时必须十分小心。例如</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">EHCache</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">拥有自己的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">CacheProvider</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">：</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> net.sf.ehcache.hibernate.Provider</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">，在这个类中引用了</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中的接口，在升级应用时，可以采用以下办法之一来升级</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">EHCache: </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">（</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">）手工修改</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">net.sf.ehcache.hibernate.Provider</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">类，使它引用</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中的接口。（</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">2</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">）等到</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">EHCache</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">软件本身升级为使用</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">后，使用新的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">EHCache</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">软件。（</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">3</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">）使用</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中内置的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">CacheProvider</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">：</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.cache.EhCacheProvider</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.2</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> org.hibernate.classic</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">包</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">把一些被废弃的接口都转移到</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.classic</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.3</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">所依赖的第三方软件包</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的软件包的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">lib</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">目录下的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">README.txt</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">文件中，描述了</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">所依赖的第三方软件包的变化。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.4</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">异常模型</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中，</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">HibernateException</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">异常以及它的所有子类都继承了</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">java.lang.RuntimeException</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。因此在编译时，编译器不会再检查</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">HibernateException</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.5</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中，原来</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口中的有些基本方法也被废弃，但为了简化升级，这些方法依然是可用的，可以通过</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.classic.Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">子接口来访问它们，例如：</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> org.hibernate.classic.Session session=sessionFactory.openSession(); session.delete("delete from Customer "); </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中，</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.classic.Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口继承了</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口，在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.classic.Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口中包含了一系列被废弃的方法，如</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">find()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">、</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">interate()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">等。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">SessionFactory</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">openSession()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法返回</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.classic.Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">类型的实例。如果希望在程序中完全使用</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">，可以采用以下方式创建</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">实例：</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> org.hibernate.Session session=sessionFactory.openSession(); </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">如果是对已有的程序进行简单的升级，并且希望仍然调用</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的一些接口，可以采用以下方式创建</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">实例：</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> org.hibernate.classic.Session session=sessionFactory.openSession(); </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中，</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口中被废弃的方法包括：</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> * </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">执行查询的方法：</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">find()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">、</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">iterate()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">、</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">filter()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">delete(String hqlSelectQuery) * saveOrUpdateCopy() Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">一律采用</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">createQuery()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法来执行所有的查询语句，采用</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">DELETE </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">查询语句来执行批量删除，采用</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">merge()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法来替代</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> saveOrUpdateCopy()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">提示：在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中，</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">delete()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法有几种重载形式，其中参数为</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">HQL</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">查询语句的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">delete()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中被废弃，而参数为</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Ojbect</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">类型的的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">delete()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法依然被支持。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">delete(Object o)</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法用于删除参数指定的对象，该方法支持级联删除。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate2.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">没有对批量更新和批量删除提供很好的支持，参见</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">&lt;&lt;</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">精通</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate&gt;&gt;</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">一书的第</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">13</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">章的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">13.1.1</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">节（批量更新和批量删除），而</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">对批量更新和批量删除提供了支持，能够直接执行批量更新或批量删除语句，无需把被更新或删除的对象先加载到内存中。以下是通过</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">执行批量更新的程序代码：</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); String hqlUpdate = "update Customer set name = :newName where name = :oldName"; int updatedEntities = s.createQuery( hqlUpdate ) .setString( "newName", newName ) .setString( "oldName", oldName ) .executeUpdate(); tx.commit(); session.close(); </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">以下是通过</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">执行批量删除的程序代码：</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); String hqlDelete = "delete Customer where name = :oldName"; int deletedEntities = s.createQuery( hqlDelete ) .setString( "oldName", oldName ) .executeUpdate(); tx.commit(); session.close(); </span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.6</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> createSQLQuery() </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">中，</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">createSQLQuery()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法被废弃，被移到</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.classic.Session</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口中。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">采用新的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">SQLQuery</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口来完成相同的功能。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.7</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Lifecycle </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Validatable </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Lifecycle</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Validatable </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口被废弃，并且被移到</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.classic</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">包中。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.8</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Interceptor</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Interceptor </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口中加入了两个新的方法。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">用户创建的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Interceptor</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">实现类在升级的过程中，需要为这两个新方法提供方法体为空的实现。此外，</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">instantiate()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法的参数作了修改，</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">isUnsaved()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法被改名为</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">isTransient()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.9</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> UserType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">CompositeUserType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">在</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">UserType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">CompositeUserType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口中都加入了一些新的方法，这两个接口被移到</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">org.hibernate.usertype</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">包中，用户定义的</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">UserType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">CompositeUserType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">实现类必须实现这些新方法。</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate3.0</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">提供了</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">ParameterizedType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">接口，用于更好的重用用户自定义的类型。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.10</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> FetchMode</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">类</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> FetchMode.LAZY </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> FetchMode.EAGER</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">被废弃。取而代之的分别为</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">FetchMode.SELECT </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">FetchMode.JOIN</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.11 P</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">ersistentEnum</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">类</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> PersistentEnum</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">被废弃并删除。已经存在的应用应该采用</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">UserType</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">来处理枚举类型。</span></p>
<p style="text-indent: 21pt; line-height: 150%"><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">1.1.12</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">对</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Blob </span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Clob</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">的支持</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana"> Hibernate</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">对</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Blob</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">和</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Clob</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">实例进行了包装，使得那些拥有</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Blob</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">或</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">Clob</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">类型的属性的类的实例可以被游离、序列化或反序列化，以及传递到</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: Verdana">merge()</span><span style="font-size: 10pt; color: #5e5e5e; line-height: 150%; font-family: 宋体">方法中。</span></p>
<img src ="http://www.blogjava.net/kennyr/aggbug/214410.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kennyr/" target="_blank">-南风</a> 2008-07-12 12:28 <a href="http://www.blogjava.net/kennyr/articles/214410.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>