﻿<?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-Goingmm-随笔分类-Reading Note</title><link>http://www.blogjava.net/goingmm/category/3787.html</link><description>&lt;!--
&lt;table&gt;
&lt;tr&gt;
&lt;font color="red"&gt;共有&lt;script src="http://fastonlineusers.com/online.php?d=goingmm.blogjava.net"&gt;&lt;/script&gt;人正在阅读&lt;/font&gt;
&lt;/tr&gt;
&lt;/table&gt;
--&gt;
</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 12:33:03 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 12:33:03 GMT</pubDate><ttl>60</ttl><item><title>是我折腾了你? 安装PMD</title><link>http://www.blogjava.net/goingmm/archive/2006/08/31/66965.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Thu, 31 Aug 2006 15:26:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2006/08/31/66965.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/66965.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2006/08/31/66965.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/66965.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/66965.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Java源代码分析工具PMD 安装记&nbsp;&nbsp;<a href='http://www.blogjava.net/goingmm/archive/2006/08/31/66965.html'>阅读全文</a><img src ="http://www.blogjava.net/goingmm/aggbug/66965.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2006-08-31 23:26 <a href="http://www.blogjava.net/goingmm/archive/2006/08/31/66965.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>再回来改造 tomcat</title><link>http://www.blogjava.net/goingmm/archive/2006/03/19/36013.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Sat, 18 Mar 2006 22:33:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2006/03/19/36013.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/36013.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2006/03/19/36013.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/36013.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/36013.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: tomcat&nbsp;&nbsp;<a href='http://www.blogjava.net/goingmm/archive/2006/03/19/36013.html'>阅读全文</a><img src ="http://www.blogjava.net/goingmm/aggbug/36013.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2006-03-19 06:33 <a href="http://www.blogjava.net/goingmm/archive/2006/03/19/36013.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>DB2 Viper 一个能存储XML的关系数据库</title><link>http://www.blogjava.net/goingmm/archive/2006/02/23/32065.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Thu, 23 Feb 2006 01:56:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2006/02/23/32065.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/32065.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2006/02/23/32065.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/32065.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/32065.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 一个能 物理存储XML的 关系数据库&nbsp;&nbsp;<a href='http://www.blogjava.net/goingmm/archive/2006/02/23/32065.html'>阅读全文</a><img src ="http://www.blogjava.net/goingmm/aggbug/32065.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2006-02-23 09:56 <a href="http://www.blogjava.net/goingmm/archive/2006/02/23/32065.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>再概念“类装载细节”</title><link>http://www.blogjava.net/goingmm/archive/2006/02/23/32063.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Thu, 23 Feb 2006 01:51:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2006/02/23/32063.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/32063.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2006/02/23/32063.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/32063.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/32063.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 再探类装载之秘...&nbsp;&nbsp;<a href='http://www.blogjava.net/goingmm/archive/2006/02/23/32063.html'>阅读全文</a><img src ="http://www.blogjava.net/goingmm/aggbug/32063.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2006-02-23 09:51 <a href="http://www.blogjava.net/goingmm/archive/2006/02/23/32063.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>2006 我们将何去何从</title><link>http://www.blogjava.net/goingmm/archive/2006/02/03/29489.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Fri, 03 Feb 2006 05:08:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2006/02/03/29489.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/29489.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2006/02/03/29489.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/29489.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/29489.html</trackback:ping><description><![CDATA[<P><BR><FONT size=2>凌晨，看到一个挺有趣的讨论[<A href="http://www.hibernate.org.cn">JavaEye</A>]。2006年，Java界的主题将是什么？</FONT></P>
<P><FONT size=2>两年的开发经历，对新技术的追逐与否我不敢妄自评论。茶余饭后无聊的思考<BR>基础显然重要，当新事物能为我所用的时候，能快速应对，足以<BR>不可否认，新技术的出现,往往能成就一批热心追逐的人[只是少部分，大部分属于随波逐流的困惑]</FONT></P>
<P><FONT size=2>2000年 应用服务器年&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这一年，Java应用服务器的需求成为各大公司的最大利益。谁不希望用“业界标准”来标榜自己呢！<BR>■&nbsp; BEA公司的繁荣从此开始</FONT></P>
<P><FONT size=2>2001年 EJB年 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这一年，EJB2.0发布，整个Java业界为之震动，“牵强”的分布式架构，让EJB成了魔术词汇<BR>■&nbsp; EJB成了高价企业软件的“文凭”。懂不懂EJB成为能不能拿到高薪的关键</FONT></P>
<P><FONT size=2>2002年 设计模式年 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这一年，大家开始发现EJB真TNND难用，开始发现Java开发需要遵循某种规则，设计模式开始流行，<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; J2EE核心模式也应运而生<BR>■&nbsp;&nbsp; <A href="http://www.jdon.com">jdon</A>网站借着设计模式的热点一举成名</FONT></P>
<P><FONT size=2>2003年 Hibernate年 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这一年，大家开始否定EJB，开始采用O/R Mapping，Hibernate迅速流行<BR>■&nbsp; <A href="http://www.hibernate.org.cn">JavaEye</A>由于颇有预见性的推广普及Hibernate而成为国内Java社区的亮点</FONT></P>
<P><FONT size=2>2004年 Spring年&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;这一年,EJB3规范和JDO2规范忙着打架，但是真正的主角是Spring，Spring携着IoC和AOP迅速占领J2EE的眼球.<BR>■&nbsp; 《Without EJB》 成为大家背弃EJB2.0的宣言书</FONT></P>
<P><FONT size=2>2005年 AJAX年 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这一年，大部分时间大家都在反思，或者是学习合适的应用程序架构。伴随着Google的Gmail，<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Google Maps等一系列AJAX应用，一个古老的XMLHTTP组件咸鱼翻身。这个冬天终于找到了主题-AJAX<BR>■&nbsp; 骄傲的程序员回头关注“用户体验”</FONT></P>
<P><FONT size=2>2006年 XX年？ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这一年，除了成名已久的EJB3.0值得期待，我们还能看到出人意料的新名词吗？<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;这一年，将会是更深刻的反思年吗？[用已有的技术集合更完美的“用户体验”]<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这一年，我们将何去何从，我也说不清楚 <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 你呢？<BR><BR>&nbsp;Goingmm&nbsp; 2006-02-03<BR></FONT></P><img src ="http://www.blogjava.net/goingmm/aggbug/29489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2006-02-03 13:08 <a href="http://www.blogjava.net/goingmm/archive/2006/02/03/29489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WTP DEMO LOG</title><link>http://www.blogjava.net/goingmm/archive/2006/01/02/26324.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Mon, 02 Jan 2006 06:19:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2006/01/02/26324.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/26324.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2006/01/02/26324.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/26324.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/26324.html</trackback:ping><description><![CDATA[<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT size=2><FONT color=#ff0000>WTP（Web Tools Platform）</FONT>是Eclipse组织的一个针对J2EE做的一个开发工具插件，是Eclipse下面的一个项目.使用过WTP 0.7的用户都知道，WTP提供了几乎完整的Web应用开发的工具支持.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12月19日，Eclipse基金会发布了WTP(Web Tool Project) 1.0rc版本.当天只发布了相关的插件包。我大概是25号从官方网站</FONT><A href="http://download.eclipse.org/webtools/downloads/drops/R-1.0-200512210855/"><FONT size=2>http://download.eclipse.org/webtools/downloads/drops/R-1.0-200512210855/</FONT></A><FONT size=2>拿到了全集成的版本（Eclipse Version: 3.1.1 Build id: M20050929-0840）。<BR>&nbsp;&nbsp;&nbsp;&nbsp; 用这个版本写了一个DEMO。感觉是上手挺容易的。V1.0在V0.7的基础上Fixed了一些Bug。而且有些功能点简化了。做得更common一些。使用过程遇到一些问题，但我不肯定是不是对环境不够熟悉造成的误解。比如修改一个JSP的名字，怎么发布都报错，只有关掉WTP重新Init一次。还有中文问题在这个环境中仍然存在。为了不写Action和相关配置文件，我用一个Servlet来控制转发的，加上一句req.setCharacterEncoding("gb2312")就搞定了。<BR><BR>&nbsp;&nbsp;&nbsp; <FONT color=#ff0000>列举主要使用过程：<BR></FONT></FONT>&nbsp;&nbsp;&nbsp; ■ Setup and configuration&nbsp;<BR>&nbsp;&nbsp;&nbsp; ■ Development basics&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;■&nbsp;JSP Editing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; ■&nbsp; Servlets&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; ■&nbsp; Deployment descriptors&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; ■&nbsp; Structure Source Editing (SSE) framework<BR>&nbsp;&nbsp;&nbsp; ■&nbsp; Server<BR>&nbsp;&nbsp;&nbsp; ■&nbsp; Running and debugging the web app<BR><BR><FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp; 准备放这个Demo的过程,和简单的代码。但是篇幅原因，我就只能放一些零碎的图片。在这里没有打算告诉大家怎么去写一个简单的Web应用。如果对WTP感兴趣的话，这里就当是一些初级的了解吧。有什么问题<A href="goingmm@gmail.com">欢迎讨论</A>。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT color=#ff0000>WTP的基础了解 PIC</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <IMG height=396 alt=WTP-ProjectScopes.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-ProjectScopes.JPG" width=550 border=0><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp; <IMG height=398 alt=WTP-Architecture.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-Architecture.JPG" width=550 border=0><BR><BR>&nbsp;&nbsp;&nbsp; <FONT color=#ff0000>基本配置 PIC</FONT><BR>&nbsp;&nbsp;&nbsp; <IMG height=392 alt=Configuration-InstalledJRE.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/Configuration-InstalledJRE.JPG" width=550 border=0><BR><BR>&nbsp;&nbsp;&nbsp; <IMG height=393 alt=Configuration-ServerRuntime.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/Configuration-ServerRuntime.JPG" width=550 border=0><BR><BR>&nbsp;&nbsp; <FONT color=#ff0000>关于DEMO PIC<BR></FONT>&nbsp;&nbsp; <IMG height=452 alt=WTP-ProjectFileView.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-ProjectFileView.JPG" width=333 border=0><BR><BR>&nbsp; <FONT color=#ff0000>添加一个这样的服务器很简单。和WSAD差不多</FONT><IMG height=322 alt=WTP-ProjectStartServer.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-ProjectStartServer.JPG" width=734 border=0><BR><BR><FONT color=#ff0000>启动好的服务器<BR></FONT><IMG height=93 alt=WTP-ServerStarted.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-ServerStarted.JPG" width=727 border=0><BR><BR><FONT color=#ff0000>运行JSP<BR></FONT><IMG height=457 alt=WTP-ProjectRun.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-ProjectRun.JPG" width=593 border=0><BR><BR><FONT color=#ff0000>登陆页面</FONT><BR><IMG height=177 alt=WTP-ProjectLoginError.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-ProjectLoginError.JPG" width=320 border=0><BR><BR><IMG height=210 alt=WTP-ProjectLogin.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-ProjectLogin.JPG" width=451 border=0><BR><BR><FONT color=#ff0000>登陆成功<BR></FONT><IMG height=152 alt=WTP-ProjectLoginSuccessful.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-ProjectLoginSuccessful.JPG" width=320 border=0><BR><BR><FONT color=#ff0000>中文请求 演示</FONT><BR><IMG height=166 alt=WTP-RequestZH.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-RequestZH.JPG" width=430 border=0><BR><BR><IMG height=153 alt=WTP-ResponseZH.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/WTP/WTP-ResponseZH.JPG" width=447 border=0><BR><BR><BR>END<BR><BR><BR><A href="goingmm@gmail.com">goingmm</A> 2006-01-02<BR><BR></FONT></P><img src ="http://www.blogjava.net/goingmm/aggbug/26324.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2006-01-02 14:19 <a href="http://www.blogjava.net/goingmm/archive/2006/01/02/26324.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>看别人谈异常处理</title><link>http://www.blogjava.net/goingmm/archive/2005/12/17/24367.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Sat, 17 Dec 2005 07:58:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/12/17/24367.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/24367.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/12/17/24367.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/24367.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/24367.html</trackback:ping><description><![CDATA[<P><FONT size=2><FONT color=#000080>异常处理</FONT><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 曾经专门花时间研究过JAVA中“异常处理”。一直想写一篇文章。也一直没有找到合适的方式。概念书上都有，在这里我再重提又觉得对不起大家。最后就不了了之。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 无意间，看到CSDN上有一篇文章写得不错。转给大家看看吧。作者给出了很标准的做法，这里我加点建议。<BR><FONT color=#ff0000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 仅供参考 </FONT><FONT color=#ff0000>注：所有建议都不会去怀疑和针对，作者想要讲解的异常处理知识点</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">￠<SPAN lang=EN-US> Source code</SPAN>的每一个角落都这样<SPAN lang=EN-US>100%</SPAN>标准的去处理异常。会一定程度的影响代码质量。不要相同的处理逻辑反复出现（比如用<SPAN lang=EN-US>Template</SPAN>模式简化处理过程）<SPAN lang=EN-US>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;</SPAN>￠ 根据自己的实际情况选择异常使用，能不用异常处理的时候尽量不要用。有时候没有必要<SPAN lang=EN-US>“</SPAN>强求<SPAN lang=EN-US>”100%</SPAN></SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONT color=#ff0000>转贴内容<BR></FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 你觉得自己是一个Java专家吗？是否肯定自己已经全面掌握了Java的异常处理机制？在下面这段代码中，你能够迅速找出异常处理的六个问题吗？<BR>&nbsp;&nbsp;&nbsp;&nbsp; </P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">&nbsp;OutputStreamWriter&nbsp;out&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;<IMG src="http://www.blogjava.net/images/dot.gif">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">&nbsp;java.sql.Connection&nbsp;conn&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;<IMG src="http://www.blogjava.net/images/dot.gif">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_72_368_Open_Image onclick="this.style.display='none'; Codehighlighter1_72_368_Open_Text.style.display='none'; Codehighlighter1_72_368_Closed_Image.style.display='inline'; Codehighlighter1_72_368_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_72_368_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_72_368_Closed_Text.style.display='none'; Codehighlighter1_72_368_Open_Image.style.display='inline'; Codehighlighter1_72_368_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_72_368_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_72_368_Open_Text><SPAN style="COLOR: #000000">{&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;⑸&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000">&nbsp;　Statement&nbsp;stat&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;conn.createStatement();&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">5</SPAN><SPAN style="COLOR: #000000">&nbsp;　ResultSet&nbsp;rs&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;stat.executeQuery(&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">6</SPAN><SPAN style="COLOR: #000000">&nbsp;　　</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">select&nbsp;uid,&nbsp;name&nbsp;from&nbsp;user</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">7</SPAN><SPAN style="COLOR: #000000">&nbsp;　</SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">&nbsp;(rs.next())&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_224_320_Open_Image onclick="this.style.display='none'; Codehighlighter1_224_320_Open_Text.style.display='none'; Codehighlighter1_224_320_Closed_Image.style.display='inline'; Codehighlighter1_224_320_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_224_320_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_224_320_Closed_Text.style.display='none'; Codehighlighter1_224_320_Open_Image.style.display='inline'; Codehighlighter1_224_320_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">8</SPAN><SPAN style="COLOR: #000000">&nbsp;　</SPAN><SPAN id=Codehighlighter1_224_320_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_224_320_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">9</SPAN><SPAN style="COLOR: #000000">&nbsp;　　out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ID：</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;rs.getString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">uid</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;⑹&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">10</SPAN><SPAN style="COLOR: #000000">&nbsp;　　　</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">，姓名：</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;rs.getString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">name</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">11</SPAN><SPAN style="COLOR: #000000">&nbsp;　}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">12</SPAN><SPAN style="COLOR: #000000">&nbsp;　conn.close();&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;⑶&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">13</SPAN><SPAN style="COLOR: #000000">&nbsp;　out.close();&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">14</SPAN><SPAN style="COLOR: #000000">&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #000000">15</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(Exception&nbsp;ex)&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;⑵&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #008000"><IMG id=Codehighlighter1_403_442_Open_Image onclick="this.style.display='none'; Codehighlighter1_403_442_Open_Text.style.display='none'; Codehighlighter1_403_442_Closed_Image.style.display='inline'; Codehighlighter1_403_442_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_403_442_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_403_442_Closed_Text.style.display='none'; Codehighlighter1_403_442_Open_Image.style.display='inline'; Codehighlighter1_403_442_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">16</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_403_442_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_403_442_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">17</SPAN><SPAN style="COLOR: #000000">&nbsp;　ex.printStackTrace();&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">⑴，⑷&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">18</SPAN><SPAN style="COLOR: #000000">&nbsp;}</SPAN></SPAN></DIV><BR>作为一个Java程序员，你至少应该能够找出两个问题。但是，如果你不能找出全部六个问题，请继续阅读本文。 <BR><BR>　　本文讨论的不是Java异常处理的一般性原则，因为这些原则已经被大多数人熟知。我们要做的是分析各种可称为“反例”（anti-pattern）的违背优秀编码规范的常见坏习惯，帮助读者熟悉这些典型的反面例子，从而能够在实际工作中敏锐地察觉和避免这些问题。 <BR><BR>　　<B>反例之一：丢弃异常 </B><BR><BR>　　代码：15行-18行。 <BR><BR>　　这段代码捕获了异常却不作任何处理，可以算得上Java编程中的杀手。从问题出现的频繁程度和祸害程度来看，它也许可以和C/C++程序的一个恶名远播的问题相提并论??不检查缓冲区是否已满。如果你看到了这种丢弃（而不是抛出）异常的情况，可以百分之九十九地肯定代码存在问题（在极少数情况下，这段代码有存在的理由，但最好加上完整的注释，以免引起别人误解）。 <BR><BR>　　这段代码的错误在于，异常（几乎）总是意味着某些事情不对劲了，或者说至少发生了某些不寻常的事情，我们不应该对程序发出的求救信号保持沉默和无动于衷。调用一下printStackTrace算不上“处理异常”。不错，调用printStackTrace对调试程序有帮助，但程序调试阶段结束之后，printStackTrace就不应再在异常处理模块中担负主要责任了。 <BR><BR>　　丢弃异常的情形非常普遍。打开JDK的ThreadDeath类的文档，可以看到下面这段说明：“特别地，虽然出现ThreadDeath是一种‘正常的情形’，但ThreadDeath类是Error而不是Exception的子类，因为许多应用会捕获所有的Exception然后丢弃它不再理睬。”这段话的意思是，虽然ThreadDeath代表的是一种普通的问题，但鉴于许多应用会试图捕获所有异常然后不予以适当的处理，所以JDK把ThreadDeath定义成了Error的子类，因为Error类代表的是一般的应用不应该去捕获的严重问题。可见，丢弃异常这一坏习惯是如此常见，它甚至已经影响到了Java本身的设计。 <BR><BR>　　那么，应该怎样改正呢？主要有四个选择： <BR><BR>　　1、处理异常。针对该异常采取一些行动，例如修正问题、提醒某个人或进行其他一些处理，要根据具体的情形确定应该采取的动作。再次说明，调用printStackTrace算不上已经“处理好了异常”。 <BR><BR>　　2、重新抛出异常。处理异常的代码在分析异常之后，认为自己不能处理它，重新抛出异常也不失为一种选择。 <BR><BR>　　3、把该异常转换成另一种异常。大多数情况下，这是指把一个低级的异常转换成应用级的异常（其含义更容易被用户了解的异常）。 <BR><BR>　　4、不要捕获异常。 <BR><BR>　　结论一：既然捕获了异常，就要对它进行适当的处理。不要捕获异常之后又把它丢弃，不予理睬。 <BR><BR>　　<B>反例之二：不指定具体的异常 </B><BR><BR>　　代码：15行。 <BR><BR>　　许多时候人们会被这样一种“美妙的”想法吸引：用一个catch语句捕获所有的异常。最常见的情形就是使用catch(Exception ex)语句。但实际上，在绝大多数情况下，这种做法不值得提倡。为什么呢？ <BR><BR>　　要理解其原因，我们必须回顾一下catch语句的用途。catch语句表示我们预期会出现某种异常，而且希望能够处理该异常。异常类的作用就是告诉Java编译器我们想要处理的是哪一种异常。由于绝大多数异常都直接或间接从java.lang.Exception派生，catch(Exception ex)就相当于说我们想要处理几乎所有的异常。 <BR><BR>　　再来看看前面的代码例子。我们真正想要捕获的异常是什么呢？最明显的一个是SQLException，这是JDBC操作中常见的异常。另一个可能的异常是IOException，因为它要操作OutputStreamWriter。显然，在同一个catch块中处理这两种截然不同的异常是不合适的。如果用两个catch块分别捕获SQLException和IOException就要好多了。这就是说，catch语句应当尽量指定具体的异常类型，而不应该指定涵盖范围太广的Exception类。 <BR><BR>　　另一方面，除了这两个特定的异常，还有其他许多异常也可能出现。例如，如果由于某种原因，executeQuery返回了null，该怎么办？答案是让它们继续抛出，即不必捕获也不必处理。实际上，我们不能也不应该去捕获可能出现的所有异常，程序的其他地方还有捕获异常的机会??直至最后由JVM处理。 <BR><BR>　　结论二：在catch语句中尽可能指定具体的异常类型，必要时使用多个catch。不要试图处理所有可能出现的异常。 <BR><BR>　　<B>反例之三：占用资源不释放 </B><BR><BR>　　代码：3行-14行。 <BR><BR>　　异常改变了程序正常的执行流程。这个道理虽然简单，却常常被人们忽视。如果程序用到了文件、Socket、JDBC连接之类的资源，即使遇到了异常，也要正确释放占用的资源。为此，Java提供了一个简化这类操作的关键词finally。 <BR><BR>　　finally是样好东西：不管是否出现了异常，Finally保证在try/catch/finally块结束之前，执行清理任务的代码总是有机会执行。遗憾的是有些人却不习惯使用finally。 <BR><BR>　　当然，编写finally块应当多加小心，特别是要注意在finally块之内抛出的异常??这是执行清理任务的最后机会，尽量不要再有难以处理的错误。 <BR><BR>　　结论三：保证所有资源都被正确释放。充分运用finally关键词。 
<P><FONT size=2><STRONG>反例之四：不说明异常的详细信息 <BR><BR></STRONG>　　代码：3行-18行。 <BR><BR>　　仔细观察这段代码：如果循环内部出现了异常，会发生什么事情？我们可以得到足够的信息判断循环内部出错的原因吗？不能。我们只能知道当前正在处理的类发生了某种错误，但却不能获得任何信息判断导致当前错误的原因。 <BR><BR>　　printStackTrace的堆栈跟踪功能显示出程序运行到当前类的执行流程，但只提供了一些最基本的信息，未能说明实际导致错误的原因，同时也不易解读。 <BR><BR>　　因此，在出现异常时，最好能够提供一些文字信息，例如当前正在执行的类、方法和其他状态信息，包括以一种更适合阅读的方式整理和组织printStackTrace提供的信息。 <BR><BR>　　结论四：在异常处理模块中提供适量的错误原因信息，组织错误信息使其易于理解和阅读。 <BR><BR>　　<B>反例之五：过于庞大的try块 </B><BR><BR>　　代码：3行-14行。 <BR><BR>　　经常可以看到有人把大量的代码放入单个try块，实际上这不是好习惯。这种现象之所以常见，原因就在于有些人图省事，不愿花时间分析一大块代码中哪几行代码会抛出异常、异常的具体类型是什么。把大量的语句装入单个巨大的try块就象是出门旅游时把所有日常用品塞入一个大箱子，虽然东西是带上了，但要找出来可不容易。 <BR><BR>　　一些新手常常把大量的代码放入单个try块，然后再在catch语句中声明Exception，而不是分离各个可能出现异常的段落并分别捕获其异常。这种做法为分析程序抛出异常的原因带来了困难，因为一大段代码中有太多的地方可能抛出Exception。 <BR><BR>　　结论五：尽量减小try块的体积。 <BR><BR>　　<B>反例之六：输出数据不完整</B> <BR><BR>　　代码：7行-11行。 <BR><BR>　　不完整的数据是Java程序的隐形杀手。仔细观察这段代码，考虑一下如果循环的中间抛出了异常，会发生什么事情。循环的执行当然是要被打断的，其次，catch块会执行??就这些，再也没有其他动作了。已经输出的数据怎么办？使用这些数据的人或设备将收到一份不完整的（因而也是错误的）数据，却得不到任何有关这份数据是否完整的提示。对于有些系统来说，数据不完整可能比系统停止运行带来更大的损失。 <BR><BR>　　较为理想的处置办法是向输出设备写一些信息，声明数据的不完整性；另一种可能有效的办法是，先缓冲要输出的数据，准备好全部数据之后再一次性输出。 <BR><BR>　　结论六：全面考虑可能出现的异常以及这些异常对执行流程的影响。<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<STRONG>改写后的代码</STRONG> <BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">OutputStreamWriter&nbsp;out&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;<IMG src="http://www.blogjava.net/images/dot.gif">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>java.sql.Connection&nbsp;conn&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;<IMG src="http://www.blogjava.net/images/dot.gif">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_66_288_Open_Image onclick="this.style.display='none'; Codehighlighter1_66_288_Open_Text.style.display='none'; Codehighlighter1_66_288_Closed_Image.style.display='inline'; Codehighlighter1_66_288_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_66_288_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_66_288_Closed_Text.style.display='none'; Codehighlighter1_66_288_Open_Image.style.display='inline'; Codehighlighter1_66_288_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_66_288_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_66_288_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　Statement&nbsp;stat&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;conn.createStatement();&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　ResultSet&nbsp;rs&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;stat.executeQuery(&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　　</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">select&nbsp;uid,&nbsp;name&nbsp;from&nbsp;user</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　</SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">&nbsp;(rs.next())&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_203_285_Open_Image onclick="this.style.display='none'; Codehighlighter1_203_285_Open_Text.style.display='none'; Codehighlighter1_203_285_Closed_Image.style.display='inline'; Codehighlighter1_203_285_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_203_285_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_203_285_Closed_Text.style.display='none'; Codehighlighter1_203_285_Open_Image.style.display='inline'; Codehighlighter1_203_285_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>　</SPAN><SPAN id=Codehighlighter1_203_285_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_203_285_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　　out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ID：</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;rs.getString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">uid</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">，姓名:&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;rs.getString(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">name</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>　}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(SQLException&nbsp;sqlex)&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_318_405_Open_Image onclick="this.style.display='none'; Codehighlighter1_318_405_Open_Text.style.display='none'; Codehighlighter1_318_405_Closed_Image.style.display='inline'; Codehighlighter1_318_405_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_318_405_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_318_405_Closed_Text.style.display='none'; Codehighlighter1_318_405_Open_Image.style.display='inline'; Codehighlighter1_318_405_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_318_405_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_318_405_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　out.println(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">警告：数据不完整</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　</SPAN><SPAN style="COLOR: #0000ff">throw</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;ApplicationException(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">读取数据时出现SQL错误</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;sqlex);&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(IOException&nbsp;ioex)&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_433_491_Open_Image onclick="this.style.display='none'; Codehighlighter1_433_491_Open_Text.style.display='none'; Codehighlighter1_433_491_Closed_Image.style.display='inline'; Codehighlighter1_433_491_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_433_491_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_433_491_Closed_Text.style.display='none'; Codehighlighter1_433_491_Open_Image.style.display='inline'; Codehighlighter1_433_491_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_433_491_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_433_491_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　</SPAN><SPAN style="COLOR: #0000ff">throw</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;ApplicationException(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">写入数据时出现IO错误</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;ioex);&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">finally</SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_503_877_Open_Image onclick="this.style.display='none'; Codehighlighter1_503_877_Open_Text.style.display='none'; Codehighlighter1_503_877_Closed_Image.style.display='inline'; Codehighlighter1_503_877_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_503_877_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_503_877_Closed_Text.style.display='none'; Codehighlighter1_503_877_Open_Image.style.display='inline'; Codehighlighter1_503_877_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_503_877_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_503_877_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_525_692_Open_Image onclick="this.style.display='none'; Codehighlighter1_525_692_Open_Text.style.display='none'; Codehighlighter1_525_692_Closed_Image.style.display='inline'; Codehighlighter1_525_692_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_525_692_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_525_692_Closed_Text.style.display='none'; Codehighlighter1_525_692_Open_Image.style.display='inline'; Codehighlighter1_525_692_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>　</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(conn&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN id=Codehighlighter1_525_692_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_525_692_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_534_557_Open_Image onclick="this.style.display='none'; Codehighlighter1_534_557_Open_Text.style.display='none'; Codehighlighter1_534_557_Closed_Image.style.display='inline'; Codehighlighter1_534_557_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_534_557_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_534_557_Closed_Text.style.display='none'; Codehighlighter1_534_557_Open_Image.style.display='inline'; Codehighlighter1_534_557_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>　　</SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_534_557_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_534_557_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　　　conn.close();&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>　　}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　　</SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(SQLException&nbsp;sqlex2)&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_592_688_Open_Image onclick="this.style.display='none'; Codehighlighter1_592_688_Open_Text.style.display='none'; Codehighlighter1_592_688_Closed_Image.style.display='inline'; Codehighlighter1_592_688_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_592_688_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_592_688_Closed_Text.style.display='none'; Codehighlighter1_592_688_Open_Image.style.display='inline'; Codehighlighter1_592_688_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>　　</SPAN><SPAN id=Codehighlighter1_592_688_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_592_688_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　　　System.err(</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.getClass().getName()&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">.mymethod&nbsp;-&nbsp;不能关闭数据库连接:&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;sqlex2.toString());&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>　　}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>　}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_714_874_Open_Image onclick="this.style.display='none'; Codehighlighter1_714_874_Open_Text.style.display='none'; Codehighlighter1_714_874_Closed_Image.style.display='inline'; Codehighlighter1_714_874_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_714_874_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_714_874_Closed_Text.style.display='none'; Codehighlighter1_714_874_Open_Image.style.display='inline'; Codehighlighter1_714_874_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>　</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(out&nbsp;</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">)&nbsp;</SPAN><SPAN id=Codehighlighter1_714_874_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_714_874_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_723_745_Open_Image onclick="this.style.display='none'; Codehighlighter1_723_745_Open_Text.style.display='none'; Codehighlighter1_723_745_Closed_Image.style.display='inline'; Codehighlighter1_723_745_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_723_745_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_723_745_Closed_Text.style.display='none'; Codehighlighter1_723_745_Open_Image.style.display='inline'; Codehighlighter1_723_745_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>　　</SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_723_745_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_723_745_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　　　out.close();&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">36</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>　　}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　　</SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000">(IOException&nbsp;ioex2)&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_778_870_Open_Image onclick="this.style.display='none'; Codehighlighter1_778_870_Open_Text.style.display='none'; Codehighlighter1_778_870_Closed_Image.style.display='inline'; Codehighlighter1_778_870_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_778_870_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_778_870_Closed_Text.style.display='none'; Codehighlighter1_778_870_Open_Image.style.display='inline'; Codehighlighter1_778_870_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align=top>　　</SPAN><SPAN id=Codehighlighter1_778_870_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.blogjava.net/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_778_870_Open_Text><SPAN style="COLOR: #000000">{&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">39</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align=top>　　　System.err(</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">.getClass().getName()&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">.mymethod&nbsp;-&nbsp;不能关闭输出文件</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">&nbsp;ioex2.toString());&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">40</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>　　}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">41</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>　}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">42</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN></DIV>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 本文的结论不是放之四海皆准的教条，有时常识和经验才是最好的老师。如果你对自己的做法没有百分之百的信心，务必加上详细、全面的注释。 <BR><BR>　　另一方面，不要笑话这些错误，不妨问问你自己是否真地彻底摆脱了这些坏习惯。即使最有经验的程序员偶尔也会误入歧途，原因很简单，因为它们确确实实带来了“方便”。所有这些反例都可以看作Java编程世界的恶魔，它们美丽动人，无孔不入，时刻诱惑着你。也许有人会认为这些都属于鸡皮蒜毛的小事，不足挂齿，但请记住：勿以恶小而为之，勿以善小而不为。<BR><BR>2005-12-17<BR>Goingmm &nbsp;Subscription <BR><BR></FONT></P></FONT><img src ="http://www.blogjava.net/goingmm/aggbug/24367.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-12-17 15:58 <a href="http://www.blogjava.net/goingmm/archive/2005/12/17/24367.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>New Version(3.1) release - Hibernate</title><link>http://www.blogjava.net/goingmm/archive/2005/12/13/23664.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Tue, 13 Dec 2005 07:01:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/12/13/23664.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/23664.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/12/13/23664.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/23664.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/23664.html</trackback:ping><description><![CDATA[<P><BR><FONT size=2>几天没看新闻，Hibernate已经发布3.1版本<BR></FONT><A href="http://sourceforge.net/project/showfiles.php?group_id=40712&amp;package_id=127784&amp;release_id=377721"><FONT size=2>http://sourceforge.net/project/showfiles.php?group_id=40712&amp;package_id=127784&amp;release_id=377721</FONT></A><BR><BR><FONT size=2>Down下来简单看了看。初看，没多大变化嘛。但是关注一下Change Log. <BR>感觉这个版本主要是Fixed 3.0的一些Bug<BR><BR>Change Log 部分引用</FONT></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">Changes&nbsp;in&nbsp;version&nbsp;3.1&nbsp;&nbsp;(12.12.2005)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>-------------------------------------------<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;Bug<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-849]&nbsp;&nbsp;&nbsp;-&nbsp;Cartesian&nbsp;product&nbsp;+&nbsp;implicit&nbsp;joins<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1065]&nbsp;-&nbsp;user&nbsp;provided&nbsp;connection&nbsp;not&nbsp;usable&nbsp;by&nbsp;default&nbsp;due&nbsp;to&nbsp;agressive&nbsp;release&nbsp;changes<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1101]&nbsp;-&nbsp;associations&nbsp;join&nbsp;fetched&nbsp;in&nbsp;HQL&nbsp;without&nbsp;owner&nbsp;being&nbsp;selected<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1133]&nbsp;-&nbsp;Comparators,&nbsp;defined&nbsp;for&nbsp;collections&nbsp;in&nbsp;mapping&nbsp;files,&nbsp;are&nbsp;not&nbsp;set<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1149]&nbsp;-&nbsp;NPE&nbsp;flushing&nbsp;reattached&nbsp;entity&nbsp;&nbsp;w/&nbsp;non-mutable&nbsp;natural-id<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1170]&nbsp;-&nbsp;HQL&nbsp;'cast'&nbsp;function&nbsp;doesn't&nbsp;work&nbsp;with&nbsp;MySQL&nbsp;4&nbsp;when&nbsp;casting&nbsp;to&nbsp;string<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1187]&nbsp;-&nbsp;Cannot&nbsp;delete&nbsp;a&nbsp;object&nbsp;having&nbsp;a&nbsp;delete-orphan&nbsp;collection&nbsp;when&nbsp;user_rollback_id&nbsp;is&nbsp;set<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1191]&nbsp;-&nbsp;HQL&nbsp;fails&nbsp;backward&nbsp;compatibility&nbsp;using&nbsp;classic&nbsp;translator<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1194]&nbsp;-&nbsp;hql&nbsp;delete&nbsp;statements&nbsp;with&nbsp;joined-subclass&nbsp;hierarchies&nbsp;with&nbsp;a&nbsp;mapped&nbsp;where&nbsp;attribute&nbsp;at&nbsp;the&nbsp;root<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1206]&nbsp;-&nbsp;Mappings.TableDescription&nbsp;is&nbsp;not&nbsp;serializable<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1212]&nbsp;-&nbsp;mismatch&nbsp;in&nbsp;entity-modes&nbsp;defined&nbsp;in&nbsp;DTD&nbsp;and&nbsp;EntityMode&nbsp;class<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1227]&nbsp;-&nbsp;ClassCastException&nbsp;on&nbsp;DOM4J&nbsp;replicate&nbsp;of&nbsp;Calendar&nbsp;property<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1239]&nbsp;-&nbsp;BinaryArithmeticOperatorNode.getDataType()&nbsp;does&nbsp;not&nbsp;properly&nbsp;handle&nbsp;date/time&nbsp;arithmetic<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1240]&nbsp;-&nbsp;Track&nbsp;connection&nbsp;leakage&nbsp;in&nbsp;JDBCContext.afterTransactionCompletion()<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1245]&nbsp;-&nbsp;Calling&nbsp;the&nbsp;Session&nbsp;should&nbsp;register&nbsp;it&nbsp;with&nbsp;the&nbsp;current&nbsp;JTA&nbsp;txn.<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1254]&nbsp;-&nbsp;Serialization&nbsp;of&nbsp;Sessions&nbsp;using&nbsp;JDBCTransactions&nbsp;with&nbsp;auto-flush/auto-close<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;New&nbsp;Feature<BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1222]&nbsp;-&nbsp;Autodiscover&nbsp;scalar&nbsp;types&nbsp;in&nbsp;native-sql<BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1243]&nbsp;-&nbsp;allow&nbsp;placeholders&nbsp;to&nbsp;system&nbsp;properties&nbsp;in&nbsp;config&nbsp;properties<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1244]&nbsp;-&nbsp;Support&nbsp;for&nbsp;MySQL5&nbsp;stored&nbsp;procedures<BR></SPAN><SPAN style="COLOR: #008080">26</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1260]&nbsp;-&nbsp;Configuration.mergeProperties()<BR></SPAN><SPAN style="COLOR: #008080">27</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">28</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;Task<BR></SPAN><SPAN style="COLOR: #008080">29</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1066]&nbsp;-&nbsp;Upgrade&nbsp;CGLIB&nbsp;to&nbsp;fix&nbsp;proxy&nbsp;memory&nbsp;leak<BR></SPAN><SPAN style="COLOR: #008080">30</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1242]&nbsp;-&nbsp;upgrade&nbsp;ANTLR&nbsp;to&nbsp;2.7.6rc1<BR></SPAN><SPAN style="COLOR: #008080">31</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">32</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;Improvement<BR></SPAN><SPAN style="COLOR: #008080">33</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-860]&nbsp;-&nbsp;insert&nbsp;<IMG src="http://www.blogjava.net/images/dot.gif">&nbsp;select&nbsp;<IMG src="http://www.blogjava.net/images/dot.gif">&nbsp;and&nbsp;version&nbsp;numbers<BR></SPAN><SPAN style="COLOR: #008080">34</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-926]&nbsp;-&nbsp;TypeDef&nbsp;should&nbsp;be&nbsp;global<BR></SPAN><SPAN style="COLOR: #008080">35</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1138]&nbsp;-&nbsp;No&nbsp;ConstraintName&nbsp;when&nbsp;using&nbsp;PostgreSQL<BR></SPAN><SPAN style="COLOR: #008080">36</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1144]&nbsp;-&nbsp;Implement&nbsp;naming&nbsp;convention&nbsp;for&nbsp;temporary&nbsp;test&nbsp;failures<BR></SPAN><SPAN style="COLOR: #008080">37</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1153]&nbsp;-&nbsp;PropertiesHelper&nbsp;fails&nbsp;reading&nbsp;primitive&nbsp;values&nbsp;from&nbsp;hibernate-mapping&nbsp;when&nbsp;doc&nbsp;has&nbsp;whitespace<BR></SPAN><SPAN style="COLOR: #008080">38</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1182]&nbsp;-&nbsp;Access&nbsp;to&nbsp;filter&nbsp;metadata<BR></SPAN><SPAN style="COLOR: #008080">39</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1183]&nbsp;-&nbsp;Getting&nbsp;sql&nbsp;"plan"&nbsp;for&nbsp;DML&nbsp;operations<BR></SPAN><SPAN style="COLOR: #008080">40</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1197]&nbsp;-&nbsp;Support&nbsp;for&nbsp;HQL&nbsp;delete&nbsp;on&nbsp;MaxDB<BR></SPAN><SPAN style="COLOR: #008080">41</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1198]&nbsp;-&nbsp;post-insert&nbsp;event&nbsp;pass&nbsp;the&nbsp;entity&nbsp;wo&nbsp;the&nbsp;id&nbsp;field&nbsp;filled&nbsp;when&nbsp;the&nbsp;generator&nbsp;is&nbsp;identity<BR></SPAN><SPAN style="COLOR: #008080">42</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1213]&nbsp;-&nbsp;make&nbsp;JACC&nbsp;event&nbsp;listeners&nbsp;auto&nbsp;configurable&nbsp;(through&nbsp;initialize(Configuration))<BR></SPAN><SPAN style="COLOR: #008080">43</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1215]&nbsp;-&nbsp;Added&nbsp;support&nbsp;for&nbsp;LVARCHAR&nbsp;in&nbsp;InformixDialect<BR></SPAN><SPAN style="COLOR: #008080">44</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1218]&nbsp;-&nbsp;Add&nbsp;concat()&nbsp;function&nbsp;support&nbsp;to&nbsp;SAPDBDialect<BR></SPAN><SPAN style="COLOR: #008080">45</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1255]&nbsp;-&nbsp;ThreadLocalSessionContext&nbsp;and&nbsp;Session&nbsp;serialization<BR></SPAN><SPAN style="COLOR: #008080">46</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">47</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;Patch<BR></SPAN><SPAN style="COLOR: #008080">48</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-967]&nbsp;-&nbsp;executeUpdate&nbsp;on&nbsp;StatelessSession<BR></SPAN><SPAN style="COLOR: #008080">49</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1172]&nbsp;-&nbsp;Missing&nbsp;configuration&nbsp;templates&nbsp;for&nbsp;the&nbsp;new&nbsp;MimerSQLDialect<BR></SPAN><SPAN style="COLOR: #008080">50</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">51</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;Deprecation<BR></SPAN><SPAN style="COLOR: #008080">52</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1229]&nbsp;-&nbsp;deprecate&nbsp;ability&nbsp;for&nbsp;entities&nbsp;to&nbsp;not&nbsp;define&nbsp;identifier&nbsp;properties<BR></SPAN><SPAN style="COLOR: #008080">53</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">54</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">55</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>Changes&nbsp;in&nbsp;version&nbsp;3.1&nbsp;rc3&nbsp;&nbsp;(17.11.2005)<BR></SPAN><SPAN style="COLOR: #008080">56</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>-------------------------------------------<BR></SPAN><SPAN style="COLOR: #008080">57</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">58</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;Bug<BR></SPAN><SPAN style="COLOR: #008080">59</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-755]&nbsp;-&nbsp;Setter&nbsp;/&nbsp;Getter&nbsp;for&nbsp;property&nbsp;gDate&nbsp;are&nbsp;wrong<BR></SPAN><SPAN style="COLOR: #008080">60</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-764]&nbsp;-&nbsp;XML&nbsp;mapping<BR></SPAN><SPAN style="COLOR: #008080">61</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1034]&nbsp;-&nbsp;The&nbsp;connection&nbsp;is&nbsp;closed&nbsp;&nbsp;*outside*&nbsp;the&nbsp;JTA&nbsp;transaction&nbsp;in&nbsp;TransactionHelper<BR></SPAN><SPAN style="COLOR: #008080">62</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1062]&nbsp;-&nbsp;java:comp/UserTransaction&nbsp;not&nbsp;correct&nbsp;for&nbsp;JBoss<BR></SPAN><SPAN style="COLOR: #008080">63</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1064]&nbsp;-&nbsp;Exception&nbsp;using&nbsp;JTATransaction&nbsp;in&nbsp;WebSphere&nbsp;6<BR></SPAN><SPAN style="COLOR: #008080">64</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1069]&nbsp;-&nbsp;Unnecessary&nbsp;commas&nbsp;generated&nbsp;in&nbsp;select&nbsp;with&nbsp;left&nbsp;outer&nbsp;joins<BR></SPAN><SPAN style="COLOR: #008080">65</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1075]&nbsp;-&nbsp;New&nbsp;parser&nbsp;&nbsp;"not&nbsp;exists"&nbsp;command&nbsp;bug<BR></SPAN><SPAN style="COLOR: #008080">66</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1077]&nbsp;-&nbsp;Typo&nbsp;in&nbsp;docs:&nbsp;"equiped"<BR></SPAN><SPAN style="COLOR: #008080">67</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1080]&nbsp;-&nbsp;HQL&nbsp;delete&nbsp;fails&nbsp;on&nbsp;entities&nbsp;with&nbsp;where-fragments&nbsp;using&nbsp;operators&nbsp;other&nbsp;than&nbsp;'='<BR></SPAN><SPAN style="COLOR: #008080">68</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1081]&nbsp;-&nbsp;missing&nbsp;parens&nbsp;in&nbsp;example&nbsp;code&nbsp;for&nbsp;Criteria&nbsp;Associations<BR></SPAN><SPAN style="COLOR: #008080">69</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1084]&nbsp;-&nbsp;incorrect&nbsp;method&nbsp;name&nbsp;"sql"&nbsp;in&nbsp;Restrictions&nbsp;example,&nbsp;should&nbsp;be&nbsp;"sqlRestriction"<BR></SPAN><SPAN style="COLOR: #008080">70</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1091]&nbsp;-&nbsp;Can't&nbsp;write&nbsp;transparent&nbsp;CurrentSessionContext&nbsp;for&nbsp;BMT<BR></SPAN><SPAN style="COLOR: #008080">71</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1098]&nbsp;-&nbsp;Patch&nbsp;for&nbsp;build.sh&nbsp;to&nbsp;be&nbsp;able&nbsp;to&nbsp;build&nbsp;latest&nbsp;version&nbsp;on&nbsp;linux<BR></SPAN><SPAN style="COLOR: #008080">72</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1106]&nbsp;-&nbsp;HQL&nbsp;"not&nbsp;in"&nbsp;generatad&nbsp;wrong&nbsp;SQL<BR></SPAN><SPAN style="COLOR: #008080">73</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1111]&nbsp;-&nbsp;JDBCTransaction.rollback()&nbsp;results&nbsp;in&nbsp;a&nbsp;call&nbsp;to&nbsp;Interceptor.beforeTransactionCompletion()<BR></SPAN><SPAN style="COLOR: #008080">74</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1128]&nbsp;-&nbsp;Column&nbsp;alias&nbsp;clashes&nbsp;under&nbsp;&nbsp;certain&nbsp;circumstances<BR></SPAN><SPAN style="COLOR: #008080">75</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1146]&nbsp;-&nbsp;latest&nbsp;cvs(11/10/05)&nbsp;&nbsp;hibernate3&nbsp;issue&nbsp;with&nbsp;classic&nbsp;query<BR></SPAN><SPAN style="COLOR: #008080">76</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1156]&nbsp;-&nbsp;StatefulPersistenceContext&nbsp;not&nbsp;serializable&nbsp;when&nbsp;property-ref&nbsp;is&nbsp;used<BR></SPAN><SPAN style="COLOR: #008080">77</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1160]&nbsp;-&nbsp;Incorrect&nbsp;use&nbsp;of&nbsp;getGeneratedKey()&nbsp;for&nbsp;Oracle<BR></SPAN><SPAN style="COLOR: #008080">78</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">79</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;New&nbsp;Feature<BR></SPAN><SPAN style="COLOR: #008080">80</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-449]&nbsp;-&nbsp;korean&nbsp;hibernate&nbsp;reference&nbsp;manual<BR></SPAN><SPAN style="COLOR: #008080">81</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1129]&nbsp;-&nbsp;use&nbsp;expected-type&nbsp;in&nbsp;'untyped'&nbsp;Query.setParameter()<BR></SPAN><SPAN style="COLOR: #008080">82</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">83</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;Improvement<BR></SPAN><SPAN style="COLOR: #008080">84</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-221]&nbsp;-&nbsp;Proxy&nbsp;for&nbsp;one-to-one&nbsp;with&nbsp;property-ref<BR></SPAN><SPAN style="COLOR: #008080">85</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-844]&nbsp;-&nbsp;move&nbsp;parameter&nbsp;"bookkeeping"&nbsp;into&nbsp;QueryTranslator<BR></SPAN><SPAN style="COLOR: #008080">86</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1051]&nbsp;-&nbsp;"Compiled"&nbsp;native&nbsp;SQL&nbsp;queries&nbsp;are&nbsp;not&nbsp;cached<BR></SPAN><SPAN style="COLOR: #008080">87</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1061]&nbsp;-&nbsp;import.sql&nbsp;should&nbsp;allow&nbsp;more&nbsp;human&nbsp;readable&nbsp;and&nbsp;usable&nbsp;files<BR></SPAN><SPAN style="COLOR: #008080">88</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1078]&nbsp;-&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">dynamic-component</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;requires&nbsp;type&nbsp;on&nbsp;property<BR></SPAN><SPAN style="COLOR: #008080">89</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1120]&nbsp;-&nbsp;Make&nbsp;NamingStrategy&nbsp;to&nbsp;work&nbsp;nicely&nbsp;with&nbsp;HA&nbsp;and&nbsp;EJB3&nbsp;naming&nbsp;strategy<BR></SPAN><SPAN style="COLOR: #008080">90</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1142]&nbsp;-&nbsp;added&nbsp;getSelectSequenceNextValString()&nbsp;and&nbsp;getCurrentTimestampSelectString()&nbsp;to&nbsp;TimesTenDialect<BR></SPAN><SPAN style="COLOR: #008080">91</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">92</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>**&nbsp;Patch<BR></SPAN><SPAN style="COLOR: #008080">93</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1063]&nbsp;-&nbsp;support&nbsp;for&nbsp;'locate'&nbsp;function&nbsp;in&nbsp;SQLServer&nbsp;and&nbsp;Sybase&nbsp;dialects<BR></SPAN><SPAN style="COLOR: #008080">94</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1090]&nbsp;-&nbsp;Allow&nbsp;subqueries&nbsp;on&nbsp;criteria&nbsp;to&nbsp;obtain&nbsp;non-string&nbsp;results<BR></SPAN><SPAN style="COLOR: #008080">95</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1095]&nbsp;-&nbsp;Hibernate&nbsp;takes&nbsp;incorrect&nbsp;HasCode&nbsp;when&nbsp;a&nbsp;lot&nbsp;of&nbsp;CompositeKeys&nbsp;and&nbsp;Lazy&nbsp;loading&nbsp;is&nbsp;involved<BR></SPAN><SPAN style="COLOR: #008080">96</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1103]&nbsp;-&nbsp;&nbsp;finalize&nbsp;method&nbsp;filter&nbsp;for&nbsp;proxies<BR></SPAN><SPAN style="COLOR: #008080">97</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;[HHH-1136]&nbsp;-&nbsp;more&nbsp;meaningful&nbsp;AssertionFailure&nbsp;message&nbsp;in&nbsp;org.hibernate.persister.entity.JoinedSubclassEntityPersister.getTableId(<IMG src="http://www.blogjava.net/images/dot.gif">)<BR></SPAN><SPAN style="COLOR: #008080">98</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.blogjava.net/goingmm/aggbug/23664.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-12-13 15:01 <a href="http://www.blogjava.net/goingmm/archive/2005/12/13/23664.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java类装载体系中的隔离性-转</title><link>http://www.blogjava.net/goingmm/archive/2005/12/09/23140.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Fri, 09 Dec 2005 06:58:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/12/09/23140.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/23140.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/12/09/23140.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/23140.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/23140.html</trackback:ping><description><![CDATA[<P class=normal>&nbsp;<FONT size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在想Class.forName 和ClassLoader.loadClass 的区别的时候。找到的一篇好文章。给有兴趣的朋友推荐<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>引用：<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Java中类的查找与装载出现的问题总是会时不时出现在Java程序员面前，这并不是什么丢脸的事情，相信没有一个Java程序员没遇到过ClassNotException,因此不要为被人瞅见自己也犯这样的错误而觉得不自然，但是在如果出现了ClassNotFoundException后异常后一脸的茫然，那我想你该了解一下java的类装载的体制了，同时为了进行下面的关于类装载器之间的隔离性的讨论，我们先简单介绍一下类装载的体系结构。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>全文地址：<A href="http://gceclub.sun.com.cn/yuanchuang/week-9/classloader.html">http://gceclub.sun.com.cn/yuanchuang/week-9/classloader.html</A><BR><BR><BR>2005-12-09</FONT></P><img src ="http://www.blogjava.net/goingmm/aggbug/23140.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-12-09 14:58 <a href="http://www.blogjava.net/goingmm/archive/2005/12/09/23140.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Session和Transaction安全撤离现场</title><link>http://www.blogjava.net/goingmm/archive/2005/12/07/22850.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Wed, 07 Dec 2005 05:55:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/12/07/22850.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/22850.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/12/07/22850.html#Feedback</comments><slash:comments>11</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/22850.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/22850.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; 周末和 MIKE 吃饭的时候，他询问，上次提说的问题，什么时候能写出来。“对Session和Transaction的处理，最好单独实现一个模板类来统一做”&nbsp;温故 居于常规的Hibernate的DAO代码。例子做一个Create操作&nbsp;1public&nb...&nbsp;&nbsp;<a href='http://www.blogjava.net/goingmm/archive/2005/12/07/22850.html'>阅读全文</a><img src ="http://www.blogjava.net/goingmm/aggbug/22850.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-12-07 13:55 <a href="http://www.blogjava.net/goingmm/archive/2005/12/07/22850.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Hibernate Transaction</title><link>http://www.blogjava.net/goingmm/archive/2005/11/28/21642.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Mon, 28 Nov 2005 04:00:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/11/28/21642.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/21642.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/11/28/21642.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/21642.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/21642.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><BR>&nbsp;&nbsp;&nbsp;最近，用各种算是流行的方法写了些<SPAN lang=EN-US>Hibernate</SPAN>的例子<SPAN lang=EN-US>(</SPAN>基于测试<SPAN lang=EN-US>)</SPAN>。上次打算写两篇文章。①<SPAN lang=EN-US> Hibernate </SPAN>常用工具的配置和使用。② <SPAN lang=EN-US>Hibernate </SPAN>比较简单的，基于单表操作的例子。写了<SPAN lang=EN-US>80%</SPAN>吧。越想越感觉意义不大。现在网上很多这方面的文章。我自己也没有理由，自私的所谓备份。占用<SPAN lang=EN-US>Blogjava</SPAN>的硬盘空间。就成了后来的 “<FONT color=#ff0000>冰 冻 闲&nbsp;聊</FONT>”<BR>&nbsp;&nbsp; </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">上个星期五，因为公司停电。所以休息了三天。一年前，这个数字可能会感觉太短。但是现在却是突然觉得连续三天不上班。不知道该干什么好。<BR>&nbsp;&nbsp; </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">难道是对这种“月光”族的生活上瘾拉？</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: 宋体">…</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"> </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">这样的话题，等以后想明白了再说吧！<SPAN lang=EN-US>~<BR>&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">接着说这个周末吧！因为无聊，翻翻，去年用过的一些散乱的笔记。越看越搞笑，字迹潦草，还好基本上是一些技术痕迹。找不到从前那些“少年不知愁滋味”的感觉。<BR>&nbsp;&nbsp; </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">因为我一直不是很喜欢看书。现在的书，写得好的不多，但是价钱蛮贵的。所以，有时候就会把一些疑惑的问题写在一张纸上。然后去网上先收集一些资料，再阅读总结。<BR>&nbsp;&nbsp; </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">这里，我发现了一条有趣的问题。<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:chsdate w:st="on" Year="2004" Month="12" Day="3" IsLunarDate="False" IsROCDate="False"><SPAN lang=EN-US>2004</SPAN>年<SPAN lang=EN-US>12</SPAN>月<SPAN lang=EN-US>3</SPAN>日</st1:chsdate><SPAN lang=EN-US> Hibernate</SPAN>使用<SPAN lang=EN-US>JDBC</SPAN>和<SPAN lang=EN-US>JTA</SPAN>管理事务有什么区别？傻傻的问题。不如今天就聊聊这个话题吧！可能，现在也会有人对这个问题感觉疑惑的。<SPAN lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">打开<SPAN lang=EN-US>hibernate.cfg.xml</SPAN>看看具体的<SPAN lang=EN-US>JDBCTransaction </SPAN>和<SPAN lang=EN-US> JTATransaction </SPAN>配置：<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p></o:p></SPAN></P><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>
<P></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">1)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">property&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="hibernate.transaction.factory_class"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>org.hibernate.transaction.JDBCTransactionFactory<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">property</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>2)&nbsp;&nbsp;&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">property&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="hibernate.transaction.factory_class"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>org.hibernate.transaction.JTATransactionFactory<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">property</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left></o:p></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><BR>可能你还会问：“除了这两种还有其他的选择吗？到底选择那一种好呢？在一个应用中能混合使用吗？”等等问题<BR></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><BR>分析和解答：<BR></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">第一个问题<BR></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">&nbsp;&nbsp; <FONT color=#ff0000>可以选择其他的事务管理方式。不过都是<SPAN lang=EN-US>JTA</SPAN>的不同实现版本。这个目录下面有罗列出来<SPAN lang=EN-US>hibernate-3.0\src\org\hibernate\transaction</SPAN>。比如：<SPAN lang=EN-US><o:p></o:p></SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p></o:p></SPAN></P><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>
<P></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">property&nbsp;</SPAN><SPAN style="COLOR: #ff0000">name</SPAN><SPAN style="COLOR: #0000ff">="hibernate.transaction.manager_lookup_class"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>org.hibernate.transaction.WeblogicTransactionManagerLookup<BR></SPAN><SPAN style="COLOR: #008080">3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">property</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left></o:p></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><BR>第二个问题<BR>&nbsp;&nbsp; </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">概念事务：事务就是能以整体的原子操作形式完成的一系列操作。<BR></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><BR>&nbsp;&nbsp; 是不是感觉有些饶口？简单的说，事务 就是一个逻辑工作单元。其中包括一系列的操作。</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">至于事务为什么会产生？有什么基本特性？等等。。这些问题今天不就详细的罗列了。网络上有写得很好的文章。<BR></SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">Hibernate </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">是<SPAN lang=EN-US>JDBC</SPAN>的轻量级封装。他本身并不具备事物管理的能力。事务的管理和调度将委托给<SPAN lang=EN-US>JDBC</SPAN>或者<SPAN lang=EN-US>JTA</SPAN>去做。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><BR>&nbsp;&nbsp;&nbsp; 先说，他默认的事务处理机制<SPAN lang=EN-US>[ JDBC Transaction ]</SPAN>，这的确是最简单的处理方式，因为<SPAN lang=EN-US>Hibernate</SPAN>只是对<SPAN lang=EN-US>JDBC</SPAN>事物做了一层简单<BR>的封装。<SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">JDBC</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">事务由<SPAN lang=EN-US>Connection</SPAN>管理。事务周期局限于<SPAN lang=EN-US>Connection</SPAN>的生命周期之内。在<SPAN lang=EN-US>Hibernate</SPAN>中这种事务周期也就局限于一个<SPAN lang=EN-US>Session</SPAN>之内。</SPAN>做个比较吧！<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 193.55pt; TEXT-INDENT: -171pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-para-margin-left: 2.15gd; mso-char-indent-count: -19.0" align=left><FONT color=#ff0000><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">Connection conn = </SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: 宋体">…</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>;<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;---<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>session = sf.openSession();// </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">初始化数据库连接，<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 194.15pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-para-margin-left: 18.49gd" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000>和<SPAN lang=EN-US>setAutoCommit=<SPAN style="mso-spacerun: yes">&nbsp;</SPAN>false;<o:p></o:p></SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 196.5pt; TEXT-INDENT: -175.5pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-para-margin-left: 2.0gd; mso-char-indent-count: -19.5" align=left><FONT color=#ff0000><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">conn.setAutoCommit(false);<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>&lt;---<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>tx = session.beginTransactioin(); </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">会再次确认<SPAN lang=EN-US>setAutoCommit</SPAN>是否是<SPAN lang=EN-US>false<o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 22.5pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: 2.5" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000>调用业务方法<SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;---<SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN></SPAN>调用业务方法<SPAN lang=EN-US><o:p></o:p></SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 193.55pt; TEXT-INDENT: -171pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-para-margin-left: 2.15gd; mso-char-indent-count: -19.0" align=left><FONT color=#ff0000><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">conn.commit();<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;---<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>tx.commit(); (</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">对应左边的两句<SPAN lang=EN-US>) </SPAN>这里很关键，关掉自动<SPAN lang=EN-US>commit</SPAN>。自己就必须做<SPAN lang=EN-US>commit</SPAN>。否则数据是不会被持久到数据库<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000>conn.setAutoCommit(true);<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000>conn.close();<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;---<SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>session.close();<o:p></o:p></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">简单吧！如果你对<SPAN lang=EN-US>JDBC</SPAN>有了解，看到这里可能会坏笑，<SPAN lang=EN-US>NND</SPAN>就这么简单，我也会封装</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体; mso-ascii-font-family: 宋体">…</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">有兴趣的话可以直接去看看具体的源代码。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>&nbsp;<BR></o:p></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">看看第二种<SPAN lang=EN-US>[JTA Transaction]</SPAN>有什么神奇的地方吧！<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>JTA </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">提供了跨<SPAN lang=EN-US>Session</SPAN>的事务管理能力。</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'MS Shell Dlg'; mso-font-kerning: 0pt; mso-ansi-language: ZH-CN">JTA</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'MS Shell Dlg'; mso-bidi-font-family: 'MS Shell Dlg'; mso-ascii-font-family: 'MS Shell Dlg'; mso-ansi-language: ZH-CN">的事务是要容器支持的，即</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'MS Shell Dlg'; mso-font-kerning: 0pt; mso-ansi-language: ZH-CN">JTS</SPAN><SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'MS Shell Dlg'; mso-bidi-font-family: 'MS Shell Dlg'; mso-ascii-font-family: 'MS Shell Dlg'; mso-ansi-language: ZH-CN">，用来分布式的要求比较多一些，比如像银行这种大系统，处理多个事务源的这些的。<BR>&nbsp;&nbsp; </SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">JTA</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">事务管理则是由<SPAN lang=EN-US>JTA</SPAN>容器实现。事务的生命周期完全由容器来维护。容器中可以有很多<SPAN lang=EN-US>Connection</SPAN>。按照执行的顺序，因该是串联的一条<SPAN lang=EN-US>JDBC Connection</SPAN>事务链。所以<SPAN lang=EN-US>JTA</SPAN>的事务周期可以跨多个<SPAN lang=EN-US>JDBC Connection</SPAN>的生命周期。在<SPAN lang=EN-US>Hibernate</SPAN>中这种事务周期也就可以跨越多个<SPAN lang=EN-US>Session</SPAN>。<BR>&nbsp;&nbsp; </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">所以。<SPAN lang=EN-US>JTA</SPAN>事务的<SPAN lang=EN-US>Connection</SPAN>不能对事务管理进行干涉。意思就是，假如使用了<SPAN lang=EN-US>JTA</SPAN>就不应该再重复调用<SPAN lang=EN-US>Hibernate</SPAN>的<SPAN lang=EN-US>Transaction</SPAN>功能。这里涉及到一种事务模型（嵌套式事务模型）的问题。这里也不详细的介绍具体的几种事务模型了。在<SPAN lang=EN-US>EJB2.0</SPAN>规范里面也不支持这种事务处理模型。<BR>&nbsp;&nbsp; </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">例如<SPAN lang=EN-US> ：<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p></o:p></SPAN></P><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>
<P></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;A&nbsp;有一个方法&nbsp;savePerson()<BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;B&nbsp;有一个方法&nbsp;saveAddress()<BR></SPAN><SPAN style="COLOR: #008080">3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;Call&nbsp;A.savePerson()&nbsp;and&nbsp;B.saveAddress()&nbsp;Used&nbsp;JTATransaction</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">4</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;C&nbsp;有一个方法&nbsp;saveAll()&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>UserTransaction&nbsp;tx&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;(UserTransaction)(</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;InitialContext.lookup(“…”))<BR></SPAN><SPAN style="COLOR: #008080">6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>A.savePerson();<BR></SPAN><SPAN style="COLOR: #008080">7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>B.saveAddress();<BR></SPAN><SPAN style="COLOR: #008080">8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>tx.commit();<BR></SPAN><SPAN style="COLOR: #008080">9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">那么下面这段代码</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p></o:p></SPAN></P><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">
<P></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">1</SPAN><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">Transaction&nbsp;tx&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;session.beginTransaction();<BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top>tx.commit();<BR></SPAN><SPAN style="COLOR: #008080">3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.blogjava.net/images/OutliningIndicators/None.gif" align=top></SPAN></DIV>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><BR>就不能在<SPAN lang=EN-US>class A </SPAN>和<SPAN lang=EN-US> class B </SPAN>中出现。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000>原因：</FONT><FONT color=#ff0000><SPAN lang=EN-US>session.beginTransaction()</SPAN>也同样执行了<SPAN lang=EN-US>InitialContext.lookup</SPAN>方法来获<SPAN lang=EN-US>UserTransaction</SPAN>的实例，<SPAN lang=EN-US>tx.commit()</SPAN>也同样调用了<SPAN lang=EN-US>UserTransaction.commit().</SPAN>这样做就会形成嵌套式的事务。在<SPAN lang=EN-US>Hibernate</SPAN>里面是不被允许的。会导致运行期错误</FONT>。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">谈到这里，不难看出，他们都有着自己鲜明的特点和基本的联系。回到开头的问题，在实际项目中该选用谁好呢？<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">这就需要分情况而定了。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><FONT color=#ff0000><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">1) </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">如果项目有用到<SPAN lang=EN-US>Sessionbean.</SPAN>可能你会疑问？这时候由谁来管理事务呢？<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 40.55pt; TEXT-INDENT: -27pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-para-margin-left: 1.29gd; mso-char-indent-count: -3.0" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000>答案：用<SPAN lang=EN-US>SessionBean</SPAN>来管理。使用<SPAN lang=EN-US>JTA</SPAN>会很方便。因为你完全没有必要去理会<SPAN lang=EN-US>Transaction</SPAN>。直接在<SPAN lang=EN-US>SessionBean</SPAN>的部署描述符里面声明事务就行了。<SPAN lang=EN-US><o:p></o:p></SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 13.5pt; TEXT-INDENT: -13.5pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-char-indent-count: -1.5" align=left><FONT color=#ff0000><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">2) </SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">自己实现一个<SPAN lang=EN-US>Service</SPAN>类，来统一调用持久层的方法。这样也能做到前后台的松耦合。但是这时候你对<SPAN lang=EN-US>session</SPAN>和<SPAN lang=EN-US>Transaction</SPAN>的处理就需要小心了。如果系统考虑分布式就使用<SPAN lang=EN-US>JTA</SPAN>否则就<SPAN lang=EN-US>JDBC</SPAN>足夷。但还是有必要考虑系统的升级，变迁什么的。对<SPAN lang=EN-US>session</SPAN>和<SPAN lang=EN-US>Transaction</SPAN>的处理，最好不要放在<SPAN lang=EN-US>DAO</SPAN>里面做。单独实现一个模板类来统一做。具体的原因和做法，以后有时间再写出来。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">第三个问题<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">由于<SPAN lang=EN-US>SessionFactory</SPAN>是线程安全的，他的创建过程非常复杂，代价极其昂贵。一个应用中最好只有一个<SPAN lang=EN-US>SessionFactory</SPAN>。事务管理类型的选择是在<SPAN lang=EN-US>SessionFactory</SPAN>的属性里面配置的。这里只能选择一种事务管理方式。<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">当然，你可以说还有特殊的情况，假如，这个应用需要连接到两台数据库服务器，就必须为他创建另一个<SPAN lang=EN-US>SessionFactory</SPAN>。那么就可以选用另一种事务管理方式。表面上看这种情况是可以的。居于两种事务的性能考虑。混和用的意义不是很大。假设这样用<SPAN lang=EN-US>+</SPAN>面对考虑不周全的<SPAN lang=EN-US>DAO</SPAN>，也违背了设计原则，想想，这样的话，因为数据库的变动，还得回去修改<SPAN lang=EN-US>DAO</SPAN>的代码吗？（可能会产生嵌套问题）<BR><BR></SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">所以关于这个问题的结论就是：<SPAN lang=EN-US><o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000>在一个<SPAN lang=EN-US>SessionFactory</SPAN>中只能选用一种事务管理<SPAN lang=EN-US><o:p></o:p></SPAN></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000>面对多个<SPAN lang=EN-US>SessionFactory</SPAN>的时候，可以混合用，但是不推荐<BR></FONT><SPAN lang=EN-US><o:p><BR>2005-11-28 CTU OFFICE GOINGMM<BR></o:p></SPAN></SPAN></P><img src ="http://www.blogjava.net/goingmm/aggbug/21642.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-11-28 12:00 <a href="http://www.blogjava.net/goingmm/archive/2005/11/28/21642.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Eclipse + Junit </title><link>http://www.blogjava.net/goingmm/archive/2005/11/13/19590.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Sun, 13 Nov 2005 05:45:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/11/13/19590.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/19590.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/11/13/19590.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/19590.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/19590.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; BACKGROUND: white; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-highlight: white">------------------------------------------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp;<FONT color=#ff0000 size=3>Eclipse Platform</FONT></SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000><FONT size=3> <SPAN style="BACKGROUND: white; mso-highlight: white">Version: <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:chsdate w:st="on" IsROCDate="False" IsLunarDate="False" Day="30" Month="12" Year="1899">3.1.0</st1:chsdate></SPAN> <SPAN style="BACKGROUND: white; mso-highlight: white">Build id: I20050219-1500</SPAN><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></FONT></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><FONT color=#ff0000><FONT size=3>&nbsp;&nbsp;&nbsp;<BR>&nbsp; Junit&nbsp;<SPAN style="BACKGROUND: white; mso-highlight: white">Version:</SPAN></FONT></FONT><st1:chsdate w:st="on" IsROCDate="False" IsLunarDate="False" Day="30" Month="12" Year="1899"><FONT color=#ff0000 size=3>3.8.1</FONT><BR></st1:chsdate><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>------------------------------------------------------------------------------------------------<BR><BR></o:p></SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt; BACKGROUND: white; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体; mso-highlight: white">Eclipse</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">和<SPAN lang=EN-US>Junit </SPAN>大家应该都很熟悉了。这里我也不打算去讲为什么需要做这样的组合。为什么需要测试。为什么测试还有那么多讲究和学问。</SPAN><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体">用一个最简单的例子，让还没有使用过的朋友，有一个简单的认识。主要是发图玩玩 <IMG height=19 src="http://www.blogjava.net/Emoticons/teeth_smile.gif" width=19 border=0></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋体"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 24.75pt; TEXT-INDENT: -24.75pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 24.75pt" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; mso-fareast-font-family: Arial"><SPAN style="mso-list: Ignore">1）看看完成后的效果图 <BR><IMG height=199 alt=Project.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/Project.JPG" width=298 border=0><BR><BR>2）<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">运行</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Eclipse</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">。新建一个</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">workplace</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">项目，点击</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"> <SPAN lang=EN-US>file-&gt;new-&gt;project</SPAN></SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">，选择</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Java</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">项目，点击下一步。写一个项目名称，例如</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">UseJUnit</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">。点击</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Finish</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">。这样就完成新项目的建立。再来配置一下</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Eclipse</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">，在构建路径中添加</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">JUnit</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">类库。在工具条上点击项目</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">-&gt;</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">属性，选择</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Java</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial"> Build Path，Libraries，选择 Add external </SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">JARs</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">，浏览</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Junit</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">被存储的目录，选择</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">junit.jar</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">，点击打开。你将会看见</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">JUnit</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">出现在库的列表中。点击确定，让</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Eclipse</SPAN><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial">重建路径。<BR></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体; mso-hansi-font-family: Arial; mso-bidi-font-family: Arial; mso-ascii-font-family: Arial"><IMG height=128 alt=addJar.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/addJar.JPG" width=488 border=0><BR></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 24.75pt; TEXT-INDENT: -24.75pt; TEXT-ALIGN: left; mso-layout-grid-align: none; mso-list: l0 level1 lfo1; tab-stops: list 24.75pt" align=left>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><BR>3）新建一个Class Person<BR><IMG height=93 alt=Person.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/Person.JPG" width=262 border=0><BR><BR>4) 新建一个Test Class TestCaseWithJunit<BR><IMG height=477 alt=newJunit.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/newJunit.JPG" width=545 border=0><BR><BR>代码如下：<FONT color=#ff0000>public&nbsp;void testSay() 方法是我自己加进去的</FONT><BR><BR><IMG height=271 alt=TestCaseWithJunit.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/TestCaseWithJunit.JPG" width=492 border=0><BR><BR>5) Run Test case<BR>&nbsp;&nbsp;&nbsp;<IMG height=93 alt=runJunit.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/runJunit.JPG" width=566 border=0><BR><BR>6) 看看测试结果<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<IMG height=221 alt=result-1.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/result-1.JPG" width=318 border=0><BR><BR>7）修改一下测试代码<BR>&nbsp;&nbsp;&nbsp;<IMG height=93 alt=modifiedcode.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/modifiedcode.JPG" width=393 border=0><BR><BR>8）再看测试结果<BR><IMG height=434 alt=result-2.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/result-2.JPG" width=321 border=0><BR><BR><IMG height=110 alt=result-3.JPG src="http://www.blogjava.net/images/blogjava_net/goingmm/Junit/result-3.JPG" width=736 border=0><BR><BR><BR><BR>呵呵！ 第一次发图。如果上面的过程描述有什么不清楚的地方。请与我联系<BR><BR>2005-11-13&nbsp; 听涛 窗台 <BR><BR><BR></SPAN></P></o:p></SPAN><img src ="http://www.blogjava.net/goingmm/aggbug/19590.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-11-13 13:45 <a href="http://www.blogjava.net/goingmm/archive/2005/11/13/19590.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MySQL-Front  +  MySQL</title><link>http://www.blogjava.net/goingmm/archive/2005/11/05/18293.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Sat, 05 Nov 2005 06:43:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/11/05/18293.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/18293.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/11/05/18293.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/18293.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/18293.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>-------------------------------------------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp;MySQL-<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Front</SPAN>&nbsp;<SPAN style="mso-spacerun: yes">&nbsp;</SPAN>V3.2 Build 6.25 </SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>&nbsp;&nbsp;&nbsp;MySQL<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>V4.1<BR></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><SPAN lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">-------------------------------------------------------------------------------------------------<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">从名字看双胞胎一般的他们俩。是绝配吗？我也不知道，有时候，</SPAN><SPAN lang=EN-US>MySQL-<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Front</SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">会告诉我：“我不认识</SPAN><SPAN lang=EN-US>MySQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">”。不要以为我和他有啥子关系。这就是我今天要谈到的问题。因为刚用</SPAN><SPAN lang=EN-US>MySQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一段时间。不知道还有没有更好的组合式用法。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）用</SPAN><SPAN lang=EN-US>[MySQL Command Line Client]</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进入</SPAN><SPAN lang=EN-US>MySQL cmd</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">操作模式</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>drop database dbName;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><SPAN lang=EN-US>create database dbName;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><SPAN lang=EN-US>use dbName;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>2) </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">数据库建立好以后开始建立表</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>drop table person;</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>create table person (</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>&nbsp;&nbsp;&nbsp;person_name varchar(16) not null primary key,</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>&nbsp;&nbsp;&nbsp;person_pass varchar(32) not null,</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>&nbsp;&nbsp;&nbsp;person_sex int(1) default '0' ,</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>&nbsp;&nbsp;&nbsp;person_email varchar(30) default null,</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>person_lastLogTime dateTime,</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>active_status int(1) default '0'</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><SPAN lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-list: Ignore">3）<SPAN style="FONT: 7pt 'Times New Roman'"><FONT size=3>&nbsp; </FONT></SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">现在你可以插入一些数据</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt"><SPAN lang=EN-US>insert into person <SPAN style="mso-spacerun: yes">&nbsp;</SPAN>values('goingmm','***','</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">男</SPAN><SPAN lang=EN-US>', 'todogoingmm@163.com', '<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:chsdate w:st="on" IsROCDate="False" IsLunarDate="False" Day="5" Month="11" Year="2005">2005-11-5</st1:chsdate>',1);</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 21pt"><SPAN lang=EN-US>…………...........</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>4)<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>OK </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">现在可以查询出来看了</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US>select * from person</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">突然感觉老在这里操作很是不方便。于是想起了</SPAN><SPAN lang=EN-US>MySQL-<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Front</SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。打开看看，咦！没有找到数据库</SPAN><SPAN lang=EN-US>dbName</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。努力了</SPAN><SPAN lang=EN-US>1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">个小时。原因猜完，办法想尽。</SPAN><SPAN lang=EN-US>MySQL-<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Front</SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">还是说我认识他，你不要搞我拉！</SPAN><SPAN lang=EN-US>~</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">果然，再搞</SPAN><SPAN lang=EN-US> MySQL-<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Front</SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">死掉拉。有个性。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">后来把刚才做的</SPAN><SPAN lang=EN-US>1</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</SPAN><SPAN lang=EN-US>2</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</SPAN><SPAN lang=EN-US>3</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</SPAN><SPAN lang=EN-US>4</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）全部回滚。就是删掉数据库。在</SPAN><SPAN lang=EN-US>MySQL-<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Front</SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里面先建立一个数据库。然后去</SPAN><SPAN lang=EN-US>cmd</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">建立表，插入数据。最后回到</SPAN><SPAN lang=EN-US>MySQL-<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Front</SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。哈哈，这回看到刚刚建立的数据库了。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不知道大家有没有遇到过这个问题。是</SPAN><SPAN lang=EN-US>MySQL-<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Front</SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>bug</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">吗？还有一些</SPAN><SPAN lang=EN-US>MySQL-<SPAN lang=EN-US style="FONT-SIZE: 10.5pt; FONT-FAMILY: 'Times New Roman'; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: 宋体; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">Front</SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">很弱智的问题，比如</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">编辑器。希望他的下一个版本不要这么粗糙。毕竟</SPAN><SPAN lang=EN-US>MySQL </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">都</SPAN><SPAN lang=EN-US>5.0</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">了<BR><BR><BR>2005年11月5日<BR><BR>-----------------------------------------------------------------------------------------<BR></SPAN></P><img src ="http://www.blogjava.net/goingmm/aggbug/18293.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-11-05 14:43 <a href="http://www.blogjava.net/goingmm/archive/2005/11/05/18293.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Cognize Hibernate ... Third</title><link>http://www.blogjava.net/goingmm/archive/2005/11/03/18032.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Thu, 03 Nov 2005 15:16:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/11/03/18032.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/18032.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/11/03/18032.html#Feedback</comments><slash:comments>21</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/18032.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/18032.html</trackback:ping><description><![CDATA[<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><BR>很不好意思，前三篇都还是概念。<BR><BR>其一： 我想归纳下来，给自己以后看做一个备份<BR>其二： 现在真没时间去写代码<BR><BR>项目做完，回到成都，在后面的文章中，我会抽空写一些实际的例子<BR><BR><BR>---------------------------------------------------------------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp;概念Hibernate中的接口<BR>---------------------------------------------------------------------------------------------------------------------<BR><BR>大致分类：<BR></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体"><SPAN style="mso-list: Ignore">■<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">被用户的应用程序调用的，用来完成基本的创建、读取、更新、删除操作以及查询操作的接口。这些接口是</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现用户程序的商业逻辑的主要接口，它们包括</SPAN><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</SPAN><SPAN lang=EN-US>Transaction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN-US>Query</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体"><SPAN style="mso-list: Ignore">■<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">用来读取诸如映射表这类配置文件的接口，典型的代表有</SPAN><SPAN lang=EN-US>Configuration</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体"><SPAN style="mso-list: Ignore">■<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">回调</SPAN><SPAN lang=EN-US>(Callback)</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口。它允许应用程序能对一些事件的发生作出相应的操作，例如</SPAN><SPAN lang=EN-US>Interceptor</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</SPAN><SPAN lang=EN-US>Lifecycle</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN-US>Validatable</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">都是这一类接口</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-list: l0 level1 lfo1; tab-stops: list 18.0pt"><SPAN lang=EN-US style="FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体"><SPAN style="mso-list: Ignore">■<SPAN style="FONT: 7pt 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">一些可以用来扩展</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的映射机制的接口，例如</SPAN><SPAN lang=EN-US>UserType</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</SPAN><SPAN lang=EN-US>CompositeUserType</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN-US>IdentifierGenerator</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。如果你确认有必要的话这些接口可由用户程序来实现。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>&nbsp;</o:p></SPAN><SPAN lang=EN-US><o:p><BR></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口对于</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开发人员来说是一个最重要的接口。然而在</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中，实例化的</SPAN><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是一个轻量级的类，创建和销毁它都不会占用很多资源。这在实际项目中确实很重要，因为在客户程序中，可能会不断地创建以及销毁</SPAN><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象，如果</SPAN><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的开销太大，会给系统带来不良影响。但值得注意的是</SPAN><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象是非线程安全的，因此在你的设计中，最好是一个线程只创建一个</SPAN><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的设计者将</SPAN><SPAN lang=EN-US>session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">看作介于数据连接与事务管理一种中间接口。我们可以将</SPAN><SPAN lang=EN-US>session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">想象成一个持久对象的缓冲区，</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">能检测到这些持久对象的改变，并及时刷新数据库。我们有时也称</SPAN><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是一个持久层管理器，因为它包含这一些持久层相关的操作，诸如存储持久对象至数据库，以及从数据库从获得它们。请注意，</SPAN><SPAN lang=EN-US>Hibernate </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN lang=EN-US>session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不同于</SPAN><SPAN lang=EN-US>JSP</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应用中的</SPAN><SPAN lang=EN-US>HttpSession</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。我们通常会将</SPAN><SPAN lang=EN-US>HttpSesion</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象称为用户</SPAN><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>SessionFactory </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">他用到了一个设计模式</SPAN><SPAN lang=EN-US>[</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">工厂模式</SPAN><SPAN lang=EN-US>]</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，用户程序从工厂类</SPAN><SPAN lang=EN-US>SessionFactory</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中取得</SPAN><SPAN lang=EN-US>Session</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的实例。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">但是请记住，</SPAN><SPAN lang=EN-US>SessionFactory</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">并不是轻量级的！实际上它的设计者的意图是让它能在整个应用中共享。典型地来说，一个项目通常只需要一个</SPAN><SPAN lang=EN-US>SessionFactory</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就够了，但是当你的项目要操作多个数据库时，那你必须为每个数据库指定一个</SPAN><SPAN lang=EN-US>SessionFactory</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>Configuration </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Configuration</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口的作用是对</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">进行配置，以及对它进行启动。在</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的启动过程中，</SPAN><SPAN lang=EN-US>Configuration</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类的实例首先定位映射文档的位置，读取这些配置，然后创建一个</SPAN><SPAN lang=EN-US>SessionFactory</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对象。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>Transaction </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Transaction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口是一个可选的</SPAN><SPAN lang=EN-US>API</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，你可以选择不使用这个接口，取而代之的是</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的设计者自己写的底层事务处理代码。</SPAN><SPAN lang=EN-US> Transaction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口是对实际事务实现的一个抽象，这些实现包括</SPAN><SPAN lang=EN-US>JDBC</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的事务、</SPAN><SPAN lang=EN-US>JTA</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的</SPAN><SPAN lang=EN-US>UserTransaction</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、甚至可以是</SPAN><SPAN lang=EN-US>CORBA</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">事务。<BR>为什么要这样设计呢？因为这样使开发者能够使用一个统一事务的操作界面，使得自己的项目可以在不同的环境和容器之间方便地移值。</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>Query</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN lang=EN-US>Criteria</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Query</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口让你方便地对数据库及持久对象进行查询，它可以有两种表达方式：</SPAN><SPAN lang=EN-US>HQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语言或本地数据库的</SPAN><SPAN lang=EN-US>SQL</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">语句。</SPAN><SPAN lang=EN-US>Query</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">经常被用来绑定查询参数、限制查询记录数量，并最终执行查询操作</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US>Callback </SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口</SPAN></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当一些有用的事件发生时。例如持久对象的载入、存储、删除时，</SPAN><SPAN lang=EN-US>Callback</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口会通知</SPAN><SPAN lang=EN-US>Hibernate</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">去接收一个通知消息。一般而言，</SPAN><SPAN lang=EN-US>Callback</SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口在用户程序中并不是必须的，但你要在你的项目中创建审计日志时，你可能会用到它。<BR><BR><BR>2005年11月3日 夜&nbsp; 阴天 温度偏低<BR><BR>听涛[601]室&nbsp;窗台<BR><BR></SPAN></P><img src ="http://www.blogjava.net/goingmm/aggbug/18032.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-11-03 23:16 <a href="http://www.blogjava.net/goingmm/archive/2005/11/03/18032.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Cognize Hibernate ... Second</title><link>http://www.blogjava.net/goingmm/archive/2005/10/22/16448.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Sat, 22 Oct 2005 14:11:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/10/22/16448.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/16448.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/10/22/16448.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/16448.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/16448.html</trackback:ping><description><![CDATA[<P><BR>&nbsp;&nbsp;&nbsp; 学习Hibernate之前，需要理解 <FONT color=#ff0000>对象持续性和对象-关系映射</FONT> 的核心问题</P>
<P>&nbsp; <FONT color=#ff0000>【概念】</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1）Hibernate是一个面向java环境的对象/关系数据库映射(ORM)工具。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2）ORM 表示一种技术，用来把对象模型表示的对象映射到基于SQL的关系模型中去。</P>
<P>&nbsp; <FONT color=#ff0000>【目标】</FONT>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;对于开发者通常的数据持久化的编程任务。解放其中的95%，成为Java管理持续性数据问题的一种完整的解决方案<BR>&nbsp; <BR>&nbsp; <FONT color=#ff0000>【体现】</FONT><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;他协调应用与关系数据库的交互，让开发者解放出来专注于手中的业务问题。他是一种非强迫性的解决方案</P>
<P>&nbsp; <FONT color=#ff0000>【运行Hibernate需要的第三方库】<BR></FONT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dom4j (必需）:&nbsp;&nbsp; Hibernate在解析XML配置和XML映射元文件时需要使用dom4j。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CGLIB (必需）:&nbsp; Hibernate在运行时使用这个代码生成库强化类（与Java反射机制联合使用）。&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Commons Collections and Commons Logging (必需）: Hibernat使用Apache Jakarta Commons项目提供的多个工具类库<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ODMG4 (必需) : Hibernate提供了一个可选的ODMG兼容持久化管理界面。如果你需要映射集合，你就需要这个类库，<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;就算你不是为了使用ODMG API （注意：为什么在Hibernate 3.0 就没有这个jar了？）<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Log4j (可选）：Log4j 是一款优秀的Debug工具，具体使用方式网络上有很多介绍</P><img src ="http://www.blogjava.net/goingmm/aggbug/16448.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-10-22 22:11 <a href="http://www.blogjava.net/goingmm/archive/2005/10/22/16448.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Cognize Hibernate ... First</title><link>http://www.blogjava.net/goingmm/archive/2005/10/22/16444.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Sat, 22 Oct 2005 13:52:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/10/22/16444.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/16444.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/10/22/16444.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/16444.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/16444.html</trackback:ping><description><![CDATA[<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 几个月前项目中用过hibernate。但是突击式的学习过程。现在回想起来，还真是没能留下什么痕迹。<BR>今天开始，我将会在空闲时间写下对Hibernate的一些认识。就当是一个 "认知" 的过程<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Web应用框架(Jakarta Struts 对 WebWork)，GUI组件框架（Swing 对 SWT），或模版工具（JSP 对 <BR>Velocity）。每一种相互竞争的解决方案都有其优缺点，但它们至少都共享了相同的范围与总体的方法。<BR>不幸的是，这还不是持续性技术的情形，对持续性技术相同的问题有许多不同的混乱的解决方案。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 前面这段话，意味深长。这是对"持续性技术"现状的一个概括。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 本着这种现状去学习和研究"持续性技术"，把现今熟悉的"持续性技术"进行对比式的学习。寻求框架<BR>的处理思路。分析他们的优点，缺点...</P>
<P>&nbsp;&nbsp;先思考几个问题</P>
<P>&nbsp;1）数据持久到底有那些成熟的方式？&nbsp; <BR>&nbsp;&nbsp;&nbsp; ■ 直接使用SQL和JDBC进行工作 也可以结合DAO模式<BR>&nbsp;&nbsp;&nbsp; ■ 序列化持续性机制 他提供了将对象图（应用状态）写到字节流中的能力，然后它可能被持续化到文件或数据库中。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 他也被Java的远程方法调用（RMI）使用来为复杂对象传递值语义。他的另一种用法是在机器集群中跨节点复制应<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用状态。<BR>&nbsp;&nbsp;&nbsp; ■ EJB实体Bean <BR>&nbsp;&nbsp;&nbsp; ■ JDO<BR>&nbsp;&nbsp;&nbsp; ■ ORM&nbsp; 对象-关系映射：中间的短线强调了当这两个领域相碰撞时出现的不匹配问题<BR>&nbsp;&nbsp;&nbsp; ■ XML持续层 XML持续层是序列化模式的变种。<BR>&nbsp;&nbsp;&nbsp; ■ 存储过程</P>
<P>&nbsp;2）ORM解决方案有那些组成部分？<BR>&nbsp;&nbsp;&nbsp; ■ 在持续类的对象上执行基本的CRUD操作的一组API。<BR>&nbsp;&nbsp;&nbsp; ■ 用于指定查询的一种语言或一组API，这些查询会引用类和类属性。<BR>&nbsp;&nbsp;&nbsp; ■ 用于指定映射元数据的工具。<BR>&nbsp;&nbsp;&nbsp; ■ 实现ORM的一项技术，用来与事务对象交互以完成脏检查、懒关联存取和其它优化功能。</P>
<P>&nbsp;3）实现ORM的有那些不同的方式？<BR>&nbsp;&nbsp;&nbsp; ■ 纯关系 <BR>&nbsp;&nbsp;&nbsp; ■ 轻量对象映射<BR>&nbsp;&nbsp;&nbsp; ■ 中等对象映射<BR>&nbsp;&nbsp;&nbsp; ■ 完全对象映射</P>
<P>&nbsp;4）相关的ORM有那些问题？<BR>&nbsp;&nbsp;&nbsp; ■ 持续类像什么？它们是细粒度的JavaBean吗？或者它们是一些类似于EJB的组件模型的实例吗？持续性工具有多么<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;透明？我们需要为业务领域的类采用一种编程模型或一些规范吗？<BR>&nbsp;&nbsp;&nbsp; ■ 映射元数据是如何定义的？因为对象-关系转换完全由元数据控制，这些元数据的格式和定义是重要的核心问题。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORM工具应该提供一个图形化处理元数据的GUI吗？或者有定义元数据的更好的方法吗？<BR>&nbsp;&nbsp;&nbsp; ■ 我们应该映射类的继承层次吗？这有几种标准策略。多态关联、抽象类和接口怎么映射呢？<BR>&nbsp;&nbsp;&nbsp; ■ 对象同一性和相等性如何关联到数据库同一性（主键）？我们如何将特定类的实例映射到特定表的行。<BR>&nbsp;&nbsp;&nbsp; ■ 在运行时持续性逻辑如何与业务域对象交互？这是一个普通的编程问题，有许多的解决方案包括源代码生成、运行时<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 反射、运行时字节码生成和编译时字节码增强。这个问题的解决方案可能影响到你的构建过程（但宁可如此，你也不<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 愿受到其它像用户那样的影响）<BR>&nbsp;&nbsp;&nbsp; ■ 持续性对象的生命周期是什么样的？有些对象的生命周期依赖于其它关联对象的生命周期吗？<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 我们如何将一个对象的生命周期转化为数据库行的生命周期？<BR>&nbsp;&nbsp;&nbsp; ■ 为排序、检索和合计提供了什么样的工具？应用可以在内存中处理其中的一些事情。但为了有效地使用关系技术有时<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 需要通过数据库完成这些工作<BR>&nbsp;&nbsp;&nbsp; ■ 如何有效地取出关联数据？对关系数据的有效访问通常通过表连接实现。面向对象的应用通常通过导航对象图访问数<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 据可能的话，两种数据访问模式应该避免n+1次选择的问题，以及它的补充笛卡尔积的问题（在一次查询中取出过多的<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 数据)</P>
<P>&nbsp;&nbsp;5）所有数据访问技术都不得不面对的问题有那些？<BR>&nbsp;&nbsp;&nbsp; ■ 事务和并发性<BR>&nbsp;&nbsp;&nbsp; ■ 缓存管理（和并发性）<BR></P><img src ="http://www.blogjava.net/goingmm/aggbug/16444.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-10-22 21:52 <a href="http://www.blogjava.net/goingmm/archive/2005/10/22/16444.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>P2P JBuilder 2006 TOP New Function</title><link>http://www.blogjava.net/goingmm/archive/2005/10/21/16196.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Thu, 20 Oct 2005 16:15:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/10/21/16196.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/16196.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/10/21/16196.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/16196.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/16196.html</trackback:ping><description><![CDATA[<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 谈不上JBuilder的忠实用户，只是到现在还保持着对他的那份亲切。 9月2日发布的Borland JBuilder 2006 首先在界面上变得更加简单，直接，咋看少了几分商业味<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;他创造性引入P2P对等协作功能，使开发团队能够跨越地域的限制进行即时交互(chatting, editing, designing, and debugging)，实现虚拟化团队编程(Virtual Peer Programming)。<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 详细介绍：<A href="http://dev.yesky.com/279/2157279_2.shtml">http://dev.yesky.com/279/2157279_2.shtml</A><BR>&nbsp;<BR></P><img src ="http://www.blogjava.net/goingmm/aggbug/16196.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-10-21 00:15 <a href="http://www.blogjava.net/goingmm/archive/2005/10/21/16196.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>常见　HTTP 响应状态代码</title><link>http://www.blogjava.net/goingmm/archive/2005/10/10/15111.html</link><dc:creator>Goingmm</dc:creator><author>Goingmm</author><pubDate>Mon, 10 Oct 2005 02:58:00 GMT</pubDate><guid>http://www.blogjava.net/goingmm/archive/2005/10/10/15111.html</guid><wfw:comment>http://www.blogjava.net/goingmm/comments/15111.html</wfw:comment><comments>http://www.blogjava.net/goingmm/archive/2005/10/10/15111.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/goingmm/comments/commentRss/15111.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/goingmm/services/trackbacks/15111.html</trackback:ping><description><![CDATA[<FONT size=2><BR>初期接触web程序开发的时候，遇到出错一定会抱怨错误提示不准确，不具体．不直观...<BR>记录：<STRONG>常见的HTTP 响应状态代码．</STRONG>能帮助理解出错的原因．<BR><BR><BR>　　代码　　　　　　　含义　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　2005年10月10日<BR>－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;成功&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;：请求成功．<BR>　　302　　　　　　　临时移动：请求消息临时&nbsp;驻留在不同的URI.如果驻留位置是新的URI,则响应中的Location题头域<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 会给出新的URI.&nbsp;当客户端被重新定向时，通常使用此代码．<BR>　　400　　　　　　　不良请求：由于语法错误而导致服务器无法理解请求信息．<BR>　　401　　　　　　　未授权　：请求要求身份验证或授权．<BR>　　403　　　　　　　禁止　　：服务器理解了请求，但是出于某种原因却拒绝处理请求．服务器可能会揭示拒绝原<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;因，也&nbsp;可能不揭示．<BR>　　404　　　　　　　未发现　：服务器未发现与请求URI相匹配的内容．<BR>　　500　　　　　　　内部服务器错误：服务器遇到了未预期的情况，使它无法处理请求．　　&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－&nbsp; </FONT><img src ="http://www.blogjava.net/goingmm/aggbug/15111.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/goingmm/" target="_blank">Goingmm</a> 2005-10-10 10:58 <a href="http://www.blogjava.net/goingmm/archive/2005/10/10/15111.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>