437 lines
20 KiB
XML
437 lines
20 KiB
XML
|
<?xml version='1.0' encoding="UTF-8"?>
|
|||
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3CR3//EN"
|
|||
|
"../support/docbook-dtd/docbookx.dtd"
|
|||
|
[
|
|||
|
<!ENTITY quickstart SYSTEM "modules/quickstart.xml">
|
|||
|
<!ENTITY tutorial SYSTEM "modules/tutorial.xml">
|
|||
|
<!ENTITY architecture SYSTEM "modules/architecture.xml">
|
|||
|
<!ENTITY configuration SYSTEM "modules/configuration.xml">
|
|||
|
<!ENTITY persistent-classes SYSTEM "modules/persistent_classes.xml">
|
|||
|
<!ENTITY basic-mapping SYSTEM "modules/basic_mapping.xml">
|
|||
|
<!ENTITY collection-mapping SYSTEM "modules/collection_mapping.xml">
|
|||
|
<!ENTITY association-mapping SYSTEM "modules/association_mapping.xml">
|
|||
|
<!ENTITY component-mapping SYSTEM "modules/component_mapping.xml">
|
|||
|
<!ENTITY inheritance-mapping SYSTEM "modules/inheritance_mapping.xml">
|
|||
|
<!ENTITY session-api SYSTEM "modules/session_api.xml">
|
|||
|
<!ENTITY transactions SYSTEM "modules/transactions.xml">
|
|||
|
<!ENTITY events SYSTEM "modules/events.xml">
|
|||
|
<!ENTITY batch SYSTEM "modules/batch.xml">
|
|||
|
<!ENTITY query-hql SYSTEM "modules/query_hql.xml">
|
|||
|
<!ENTITY query-criteria SYSTEM "modules/query_criteria.xml">
|
|||
|
<!ENTITY query-sql SYSTEM "modules/query_sql.xml">
|
|||
|
<!ENTITY filters SYSTEM "modules/filters.xml">
|
|||
|
<!ENTITY xml SYSTEM "modules/xml.xml">
|
|||
|
<!ENTITY performance SYSTEM "modules/performance.xml">
|
|||
|
<!ENTITY toolset-guide SYSTEM "modules/toolset_guide.xml">
|
|||
|
<!ENTITY example-parentchild SYSTEM "modules/example_parentchild.xml">
|
|||
|
<!ENTITY example-weblog SYSTEM "modules/example_weblog.xml">
|
|||
|
<!ENTITY example-mappings SYSTEM "modules/example_mappings.xml">
|
|||
|
<!ENTITY best-practices SYSTEM "modules/best_practices.xml">
|
|||
|
]>
|
|||
|
|
|||
|
|
|||
|
<book lang="zh-cn">
|
|||
|
|
|||
|
<bookinfo>
|
|||
|
<title>HIBERNATE - 符合Java习惯的关系数据库持久化</title>
|
|||
|
|
|||
|
<subtitle>Hibernate参考文档</subtitle>
|
|||
|
<releaseinfo>3.0.4</releaseinfo>
|
|||
|
</bookinfo>
|
|||
|
|
|||
|
<toc/>
|
|||
|
|
|||
|
<preface id="preface" revision="2">
|
|||
|
<title>前言</title>
|
|||
|
|
|||
|
<para>
|
|||
|
WARNING! This is a translated version of the English Hibernate reference
|
|||
|
documentation. The translated version might not be up to date! However, the
|
|||
|
differences should only be very minor. Consult the English reference
|
|||
|
documentation if you are missing information or encounter a translation
|
|||
|
error. If you like to contribute to a particular translation, contact us
|
|||
|
on the Hibernate developer mailing list.
|
|||
|
</para>
|
|||
|
|
|||
|
<para>
|
|||
|
Translator(s): RedSaga Translate Team <caoxg@yahoo.com>
|
|||
|
</para>
|
|||
|
|
|||
|
<para>
|
|||
|
在今日的企业环境中,把面向对象的软件和关系数据库一起使用可能是相当麻烦、浪费时间的。Hibernate是一个面向Java环境的对象/关系数据库映射工具。对象/关系数据库映射(object/relational mapping (ORM))这个术语表示一种技术,用来把对象模型表示的对象映射到基于SQL的关系模型数据结构中去。
|
|||
|
</para>
|
|||
|
|
|||
|
<para>
|
|||
|
Hibernate不仅仅管理Java类到数据库表的映射(包括Java数据类型到SQL数据类型的映射),还提供数据查询和获取数据的方法,可以大幅度减少开发时人工使用SQL和JDBC处理数据的时间。
|
|||
|
</para>
|
|||
|
|
|||
|
<para>
|
|||
|
Hibernate的目标是对于开发者通常的数据持久化相关的编程任务,解放其中的95%。对于以数据为中心的程序来说,它们往往只在数据库中使用存储过程来实现商业逻辑,Hibernate可能不是最好的解决方案;对于那些在基于Java的中间层应用中,它们实现面向对象的业务模型和商业逻辑的应用,Hibernate是最有用的。不管怎样,Hibernate一定可以帮助你消除或者包装那些针对特定厂商的SQL代码,并且帮你把结果集从表格式的表示形式转换到一系列的对象去。
|
|||
|
</para>
|
|||
|
|
|||
|
<para>
|
|||
|
如果你对Hibernate和对象/关系数据库映射还是个新手,或者甚至对Java也不熟悉,请按照下面的步骤来学习。
|
|||
|
</para>
|
|||
|
|
|||
|
<orderedlist>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
阅读这个30分钟就可以结束的<xref linkend="quickstart"/>,它使用Tomcat。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
阅读<xref linkend="tutorial"/>,这是一篇较长的指南,包含详细的逐步指导。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
阅读<xref linkend="architecture"/>来理解Hibernate可以使用的环境。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
查看Hibernate发行包中的<literal>eg/</literal>目录,里面有一个简单的独立运行的程序。把你的JDBC驱动拷贝到<literal>lib/</literal>目录下,修改一下<literal>src/hibernate.properties</literal>,指定其中你的数据库的信息。进入命令行,切换到你的发行包的目录,输入<literal>ant eg</literal>(使用了Ant),或者在Windows操作系统中使用<literal>build eg</literal>。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
把这份参考文档作为你学习的主要信息来源。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
在Hibernate 的网站上可以找到经常提问的问题与解答(FAQ)。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
在Hibernate网站上还有第三方的演示、示例和教程的链接。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
Hibernate网站的“社区(Community Area)”是讨论关于设计模式以及很多整合方案(Tomcat, JBoss AS, Struts, EJB,等等)的好地方。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
</orderedlist>
|
|||
|
|
|||
|
<para>
|
|||
|
如果你有问题,请使用Hibernate网站上链接的用户论坛。我们也提供一个JIRA问题追踪系统,来搜集bug报告和新功能请求。如果你对开发Hibernate有兴趣,请加入开发者的邮件列表。
|
|||
|
(Hibernate网站上的用户论坛有一个中文版面,您可以在那里交流问题与经验。)
|
|||
|
</para>
|
|||
|
|
|||
|
<para>
|
|||
|
商业开发、产品支持和Hibernate培训可以通过JBoss Inc.获得。(请查阅:http://www.hibernate.org/SupportTraining/)。
|
|||
|
Hibernate是一个专业的开放源代码项目(Professional Open Source project),也是JBoss Enterprise Middleware System(JEMS),JBoss企业级中间件系统的一个核心组件。
|
|||
|
</para>
|
|||
|
|
|||
|
<sect1 id="preface-translate-comments-zh-cn">
|
|||
|
<title>翻译说明</title>
|
|||
|
|
|||
|
<para>
|
|||
|
本文档的翻译是在网络上协作进行的,也会不断根据Hibernate的升级进行更新。提供此文档的目的是为了减缓学习Hibernate的坡度,而非代替原文档。我们建议所有有能力的读者都直接阅读英文原文。若您对翻译有异议,或发现翻译错误,敬请不吝赐教,报告到如下email地址:cao at redsaga.com
|
|||
|
</para>
|
|||
|
|
|||
|
<para>
|
|||
|
Hibernate版本3的翻译由满江红翻译团队(RedSaga Translate Team)集体进行,这也是一次大规模网络翻译的试验。在不到20天的时间内,我们完成了两百多页文档的翻译,这一成果是通过十几位网友集体努力完成的。通过这次翻译,我们也有了一套完整的流程,从初译、技术审核一直到文字审核、发布。我们的翻译团队还会继续完善我们的翻译流程,并翻译其他优秀的Java开源资料,敬请期待。
|
|||
|
</para>
|
|||
|
|
|||
|
<table frame="topbot" id="redsaga-translate-team">
|
|||
|
<title>
|
|||
|
Hibernate v3翻译团队
|
|||
|
</title>
|
|||
|
<tgroup cols="5" rowsep="1" colsep="1">
|
|||
|
<colspec colname="c1" colwidth="1*"/>
|
|||
|
<colspec colname="c2" colwidth="2*"/>
|
|||
|
<colspec colname="c3" colwidth="2*"/>
|
|||
|
<colspec colname="c4" colwidth="2*"/>
|
|||
|
<colspec colname="c5" colwidth="2*"/>
|
|||
|
<thead>
|
|||
|
<row>
|
|||
|
<entry align="center">
|
|||
|
序号
|
|||
|
</entry>
|
|||
|
<entry align="center">
|
|||
|
标题
|
|||
|
</entry>
|
|||
|
<entry align="center">
|
|||
|
中文标题
|
|||
|
</entry>
|
|||
|
<entry align="center">
|
|||
|
翻译
|
|||
|
</entry>
|
|||
|
<entry align="center">
|
|||
|
一审
|
|||
|
</entry>
|
|||
|
</row>
|
|||
|
</thead>
|
|||
|
<tbody>
|
|||
|
<row>
|
|||
|
<entry>#1</entry>
|
|||
|
<entry>Quickstart with Tomcat(*)</entry>
|
|||
|
<entry>在Tomcat中快速上手</entry>
|
|||
|
<entry>caoxiaogang</entry>
|
|||
|
<entry>zoujm</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#2</entry>
|
|||
|
<entry>Architecture</entry>
|
|||
|
<entry>体系结构</entry>
|
|||
|
<entry>Hilton(BJUG)</entry>
|
|||
|
<entry>厌倦发呆</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#3</entry>
|
|||
|
<entry>Configuration</entry>
|
|||
|
<entry>配置</entry>
|
|||
|
<entry>Goncha</entry>
|
|||
|
<entry>mochow</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#4</entry>
|
|||
|
<entry>Persistent Classes(*)</entry>
|
|||
|
<entry>持久化类</entry>
|
|||
|
<entry>caoxiaogang</entry>
|
|||
|
<entry>mochow</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#5</entry>
|
|||
|
<entry>Basic O/R Mapping</entry>
|
|||
|
<entry>对象/关系数据库映射基础(上)</entry>
|
|||
|
<entry>moxie</entry>
|
|||
|
<entry>Kingfish</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry></entry>
|
|||
|
<entry></entry>
|
|||
|
<entry>对象/关系数据库映射基础(下)</entry>
|
|||
|
<entry>inter_dudu</entry>
|
|||
|
<entry>vincent</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#6</entry>
|
|||
|
<entry>Collection Mapping(*)</entry>
|
|||
|
<entry>集合类映射</entry>
|
|||
|
<entry>caoxiaogang</entry>
|
|||
|
<entry>robbin</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#7</entry>
|
|||
|
<entry>Association Mappings</entry>
|
|||
|
<entry>关联关系映射</entry>
|
|||
|
<entry>Robbin</entry>
|
|||
|
<entry>devils.advocate</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#8</entry>
|
|||
|
<entry>Component Mapping(*)</entry>
|
|||
|
<entry>组件映射</entry>
|
|||
|
<entry>caoxiaogang</entry>
|
|||
|
<entry>Robbin</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#9</entry>
|
|||
|
<entry>Inheritance Mappings</entry>
|
|||
|
<entry>继承映射</entry>
|
|||
|
<entry>morning(BJUG)</entry>
|
|||
|
<entry>mochow</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#10</entry>
|
|||
|
<entry>Working with objects</entry>
|
|||
|
<entry>与对象共事</entry>
|
|||
|
<entry>程广楠</entry>
|
|||
|
<entry>厌倦发呆</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#11</entry>
|
|||
|
<entry>Transactions And Concurrency</entry>
|
|||
|
<entry>事务和并发</entry>
|
|||
|
<entry>Robbin</entry>
|
|||
|
<entry>mochow</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#12</entry>
|
|||
|
<entry>Interceptors and events</entry>
|
|||
|
<entry>继承映射</entry>
|
|||
|
<entry>七彩狼(BJUG)</entry>
|
|||
|
<entry>厌倦发呆</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#13</entry>
|
|||
|
<entry>Batch processing</entry>
|
|||
|
<entry>批量处理</entry>
|
|||
|
<entry>Kingfish(BJUG)</entry>
|
|||
|
<entry>厌倦发呆</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#14</entry>
|
|||
|
<entry>HQL: The Hibernate Query Language</entry>
|
|||
|
<entry>HQL: Hibernate查询语言</entry>
|
|||
|
<entry>郑浩(BJUG)</entry>
|
|||
|
<entry>zhengshuai</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#15</entry>
|
|||
|
<entry>Criteria Queries</entry>
|
|||
|
<entry>条件查询</entry>
|
|||
|
<entry>nemo(BJUG)</entry>
|
|||
|
<entry>zhengshuai</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#16</entry>
|
|||
|
<entry>Native SQL</entry>
|
|||
|
<entry>Native SQL查询</entry>
|
|||
|
<entry>似水流年</entry>
|
|||
|
<entry>zoujm</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#17</entry>
|
|||
|
<entry>Filters</entry>
|
|||
|
<entry>过滤数据</entry>
|
|||
|
<entry>冰云(BJUG)</entry>
|
|||
|
<entry>Goncha</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#18</entry>
|
|||
|
<entry>XML Mapping</entry>
|
|||
|
<entry>XML映射</entry>
|
|||
|
<entry>edward(BJUG)</entry>
|
|||
|
<entry>Goncha</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#19</entry>
|
|||
|
<entry>Improving performance</entry>
|
|||
|
<entry>性能提升</entry>
|
|||
|
<entry>Wangjinfeng</entry>
|
|||
|
<entry>Robbin</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#20</entry>
|
|||
|
<entry>Toolset Guide(*)</entry>
|
|||
|
<entry>工具箱指南</entry>
|
|||
|
<entry>caoxiaogang</entry>
|
|||
|
<entry>Robbin</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#21</entry>
|
|||
|
<entry>Example: Parent/Child(*)</entry>
|
|||
|
<entry>示例:父子关系</entry>
|
|||
|
<entry>caoxiaogang</entry>
|
|||
|
<entry>devils.advocate</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#22</entry>
|
|||
|
<entry>Example: Weblog Application(*)</entry>
|
|||
|
<entry>示例:Weblog 应用程序</entry>
|
|||
|
<entry>caoxiaogang</entry>
|
|||
|
<entry>devils.advocate</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#23</entry>
|
|||
|
<entry>Example: Various Mappings</entry>
|
|||
|
<entry>示例:多种映射</entry>
|
|||
|
<entry>shidu(BJUG)</entry>
|
|||
|
<entry>冰云</entry>
|
|||
|
</row>
|
|||
|
<row>
|
|||
|
<entry>#24</entry>
|
|||
|
<entry>Best Practices(*)</entry>
|
|||
|
<entry>最佳实践</entry>
|
|||
|
<entry>caoxiaogang</entry>
|
|||
|
<entry>冰云</entry>
|
|||
|
</row>
|
|||
|
</tbody>
|
|||
|
</tgroup>
|
|||
|
</table>
|
|||
|
|
|||
|
<para>
|
|||
|
关于我们
|
|||
|
</para>
|
|||
|
|
|||
|
|
|||
|
<variablelist spacing="compact">
|
|||
|
<varlistentry>
|
|||
|
<term>满江红.开源, http://www.redsaga.com</term>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
致力于Java开放源代码在中国的传播与发展。目前有两个团队,“OpenDoc团队”与“翻译团队”。OpenDoc团队已经推出包括Hibernate、iBatis、Spring、WebWork的多份开放文档,并于2005年5月在Hibernate开放文档基础上扩充成书,出版了原创书籍:《深入浅出Hibernate》,本书400余页,适合各个层次的Hibernate用户。(http://www.redsaga.com/hibernate_book.html)敬请支持。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
</varlistentry>
|
|||
|
<varlistentry>
|
|||
|
<term>北京Java用户组, http://www.bjug.org</term>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
Beiing Java User Group(http://www.bjug.org),民间技术交流组织,成立于2004年6月。以交流与共享为宗旨,每两周举行一次技术聚会活动。BJUG的目标是,通过小部分人的努力,形成一个技术社群,创建良好的交流氛围,并将新的技术和思想推广到整个IT界,让我们共同进步。
|
|||
|
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
</varlistentry>
|
|||
|
<varlistentry>
|
|||
|
<term>Java视线, http://www.javaeye.com</term>
|
|||
|
<listitem>
|
|||
|
<para>
|
|||
|
前身为Hibernate中文论坛,现在已发展为包括Java,.NET,python等各种技术的高质量论坛。Java视线论坛注重质量更甚于注重人气。
|
|||
|
</para>
|
|||
|
</listitem>
|
|||
|
</varlistentry>
|
|||
|
</variablelist>
|
|||
|
|
|||
|
</sect1>
|
|||
|
|
|||
|
<sect1 id="preface-translate-licence-zh-cn">
|
|||
|
<title>版权声明</title>
|
|||
|
|
|||
|
<para>
|
|||
|
Hibernate英文文档属于Hibernate发行包的一部分,遵循LGPL协议。本翻译版本同样遵循LGPL协议。参与翻译的译者一致同意放弃除署名权外对本翻译版本的其它权利要求。
|
|||
|
</para>
|
|||
|
|
|||
|
<para>
|
|||
|
您可以自由链接、下载、传播此文档,或者放置在您的网站上,甚至作为产品的一部分发行。但前提是必须保证全文完整转载,包括完整的版权信息和作译者声明,并不能违反LGPL协议。这里“完整”的含义是,不能进行任何删除/增添/注解。若有删除/增添/注解,必须逐段明确声明那些部分并非本文档的一部分。
|
|||
|
</para>
|
|||
|
</sect1>
|
|||
|
|
|||
|
</preface>
|
|||
|
|
|||
|
&quickstart;
|
|||
|
|
|||
|
&tutorial;
|
|||
|
|
|||
|
&architecture;
|
|||
|
|
|||
|
&configuration;
|
|||
|
|
|||
|
&persistent-classes;
|
|||
|
|
|||
|
&basic-mapping;
|
|||
|
&collection-mapping;
|
|||
|
&association-mapping;
|
|||
|
&component-mapping;
|
|||
|
&inheritance-mapping;
|
|||
|
|
|||
|
&session-api;
|
|||
|
&transactions;
|
|||
|
&events;
|
|||
|
&batch;
|
|||
|
|
|||
|
&query-hql;
|
|||
|
&query-criteria;
|
|||
|
&query-sql;
|
|||
|
&filters;
|
|||
|
&xml;
|
|||
|
|
|||
|
&performance;
|
|||
|
|
|||
|
&toolset-guide;
|
|||
|
|
|||
|
&example-parentchild;
|
|||
|
&example-weblog;
|
|||
|
&example-mappings;
|
|||
|
|
|||
|
&best-practices;
|
|||
|
|
|||
|
</book>
|
|||
|
|