﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-黑铁时代-文章分类-Hibernate</title><link>http://www.blogjava.net/Mars/category/39806.html</link><description>一个人倘若需要从思想中得到快乐，那么他的第一个欲望就是学习。</description><language>zh-cn</language><lastBuildDate>Mon, 25 May 2009 04:15:50 GMT</lastBuildDate><pubDate>Mon, 25 May 2009 04:15:50 GMT</pubDate><ttl>60</ttl><item><title> Hibernate依赖包简单介绍</title><link>http://www.blogjava.net/Mars/articles/277806.html</link><dc:creator>BruceLeey</dc:creator><author>BruceLeey</author><pubDate>Mon, 25 May 2009 03:24:00 GMT</pubDate><guid>http://www.blogjava.net/Mars/articles/277806.html</guid><wfw:comment>http://www.blogjava.net/Mars/comments/277806.html</wfw:comment><comments>http://www.blogjava.net/Mars/articles/277806.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Mars/comments/commentRss/277806.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Mars/services/trackbacks/277806.html</trackback:ping><description><![CDATA[<p style="margin: 0cm 0cm 0pt;"><span style="font-family: 宋体;"><font size="2"><span style="color: #ff0000;"><span style="font-family: 宋体;"><font size="2">转载自</font></span><a href="http://blog.csdn.net/sunyujia/archive/2008/05/02/2362478.aspx">http://blog.csdn.net/sunyujia/archive/2008/05/02/2362478.aspx</a></span></font></span><a href="http://blog.csdn.net/sunyujia/archive/2008/05/02/2362478.aspx"></a></p>
<p style="margin: 0cm 0cm 0pt;"><span style="font-family: 宋体;"><font size="2">由于无法找到该文章的原创作者,在此无法注明出处,请作者见谅.如有问题或侵害到您的利益,请与我联系.
</font></span></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><span style="font-family: 宋体;">以</span><font face="Times New Roman">Hibernate2.0.3</font><span style="font-family: 宋体;">为例</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">hibernate2.jar: </font></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">的库，没有什么可说的，必须使用的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">cglib-asm.jar: </font></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">CGLIB</font><span style="font-family: 宋体;">库，</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">用它来实现</span><font face="Times New Roman">PO</font><span style="font-family: 宋体;">字节码的动态生成，非常核心的库，必须使用的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font face="Times New Roman"><font size="2">dom4j.jar: </font></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">dom4j</font><span style="font-family: 宋体;">是一个</span><font face="Times New Roman">Java</font><span style="font-family: 宋体;">的</span><font face="Times New Roman">XML API</font><span style="font-family: 宋体;">，类似于</span><font face="Times New Roman">jdom</font><span style="font-family: 宋体;">，用来读写</span><font face="Times New Roman">XML</font><span style="font-family: 宋体;">文件的。</span><font face="Times New Roman">dom4j</font><span style="font-family: 宋体;">是一个非常非常优秀的</span><font face="Times New Roman">Java XML API</font><span style="font-family: 宋体;">，具有性能优异、功能强大和极端易用使用的特点，同时它也是一个开放源代码的软件，可以在</span><font face="Times New Roman">SourceForge</font><span style="font-family: 宋体;">上找到它。在</span><font face="Times New Roman">IBM developerWorks</font><span style="font-family: 宋体;">上面可以找到一篇文章，对主流的</span><font face="Times New Roman">Java XML API</font><span style="font-family: 宋体;">进行的性能、功能和易用性的评测，</span><font face="Times New Roman">dom4j</font><span style="font-family: 宋体;">无论在那个方面都是非常出色的。我早在将近两年之前就开始使用</span><font face="Times New Roman">dom4j</font><span style="font-family: 宋体;">，直到现在。如今你可以看到越来越多的</span><font face="Times New Roman">Java</font><span style="font-family: 宋体;">软件都在使用</span><font face="Times New Roman">dom4j</font><span style="font-family: 宋体;">来读写</span><font face="Times New Roman">XML</font><span style="font-family: 宋体;">，特别值得一提的是连</span><font face="Times New Roman">Sun</font><span style="font-family: 宋体;">的</span><font face="Times New Roman">JAXM</font><span style="font-family: 宋体;">也在用</span><font face="Times New Roman">dom4j</font><span style="font-family: 宋体;">。这是必须使用的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包，</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">用它来读写配置文件。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font face="Times New Roman"><font size="2">odmg.jar: </font></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">ODMG</font><span style="font-family: 宋体;">是一个</span><font face="Times New Roman">ORM</font><span style="font-family: 宋体;">的规范，</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">实现了</span><font face="Times New Roman">ODMG</font><span style="font-family: 宋体;">规范，这是一个核心的库，必须使用的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">commons-collections.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">Apache Commons</font><span style="font-family: 宋体;">包中的一个，包含了一些</span><font face="Times New Roman">Apache</font><span style="font-family: 宋体;">开发的集合类，功能比</span><font face="Times New Roman">java.util.*</font><span style="font-family: 宋体;">强大。必须使用的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">commons-beanutils.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">Apache Commons</font><span style="font-family: 宋体;">包中的一个，包含了一些</span><font face="Times New Roman">Bean</font><span style="font-family: 宋体;">工具类类。必须使用的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font face="Times New Roman"><font size="2">commons-lang.jar: </font></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">Apache Commons</font><span style="font-family: 宋体;">包中的一个，包含了一些数据类型工具类，是</span><font face="Times New Roman">java.lang.*</font><span style="font-family: 宋体;">的扩展。必须使用的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font face="Times New Roman"><font size="2">commons-logging.jar: </font></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">Apache Commons</font><span style="font-family: 宋体;">包中的一个，包含了日志功能，必须使用的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><span style="font-family: 宋体;">这个包本身包含了一个</span><font face="Times New Roman">Simple Logger</font><span style="font-family: 宋体;">，但是功能很弱。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><span style="font-family: 宋体;">在运行的时候它会先在</span><font face="Times New Roman">CLASSPATH</font><span style="font-family: 宋体;">找</span><font face="Times New Roman">log4j</font><span style="font-family: 宋体;">，如果有，就使用</span><font face="Times New Roman">log4j</font><span style="font-family: 宋体;">，如果没有，就找</span><font face="Times New Roman">JDK1.4</font><span style="font-family: 宋体;">带的</span><font face="Times New Roman">java.util.logging</font><span style="font-family: 宋体;">，如果也找不到就用</span><font face="Times New Roman">Simple Logger</font><span style="font-family: 宋体;">。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">commons-logging.jar</font><span style="font-family: 宋体;">的出现是一个历史的的遗留的遗憾，当初</span><font face="Times New Roman">Apache</font><span style="font-family: 宋体;">极力游说</span><font face="Times New Roman">Sun</font><span style="font-family: 宋体;">把</span><font face="Times New Roman">log4j</font><span style="font-family: 宋体;">加入</span><font face="Times New Roman">JDK1.4</font><span style="font-family: 宋体;">，然而</span><font face="Times New Roman">JDK1.4</font><span style="font-family: 宋体;">项目小组已经接近发布</span><font face="Times New Roman">JDK1.4</font><span style="font-family: 宋体;">产品的时间了，因此拒绝了</span><font face="Times New Roman">Apache</font><span style="font-family: 宋体;">的要求，使用自己的</span><font face="Times New Roman">java.util.logging</font><span style="font-family: 宋体;">，这个包的功能比</span><font face="Times New Roman">log4j</font><span style="font-family: 宋体;">差的很远，性能也一般。后来</span><font face="Times New Roman">Apache</font><span style="font-family: 宋体;">就开发出来了</span><font face="Times New Roman">commons-logging.jar</font><span style="font-family: 宋体;">用来兼容两个</span><font face="Times New Roman">logger</font><span style="font-family: 宋体;">。因此用</span><font face="Times New Roman">commons-logging.jar</font><span style="font-family: 宋体;">写的</span><font face="Times New Roman">log</font><span style="font-family: 宋体;">程序，底层的</span><font face="Times New Roman">Logger</font><span style="font-family: 宋体;">是可以切换的，你可以选择</span><font face="Times New Roman">log4j</font><span style="font-family: 宋体;">，</span><font face="Times New Roman">java.util.logging</font><span style="font-family: 宋体;">或者它自带的</span><font face="Times New Roman">Simple Logger</font><span style="font-family: 宋体;">。不过我仍然强烈建议使用</span><font face="Times New Roman">log4j</font><span style="font-family: 宋体;">，因为</span><font face="Times New Roman">log4j</font><span style="font-family: 宋体;">性能很高，</span><font face="Times New Roman">log</font><span style="font-family: 宋体;">输出信息时间几乎等于</span><font face="Times New Roman">System.out</font><span style="font-family: 宋体;">，而处理一条</span><font face="Times New Roman">log</font><span style="font-family: 宋体;">平均只需要</span><font face="Times New Roman">5us</font><span style="font-family: 宋体;">。你可以在</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">的</span><font face="Times New Roman">src</font><span style="font-family: 宋体;">目录下找到</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">已经为你准备好了的</span><font face="Times New Roman">log4j</font><span style="font-family: 宋体;">的配置文件，你只需要到</span><font face="Times New Roman">Apache </font><span style="font-family: 宋体;">网站去下载</span><font face="Times New Roman">log4j</font><span style="font-family: 宋体;">就可以了。</span><font face="Times New Roman">commons-logging.jar</font><span style="font-family: 宋体;">也是必须的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包。</span><span style="font-family: 宋体;">　　使用</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">必须的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包就是以上的这几个，剩下的都是可选的。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font face="Times New Roman"><font size="2">ant.jar: </font></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">Ant</font><span style="font-family: 宋体;">编译工具的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包，用来编译</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">源代码的。如果你不准备修改和编译</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">源代码，那么就没有什么用，可选的</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包</span><span style="font-family: 宋体;">。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">optional.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">Ant</font><span style="font-family: 宋体;">的一个辅助包。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">c3p0.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">C3PO</font><span style="font-family: 宋体;">是一个数据库连接池，</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">可以配置为使用</span><font face="Times New Roman">C3PO</font><span style="font-family: 宋体;">连接池。如果你准备用这个连接池，就需要这个</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">包。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">proxool.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><span style="font-family: 宋体;">也是一个连接池，同上。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">commons-pool.jar, commons-dbcp.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">DBCP</font><span style="font-family: 宋体;">数据库连接池，</span><font face="Times New Roman">Apache</font><span style="font-family: 宋体;">的</span><font face="Times New Roman">Jakarta</font><span style="font-family: 宋体;">组织开发的，</span><font face="Times New Roman">Tomcat4</font><span style="font-family: 宋体;">的连接池也是</span><font face="Times New Roman">DBCP</font><span style="font-family: 宋体;">。</span><span style="font-family: 宋体;">实际上</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">自己也实现了一个非常非常简单的数据库连接池，加上上面</span><font face="Times New Roman">3</font><span style="font-family: 宋体;">个，你实际上可以在</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">上选择</span><font face="Times New Roman">4</font><span style="font-family: 宋体;">种不同的数据库连接池，选择哪一个看个人的偏好，不过</span><font face="Times New Roman">DBCP</font><span style="font-family: 宋体;">可能更通用一些。另外强调一点，如果在</span><font face="Times New Roman">EJB</font><span style="font-family: 宋体;">中使用</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">，一定要用</span><font face="Times New Roman">App Server</font><span style="font-family: 宋体;">的连接池，不要用以上</span><font face="Times New Roman">4</font><span style="font-family: 宋体;">种连接池，否则容器管理事务不起作用。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">connector.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">JCA </font><span style="font-family: 宋体;">规范，如果你在</span><font face="Times New Roman">App Server</font><span style="font-family: 宋体;">上把</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">配置为</span><font face="Times New Roman">Connector</font><span style="font-family: 宋体;">的话，就需要这个</span><font face="Times New Roman">jar</font><span style="font-family: 宋体;">。不过实际上一般</span><font face="Times New Roman">App Server</font><span style="font-family: 宋体;">肯定会带上这个包，所以实际上是多余的包。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">jaas.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">JAAS</font><span style="font-family: 宋体;">是用来进行权限验证的，已经包含在</span><font face="Times New Roman">JDK1.4</font><span style="font-family: 宋体;">里面了。所以实际上是多余的包。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">jcs.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><span style="font-family: 宋体;">如果你准备在</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">中使用</span><font face="Times New Roman">JCS</font><span style="font-family: 宋体;">的话，那么必须包括它，否则就不用。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">jdbc2_0-stdext.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">JDBC2.0</font><span style="font-family: 宋体;">的扩展包，一般来说数据库连接池会用上它。不过</span><font face="Times New Roman">App Server</font><span style="font-family: 宋体;">都会带上，所以也是多余的。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">jta.jar</font><span style="font-family: 宋体;">：</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">JTA</font><span style="font-family: 宋体;">规范，当</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">使用</span><font face="Times New Roman">JTA</font><span style="font-family: 宋体;">的时候需要，不过</span><font face="Times New Roman">App Server</font><span style="font-family: 宋体;">都会带上，所以也是多余的。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font face="Times New Roman"><font size="2">junit.jar: </font></font></p>
<p style="margin: 0cm 0cm 0pt;"><font size="2"><font face="Times New Roman">Junit</font><span style="font-family: 宋体;">包，当你运行</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">自带的测试代码的时候需要，否则就不用。</span></font></p>
<p style="margin: 0cm 0cm 0pt;"><font face="Times New Roman"><font size="2">xalan.jar, xerces.jar, xml-apis.jar: </font></font></p>
<font size="2"><font face="Times New Roman">Xerces</font><span style="font-family: 宋体;">是</span><font face="Times New Roman">XML</font><span style="font-family: 宋体;">解析器，</span><font face="Times New Roman">Xalan</font><span style="font-family: 宋体;">是格式化器，</span><font face="Times New Roman">xml-apis</font><span style="font-family: 宋体;">实际上是</span><font face="Times New Roman">JAXP</font><span style="font-family: 宋体;">。一般</span><font face="Times New Roman">App Server</font><span style="font-family: 宋体;">都会带上，</span><font face="Times New Roman">JDK1.4</font><span style="font-family: 宋体;">也包含了解析器，不过不是</span><font face="Times New Roman">Xerces</font><span style="font-family: 宋体;">，是</span><font face="Times New Roman">Crimson</font><span style="font-family: 宋体;">，效率比较差，不过</span><font face="Times New Roman">Hibernate</font><span style="font-family: 宋体;">用</span><font face="Times New Roman">XML</font><span style="font-family: 宋体;">只不过是读取配置文件，性能没什么紧要的，所以也是多余的。</span></font>
<img src ="http://www.blogjava.net/Mars/aggbug/277806.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Mars/" target="_blank">BruceLeey</a> 2009-05-25 11:24 <a href="http://www.blogjava.net/Mars/articles/277806.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>