Generated via merging XML with English XML

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14138 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
xhuang 2007-10-26 01:01:14 +00:00
parent a445b5703c
commit 0a97c39acc
25 changed files with 28883 additions and 11985 deletions

View File

@ -1,216 +1,594 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:21 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: architecture.xml:21
#, no-c-format
msgid "Architecture" msgid "Architecture"
msgstr "" msgstr "体系结构(Architecture)"
#: index.docbook:24 #. Tag: title
#: architecture.xml:24
#, no-c-format
msgid "Overview" msgid "Overview"
msgstr "" msgstr "概况(Overview)"
#: index.docbook:26 #. Tag: para
#: architecture.xml:26
#, no-c-format
msgid "A (very) high-level view of the Hibernate architecture:" msgid "A (very) high-level view of the Hibernate architecture:"
msgstr "" msgstr "一个非常简要的Hibernate体系结构的概要图"
#: index.docbook:39 #. Tag: para
msgid "This diagram shows Hibernate using the database and configuration data to provide persistence services (and persistent objects) to the application." #: architecture.xml:39
#, no-c-format
msgid ""
"This diagram shows Hibernate using the database and configuration data to "
"provide persistence services (and persistent objects) to the application."
msgstr "" msgstr ""
"从这个图可以看出Hibernate使用数据库和配置信息来为应用程序提供持久化服务以"
"及持久的对象)。"
#: index.docbook:44 #. Tag: para
msgid "We would like to show a more detailed view of the runtime architecture. Unfortunately, Hibernate is flexible and supports several approaches. We will show the two extremes. The \"lite\" architecture has the application provide its own JDBC connections and manage its own transactions. This approach uses a minimal subset of Hibernate's APIs:" #: architecture.xml:44
#, no-c-format
msgid ""
"We would like to show a more detailed view of the runtime architecture. "
"Unfortunately, Hibernate is flexible and supports several approaches. We "
"will show the two extremes. The \"lite\" architecture has the application "
"provide its own JDBC connections and manage its own transactions. This "
"approach uses a minimal subset of Hibernate's APIs:"
msgstr "" msgstr ""
"我们来更详细地看一下Hibernate运行时体系结构。由于Hibernate非常灵活且支持多"
"种应用方案, 所以我们这只描述一下两种极端的情况。“轻型”的体系结构方案,要求应"
"用程序提供自己的JDBC 连接并管理自己的事务。这种方案使用了Hibernate API的最小"
"子集:"
#: index.docbook:61 #. Tag: para
msgid "The \"full cream\" architecture abstracts the application away from the underlying JDBC/JTA APIs and lets Hibernate take care of the details." #: architecture.xml:61
#, no-c-format
msgid ""
"The \"full cream\" architecture abstracts the application away from the "
"underlying JDBC/JTA APIs and lets Hibernate take care of the details."
msgstr "" msgstr ""
"“全面解决”的体系结构方案将应用层从底层的JDBC/JTA API中抽象出来而让"
"Hibernate来处理这些细节。"
#: index.docbook:75 #. Tag: para
#: architecture.xml:75
#, fuzzy, no-c-format
msgid "Heres some definitions of the objects in the diagrams:" msgid "Heres some definitions of the objects in the diagrams:"
msgstr "" msgstr "图中各个对象的定义如下: <placeholder-1/>"
#: index.docbook:80 #. Tag: term
#: architecture.xml:80
#, no-c-format
msgid "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)" msgid "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
msgstr "" msgstr "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
#: index.docbook:82 #. Tag: para
msgid "A threadsafe (immutable) cache of compiled mappings for a single database. A factory for <literal>Session</literal> and a client of <literal>ConnectionProvider</literal>. Might hold an optional (second-level) cache of data that is reusable between transactions, at a process- or cluster-level." #: architecture.xml:82
#, no-c-format
msgid ""
"A threadsafe (immutable) cache of compiled mappings for a single database. A "
"factory for <literal>Session</literal> and a client of "
"<literal>ConnectionProvider</literal>. Might hold an optional (second-level) "
"cache of data that is reusable between transactions, at a process- or "
"cluster-level."
msgstr "" msgstr ""
"针对单个数据库映射关系经过编译后的内存镜像,是线程安全的(不可变)。 它是生成"
"<literal>Session</literal>的工厂,本身要用到<literal>ConnectionProvider</"
"literal>。 该对象可以在进程或集群的级别上,为那些事务之间可以重用的数据提供可"
"选的二级缓存。"
#: index.docbook:92 #. Tag: term
#: architecture.xml:92
#, no-c-format
msgid "Session (<literal>org.hibernate.Session</literal>)" msgid "Session (<literal>org.hibernate.Session</literal>)"
msgstr "" msgstr "Session (<literal>org.hibernate.Session</literal>)"
#: index.docbook:94 #. Tag: para
msgid "A single-threaded, short-lived object representing a conversation between the application and the persistent store. Wraps a JDBC connection. Factory for <literal>Transaction</literal>. Holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier." #: architecture.xml:94
#, no-c-format
msgid ""
"A single-threaded, short-lived object representing a conversation between "
"the application and the persistent store. Wraps a JDBC connection. Factory "
"for <literal>Transaction</literal>. Holds a mandatory (first-level) cache of "
"persistent objects, used when navigating the object graph or looking up "
"objects by identifier."
msgstr "" msgstr ""
"表示应用程序与持久储存层之间交互操作的一个单线程对象,此对象生存期很短。 其隐"
"藏了JDBC连接也是<literal>Transaction</literal>的工厂。 其会持有一个针对持久"
"化对象的必选(第一级)缓存,在遍历对象图或者根据持久化标识查找对象时会用到。"
#: index.docbook:104 #. Tag: term
#: architecture.xml:104
#, no-c-format
msgid "Persistent objects and collections" msgid "Persistent objects and collections"
msgstr "" msgstr "持久的对象及其集合"
#: index.docbook:106 #. Tag: para
msgid "Short-lived, single threaded objects containing persistent state and business function. These might be ordinary JavaBeans/POJOs, the only special thing about them is that they are currently associated with (exactly one) <literal>Session</literal>. As soon as the <literal>Session</literal> is closed, they will be detached and free to use in any application layer (e.g. directly as data transfer objects to and from presentation)." #: architecture.xml:106
#, no-c-format
msgid ""
"Short-lived, single threaded objects containing persistent state and "
"business function. These might be ordinary JavaBeans/POJOs, the only special "
"thing about them is that they are currently associated with (exactly one) "
"<literal>Session</literal>. As soon as the <literal>Session</literal> is "
"closed, they will be detached and free to use in any application layer (e.g. "
"directly as data transfer objects to and from presentation)."
msgstr "" msgstr ""
"带有持久化状态的、具有业务功能的单线程对象,此对象生存期很短。 这些对象可能是"
"普通的JavaBeans/POJO唯一特殊的是他们正与仅仅一个<literal>Session</"
"literal>相关联。 一旦这个<literal>Session</literal>被关闭,这些对象就会脱离持"
"久化状态,这样就可被应用程序的任何层自由使用。 (例如,用作跟表示层打交道的数"
"据传输对象。)"
#: index.docbook:117 #. Tag: term
#: architecture.xml:117
#, no-c-format
msgid "Transient and detached objects and collections" msgid "Transient and detached objects and collections"
msgstr "" msgstr "瞬态(transient)和脱管(detached)的对象及其集合"
#: index.docbook:119 #. Tag: para
msgid "Instances of persistent classes that are not currently associated with a <literal>Session</literal>. They may have been instantiated by the application and not (yet) persisted or they may have been instantiated by a closed <literal>Session</literal>." #: architecture.xml:119
#, no-c-format
msgid ""
"Instances of persistent classes that are not currently associated with a "
"<literal>Session</literal>. They may have been instantiated by the "
"application and not (yet) persisted or they may have been instantiated by a "
"closed <literal>Session</literal>."
msgstr "" msgstr ""
"那些目前没有与session关联的持久化类实例。 他们可能是在被应用程序实例化后,尚"
"未进行持久化的对象。 也可能是因为实例化他们的<literal>Session</literal>已经被"
"关闭而脱离持久化的对象。"
#: index.docbook:128 #. Tag: term
#: architecture.xml:128
#, no-c-format
msgid "Transaction (<literal>org.hibernate.Transaction</literal>)" msgid "Transaction (<literal>org.hibernate.Transaction</literal>)"
msgstr "" msgstr "事务Transaction (<literal>org.hibernate.Transaction</literal>)"
#: index.docbook:130 #. Tag: para
msgid "(Optional) A single-threaded, short-lived object used by the application to specify atomic units of work. Abstracts application from underlying JDBC, JTA or CORBA transaction. A <literal>Session</literal> might span several <literal>Transaction</literal>s in some cases. However, transaction demarcation, either using the underlying API or <literal>Transaction</literal>, is never optional!" #: architecture.xml:130
#, no-c-format
msgid ""
"(Optional) A single-threaded, short-lived object used by the application to "
"specify atomic units of work. Abstracts application from underlying JDBC, "
"JTA or CORBA transaction. A <literal>Session</literal> might span several "
"<literal>Transaction</literal>s in some cases. However, transaction "
"demarcation, either using the underlying API or <literal>Transaction</"
"literal>, is never optional!"
msgstr "" msgstr ""
"(可选的)应用程序用来指定原子操作单元范围的对象,它是单线程的,生命周期很"
"短。 它通过抽象将应用从底层具体的JDBC、JTA以及CORBA事务隔离开。 某些情况下,"
"一个<literal>Session</literal>之内可能包含多个<literal>Transaction</literal>"
"对象。 尽管是否使用该对象是可选的但无论是使用底层的API还是使用"
"<literal>Transaction</literal>对象,事务边界的开启与关闭是必不可少的。"
#: index.docbook:141 #. Tag: term
msgid "ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</literal>)" #: architecture.xml:141
#, no-c-format
msgid ""
"ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</"
"literal>)"
msgstr "" msgstr ""
"ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</"
"literal>)"
#: index.docbook:143 #. Tag: para
msgid "(Optional) A factory for (and pool of) JDBC connections. Abstracts application from underlying <literal>Datasource</literal> or <literal>DriverManager</literal>. Not exposed to application, but can be extended/implemented by the developer." #: architecture.xml:143
#, no-c-format
msgid ""
"(Optional) A factory for (and pool of) JDBC connections. Abstracts "
"application from underlying <literal>Datasource</literal> or "
"<literal>DriverManager</literal>. Not exposed to application, but can be "
"extended/implemented by the developer."
msgstr "" msgstr ""
"可选的生成JDBC连接的工厂同时也起到连接池的作用。 它通过抽象将应用从底"
"层的<literal>Datasource</literal>或<literal>DriverManager</literal>隔离开。 "
"仅供开发者扩展/实现用,并不暴露给应用程序使用。"
#: index.docbook:151 #. Tag: term
msgid "TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)" #: architecture.xml:151
#, no-c-format
msgid ""
"TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
msgstr "" msgstr ""
"TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
#: index.docbook:153 #. Tag: para
msgid "(Optional) A factory for <literal>Transaction</literal> instances. Not exposed to the application, but can be extended/implemented by the developer." #: architecture.xml:153
#, no-c-format
msgid ""
"(Optional) A factory for <literal>Transaction</literal> instances. Not "
"exposed to the application, but can be extended/implemented by the developer."
msgstr "" msgstr ""
"(可选的)生成<literal>Transaction</literal>对象实例的工厂。 仅供开发者扩展/"
"实现用,并不暴露给应用程序使用。"
#: index.docbook:160 #. Tag: emphasis
#: architecture.xml:160
#, no-c-format
msgid "Extension Interfaces" msgid "Extension Interfaces"
msgstr "" msgstr "扩展接口"
#: index.docbook:162 #. Tag: para
msgid "Hibernate offers many optional extension interfaces you can implement to customize the behavior of your persistence layer. See the API documentation for details." #: architecture.xml:162
#, no-c-format
msgid ""
"Hibernate offers many optional extension interfaces you can implement to "
"customize the behavior of your persistence layer. See the API documentation "
"for details."
msgstr "" msgstr ""
"Hibernate提供了很多可选的扩展接口你可以通过实现它们来定制你的持久层的行"
"为。 具体请参考API文档。"
#: index.docbook:171 #. Tag: para
msgid "Given a \"lite\" architecture, the application bypasses the <literal>Transaction</literal>/<literal>TransactionFactory</literal> and/or <literal>ConnectionProvider</literal> APIs to talk to JTA or JDBC directly." #: architecture.xml:171
#, no-c-format
msgid ""
"Given a \"lite\" architecture, the application bypasses the "
"<literal>Transaction</literal>/<literal>TransactionFactory</literal> and/or "
"<literal>ConnectionProvider</literal> APIs to talk to JTA or JDBC directly."
msgstr "" msgstr ""
"在特定“轻型”的体系结构中,应用程序可能绕过 <literal>Transaction</literal>/"
"<literal>TransactionFactory</literal> 以及 <literal>ConnectionProvider</"
"literal> 等API直接跟JTA或JDBC打交道。"
#: index.docbook:179 #. Tag: title
#: architecture.xml:179
#, no-c-format
msgid "Instance states" msgid "Instance states"
msgstr "" msgstr "实例状态"
#: index.docbook:180 #. Tag: para
msgid "An instance of a persistent classes may be in one of three different states, which are defined with respect to a <emphasis>persistence context</emphasis>. The Hibernate <literal>Session</literal> object is the persistence context:" #: architecture.xml:180
#, no-c-format
msgid ""
"An instance of a persistent classes may be in one of three different states, "
"which are defined with respect to a <emphasis>persistence context</"
"emphasis>. The Hibernate <literal>Session</literal> object is the "
"persistence context:"
msgstr "" msgstr ""
"一个持久化类的实例可能处于三种不同状态中的某一种。 这三种状态的定义则与所谓的"
"<emphasis>持久化上下文(persistence context)</emphasis>有关。 Hibernate的"
"<literal>Session</literal>对象就是这个所谓的持久化上下文:"
#: index.docbook:188 #. Tag: term
#: architecture.xml:188
#, no-c-format
msgid "transient" msgid "transient"
msgstr "" msgstr "瞬态transient"
#: index.docbook:190 #. Tag: para
msgid "The instance is not, and has never been associated with any persistence context. It has no persistent identity (primary key value)." #: architecture.xml:190
msgstr "" #, no-c-format
msgid ""
"The instance is not, and has never been associated with any persistence "
"context. It has no persistent identity (primary key value)."
msgstr "该实例从未与任何持久化上下文关联过。它没有持久化标识(相当于主键值)。"
#: index.docbook:198 #. Tag: term
#: architecture.xml:198
#, no-c-format
msgid "persistent" msgid "persistent"
msgstr "" msgstr "持久化(persistent)"
#: index.docbook:200 #. Tag: para
msgid "The instance is currently associated with a persistence context. It has a persistent identity (primary key value) and, perhaps, a corresponding row in the database. For a particular persistence context, Hibernate <emphasis>guarantees</emphasis> that persistent identity is equivalent to Java identity (in-memory location of the object)." #: architecture.xml:200
#, no-c-format
msgid ""
"The instance is currently associated with a persistence context. It has a "
"persistent identity (primary key value) and, perhaps, a corresponding row in "
"the database. For a particular persistence context, Hibernate "
"<emphasis>guarantees</emphasis> that persistent identity is equivalent to "
"Java identity (in-memory location of the object)."
msgstr "" msgstr ""
"实例目前与某个持久化上下文有关联。 它拥有持久化标识(相当于主键值),并且可能"
"在数据库中有一个对应的行。 对于某一个特定的持久化上下文Hibernate<emphasis>"
"保证</emphasis>持久化标识与Java标识其值代表对象在内存中的位置等价。"
#: index.docbook:212 #. Tag: term
#: architecture.xml:212
#, no-c-format
msgid "detached" msgid "detached"
msgstr "" msgstr "脱管(detached)"
#: index.docbook:214 #. Tag: para
msgid "The instance was once associated with a persistence context, but that context was closed, or the instance was serialized to another process. It has a persistent identity and, perhaps, a corrsponding row in the database. For detached instances, Hibernate makes no guarantees about the relationship between persistent identity and Java identity." #: architecture.xml:214
#, no-c-format
msgid ""
"The instance was once associated with a persistence context, but that "
"context was closed, or the instance was serialized to another process. It "
"has a persistent identity and, perhaps, a corrsponding row in the database. "
"For detached instances, Hibernate makes no guarantees about the relationship "
"between persistent identity and Java identity."
msgstr "" msgstr ""
"实例曾经与某个持久化上下文发生过关联,不过那个上下文被关闭了, 或者这个实例是"
"被序列化(serialize)到另外的进程。 它拥有持久化标识,并且在数据库中可能存在一"
"个对应的行。 对于脱管状态的实例Hibernate不保证任何持久化标识和Java标识的关"
"系。"
#: index.docbook:229 #. Tag: title
#: architecture.xml:229
#, no-c-format
msgid "JMX Integration" msgid "JMX Integration"
msgstr "" msgstr "JMX整合"
#: index.docbook:231 #. Tag: para
msgid "JMX is the J2EE standard for management of Java components. Hibernate may be managed via a JMX standard service. We provide an MBean implementation in the distribution, <literal>org.hibernate.jmx.HibernateService</literal>." #: architecture.xml:231
#, no-c-format
msgid ""
"JMX is the J2EE standard for management of Java components. Hibernate may be "
"managed via a JMX standard service. We provide an MBean implementation in "
"the distribution, <literal>org.hibernate.jmx.HibernateService</literal>."
msgstr "" msgstr ""
"JMX是管理Java组件(Java components)的J2EE标准。 Hibernate 可以通过一个JMX标准"
"服务来管理。 在这个发行版本中我们提供了一个MBean接口的实现,即 <literal>org."
"hibernate.jmx.HibernateService</literal>。"
#: index.docbook:237 #. Tag: para
msgid "For an example how to deploy Hibernate as a JMX service on the JBoss Application Server, please see the JBoss User Guide. On JBoss AS, you also get these benefits if you deploy using JMX:" #: architecture.xml:237
#, no-c-format
msgid ""
"For an example how to deploy Hibernate as a JMX service on the JBoss "
"Application Server, please see the JBoss User Guide. On JBoss AS, you also "
"get these benefits if you deploy using JMX:"
msgstr "" msgstr ""
"想要看如何在JBoss应用服务器上将Hibernate部署为一个JMX服务的例子您可以参考"
"JBoss用户指南。 我们现在说一下在Jboss应用服务器上使用JMX来部署Hibernate的好"
"处:"
#: index.docbook:245 #. Tag: para
msgid "<emphasis>Session Management:</emphasis> The Hibernate <literal>Session</literal>'s life cycle can be automatically bound to the scope of a JTA transaction. This means you no longer have to manually open and close the <literal>Session</literal>, this becomes the job of a JBoss EJB interceptor. You also don't have to worry about transaction demarcation in your code anymore (unless you'd like to write a portable persistence layer of course, use the optional Hibernate <literal>Transaction</literal> API for this). You call the <literal>HibernateContext</literal> to access a <literal>Session</literal>." #: architecture.xml:245
#, no-c-format
msgid ""
"<emphasis>Session Management:</emphasis> The Hibernate <literal>Session</"
"literal>'s life cycle can be automatically bound to the scope of a JTA "
"transaction. This means you no longer have to manually open and close the "
"<literal>Session</literal>, this becomes the job of a JBoss EJB interceptor. "
"You also don't have to worry about transaction demarcation in your code "
"anymore (unless you'd like to write a portable persistence layer of course, "
"use the optional Hibernate <literal>Transaction</literal> API for this). You "
"call the <literal>HibernateContext</literal> to access a <literal>Session</"
"literal>."
msgstr "" msgstr ""
"<emphasis>Session管理</emphasis> Hibernate的<literal>Session</literal>对象"
"的生命周期可以 自动跟一个JTA事务边界绑定。这意味着你无需手工开关"
"<literal>Session</literal>了, 这项 工作会由JBoss EJB 拦截器来完成。你再也不用"
"担心你的代码中的事务边界了(除非你想利用Hibernate提供可选 的"
"<literal>Transaction</literal> API来自己写一个便于移植的的持久层)。 你通过调"
"用<literal>HibernateContext</literal>来访问<literal>Session</literal>。"
#: index.docbook:257 #. Tag: para
msgid "<emphasis>HAR deployment:</emphasis> Usually you deploy the Hibernate JMX service using a JBoss service deployment descriptor (in an EAR and/or SAR file), it supports all the usual configuration options of a Hibernate <literal>SessionFactory</literal>. However, you still have to name all your mapping files in the deployment descriptor. If you decide to use the optional HAR deployment, JBoss will automatically detect all mapping files in your HAR file." #: architecture.xml:257
#, no-c-format
msgid ""
"<emphasis>HAR deployment:</emphasis> Usually you deploy the Hibernate JMX "
"service using a JBoss service deployment descriptor (in an EAR and/or SAR "
"file), it supports all the usual configuration options of a Hibernate "
"<literal>SessionFactory</literal>. However, you still have to name all your "
"mapping files in the deployment descriptor. If you decide to use the "
"optional HAR deployment, JBoss will automatically detect all mapping files "
"in your HAR file."
msgstr "" msgstr ""
"<emphasis>HAR 部署:</emphasis> 通常情况下你会使用JBoss的服务部署描述符在"
"EAR或/和SAR文件中来部署Hibernate JMX服务。 这种部署方式支持所有常见的"
"Hibernate <literal>SessionFactory</literal>的配置选项。 不过,你仍需在部署描"
"述符中列出你所有的映射文件的名字。如果你使用HAR部署方式, JBoss 会自动探测出"
"你的HAR文件中所有的映射文件。"
#: index.docbook:268 #. Tag: para
msgid "Consult the JBoss AS user guide for more information about these options." #: architecture.xml:268
#, no-c-format
msgid ""
"Consult the JBoss AS user guide for more information about these options."
msgstr "这些选项更多的描述请参考JBoss 应用程序用户指南。"
#. Tag: para
#: architecture.xml:272
#, no-c-format
msgid ""
"Another feature available as a JMX service are runtime Hibernate statistics. "
"See <xref linkend=\"configuration-optional-statistics\"/>."
msgstr "" msgstr ""
"将Hibernate以部署为JMX服务的另一个好处是可以查看Hibernate的运行时统计信息。"
"参看 <xref linkend=\"configuration-optional-statistics\"/>."
#: index.docbook:272 #. Tag: title
msgid "Another feature available as a JMX service are runtime Hibernate statistics. See <xref linkend=\"configuration-optional-statistics\"/>." #: architecture.xml:279
msgstr "" #, no-c-format
#: index.docbook:279
msgid "JCA Support" msgid "JCA Support"
msgstr "" msgstr "对JCA的支持"
#: index.docbook:280 #. Tag: para
msgid "Hibernate may also be configured as a JCA connector. Please see the website for more details. Please note that Hibernate JCA support is still considered experimental." #: architecture.xml:280
#, no-c-format
msgid ""
"Hibernate may also be configured as a JCA connector. Please see the website "
"for more details. Please note that Hibernate JCA support is still considered "
"experimental."
msgstr "" msgstr ""
"Hibernate也可以被配置为一个JCA连接器JCA connector。更多信息请参看网站。 "
"请注意Hibernate对JCA的支持仍处于实验性阶段。"
#: index.docbook:287 #. Tag: title
#: architecture.xml:287
#, no-c-format
msgid "Contextual Sessions" msgid "Contextual Sessions"
msgstr "上下文相关的ContextualSession"
#. Tag: para
#: architecture.xml:288
#, no-c-format
msgid ""
"Most applications using Hibernate need some form of \"contextual\" sessions, "
"where a given session is in effect throughout the scope of a given context. "
"However, across applications the definition of what constitutes a context is "
"typically different; and different contexts define different scopes to the "
"notion of current. Applications using Hibernate prior to version 3.0 tended "
"to utilize either home-grown <literal>ThreadLocal</literal>-based contextual "
"sessions, helper classes such as <literal>HibernateUtil</literal>, or "
"utilized third-party frameworks (such as Spring or Pico) which provided "
"proxy/interception-based contextual sessions."
msgstr "" msgstr ""
"使用Hibernate的大多数应用程序需要某种形式的“上下文相关的” session特定的"
"session在整个特定的上下文范围内始终有效。然而对不同类型的应用程序而言要为"
"什么是组成这种“上下文”下一个定义通常是困难的;不同的上下文对“当前”这个概念定"
"义了不同的范围。在3.0版本之前使用Hibernate的程序要么采用自行编写的基于"
"<literal>ThreadLocal</literal>的上下文session要么采用"
"<literal>HibernateUtil</literal>这样的辅助类要么采用第三方框架比如Spring"
"或Pico),它们提供了基于代理(proxy)或者基于拦截器(interception)的上下文相关"
"session。"
#: index.docbook:288 #. Tag: para
msgid "Most applications using Hibernate need some form of \"contextual\" sessions, where a given session is in effect throughout the scope of a given context. However, across applications the definition of what constitutes a context is typically different; and different contexts define different scopes to the notion of current. Applications using Hibernate prior to version 3.0 tended to utilize either home-grown <literal>ThreadLocal</literal>-based contextual sessions, helper classes such as <literal>HibernateUtil</literal>, or utilized third-party frameworks (such as Spring or Pico) which provided proxy/interception-based contextual sessions." #: architecture.xml:297
#, no-c-format
msgid ""
"Starting with version 3.0.1, Hibernate added the <literal>SessionFactory."
"getCurrentSession()</literal> method. Initially, this assumed usage of "
"<literal>JTA</literal> transactions, where the <literal>JTA</literal> "
"transaction defined both the scope and context of a current session. The "
"Hibernate team maintains that, given the maturity of the numerous stand-"
"alone <literal>JTA TransactionManager</literal> implementations out there, "
"most (if not all) applications should be using <literal>JTA</literal> "
"transaction management whether or not they are deployed into a "
"<literal>J2EE</literal> container. Based on that, the <literal>JTA</literal>-"
"based contextual sessions is all you should ever need to use."
msgstr "" msgstr ""
"从3.0.1版本开始Hibernate增加了<literal>SessionFactory.getCurrentSession()</"
"literal>方法。一开始,它假定了采用<literal>JTA</literal>事务,<literal>JTA</"
"literal>事务定义了当前session的范围和上下文(scope and context)。Hibernate开发"
"团队坚信,因为有好几个独立的<literal>JTA TransactionManager</literal>实现稳定"
"可用,不论是否被部署到一个<literal>J2EE</literal>容器中,大多数(假若不是所有"
"的)应用程序都应该采用<literal>JTA</literal>事务管理。基于这一点,采用"
"<literal>JTA</literal>的上下文相关session可以满足你一切需要。"
#: index.docbook:297 #. Tag: para
msgid "Starting with version 3.0.1, Hibernate added the <literal>SessionFactory.getCurrentSession()</literal> method. Initially, this assumed usage of <literal>JTA</literal> transactions, where the <literal>JTA</literal> transaction defined both the scope and context of a current session. The Hibernate team maintains that, given the maturity of the numerous stand-alone <literal>JTA TransactionManager</literal> implementations out there, most (if not all) applications should be using <literal>JTA</literal> transaction management whether or not they are deployed into a <literal>J2EE</literal> container. Based on that, the <literal>JTA</literal>-based contextual sessions is all you should ever need to use." #: architecture.xml:307
#, no-c-format
msgid ""
"However, as of version 3.1, the processing behind <literal>SessionFactory."
"getCurrentSession()</literal> is now pluggable. To that end, a new extension "
"interface (<literal>org.hibernate.context.CurrentSessionContext</literal>) "
"and a new configuration parameter (<literal>hibernate."
"current_session_context_class</literal>) have been added to allow "
"pluggability of the scope and context of defining current sessions."
msgstr "" msgstr ""
"更好的是从3.1开始,<literal>SessionFactory.getCurrentSession()</literal>的"
"后台实现是可拔插的。因此,我们引入了新的扩展接口(<literal>org.hibernate."
"context.CurrentSessionContext</literal>)和新的配置参数(<literal>hibernate."
"current_session_context_class</literal>)以便对什么是“当前session”的范围和上"
"下文(scope and context)的定义进行拔插。"
#: index.docbook:307 #. Tag: para
msgid "However, as of version 3.1, the processing behind <literal>SessionFactory.getCurrentSession()</literal> is now pluggable. To that end, a new extension interface (<literal>org.hibernate.context.CurrentSessionContext</literal>) and a new configuration parameter (<literal>hibernate.current_session_context_class</literal>) have been added to allow pluggability of the scope and context of defining current sessions." #: architecture.xml:314
#, no-c-format
msgid ""
"See the Javadocs for the <literal>org.hibernate.context."
"CurrentSessionContext</literal> interface for a detailed discussion of its "
"contract. It defines a single method, <literal>currentSession()</literal>, "
"by which the implementation is responsible for tracking the current "
"contextual session. Out-of-the-box, Hibernate comes with three "
"implementations of this interface."
msgstr "" msgstr ""
"请参阅<literal>org.hibernate.context.CurrentSessionContext</literal>接口的"
"Javadoc,那里有关于它的契约的详细讨论。它定义了单一的方法,"
"<literal>currentSession()</literal>,特定的实现用它来负责跟踪当前的上下文"
"session。Hibernate内置了此接口的三种实现。"
#: index.docbook:314 #. Tag: para
msgid "See the Javadocs for the <literal>org.hibernate.context.CurrentSessionContext</literal> interface for a detailed discussion of its contract. It defines a single method, <literal>currentSession()</literal>, by which the implementation is responsible for tracking the current contextual session. Out-of-the-box, Hibernate comes with three implementations of this interface." #: architecture.xml:324
#, no-c-format
msgid ""
"<literal>org.hibernate.context.JTASessionContext</literal> - current "
"sessions are tracked and scoped by a <literal>JTA</literal> transaction. The "
"processing here is exactly the same as in the older JTA-only approach. See "
"the Javadocs for details."
msgstr "" msgstr ""
"<literal>org.hibernate.context.JTASessionContext</literal> - 当前session根据"
"<literal>JTA</literal>来跟踪和界定。这和以前的仅支持JTA的方法是完全一样的。详"
"情请参阅Javadoc。"
#: index.docbook:324 #. Tag: para
msgid "<literal>org.hibernate.context.JTASessionContext</literal> - current sessions are tracked and scoped by a <literal>JTA</literal> transaction. The processing here is exactly the same as in the older JTA-only approach. See the Javadocs for details." #: architecture.xml:332
#, no-c-format
msgid ""
"<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current "
"sessions are tracked by thread of execution. Again, see the Javadocs for "
"details."
msgstr "" msgstr ""
"<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - 当前"
"session通过当前执行的线程来跟踪和界定。详情也请参阅Javadoc。"
#: index.docbook:332 #. Tag: para
msgid "<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current sessions are tracked by thread of execution. Again, see the Javadocs for details." #: architecture.xml:338
#, no-c-format
msgid ""
"<literal>org.hibernate.context.ManagedSessionContext</literal> - current "
"sessions are tracked by thread of execution. However, you are responsible to "
"bind and unbind a <literal>Session</literal> instance with static methods on "
"this class, it does never open, flush, or close a <literal>Session</literal>."
msgstr "" msgstr ""
"<literal>org.hibernate.context.ManagedSessionContext</literal> - 当前session"
"通过当前执行的线程来跟踪和界定。但是,你需要负责使用这个类的静态方法将"
"<literal>Session</literal>实例绑定、或者取消绑定,它并不会打开(open)、flush或"
"者关闭(close)任何<literal>Session</literal>。"
#: index.docbook:338 #. Tag: para
msgid "<literal>org.hibernate.context.ManagedSessionContext</literal> - current sessions are tracked by thread of execution. However, you are responsible to bind and unbind a <literal>Session</literal> instance with static methods on this class, it does never open, flush, or close a <literal>Session</literal>." #: architecture.xml:347
#, no-c-format
msgid ""
"The first two implementations provide a \"one session - one database "
"transaction\" programming model, also known and used as <emphasis>session-"
"per-request</emphasis>. The beginning and end of a Hibernate session is "
"defined by the duration of a database transaction. If you use programatic "
"transaction demarcation in plain JSE without JTA, you are adviced to use the "
"Hibernate <literal>Transaction</literal> API to hide the underlying "
"transaction system from your code. If you use JTA, use the JTA interfaces to "
"demarcate transactions. If you execute in an EJB container that supports "
"CMT, transaction boundaries are defined declaratively and you don't need any "
"transaction or session demarcation operations in your code. Refer to <xref "
"linkend=\"transactions\"/> for more information and code examples."
msgstr "" msgstr ""
"前两种实现都提供了“每数据库事务对应一个session”的编程模型也称作<emphasis>每"
"次请求一个session</emphasis>。Hibernate session的起始和终结由数据库事务的生存"
"来控制。假若你在纯粹的 Java SE之上采用自行编写代码来管理事务,而不使用JTA建"
"议你使用Hibernate <literal>Transaction</literal> API来把底层事务实现从你的代"
"码中隐藏掉。如果你使用JTA请使用JTA借口来管理Transaction。如果你在支持CMT的"
"EJB容器中执行代码事务边界是声明式定义的你不需要在代码中进行任何事务或"
"session管理操作。请参阅<xref linkend=\"transactions\"/>一节来阅读更多的内容和"
"示例代码。"
#: index.docbook:347 #. Tag: para
msgid "The first two implementations provide a \"one session - one database transaction\" programming model, also known and used as <emphasis>session-per-request</emphasis>. The beginning and end of a Hibernate session is defined by the duration of a database transaction. If you use programatic transaction demarcation in plain JSE without JTA, you are adviced to use the Hibernate <literal>Transaction</literal> API to hide the underlying transaction system from your code. If you use JTA, use the JTA interfaces to demarcate transactions. If you execute in an EJB container that supports CMT, transaction boundaries are defined declaratively and you don't need any transaction or session demarcation operations in your code. Refer to <xref linkend=\"transactions\"/> for more information and code examples." #: architecture.xml:359
#, no-c-format
msgid ""
"The <literal>hibernate.current_session_context_class</literal> configuration "
"parameter defines which <literal>org.hibernate.context."
"CurrentSessionContext</literal> implementation should be used. Note that for "
"backwards compatibility, if this config param is not set but a <literal>org."
"hibernate.transaction.TransactionManagerLookup</literal> is configured, "
"Hibernate will use the <literal>org.hibernate.context.JTASessionContext</"
"literal>. Typically, the value of this parameter would just name the "
"implementation class to use; for the three out-of-the-box implementations, "
"however, there are three corresponding short names, \"jta\", \"thread\", and "
"\"managed\"."
msgstr "" msgstr ""
"<literal>hibernate.current_session_context_class</literal>配置参数定义了应该"
#: index.docbook:359 "采用哪个<literal>org.hibernate.context.CurrentSessionContext</literal>实现。"
msgid "The <literal>hibernate.current_session_context_class</literal> configuration parameter defines which <literal>org.hibernate.context.CurrentSessionContext</literal> implementation should be used. Note that for backwards compatibility, if this config param is not set but a <literal>org.hibernate.transaction.TransactionManagerLookup</literal> is configured, Hibernate will use the <literal>org.hibernate.context.JTASessionContext</literal>. Typically, the value of this parameter would just name the implementation class to use; for the three out-of-the-box implementations, however, there are three corresponding short names, \"jta\", \"thread\", and \"managed\"." "注意,为了向下兼容,如果未配置此参数,但是存在<literal>org.hibernate."
msgstr "" "transaction.TransactionManagerLookup</literal>的配置Hibernate会采用"
"<literal>org.hibernate.context.JTASessionContext</literal>。一般而言,此参数"
msgid "ROLES_OF_TRANSLATORS" "的值指明了要使用的实现类的全名,但那三种内置的实现可以使用简写,即\"jta\"、"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->" "\"thread\"和\"managed\"。"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,42 +1,89 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:6 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: association_mapping.xml:6
#, no-c-format
msgid "Association Mappings" msgid "Association Mappings"
msgstr "" msgstr "关联关系映射"
#: index.docbook:9 #. Tag: title
#: association_mapping.xml:9
#, no-c-format
msgid "Introduction" msgid "Introduction"
msgstr "" msgstr "介绍"
#: index.docbook:11 #. Tag: para
msgid "Association mappings are the often most difficult thing to get right. In this section we'll go through the canonical cases one by one, starting with unidirectional mappings, and then considering the bidirectional cases. We'll use <literal>Person</literal> and <literal>Address</literal> in all the examples." #: association_mapping.xml:11
#, no-c-format
msgid ""
"Association mappings are the often most difficult thing to get right. In "
"this section we'll go through the canonical cases one by one, starting with "
"unidirectional mappings, and then considering the bidirectional cases. We'll "
"use <literal>Person</literal> and <literal>Address</literal> in all the "
"examples."
msgstr "" msgstr ""
"关联关系映射通常情况是最难配置正确的。在这个部分中,我们从单向关系映射开始,"
"然后考虑双向关系映射,由浅至深讲述一遍典型的案例。在所有的例子中,我们都使用 "
"<literal>Person</literal>和<literal>Address</literal>。"
#: index.docbook:19 #. Tag: para
msgid "We'll classify associations by whether or not they map to an intervening join table, and by multiplicity." #: association_mapping.xml:19
#, no-c-format
msgid ""
"We'll classify associations by whether or not they map to an intervening "
"join table, and by multiplicity."
msgstr "我们根据映射关系是否涉及连接表以及多样性来划分关联类型。"
#. Tag: para
#: association_mapping.xml:24
#, no-c-format
msgid ""
"Nullable foreign keys are not considered good practice in traditional data "
"modelling, so all our examples use not null foreign keys. This is not a "
"requirement of Hibernate, and the mappings will all work if you drop the "
"nullability constraints."
msgstr "" msgstr ""
"在传统的数据建模中允许为Null值的外键被认为是一种不好的实践因此我们所有的"
"例子中都使用不允许为Null的外键。这并不是Hibernate的要求即使你删除掉不允许为"
"Null的约束Hibernate映射一样可以工作的很好。"
#: index.docbook:24 #. Tag: title
msgid "Nullable foreign keys are not considered good practice in traditional data modelling, so all our examples use not null foreign keys. This is not a requirement of Hibernate, and the mappings will all work if you drop the nullability constraints." #: association_mapping.xml:34
msgstr "" #, no-c-format
#: index.docbook:34
msgid "Unidirectional associations" msgid "Unidirectional associations"
msgstr "" msgstr "单向关联Unidirectional associations"
#: index.docbook:37, index.docbook:108 #. Tag: title
#: association_mapping.xml:37 association_mapping.xml:108
#, fuzzy, no-c-format
msgid "many to one" msgid "many to one"
msgstr "" msgstr ""
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"多对一(many to one)\n"
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"多对一many to one"
#: index.docbook:39 #. Tag: para
msgid "A <emphasis>unidirectional many-to-one association</emphasis> is the most common kind of unidirectional association." #: association_mapping.xml:39
msgstr "" #, no-c-format
msgid ""
"A <emphasis>unidirectional many-to-one association</emphasis> is the most "
"common kind of unidirectional association."
msgstr "<emphasis>单向many-to-one关联</emphasis>是最常见的单向关联关系。"
#: index.docbook:44 #. Tag: programlisting
#: association_mapping.xml:44
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -54,23 +101,39 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:45, index.docbook:161 #. Tag: programlisting
#: association_mapping.xml:45 association_mapping.xml:161
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"create table Person ( personId bigint not null primary key, addressId bigint not null )\n" "create table Person ( personId bigint not null primary key, addressId bigint "
"not null )\n"
"create table Address ( addressId bigint not null primary key )\n" "create table Address ( addressId bigint not null primary key )\n"
" ]]>" " ]]>"
msgstr "" msgstr ""
#: index.docbook:50, index.docbook:121, index.docbook:185, index.docbook:225 #. Tag: title
#: association_mapping.xml:50 association_mapping.xml:121
#: association_mapping.xml:185 association_mapping.xml:225
#, no-c-format
msgid "one to one" msgid "one to one"
msgstr "" msgstr "一对一one to one"
#: index.docbook:52 #. Tag: para
msgid "A <emphasis>unidirectional one-to-one association on a foreign key</emphasis> is almost identical. The only difference is the column unique constraint." #: association_mapping.xml:52
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-one association on a foreign key</"
"emphasis> is almost identical. The only difference is the column unique "
"constraint."
msgstr "" msgstr ""
"<emphasis>基于外键关联的单向一对一关联</emphasis>和<emphasis>单向多对一关联</"
"emphasis>几乎是一样的。唯一的不同就是单向一对一关联中的外键字段具有唯一性约"
"束。"
#: index.docbook:57 #. Tag: programlisting
#: association_mapping.xml:57
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -89,19 +152,31 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:58, index.docbook:193 #. Tag: programlisting
#: association_mapping.xml:58 association_mapping.xml:193
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"create table Person ( personId bigint not null primary key, addressId bigint not null unique )\n" "create table Person ( personId bigint not null primary key, addressId bigint "
"not null unique )\n"
"create table Address ( addressId bigint not null primary key )\n" "create table Address ( addressId bigint not null primary key )\n"
" ]]>" " ]]>"
msgstr "" msgstr ""
#: index.docbook:60 #. Tag: para
msgid "A <emphasis>unidirectional one-to-one association on a primary key</emphasis> usually uses a special id generator. (Notice that we've reversed the direction of the association in this example.)" #: association_mapping.xml:60
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-one association on a primary key</"
"emphasis> usually uses a special id generator. (Notice that we've reversed "
"the direction of the association in this example.)"
msgstr "" msgstr ""
"<emphasis>基于主键关联的单向一对一关联</emphasis>通常使用一个特定的id生成器。"
"(请注意,在这个例子中我们掉换了关联的方向。)"
#: index.docbook:66 #. Tag: programlisting
#: association_mapping.xml:66
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -119,7 +194,9 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:67, index.docbook:201 #. Tag: programlisting
#: association_mapping.xml:67 association_mapping.xml:201
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"create table Person ( personId bigint not null primary key )\n" "create table Person ( personId bigint not null primary key )\n"
@ -127,15 +204,29 @@ msgid ""
" ]]>" " ]]>"
msgstr "" msgstr ""
#: index.docbook:72, index.docbook:94 #. Tag: title
#: association_mapping.xml:72 association_mapping.xml:94
#, fuzzy, no-c-format
msgid "one to many" msgid "one to many"
msgstr "" msgstr ""
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"一对多one to many\n"
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"一对多(one to many)"
#: index.docbook:74 #. Tag: para
msgid "A <emphasis>unidirectional one-to-many association on a foreign key</emphasis> is a very unusual case, and is not really recommended." #: association_mapping.xml:74
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-many association on a foreign key</"
"emphasis> is a very unusual case, and is not really recommended."
msgstr "" msgstr ""
"<emphasis>基于外键关联的单向一对多关联</emphasis>是一种很少见的情况,并不推荐"
"使用。"
#: index.docbook:79 #. Tag: programlisting
#: association_mapping.xml:79
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -155,27 +246,45 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:80 #. Tag: programlisting
#: association_mapping.xml:80
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"create table Person ( personId bigint not null primary key )\n" "create table Person ( personId bigint not null primary key )\n"
"create table Address ( addressId bigint not null primary key, personId bigint not null )\n" "create table Address ( addressId bigint not null primary key, personId "
"bigint not null )\n"
" ]]>" " ]]>"
msgstr "" msgstr ""
#: index.docbook:82 #. Tag: para
#: association_mapping.xml:82
#, no-c-format
msgid "We think it's better to use a join table for this kind of association." msgid "We think it's better to use a join table for this kind of association."
msgstr "" msgstr "我们认为对于这种关联关系最好使用连接表。"
#: index.docbook:91 #. Tag: title
#: association_mapping.xml:91
#, no-c-format
msgid "Unidirectional associations with join tables" msgid "Unidirectional associations with join tables"
msgstr "" msgstr "使用连接表的单向关联Unidirectional associations with join tables"
#: index.docbook:96 #. Tag: para
msgid "A <emphasis>unidirectional one-to-many association on a join table</emphasis> is much preferred. Notice that by specifying <literal>unique=\"true\"</literal>, we have changed the multiplicity from many-to-many to one-to-many." #: association_mapping.xml:96
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-many association on a join table</"
"emphasis> is much preferred. Notice that by specifying <literal>unique=\"true"
"\"</literal>, we have changed the multiplicity from many-to-many to one-to-"
"many."
msgstr "" msgstr ""
"<emphasis>基于连接表的单向一对多关联</emphasis> 应该优先被采用。请注意,通过"
"指定<literal>unique=\"true\"</literal>,我们可以把多样性从多对多改变为一对"
"多。"
#: index.docbook:102 #. Tag: programlisting
#: association_mapping.xml:102
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -196,20 +305,31 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:103 #. Tag: programlisting
#: association_mapping.xml:103
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"create table Person ( personId bigint not null primary key )\n" "create table Person ( personId bigint not null primary key )\n"
"create table PersonAddress ( personId not null, addressId bigint not null primary key )\n" "create table PersonAddress ( personId not null, addressId bigint not null "
"primary key )\n"
"create table Address ( addressId bigint not null primary key )\n" "create table Address ( addressId bigint not null primary key )\n"
" ]]>" " ]]>"
msgstr "" msgstr ""
#: index.docbook:110 #. Tag: para
msgid "A <emphasis>unidirectional many-to-one association on a join table</emphasis> is quite common when the association is optional." #: association_mapping.xml:110
#, no-c-format
msgid ""
"A <emphasis>unidirectional many-to-one association on a join table</"
"emphasis> is quite common when the association is optional."
msgstr "" msgstr ""
"<emphasis>基于连接表的单向多对一关联</emphasis>在关联关系可选的情况下应用也很"
"普遍。"
#: index.docbook:115 #. Tag: programlisting
#: association_mapping.xml:115
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -231,20 +351,30 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:116 #. Tag: programlisting
#: association_mapping.xml:116
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"create table Person ( personId bigint not null primary key )\n" "create table Person ( personId bigint not null primary key )\n"
"create table PersonAddress ( personId bigint not null primary key, addressId bigint not null )\n" "create table PersonAddress ( personId bigint not null primary key, addressId "
"bigint not null )\n"
"create table Address ( addressId bigint not null primary key )\n" "create table Address ( addressId bigint not null primary key )\n"
" ]]>" " ]]>"
msgstr "" msgstr ""
#: index.docbook:123 #. Tag: para
msgid "A <emphasis>unidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible." #: association_mapping.xml:123
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-one association on a join table</emphasis> "
"is extremely unusual, but possible."
msgstr "" msgstr ""
"<emphasis>基于连接表的单向一对一关联</emphasis>非常少见,但也是可行的。"
#: index.docbook:128 #. Tag: programlisting
#: association_mapping.xml:128
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -268,24 +398,35 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:129, index.docbook:233 #. Tag: programlisting
#: association_mapping.xml:129 association_mapping.xml:233
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"create table Person ( personId bigint not null primary key )\n" "create table Person ( personId bigint not null primary key )\n"
"create table PersonAddress ( personId bigint not null primary key, addressId bigint not null unique )\n" "create table PersonAddress ( personId bigint not null primary key, addressId "
"bigint not null unique )\n"
"create table Address ( addressId bigint not null primary key )\n" "create table Address ( addressId bigint not null primary key )\n"
" ]]>" " ]]>"
msgstr "" msgstr ""
#: index.docbook:134, index.docbook:238 #. Tag: title
#: association_mapping.xml:134 association_mapping.xml:238
#, no-c-format
msgid "many to many" msgid "many to many"
msgstr "" msgstr "多对多many to many"
#: index.docbook:136 #. Tag: para
msgid "Finally, we have a <emphasis>unidirectional many-to-many association</emphasis>." #: association_mapping.xml:136
msgstr "" #, no-c-format
msgid ""
"Finally, we have a <emphasis>unidirectional many-to-many association</"
"emphasis>."
msgstr "最后,还有 <emphasis>单向多对多关联</emphasis>."
#: index.docbook:140 #. Tag: programlisting
#: association_mapping.xml:140
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -305,28 +446,47 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:141, index.docbook:246 #. Tag: programlisting
#: association_mapping.xml:141 association_mapping.xml:246
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"create table Person ( personId bigint not null primary key )\n" "create table Person ( personId bigint not null primary key )\n"
"create table PersonAddress ( personId bigint not null, addressId bigint not null, primary key (personId, addressId) )\n" "create table PersonAddress ( personId bigint not null, addressId bigint not "
"null, primary key (personId, addressId) )\n"
"create table Address ( addressId bigint not null primary key )\n" "create table Address ( addressId bigint not null primary key )\n"
" ]]>" " ]]>"
msgstr "" msgstr ""
#: index.docbook:148 #. Tag: title
#: association_mapping.xml:148
#, no-c-format
msgid "Bidirectional associations" msgid "Bidirectional associations"
msgstr "" msgstr "双向关联Bidirectional associations"
#: index.docbook:151, index.docbook:211 #. Tag: title
#: association_mapping.xml:151 association_mapping.xml:211
#, fuzzy, no-c-format
msgid "one to many / many to one" msgid "one to many / many to one"
msgstr "" msgstr ""
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"一对多one to many) / 多对一many to one\n"
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"一对多one to many /多对一( many to one"
#: index.docbook:153 #. Tag: para
msgid "A <emphasis>bidirectional many-to-one association</emphasis> is the most common kind of association. (This is the standard parent/child relationship.)" #: association_mapping.xml:153
#, no-c-format
msgid ""
"A <emphasis>bidirectional many-to-one association</emphasis> is the most "
"common kind of association. (This is the standard parent/child relationship.)"
msgstr "" msgstr ""
"<emphasis>双向多对一关联</emphasis> 是最常见的关联关系。(这也是标准的父/子关"
"联关系。)"
#: index.docbook:159 #. Tag: programlisting
#: association_mapping.xml:159
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -348,11 +508,25 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:163 #. Tag: para
msgid "If you use a <literal>List</literal> (or other indexed collection) you need to set the <literal>key</literal> column of the foreign key to <literal>not null</literal>, and let Hibernate manage the association from the collections side to maintain the index of each element (making the other side virtually inverse by setting <literal>update=\"false\"</literal> and <literal>insert=\"false\"</literal>):" #: association_mapping.xml:163
#, no-c-format
msgid ""
"If you use a <literal>List</literal> (or other indexed collection) you need "
"to set the <literal>key</literal> column of the foreign key to <literal>not "
"null</literal>, and let Hibernate manage the association from the "
"collections side to maintain the index of each element (making the other "
"side virtually inverse by setting <literal>update=\"false\"</literal> and "
"<literal>insert=\"false\"</literal>):"
msgstr "" msgstr ""
"如果你使用<literal>List</literal>(或者其他有序集合类),你需要设置外键对应的"
"<literal>key</literal>列为 <literal>not null</literal>,让Hibernate来从集合端"
"管理关联,维护每个元素的索引(通过设置<literal>update=\"false\"</literal> "
"and <literal>insert=\"false\"</literal>来对另一端反向操作)。"
#: index.docbook:171 #. Tag: programlisting
#: association_mapping.xml:171
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\"/>\n" " <id name=\"id\"/>\n"
@ -375,15 +549,34 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:173 #. Tag: para
msgid "It is important that you define <literal>not-null=\"true\"</literal> on the <literal>&lt;key&gt;</literal> element of the collection mapping if the underlying foreign key column is <literal>NOT NULL</literal>. Don't only declare <literal>not-null=\"true\"</literal> on a possible nested <literal>&lt;column&gt;</literal> element, but on the <literal>&lt;key&gt;</literal> element." #: association_mapping.xml:173
#, no-c-format
msgid ""
"It is important that you define <literal>not-null=\"true\"</literal> on the "
"<literal>&lt;key&gt;</literal> element of the collection mapping if the "
"underlying foreign key column is <literal>NOT NULL</literal>. Don't only "
"declare <literal>not-null=\"true\"</literal> on a possible nested "
"<literal>&lt;column&gt;</literal> element, but on the <literal>&lt;key&gt;</"
"literal> element."
msgstr "" msgstr ""
"假若集合映射的<literal>&lt;key&gt;</literal>元素对应的底层外键字段是"
"<literal>NOT NULL</literal>的那么为这一key元素定义<literal>not-null=\"true"
"\"</literal>是很重要的。不要仅仅为可能的嵌套<literal>&lt;column&gt;</literal>"
"元素定义<literal>not-null=\"true\"</literal><literal>&lt;key&gt;</literal>"
"元素也是需要的。"
#: index.docbook:187 #. Tag: para
msgid "A <emphasis>bidirectional one-to-one association on a foreign key</emphasis> is quite common." #: association_mapping.xml:187
msgstr "" #, no-c-format
msgid ""
"A <emphasis>bidirectional one-to-one association on a foreign key</emphasis> "
"is quite common."
msgstr "<emphasis>基于外键关联的双向一对一关联</emphasis>也很常见。"
#: index.docbook:192 #. Tag: programlisting
#: association_mapping.xml:192
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -404,11 +597,17 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:195 #. Tag: para
msgid "A <emphasis>bidirectional one-to-one association on a primary key</emphasis> uses the special id generator." #: association_mapping.xml:195
msgstr "" #, no-c-format
msgid ""
"A <emphasis>bidirectional one-to-one association on a primary key</emphasis> "
"uses the special id generator."
msgstr "<emphasis>基于主键关联的一对一关联</emphasis>需要使用特定的id生成器。"
#: index.docbook:200 #. Tag: programlisting
#: association_mapping.xml:200
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -428,15 +627,26 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:208 #. Tag: title
#: association_mapping.xml:208
#, no-c-format
msgid "Bidirectional associations with join tables" msgid "Bidirectional associations with join tables"
msgstr "" msgstr "使用连接表的双向关联Bidirectional associations with join tables"
#: index.docbook:213 #. Tag: para
msgid "A <emphasis>bidirectional one-to-many association on a join table</emphasis>. Note that the <literal>inverse=\"true\"</literal> can go on either end of the association, on the collection, or on the join." #: association_mapping.xml:213
#, no-c-format
msgid ""
"A <emphasis>bidirectional one-to-many association on a join table</"
"emphasis>. Note that the <literal>inverse=\"true\"</literal> can go on "
"either end of the association, on the collection, or on the join."
msgstr "" msgstr ""
"<emphasis>基于连接表的双向一对多关联</emphasis>。注意<literal>inverse=\"true"
"\"</literal>可以出现在关联的任意一端即collection端或者join端。"
#: index.docbook:219 #. Tag: programlisting
#: association_mapping.xml:219
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -466,20 +676,30 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:220 #. Tag: programlisting
#: association_mapping.xml:220
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"create table Person ( personId bigint not null primary key )\n" "create table Person ( personId bigint not null primary key )\n"
"create table PersonAddress ( personId bigint not null, addressId bigint not null primary key )\n" "create table PersonAddress ( personId bigint not null, addressId bigint not "
"null primary key )\n"
"create table Address ( addressId bigint not null primary key )\n" "create table Address ( addressId bigint not null primary key )\n"
" ]]>" " ]]>"
msgstr "" msgstr ""
#: index.docbook:227 #. Tag: para
msgid "A <emphasis>bidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible." #: association_mapping.xml:227
#, no-c-format
msgid ""
"A <emphasis>bidirectional one-to-one association on a join table</emphasis> "
"is extremely unusual, but possible."
msgstr "" msgstr ""
"<emphasis>基于连接表的双向一对一关联</emphasis>极为罕见,但也是可行的。"
#: index.docbook:232 #. Tag: programlisting
#: association_mapping.xml:232
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -513,11 +733,17 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:240 #. Tag: para
msgid "Finally, we have a <emphasis>bidirectional many-to-many association</emphasis>." #: association_mapping.xml:240
msgstr "" #, no-c-format
msgid ""
"Finally, we have a <emphasis>bidirectional many-to-many association</"
"emphasis>."
msgstr "最后,还有 <emphasis>双向多对多关联</emphasis>."
#: index.docbook:244 #. Tag: programlisting
#: association_mapping.xml:244
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"id\" column=\"personId\">\n" " <id name=\"id\" column=\"personId\">\n"
@ -542,31 +768,56 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:253 #. Tag: title
#: association_mapping.xml:253
#, no-c-format
msgid "More complex association mappings" msgid "More complex association mappings"
msgstr "" msgstr "更复杂的关联映射"
#: index.docbook:255 #. Tag: para
msgid "More complex association joins are <emphasis>extremely</emphasis> rare. Hibernate makes it possible to handle more complex situations using SQL fragments embedded in the mapping document. For example, if a table with historical account information data defines <literal>accountNumber</literal>, <literal>effectiveEndDate</literal> and <literal>effectiveStartDate</literal>columns, mapped as follows:" #: association_mapping.xml:255
#, no-c-format
msgid ""
"More complex association joins are <emphasis>extremely</emphasis> rare. "
"Hibernate makes it possible to handle more complex situations using SQL "
"fragments embedded in the mapping document. For example, if a table with "
"historical account information data defines <literal>accountNumber</"
"literal>, <literal>effectiveEndDate</literal> and "
"<literal>effectiveStartDate</literal>columns, mapped as follows:"
msgstr "" msgstr ""
"更复杂的关联连接<emphasis>极为</emphasis>罕见。 通过在映射文档中嵌入SQL片断"
"Hibernate也可以处理更为复杂的情况。比如假若包含历史帐户数据的表定义了"
"<literal>accountNumber</literal>, <literal>effectiveEndDate</literal> 和"
"<literal>effectiveStartDate</literal>字段,按照下面映射:"
#: index.docbook:264 #. Tag: programlisting
#: association_mapping.xml:264
#, no-c-format
msgid "" msgid ""
"<![CDATA[<properties name=\"currentAccountKey\">\n" "<![CDATA[<properties name=\"currentAccountKey\">\n"
" <property name=\"accountNumber\" type=\"string\" not-null=\"true\"/>\n" " <property name=\"accountNumber\" type=\"string\" not-null=\"true\"/>\n"
" <property name=\"currentAccount\" type=\"boolean\">\n" " <property name=\"currentAccount\" type=\"boolean\">\n"
" <formula>case when effectiveEndDate is null then 1 else 0 end</formula>\n" " <formula>case when effectiveEndDate is null then 1 else 0 end</"
"formula>\n"
" </property>\n" " </property>\n"
"</properties>\n" "</properties>\n"
"<property name=\"effectiveEndDate\" type=\"date\"/>\n" "<property name=\"effectiveEndDate\" type=\"date\"/>\n"
"<property name=\"effectiveStateDate\" type=\"date\" not-null=\"true\"/>]]>" "<property name=\"effectiveStateDate\" type=\"date\" not-null=\"true\"/>]]>"
msgstr "" msgstr ""
#: index.docbook:266 #. Tag: para
msgid "Then we can map an association to the <emphasis>current</emphasis> instance (the one with null <literal>effectiveEndDate</literal>) using:" #: association_mapping.xml:266
#, no-c-format
msgid ""
"Then we can map an association to the <emphasis>current</emphasis> instance "
"(the one with null <literal>effectiveEndDate</literal>) using:"
msgstr "" msgstr ""
"那么我们可以对<emphasis>目前(current)</emphasis>实例(其"
"<literal>effectiveEndDate</literal>为null)使用这样的关联映射:"
#: index.docbook:271 #. Tag: programlisting
#: association_mapping.xml:271
#, no-c-format
msgid "" msgid ""
"<![CDATA[<many-to-one name=\"currentAccountInfo\" \n" "<![CDATA[<many-to-one name=\"currentAccountInfo\" \n"
" property-ref=\"currentAccountKey\"\n" " property-ref=\"currentAccountKey\"\n"
@ -576,11 +827,25 @@ msgid ""
"</many-to-one>]]>" "</many-to-one>]]>"
msgstr "" msgstr ""
#: index.docbook:273 #. Tag: para
msgid "In a more complex example, imagine that the association between <literal>Employee</literal> and <literal>Organization</literal> is maintained in an <literal>Employment</literal> table full of historical employment data. Then an association to the employee's <emphasis>most recent</emphasis> employer (the one with the most recent <literal>startDate</literal>) might be mapped this way:" #: association_mapping.xml:273
#, no-c-format
msgid ""
"In a more complex example, imagine that the association between "
"<literal>Employee</literal> and <literal>Organization</literal> is "
"maintained in an <literal>Employment</literal> table full of historical "
"employment data. Then an association to the employee's <emphasis>most "
"recent</emphasis> employer (the one with the most recent <literal>startDate</"
"literal>) might be mapped this way:"
msgstr "" msgstr ""
"更复杂的例子,假想<literal>Employee</literal>和<literal>Organization</literal>"
"之间的关联是通过一个<literal>Employment</literal>中间表维护的,而中间表中填充"
"了很多历史雇员数据。那“雇员的<emphasis>最新</emphasis>雇主”这个关联(最新雇主"
"就是<literal>startDate</literal>最后的那个)可以这样映射:"
#: index.docbook:281 #. Tag: programlisting
#: association_mapping.xml:281
#, no-c-format
msgid "" msgid ""
"<![CDATA[<join>\n" "<![CDATA[<join>\n"
" <key column=\"employeeId\"/>\n" " <key column=\"employeeId\"/>\n"
@ -596,13 +861,11 @@ msgid ""
"</join>]]>" "</join>]]>"
msgstr "" msgstr ""
#: index.docbook:283 #. Tag: para
msgid "You can get quite creative with this functionality, but it is usually more practical to handle these kinds of cases using HQL or a criteria query." #: association_mapping.xml:283
#, no-c-format
msgid ""
"You can get quite creative with this functionality, but it is usually more "
"practical to handle these kinds of cases using HQL or a criteria query."
msgstr "" msgstr ""
"使用这一功能时可以充满创意但通常更加实用的是用HQL或条件查询来处理这些情形。"
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,18 +1,33 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: batch.xml:5
#, no-c-format
msgid "Batch processing" msgid "Batch processing"
msgstr "" msgstr "批量处理Batch processing"
#: index.docbook:7 #. Tag: para
msgid "A naive approach to inserting 100 000 rows in the database using Hibernate might look like this:" #: batch.xml:7
#, no-c-format
msgid ""
"A naive approach to inserting 100 000 rows in the database using Hibernate "
"might look like this:"
msgstr "" msgstr ""
"使用Hibernate将 100 000 条记录插入到数据库的一个很自然的做法可能是这样的"
#: index.docbook:12 #. Tag: programlisting
#: batch.xml:12
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n" "<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n" "Transaction tx = session.beginTransaction();\n"
@ -24,43 +39,94 @@ msgid ""
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:14 #. Tag: para
msgid "This would fall over with an <literal>OutOfMemoryException</literal> somewhere around the 50 000th row. That's because Hibernate caches all the newly inserted <literal>Customer</literal> instances in the session-level cache." #: batch.xml:14
#, no-c-format
msgid ""
"This would fall over with an <literal>OutOfMemoryException</literal> "
"somewhere around the 50 000th row. That's because Hibernate caches all the "
"newly inserted <literal>Customer</literal> instances in the session-level "
"cache."
msgstr "" msgstr ""
"这段程序大概运行到 50 000 条记录左右会失败并抛出 <literal>内存溢出异常"
"OutOfMemoryException</literal> 。 这是因为 Hibernate 把所有新插入的 "
"<literal>客户Customer</literal>实例在 session级别的缓存区进行了缓存的缘"
"故。"
#: index.docbook:20 #. Tag: para
msgid "In this chapter we'll show you how to avoid this problem. First, however, if you are doing batch processing, it is absolutely critical that you enable the use of JDBC batching, if you intend to achieve reasonable performance. Set the JDBC batch size to a reasonable number (say, 10-50):" #: batch.xml:20
#, no-c-format
msgid ""
"In this chapter we'll show you how to avoid this problem. First, however, if "
"you are doing batch processing, it is absolutely critical that you enable "
"the use of JDBC batching, if you intend to achieve reasonable performance. "
"Set the JDBC batch size to a reasonable number (say, 10-50):"
msgstr "" msgstr ""
"我们会在本章告诉你如何避免此类问题。首先,如果你要执行批量处理并且想要达到一"
"个理想的性能, 那么使用JDBC的批量batching功能是至关重要。将JDBC的批量抓取"
"数量batch size参数设置到一个合适值 比如10-50之间"
#: index.docbook:27 #. Tag: programlisting
#: batch.xml:27
#, no-c-format
msgid "<![CDATA[hibernate.jdbc.batch_size 20]]>" msgid "<![CDATA[hibernate.jdbc.batch_size 20]]>"
msgstr "" msgstr ""
#: index.docbook:29 #. Tag: para
msgid "Note that Hibernate disables insert batching at the JDBC level transparently if you use an <literal>identiy</literal> identifier generator." #: batch.xml:29
#, no-c-format
msgid ""
"Note that Hibernate disables insert batching at the JDBC level transparently "
"if you use an <literal>identiy</literal> identifier generator."
msgstr "" msgstr ""
"注意,假若你使用了<literal>identiy</literal>标识符生成器,Hibernate在JDBC级别透"
"明的关闭插入语句的批量执行。"
#: index.docbook:34 #. Tag: para
msgid "You also might like to do this kind of work in a process where interaction with the second-level cache is completely disabled:" #: batch.xml:34
msgstr "" #, no-c-format
msgid ""
"You also might like to do this kind of work in a process where interaction "
"with the second-level cache is completely disabled:"
msgstr "你也可能想在执行批量处理时关闭二级缓存:"
#: index.docbook:39 #. Tag: programlisting
#: batch.xml:39
#, no-c-format
msgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>" msgid "<![CDATA[hibernate.cache.use_second_level_cache false]]>"
msgstr "" msgstr ""
#: index.docbook:41 #. Tag: para
msgid "However, this is not absolutely necessary, since we can explicitly set the <literal>CacheMode</literal> to disable interaction with the second-level cache." #: batch.xml:41
#, no-c-format
msgid ""
"However, this is not absolutely necessary, since we can explicitly set the "
"<literal>CacheMode</literal> to disable interaction with the second-level "
"cache."
msgstr "" msgstr ""
"但是,这不是绝对必须的,因为我们可以显式设置<literal>CacheMode</literal>来关"
"闭与二级缓存的交互。"
#: index.docbook:47 #. Tag: title
#: batch.xml:47
#, no-c-format
msgid "Batch inserts" msgid "Batch inserts"
msgstr "" msgstr "批量插入Batch inserts"
#: index.docbook:49 #. Tag: para
msgid "When making new objects persistent, you must <literal>flush()</literal> and then <literal>clear()</literal> the session regularly, to control the size of the first-level cache." #: batch.xml:49
#, no-c-format
msgid ""
"When making new objects persistent, you must <literal>flush()</literal> and "
"then <literal>clear()</literal> the session regularly, to control the size "
"of the first-level cache."
msgstr "" msgstr ""
"如果要将很多对象持久化,你必须通过经常的调用 <literal>flush()</literal> 以及"
"稍后调用 <literal>clear()</literal> 来控制第一级缓存的大小。"
#: index.docbook:55 #. Tag: programlisting
#: batch.xml:55
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n" "<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n" "Transaction tx = session.beginTransaction();\n"
@ -79,15 +145,26 @@ msgid ""
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:60 #. Tag: title
#: batch.xml:60
#, no-c-format
msgid "Batch updates" msgid "Batch updates"
msgstr "" msgstr "批量更新Batch updates"
#: index.docbook:62 #. Tag: para
msgid "For retrieving and updating data the same ideas apply. In addition, you need to use <literal>scroll()</literal> to take advantage of server-side cursors for queries that return many rows of data." #: batch.xml:62
#, no-c-format
msgid ""
"For retrieving and updating data the same ideas apply. In addition, you need "
"to use <literal>scroll()</literal> to take advantage of server-side cursors "
"for queries that return many rows of data."
msgstr "" msgstr ""
"此方法同样适用于检索和更新数据。此外,在进行会返回很多行数据的查询时, 你需要"
"使用 <literal>scroll()</literal> 方法以便充分利用服务器端游标所带来的好处。"
#: index.docbook:68 #. Tag: programlisting
#: batch.xml:68
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n" "<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n" "Transaction tx = session.beginTransaction();\n"
@ -110,15 +187,42 @@ msgid ""
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:73 #. Tag: title
#: batch.xml:73
#, no-c-format
msgid "The StatelessSession interface" msgid "The StatelessSession interface"
msgstr "" msgstr "StatelessSession (无状态session)接口"
#: index.docbook:74 #. Tag: para
msgid "Alternatively, Hibernate provides a command-oriented API that may be used for streaming data to and from the database in the form of detached objects. A <literal>StatelessSession</literal> has no persistence context associated with it and does not provide many of the higher-level life cycle semantics. In particular, a stateless session does not implement a first-level cache nor interact with any second-level or query cache. It does not implement transactional write-behind or automatic dirty checking. Operations performed using a stateless session do not ever cascade to associated instances. Collections are ignored by a stateless session. Operations performed via a stateless session bypass Hibernate's event model and interceptors. Stateless sessions are vulnerable to data aliasing effects, due to the lack of a first-level cache. A stateless session is a lower-level abstraction, much closer to the underlying JDBC." #: batch.xml:74
#, no-c-format
msgid ""
"Alternatively, Hibernate provides a command-oriented API that may be used "
"for streaming data to and from the database in the form of detached objects. "
"A <literal>StatelessSession</literal> has no persistence context associated "
"with it and does not provide many of the higher-level life cycle semantics. "
"In particular, a stateless session does not implement a first-level cache "
"nor interact with any second-level or query cache. It does not implement "
"transactional write-behind or automatic dirty checking. Operations performed "
"using a stateless session do not ever cascade to associated instances. "
"Collections are ignored by a stateless session. Operations performed via a "
"stateless session bypass Hibernate's event model and interceptors. Stateless "
"sessions are vulnerable to data aliasing effects, due to the lack of a first-"
"level cache. A stateless session is a lower-level abstraction, much closer "
"to the underlying JDBC."
msgstr "" msgstr ""
"作为选择Hibernate提供了基于命令的API可以用detached object的形式把数据以流"
"的方法加入到数据库,或从数据库输出。<literal>StatelessSession</literal>没有持"
"久化上下文也不提供多少高层的生命周期语义。特别是无状态session不实现第一级"
"cache,也不和第二级缓存,或者查询缓存交互。它不实现事务化写,也不实现脏数据检"
"查。用stateless session进行的操作甚至不级联到关联实例。stateless session忽略"
"集合类(Collections)。通过stateless session进行的操作不触发Hibernate的事件模型"
"和拦截器。无状态session对数据的混淆现象免疫因为它没有第一级缓存。无状态"
"session是低层的抽象和低层JDBC相当接近。"
#: index.docbook:89 #. Tag: programlisting
#: batch.xml:89
#, no-c-format
msgid "" msgid ""
"<![CDATA[StatelessSession session = sessionFactory.openStatelessSession();\n" "<![CDATA[StatelessSession session = sessionFactory.openStatelessSession();\n"
"Transaction tx = session.beginTransaction();\n" "Transaction tx = session.beginTransaction();\n"
@ -135,53 +239,143 @@ msgid ""
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:91 #. Tag: para
msgid "Note that in this code example, the <literal>Customer</literal> instances returned by the query are immediately detached. They are never associated with any persistence context." #: batch.xml:91
#, no-c-format
msgid ""
"Note that in this code example, the <literal>Customer</literal> instances "
"returned by the query are immediately detached. They are never associated "
"with any persistence context."
msgstr "" msgstr ""
"注意在上面的例子中,查询返回的<literal>Customer</literal>实例立即被脱管"
"(detach)。它们与任何持久化上下文都没有关系。"
#: index.docbook:97 #. Tag: para
msgid "The <literal>insert(), update()</literal> and <literal>delete()</literal> operations defined by the <literal>StatelessSession</literal> interface are considered to be direct database row-level operations, which result in immediate execution of a SQL <literal>INSERT, UPDATE</literal> or <literal>DELETE</literal> respectively. Thus, they have very different semantics to the <literal>save(), saveOrUpdate()</literal> and <literal>delete()</literal> operations defined by the <literal>Session</literal> interface." #: batch.xml:97
#, no-c-format
msgid ""
"The <literal>insert(), update()</literal> and <literal>delete()</literal> "
"operations defined by the <literal>StatelessSession</literal> interface are "
"considered to be direct database row-level operations, which result in "
"immediate execution of a SQL <literal>INSERT, UPDATE</literal> or "
"<literal>DELETE</literal> respectively. Thus, they have very different "
"semantics to the <literal>save(), saveOrUpdate()</literal> and "
"<literal>delete()</literal> operations defined by the <literal>Session</"
"literal> interface."
msgstr "" msgstr ""
"<literal>StatelessSession</literal> 接口定义的<literal>insert(), update()</"
"literal> 和 <literal>delete()</literal>操作是直接的数据库行级别操作,其结果是"
"立刻执行一条<literal>INSERT, UPDATE</literal> 或 <literal>DELETE</literal> 语"
"句。因此,它们的语义和<literal>Session</literal> 接口定义的<literal>save(), "
"saveOrUpdate()</literal> 和<literal>delete()</literal> 操作有很大的不同。"
#: index.docbook:110 #. Tag: title
#: batch.xml:110
#, no-c-format
msgid "DML-style operations" msgid "DML-style operations"
msgstr "" msgstr "DML(数据操作语言)风格的操作(DML-style operations)"
#: index.docbook:112 #. Tag: para
msgid "As already discussed, automatic and transparent object/relational mapping is concerned with the management of object state. This implies that the object state is available in memory, hence manipulating (using the SQL <literal>Data Manipulation Language</literal> (DML) statements: <literal>INSERT</literal>, <literal>UPDATE</literal>, <literal>DELETE</literal>) data directly in the database will not affect in-memory state. However, Hibernate provides methods for bulk SQL-style DML statement execution which are performed through the Hibernate Query Language (<xref linkend=\"queryhql\"/>HQL)." #: batch.xml:112
#, fuzzy, no-c-format
msgid ""
"As already discussed, automatic and transparent object/relational mapping is "
"concerned with the management of object state. This implies that the object "
"state is available in memory, hence manipulating (using the SQL "
"<literal>Data Manipulation Language</literal> (DML) statements: "
"<literal>INSERT</literal>, <literal>UPDATE</literal>, <literal>DELETE</"
"literal>) data directly in the database will not affect in-memory state. "
"However, Hibernate provides methods for bulk SQL-style DML statement "
"execution which are performed through the Hibernate Query Language (<xref "
"linkend=\"queryhql\"/>HQL)."
msgstr "" msgstr ""
"hence manipulating (using the SQL <literal>Data Manipulation Language</"
"literal> (DML) statements: <literal>INSERT</literal>, <literal>UPDATE</"
"literal>, <literal>DELETE</literal>) data directly in the database will not "
"affect in-memory state. However, Hibernate provides methods for bulk SQL-"
"style DML statement execution which are performed through the Hibernate "
"Query Language (<xref linkend=\"queryhql\">HQL</xref>). 就像已经讨论的那样,"
"自动和透明的 对象/关系 映射object/relational mapping关注于管理对象的状"
"态。 这就意味着对象的状态存在于内存,因此直接操作 (使用 SQL <literal>Data "
"Manipulation Language</literal>(DML,数据操作语言)语句 <literal>INSERT</"
"literal> ,<literal>UPDATE</literal> 和 <literal>DELETE</literal>) 数据库中的"
"数据将不会影响内存中的对象状态和对象数据。 不过Hibernate提供通过Hibernate查"
"询语言(<xref linkend=\"queryhql\">HQL</xref>)来执行大批 量SQL风格的DML语句"
"的方法。"
#: index.docbook:122 #. Tag: para
msgid "The pseudo-syntax for <literal>UPDATE</literal> and <literal>DELETE</literal> statements is: <literal>( UPDATE | DELETE ) FROM? EntityName (WHERE where_conditions)?</literal>. Some points to note:" #: batch.xml:122
#, no-c-format
msgid ""
"The pseudo-syntax for <literal>UPDATE</literal> and <literal>DELETE</"
"literal> statements is: <literal>( UPDATE | DELETE ) FROM? EntityName (WHERE "
"where_conditions)?</literal>. Some points to note:"
msgstr "" msgstr ""
"<literal>UPDATE</literal> 和 <literal>DELETE</literal>语句的语法为: "
"<literal>( UPDATE | DELETE ) FROM? EntityName (WHERE where_conditions)?</"
"literal> 有几点说明:"
#: index.docbook:130 #. Tag: para
#: batch.xml:130
#, no-c-format
msgid "In the from-clause, the FROM keyword is optional" msgid "In the from-clause, the FROM keyword is optional"
msgstr "" msgstr "在FROM子句from-clauseFROM关键字是可选的"
#: index.docbook:135 #. Tag: para
msgid "There can only be a single entity named in the from-clause; it can optionally be aliased. If the entity name is aliased, then any property references must be qualified using that alias; if the entity name is not aliased, then it is illegal for any property references to be qualified." #: batch.xml:135
#, no-c-format
msgid ""
"There can only be a single entity named in the from-clause; it can "
"optionally be aliased. If the entity name is aliased, then any property "
"references must be qualified using that alias; if the entity name is not "
"aliased, then it is illegal for any property references to be qualified."
msgstr "" msgstr ""
"在FROM子句from-clause中只能有一个实体名它可以是别名。如果实体名是别名"
"那么任何被引用的属性都必须加上此别名的前缀;如果不是别名,那么任何有前缀的属"
"性引用都是非法的。"
#: index.docbook:143 #. Tag: para
msgid "No <xref linkend=\"queryhql-joins-forms\"/>joins (either implicit or explicit) can be specified in a bulk HQL query. Sub-queries may be used in the where-clause; the subqueries, themselves, may contain joins." #: batch.xml:143
#, fuzzy, no-c-format
msgid ""
"No <xref linkend=\"queryhql-joins-forms\"/>joins (either implicit or "
"explicit) can be specified in a bulk HQL query. Sub-queries may be used in "
"the where-clause; the subqueries, themselves, may contain joins."
msgstr "" msgstr ""
"不能在大批量HQL语句中使用<xref linkend=\"queryhql-joins-forms\">连接(join)</"
"xref>显式或者隐式的都不行。不过在WHERE子句中可以使用子查询。可以在where子"
"句中使用子查询子查询本身可以包含join。"
#: index.docbook:150 #. Tag: para
#: batch.xml:150
#, no-c-format
msgid "The where-clause is also optional." msgid "The where-clause is also optional."
msgstr "" msgstr "整个WHERE子句是可选的。"
#: index.docbook:156 #. Tag: para
msgid "As an example, to execute an HQL <literal>UPDATE</literal>, use the <literal>Query.executeUpdate()</literal> method (the method is named for those familiar with JDBC's <literal>PreparedStatement.executeUpdate()</literal>):" #: batch.xml:156
#, no-c-format
msgid ""
"As an example, to execute an HQL <literal>UPDATE</literal>, use the "
"<literal>Query.executeUpdate()</literal> method (the method is named for "
"those familiar with JDBC's <literal>PreparedStatement.executeUpdate()</"
"literal>):"
msgstr "" msgstr ""
"举个例子,使用<literal>Query.executeUpdate()</literal>方法执行一个HQL "
"<literal>UPDATE</literal>语句( (方法命名是来源于JDBC's "
"<literal>PreparedStatement.executeUpdate()</literal>):"
#: index.docbook:162 #. Tag: programlisting
#: batch.xml:162
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n" "<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n" "Transaction tx = session.beginTransaction();\n"
"\n" "\n"
"String hqlUpdate = \"update Customer c set c.name = :newName where c.name = :oldName\";\n" "String hqlUpdate = \"update Customer c set c.name = :newName where c.name = :"
"// or String hqlUpdate = \"update Customer set name = :newName where name = :oldName\";\n" "oldName\";\n"
"// or String hqlUpdate = \"update Customer set name = :newName where name = :"
"oldName\";\n"
"int updatedEntities = s.createQuery( hqlUpdate )\n" "int updatedEntities = s.createQuery( hqlUpdate )\n"
" .setString( \"newName\", newName )\n" " .setString( \"newName\", newName )\n"
" .setString( \"oldName\", oldName )\n" " .setString( \"oldName\", oldName )\n"
@ -190,15 +384,36 @@ msgid ""
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:164 #. Tag: para
msgid "HQL <literal>UPDATE</literal> statements, by default do not effect the <xref linkend=\"mapping-declaration-version\"/>version or the <xref linkend=\"mapping-declaration-timestamp\"/>timestamp property values for the affected entities; this is in keeping with the EJB3 specification. However, you can force Hibernate to properly reset the <literal>version</literal> or <literal>timestamp</literal> property values through the use of a <literal>versioned update</literal>. This is achieved by adding the <literal>VERSIONED</literal> keyword after the <literal>UPDATE</literal> keyword." #: batch.xml:164
#, fuzzy, no-c-format
msgid ""
"HQL <literal>UPDATE</literal> statements, by default do not effect the <xref "
"linkend=\"mapping-declaration-version\"/>version or the <xref linkend="
"\"mapping-declaration-timestamp\"/>timestamp property values for the "
"affected entities; this is in keeping with the EJB3 specification. However, "
"you can force Hibernate to properly reset the <literal>version</literal> or "
"<literal>timestamp</literal> property values through the use of a "
"<literal>versioned update</literal>. This is achieved by adding the "
"<literal>VERSIONED</literal> keyword after the <literal>UPDATE</literal> "
"keyword."
msgstr "" msgstr ""
"HQL <literal>UPDATE</literal>语句,默认不会影响更新实体的<xref linkend="
"\"mapping-declaration-version\">version</xref>或者<xref linkend=\"mapping-"
"declaration-timestamp\">timestamp</xref>属性值。这和EJB3规范是一致的。但是"
"通过使用<literal>versioned update</literal>你可以强制Hibernate正确的重置"
"<literal>version</literal>或者<literal>timestamp</literal>属性值。这通过在"
"<literal>UPDATE</literal>关键字后面增加<literal>VERSIONED</literal>关键字来实"
"现的。"
#: index.docbook:174 #. Tag: programlisting
#: batch.xml:174
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n" "<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n" "Transaction tx = session.beginTransaction();\n"
"String hqlVersionedUpdate = \"update versioned Customer set name = :newName where name = :oldName\";\n" "String hqlVersionedUpdate = \"update versioned Customer set name = :newName "
"where name = :oldName\";\n"
"int updatedEntities = s.createQuery( hqlUpdate )\n" "int updatedEntities = s.createQuery( hqlUpdate )\n"
" .setString( \"newName\", newName )\n" " .setString( \"newName\", newName )\n"
" .setString( \"oldName\", oldName )\n" " .setString( \"oldName\", oldName )\n"
@ -207,15 +422,30 @@ msgid ""
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:176 #. Tag: para
msgid "Note that custom version types (<literal>org.hibernate.usertype.UserVersionType</literal>) are not allowed in conjunction with a <literal>update versioned</literal> statement." #: batch.xml:176
#, no-c-format
msgid ""
"Note that custom version types (<literal>org.hibernate.usertype."
"UserVersionType</literal>) are not allowed in conjunction with a "
"<literal>update versioned</literal> statement."
msgstr "" msgstr ""
"注意,自定义的版本类型(<literal>org.hibernate.usertype.UserVersionType</"
"literal>)不允许和<literal>update versioned</literal>语句联用。"
#: index.docbook:181 #. Tag: para
msgid "To execute an HQL <literal>DELETE</literal>, use the same <literal>Query.executeUpdate()</literal> method:" #: batch.xml:181
#, no-c-format
msgid ""
"To execute an HQL <literal>DELETE</literal>, use the same <literal>Query."
"executeUpdate()</literal> method:"
msgstr "" msgstr ""
"执行一个HQL <literal>DELETE</literal>,同样使用 <literal>Query.executeUpdate"
"()</literal> 方法:"
#: index.docbook:186 #. Tag: programlisting
#: batch.xml:186
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n" "<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n" "Transaction tx = session.beginTransaction();\n"
@ -229,53 +459,150 @@ msgid ""
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:188 #. Tag: para
msgid "The <literal>int</literal> value returned by the <literal>Query.executeUpdate()</literal> method indicate the number of entities effected by the operation. Consider this may or may not correlate to the number of rows effected in the database. An HQL bulk operation might result in multiple actual SQL statements being executed, for joined-subclass, for example. The returned number indicates the number of actual entities affected by the statement. Going back to the example of joined-subclass, a delete against one of the subclasses may actually result in deletes against not just the table to which that subclass is mapped, but also the \"root\" table and potentially joined-subclass tables further down the inheritence hierarchy." #: batch.xml:188
#, no-c-format
msgid ""
"The <literal>int</literal> value returned by the <literal>Query.executeUpdate"
"()</literal> method indicate the number of entities effected by the "
"operation. Consider this may or may not correlate to the number of rows "
"effected in the database. An HQL bulk operation might result in multiple "
"actual SQL statements being executed, for joined-subclass, for example. The "
"returned number indicates the number of actual entities affected by the "
"statement. Going back to the example of joined-subclass, a delete against "
"one of the subclasses may actually result in deletes against not just the "
"table to which that subclass is mapped, but also the \"root\" table and "
"potentially joined-subclass tables further down the inheritence hierarchy."
msgstr "" msgstr ""
"由<literal>Query.executeUpdate()</literal>方法返回的<literal>整型</literal>值"
"表明了受此操作影响的记录数量。 注意这个数值可能与数据库中被最后一条SQL语"
"句影响了的“行”数有关也可能没有。一个大批量HQL操作可能导致多条实际的SQL语"
"句被执行, 举个例子对joined-subclass映射方式的类进行的此类操作。这个返回值"
"代表了实际被语句影响了的记录数量。在那个joined-subclass的例子中 对一个子类"
"的删除实际上可能不仅仅会删除子类映射到的表而且会影响“根”表,还有可能影响与之"
"有继承关系的joined-subclass映射方式的子类的表。"
#: index.docbook:199 #. Tag: para
msgid "The pseudo-syntax for <literal>INSERT</literal> statements is: <literal>INSERT INTO EntityName properties_list select_statement</literal>. Some points to note:" #: batch.xml:199
#, no-c-format
msgid ""
"The pseudo-syntax for <literal>INSERT</literal> statements is: "
"<literal>INSERT INTO EntityName properties_list select_statement</literal>. "
"Some points to note:"
msgstr "" msgstr ""
"<literal>INSERT</literal>语句的伪码是: <literal>INSERT INTO EntityName "
"properties_list select_statement</literal>. 要注意的是:"
#: index.docbook:207 #. Tag: para
msgid "Only the INSERT INTO ... SELECT ... form is supported; not the INSERT INTO ... VALUES ... form." #: batch.xml:207
#, no-c-format
msgid ""
"Only the INSERT INTO ... SELECT ... form is supported; not the INSERT "
"INTO ... VALUES ... form."
msgstr "" msgstr ""
"只支持INSERT INTO ... SELECT ...形式,不支持INSERT INTO ... VALUES ...形式."
#: index.docbook:210 #. Tag: para
msgid "The properties_list is analogous to the <literal>column speficiation</literal> in the SQL <literal>INSERT</literal> statement. For entities involved in mapped inheritence, only properties directly defined on that given class-level can be used in the properties_list. Superclass properties are not allowed; and subclass properties do not make sense. In other words, <literal>INSERT</literal> statements are inherently non-polymorphic." #: batch.xml:210
#, no-c-format
msgid ""
"The properties_list is analogous to the <literal>column speficiation</"
"literal> in the SQL <literal>INSERT</literal> statement. For entities "
"involved in mapped inheritence, only properties directly defined on that "
"given class-level can be used in the properties_list. Superclass properties "
"are not allowed; and subclass properties do not make sense. In other words, "
"<literal>INSERT</literal> statements are inherently non-polymorphic."
msgstr "" msgstr ""
"properties_list和SQL <literal>INSERT</literal>语句中的<literal>字段定义"
"(column speficiation)</literal>类似。对参与继承树映射的实体而言,只有直接定义"
"在给定的类级别的属性才能直接在properties_list中使用。超类的属性不被支持子类"
"的属性无意义。换句话说,<literal>INSERT</literal>天生不支持多态。"
#: index.docbook:220 #. Tag: para
msgid "select_statement can be any valid HQL select query, with the caveat that the return types must match the types expected by the insert. Currently, this is checked during query compilation rather than allowing the check to relegate to the database. Note however that this might cause problems between Hibernate <literal>Type</literal>s which are <emphasis>equivalent</emphasis> as opposed to <emphasis>equal</emphasis>. This might cause issues with mismatches between a property defined as a <literal>org.hibernate.type.DateType</literal> and a property defined as a <literal>org.hibernate.type.TimestampType</literal>, even though the database might not make a distinction or might be able to handle the conversion." #: batch.xml:220
#, no-c-format
msgid ""
"select_statement can be any valid HQL select query, with the caveat that the "
"return types must match the types expected by the insert. Currently, this is "
"checked during query compilation rather than allowing the check to relegate "
"to the database. Note however that this might cause problems between "
"Hibernate <literal>Type</literal>s which are <emphasis>equivalent</emphasis> "
"as opposed to <emphasis>equal</emphasis>. This might cause issues with "
"mismatches between a property defined as a <literal>org.hibernate.type."
"DateType</literal> and a property defined as a <literal>org.hibernate.type."
"TimestampType</literal>, even though the database might not make a "
"distinction or might be able to handle the conversion."
msgstr "" msgstr ""
"select_statement可以是任何合法的HQL选择查询不过要保证返回类型必须和要插入的"
"类型完全匹配。目前,这一检查是在查询编译的时候进行的,而不是把它交给数据库。"
"注意在Hibernate<literal>Type</literal>间如果只是<emphasis>等价"
"equivalent</emphasis>而非<emphasis>相等(equal)</emphasis>,会导致问题。定"
"义为<literal>org.hibernate.type.DateType</literal>和<literal>org.hibernate."
"type.TimestampType</literal>的两个属性可能会产生类型不匹配错误,虽然数据库级"
"可能不加区分或者可以处理这种转换。"
#: index.docbook:232 #. Tag: para
msgid "For the id property, the insert statement gives you two options. You can either explicitly specify the id property in the properties_list (in which case its value is taken from the corresponding select expression) or omit it from the properties_list (in which case a generated value is used). This later option is only available when using id generators that operate in the database; attempting to use this option with any \"in memory\" type generators will cause an exception during parsing. Note that for the purposes of this discussion, in-database generators are considered to be <literal>org.hibernate.id.SequenceGenerator</literal> (and its subclasses) and any implementors of <literal>org.hibernate.id.PostInsertIdentifierGenerator</literal>. The most notable exception here is <literal>org.hibernate.id.TableHiLoGenerator</literal>, which cannot be used because it does not expose a selectable way to get its values." #: batch.xml:232
#, no-c-format
msgid ""
"For the id property, the insert statement gives you two options. You can "
"either explicitly specify the id property in the properties_list (in which "
"case its value is taken from the corresponding select expression) or omit it "
"from the properties_list (in which case a generated value is used). This "
"later option is only available when using id generators that operate in the "
"database; attempting to use this option with any \"in memory\" type "
"generators will cause an exception during parsing. Note that for the "
"purposes of this discussion, in-database generators are considered to be "
"<literal>org.hibernate.id.SequenceGenerator</literal> (and its subclasses) "
"and any implementors of <literal>org.hibernate.id."
"PostInsertIdentifierGenerator</literal>. The most notable exception here is "
"<literal>org.hibernate.id.TableHiLoGenerator</literal>, which cannot be used "
"because it does not expose a selectable way to get its values."
msgstr "" msgstr ""
"对id属性来说,insert语句给你两个选择。你可以明确地在properties_list表中指定id"
"属性这样它的值是从对应的select表达式中获得或者在properties_list中省略它"
"此时使用生成指。后一种选择只有当使用在数据库中生成值的id产生器时才能使"
"用;如果是“内存”中计算的类型生成器,在解析时会抛出一个异常。注意,为了说明这"
"一问题,数据库产生值的生成器是<literal>org.hibernate.id.SequenceGenerator</"
"literal>(和它的子类),以及任何<literal>org.hibernate.id."
"PostInsertIdentifierGenerator</literal>接口的实现。这儿最值得注意的意外是"
"<literal>org.hibernate.id.TableHiLoGenerator</literal>,它不能在此使用,因为"
"它没有得到其值的途径。"
#: index.docbook:247 #. Tag: para
msgid "For properties mapped as either <literal>version</literal> or <literal>timestamp</literal>, the insert statement gives you two options. You can either specify the property in the properties_list (in which case its value is taken from the corresponding select expressions) or omit it from the properties_list (in which case the <literal>seed value</literal> defined by the <literal>org.hibernate.type.VersionType</literal> is used)." #: batch.xml:247
#, no-c-format
msgid ""
"For properties mapped as either <literal>version</literal> or "
"<literal>timestamp</literal>, the insert statement gives you two options. "
"You can either specify the property in the properties_list (in which case "
"its value is taken from the corresponding select expressions) or omit it "
"from the properties_list (in which case the <literal>seed value</literal> "
"defined by the <literal>org.hibernate.type.VersionType</literal> is used)."
msgstr "" msgstr ""
"对映射为<literal>version</literal> 或 <literal>timestamp</literal>的属性来"
"说insert语句也给你两个选择你可以在properties_list表中指定此时其值从对应"
"的select表达式中获得或者在properties_list中省略它此时使用在"
"<literal>org.hibernate.type.VersionType</literal> 中定义的<literal>seed value"
"(种子值)</literal>)。"
#: index.docbook:257 #. Tag: para
#: batch.xml:257
#, no-c-format
msgid "An example HQL <literal>INSERT</literal> statement execution:" msgid "An example HQL <literal>INSERT</literal> statement execution:"
msgstr "" msgstr "执行HQL <literal>INSERT</literal>语句的例子如下:"
#: index.docbook:261 #. Tag: programlisting
#: batch.xml:261
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n" "<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n" "Transaction tx = session.beginTransaction();\n"
"\n" "\n"
"String hqlInsert = \"insert into DelinquentAccount (id, name) select c.id, c.name from Customer c where ...\";\n" "String hqlInsert = \"insert into DelinquentAccount (id, name) select c.id, c."
"name from Customer c where ...\";\n"
"int createdEntities = s.createQuery( hqlInsert )\n" "int createdEntities = s.createQuery( hqlInsert )\n"
" .executeUpdate();\n" " .executeUpdate();\n"
"tx.commit();\n" "tx.commit();\n"
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,168 +1,428 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: best_practices.xml:5
#, no-c-format
msgid "Best Practices" msgid "Best Practices"
msgstr "" msgstr "最佳实践(Best Practices)"
#: index.docbook:9 #. Tag: term
msgid "Write fine-grained classes and map them using <literal>&lt;component&gt;</literal>." #: best_practices.xml:9
#, no-c-format
msgid ""
"Write fine-grained classes and map them using <literal>&lt;component&gt;</"
"literal>."
msgstr "" msgstr ""
"设计细颗粒度的持久类并且使用<literal>&lt;component&gt;</literal>来实现映射。"
#: index.docbook:11 #. Tag: para
msgid "Use an <literal>Address</literal> class to encapsulate <literal>street</literal>, <literal>suburb</literal>, <literal>state</literal>, <literal>postcode</literal>. This encourages code reuse and simplifies refactoring." #: best_practices.xml:11
#, no-c-format
msgid ""
"Use an <literal>Address</literal> class to encapsulate <literal>street</"
"literal>, <literal>suburb</literal>, <literal>state</literal>, "
"<literal>postcode</literal>. This encourages code reuse and simplifies "
"refactoring."
msgstr "" msgstr ""
"使用一个<literal>Address</literal>持久类来封装 <literal>street</literal>, "
"<literal>suburb</literal>, <literal>state</literal>, <literal>postcode</"
"literal>. 这将有利于代码重用和简化代码重构(refactoring)的工作。"
#: index.docbook:19 #. Tag: term
#: best_practices.xml:19
#, no-c-format
msgid "Declare identifier properties on persistent classes." msgid "Declare identifier properties on persistent classes."
msgstr "" msgstr "对持久类声明标识符属性( identifier properties)。"
#: index.docbook:21 #. Tag: para
msgid "Hibernate makes identifier properties optional. There are all sorts of reasons why you should use them. We recommend that identifiers be 'synthetic' (generated, with no business meaning)." #: best_practices.xml:21
#, no-c-format
msgid ""
"Hibernate makes identifier properties optional. There are all sorts of "
"reasons why you should use them. We recommend that identifiers be "
"'synthetic' (generated, with no business meaning)."
msgstr "" msgstr ""
"Hibernate中标识符属性是可选的不过有很多原因来说明你应该使用标识符属性。我们"
"建议标识符应该是“人造”的(自动生成,不涉及业务含义)。"
#: index.docbook:29 #. Tag: term
#: best_practices.xml:29
#, no-c-format
msgid "Identify natural keys." msgid "Identify natural keys."
msgstr "" msgstr "使用自然键(natural keys)标识"
#: index.docbook:31 #. Tag: para
msgid "Identify natural keys for all entities, and map them using <literal>&lt;natural-id&gt;</literal>. Implement <literal>equals()</literal> and <literal>hashCode()</literal> to compare the properties that make up the natural key." #: best_practices.xml:31
#, no-c-format
msgid ""
"Identify natural keys for all entities, and map them using <literal>&lt;"
"natural-id&gt;</literal>. Implement <literal>equals()</literal> and "
"<literal>hashCode()</literal> to compare the properties that make up the "
"natural key."
msgstr "" msgstr ""
"对所有的实体都标识出自然键,用<literal>&lt;natural-id&gt;</literal>进行映射。"
"实现<literal>equals()</literal>和<literal>hashCode()</literal>,在其中用组成"
"自然键的属性进行比较。"
#: index.docbook:39 #. Tag: term
#: best_practices.xml:39
#, no-c-format
msgid "Place each class mapping in its own file." msgid "Place each class mapping in its own file."
msgstr "" msgstr "为每个持久类写一个映射文件"
#: index.docbook:41 #. Tag: para
msgid "Don't use a single monolithic mapping document. Map <literal>com.eg.Foo</literal> in the file <literal>com/eg/Foo.hbm.xml</literal>. This makes particularly good sense in a team environment." #: best_practices.xml:41
#, no-c-format
msgid ""
"Don't use a single monolithic mapping document. Map <literal>com.eg.Foo</"
"literal> in the file <literal>com/eg/Foo.hbm.xml</literal>. This makes "
"particularly good sense in a team environment."
msgstr "" msgstr ""
"不要把所有的持久类映射都写到一个大文件中。把 <literal>com.eg.Foo</literal> 映"
"射到<literal>com/eg/Foo.hbm.xml</literal>中, 在团队开发环境中,这一点显得特"
"别有意义。"
#: index.docbook:49 #. Tag: term
#: best_practices.xml:49
#, no-c-format
msgid "Load mappings as resources." msgid "Load mappings as resources."
msgstr "" msgstr "把映射文件作为资源加载"
#: index.docbook:51 #. Tag: para
#: best_practices.xml:51
#, no-c-format
msgid "Deploy the mappings along with the classes they map." msgid "Deploy the mappings along with the classes they map."
msgstr "" msgstr "把映射文件和他们的映射类放在一起进行部署。"
#: index.docbook:57 #. Tag: term
#: best_practices.xml:57
#, no-c-format
msgid "Consider externalising query strings." msgid "Consider externalising query strings."
msgstr "" msgstr "考虑把查询字符串放在程序外面"
#: index.docbook:59 #. Tag: para
msgid "This is a good practice if your queries call non-ANSI-standard SQL functions. Externalising the query strings to mapping files will make the application more portable." #: best_practices.xml:59
#, no-c-format
msgid ""
"This is a good practice if your queries call non-ANSI-standard SQL "
"functions. Externalising the query strings to mapping files will make the "
"application more portable."
msgstr "" msgstr ""
"如果你的查询中调用了非ANSI标准的SQL函数那么这条实践经验对你适用。把查询字符"
"串放在映射文件中可以让程序具有更好的可移植性。"
#: index.docbook:67 #. Tag: term
#: best_practices.xml:67
#, no-c-format
msgid "Use bind variables." msgid "Use bind variables."
msgstr "" msgstr "使用绑定变量"
#: index.docbook:69 #. Tag: para
msgid "As in JDBC, always replace non-constant values by \"?\". Never use string manipulation to bind a non-constant value in a query! Even better, consider using named parameters in queries." #: best_practices.xml:69
#, no-c-format
msgid ""
"As in JDBC, always replace non-constant values by \"?\". Never use string "
"manipulation to bind a non-constant value in a query! Even better, consider "
"using named parameters in queries."
msgstr "" msgstr ""
"就像在JDBC编程中一样应该总是用占位符\"?\"来替换非常量值,不要在查询中用字符"
"串值来构造非常量值!更好的办法是在查询中使用命名参数。"
#: index.docbook:77 #. Tag: term
#: best_practices.xml:77
#, no-c-format
msgid "Don't manage your own JDBC connections." msgid "Don't manage your own JDBC connections."
msgstr "" msgstr "不要自己来管理JDBC connections"
#: index.docbook:79 #. Tag: para
msgid "Hibernate lets the application manage JDBC connections. This approach should be considered a last-resort. If you can't use the built-in connections providers, consider providing your own implementation of <literal>org.hibernate.connection.ConnectionProvider</literal>." #: best_practices.xml:79
#, no-c-format
msgid ""
"Hibernate lets the application manage JDBC connections. This approach should "
"be considered a last-resort. If you can't use the built-in connections "
"providers, consider providing your own implementation of <literal>org."
"hibernate.connection.ConnectionProvider</literal>."
msgstr "" msgstr ""
"Hibernate允许应用程序自己来管理JDBC connections但是应该作为最后没有办法的办"
"法。如果你不能使用Hibernate内建的connections providers那么考虑实现自己来实"
"现<literal>org.hibernate.connection.ConnectionProvider</literal>"
#: index.docbook:87 #. Tag: term
#: best_practices.xml:87
#, no-c-format
msgid "Consider using a custom type." msgid "Consider using a custom type."
msgstr "" msgstr "考虑使用用户自定义类型(custom type)"
#: index.docbook:89 #. Tag: para
msgid "Suppose you have a Java type, say from some library, that needs to be persisted but doesn't provide the accessors needed to map it as a component. You should consider implementing <literal>org.hibernate.UserType</literal>. This approach frees the application code from implementing transformations to / from a Hibernate type." #: best_practices.xml:89
#, no-c-format
msgid ""
"Suppose you have a Java type, say from some library, that needs to be "
"persisted but doesn't provide the accessors needed to map it as a component. "
"You should consider implementing <literal>org.hibernate.UserType</literal>. "
"This approach frees the application code from implementing transformations "
"to / from a Hibernate type."
msgstr "" msgstr ""
"假设你有一个Java类型来自某些类库需要被持久化但是该类没有提供映射操作需"
"要的存取方法。那么你应该考虑实现<literal>org.hibernate.UserType</literal>接"
"口。这种办法使程序代码写起来更加自如不再需要考虑类与Hibernate type之间的相"
"互转换。"
#: index.docbook:98 #. Tag: term
#: best_practices.xml:98
#, no-c-format
msgid "Use hand-coded JDBC in bottlenecks." msgid "Use hand-coded JDBC in bottlenecks."
msgstr "" msgstr "在性能瓶颈的地方使用硬编码的JDBC"
#: index.docbook:100 #. Tag: para
msgid "In performance-critical areas of the system, some kinds of operations might benefit from direct JDBC. But please, wait until you <emphasis>know</emphasis> something is a bottleneck. And don't assume that direct JDBC is necessarily faster. If you need to use direct JDBC, it might be worth opening a Hibernate <literal>Session</literal> and using that JDBC connection. That way you can still use the same transaction strategy and underlying connection provider." #: best_practices.xml:100
#, no-c-format
msgid ""
"In performance-critical areas of the system, some kinds of operations might "
"benefit from direct JDBC. But please, wait until you <emphasis>know</"
"emphasis> something is a bottleneck. And don't assume that direct JDBC is "
"necessarily faster. If you need to use direct JDBC, it might be worth "
"opening a Hibernate <literal>Session</literal> and using that JDBC "
"connection. That way you can still use the same transaction strategy and "
"underlying connection provider."
msgstr "" msgstr ""
"In performance-critical areas of the system, some kinds of operations might "
"benefit from direct JDBC. But please, wait until you <emphasis>know</"
"emphasis> something is a bottleneck. And don't assume that direct JDBC is "
"necessarily faster. If you need to use direct JDBC, it might be worth "
"opening a Hibernate <literal>Session</literal> and using that JDBC "
"connection. That way you can still use the same transaction strategy and "
"underlying connection provider. 在系统中对性能要求很严格的一些部分,某些操作"
"也许直接使用JDBC会更好。但是请先<emphasis>确认</emphasis>这的确是一个瓶颈,并"
"且不要想当然认为JDBC一定会更快。如果确实需要直接使用JDBC那么最好打开一个 "
"Hibernate <literal>Session</literal> 然后从 <literal>Session</literal>获得"
"connection按照这种办法你仍然可以使用同样的transaction策略和底层的"
"connection provider。"
#: index.docbook:110 #. Tag: term
#: best_practices.xml:110
#, no-c-format
msgid "Understand <literal>Session</literal> flushing." msgid "Understand <literal>Session</literal> flushing."
msgstr "" msgstr "理解<literal>Session</literal>清洗( flushing"
#: index.docbook:112 #. Tag: para
msgid "From time to time the Session synchronizes its persistent state with the database. Performance will be affected if this process occurs too often. You may sometimes minimize unnecessary flushing by disabling automatic flushing or even by changing the order of queries and other operations within a particular transaction." #: best_practices.xml:112
#, no-c-format
msgid ""
"From time to time the Session synchronizes its persistent state with the "
"database. Performance will be affected if this process occurs too often. You "
"may sometimes minimize unnecessary flushing by disabling automatic flushing "
"or even by changing the order of queries and other operations within a "
"particular transaction."
msgstr "" msgstr ""
"Session会不时的向数据库同步持久化状态如果这种操作进行的过于频繁性能会受到"
"一定的影响。有时候你可以通过禁止自动flushing尽量最小化非必要的flushing操"
"作或者更进一步在一个特定的transaction中改变查询和其它操作的顺序。"
#: index.docbook:121 #. Tag: term
#: best_practices.xml:121
#, no-c-format
msgid "In a three tiered architecture, consider using detached objects." msgid "In a three tiered architecture, consider using detached objects."
msgstr "" msgstr "在三层结构中考虑使用托管对象detached object"
#: index.docbook:123 #. Tag: para
msgid "When using a servlet / session bean architecture, you could pass persistent objects loaded in the session bean to and from the servlet / JSP layer. Use a new session to service each request. Use <literal>Session.merge()</literal> or <literal>Session.saveOrUpdate()</literal> to synchronize objects with the database." #: best_practices.xml:123
#, no-c-format
msgid ""
"When using a servlet / session bean architecture, you could pass persistent "
"objects loaded in the session bean to and from the servlet / JSP layer. Use "
"a new session to service each request. Use <literal>Session.merge()</"
"literal> or <literal>Session.saveOrUpdate()</literal> to synchronize objects "
"with the database."
msgstr "" msgstr ""
"当使用一个servlet / session bean 类型的架构的时候, 你可以把已加载的持久对象在"
"session bean层和servlet / JSP 层之间来回传递。使用新的session来为每个请求服"
"务,使用 <literal>Session.merge()</literal> 或者<literal>Session.saveOrUpdate"
"()</literal>来与数据库同步。"
#: index.docbook:132 #. Tag: term
#: best_practices.xml:132
#, no-c-format
msgid "In a two tiered architecture, consider using long persistence contexts." msgid "In a two tiered architecture, consider using long persistence contexts."
msgstr "" msgstr "在两层结构中,考虑使用长持久上下文(long persistence contexts)."
#: index.docbook:134 #. Tag: para
msgid "Database Transactions have to be as short as possible for best scalability. However, it is often neccessary to implement long running <emphasis>application transactions</emphasis>, a single unit-of-work from the point of view of a user. An application transaction might span several client request/response cycles. It is common to use detached objects to implement application transactions. An alternative, extremely appropriate in two tiered architecture, is to maintain a single open persistence contact (session) for the whole life cycle of the application transaction and simply disconnect from the JDBC connection at the end of each request and reconnect at the beginning of the subsequent request. Never share a single session across more than one application transaction, or you will be working with stale data." #: best_practices.xml:134
#, no-c-format
msgid ""
"Database Transactions have to be as short as possible for best scalability. "
"However, it is often neccessary to implement long running "
"<emphasis>application transactions</emphasis>, a single unit-of-work from "
"the point of view of a user. An application transaction might span several "
"client request/response cycles. It is common to use detached objects to "
"implement application transactions. An alternative, extremely appropriate in "
"two tiered architecture, is to maintain a single open persistence contact "
"(session) for the whole life cycle of the application transaction and simply "
"disconnect from the JDBC connection at the end of each request and reconnect "
"at the beginning of the subsequent request. Never share a single session "
"across more than one application transaction, or you will be working with "
"stale data."
msgstr "" msgstr ""
"为了得到最佳的可伸缩性,数据库事务(Database Transaction)应该尽可能的短。但"
"是,程序常常需要实现长时间运行的<emphasis>“应用程序事务(Application "
"Transaction)”</emphasis>,包含一个从用户的观点来看的原子操作。这个应用程序事"
"务可能跨越多次从用户请求到得到反馈的循环。用脱管对象(与session脱离的对象)来实"
"现应用程序事务是常见的。或者尤其在两层结构中把Hibernate Session从JDBC连接"
"中脱离开下次需要用的时候再连接上。绝不要把一个Session用在多个应用程序事务"
"(Application Transaction)中,否则你的数据可能会过期失效。"
#: index.docbook:148 #. Tag: term
#: best_practices.xml:148
#, no-c-format
msgid "Don't treat exceptions as recoverable." msgid "Don't treat exceptions as recoverable."
msgstr "" msgstr "不要把异常看成可恢复的"
#: index.docbook:150 #. Tag: para
msgid "This is more of a necessary practice than a \"best\" practice. When an exception occurs, roll back the <literal>Transaction</literal> and close the <literal>Session</literal>. If you don't, Hibernate can't guarantee that in-memory state accurately represents persistent state. As a special case of this, do not use <literal>Session.load()</literal> to determine if an instance with the given identifier exists on the database; use <literal>Session.get()</literal> or a query instead." #: best_practices.xml:150
#, no-c-format
msgid ""
"This is more of a necessary practice than a \"best\" practice. When an "
"exception occurs, roll back the <literal>Transaction</literal> and close the "
"<literal>Session</literal>. If you don't, Hibernate can't guarantee that in-"
"memory state accurately represents persistent state. As a special case of "
"this, do not use <literal>Session.load()</literal> to determine if an "
"instance with the given identifier exists on the database; use "
"<literal>Session.get()</literal> or a query instead."
msgstr "" msgstr ""
"这一点甚至比“最佳实践”还要重要,这是“必备常识”。当异常发生的时候,必须要回滚 "
"<literal>Transaction</literal> ,关闭<literal>Session</literal>。如果你不这样"
"做的话Hibernate无法保证内存状态精确的反应持久状态。尤其不要使用"
"<literal>Session.load()</literal>来判断一个给定标识符的对象实例在数据库中是否"
"存在,应该使用<literal>Session.get()</literal>或者进行一次查询."
#: index.docbook:160 #. Tag: term
#: best_practices.xml:160
#, no-c-format
msgid "Prefer lazy fetching for associations." msgid "Prefer lazy fetching for associations."
msgstr "" msgstr "对于关联优先考虑lazy fetching"
#: index.docbook:162 #. Tag: para
msgid "Use eager fetching sparingly. Use proxies and lazy collections for most associations to classes that are not likely to be completely held in the second-level cache. For associations to cached classes, where there is an a extremely high probability of a cache hit, explicitly disable eager fetching using <literal>lazy=\"false\"</literal>. When an join fetching is appropriate to a particular use case, use a query with a <literal>left join fetch</literal>." #: best_practices.xml:162
#, no-c-format
msgid ""
"Use eager fetching sparingly. Use proxies and lazy collections for most "
"associations to classes that are not likely to be completely held in the "
"second-level cache. For associations to cached classes, where there is an a "
"extremely high probability of a cache hit, explicitly disable eager fetching "
"using <literal>lazy=\"false\"</literal>. When an join fetching is "
"appropriate to a particular use case, use a query with a <literal>left join "
"fetch</literal>."
msgstr "" msgstr ""
"谨慎的使用主动抓取(eager fetching)。对于关联来说,若其目标是无法在第二级缓存"
"中完全缓存所有实例的类,应该使用代理(proxies)与/或具有延迟加载属性的集合"
"(lazy collections)。若目标是可以被缓存的,尤其是缓存的命中率非常高的情况下,"
"应该使用<literal>lazy=\"false\"</literal>明确的禁止掉eager fetching。如果那"
"些特殊的确实适合使用join fetch 的场合,请在查询中使用<literal>left join "
"fetch</literal>。"
#: index.docbook:172 #. Tag: term
msgid "Use the <emphasis>open session in view</emphasis> pattern, or a disciplined <emphasis>assembly phase</emphasis> to avoid problems with unfetched data." #: best_practices.xml:172
#, no-c-format
msgid ""
"Use the <emphasis>open session in view</emphasis> pattern, or a disciplined "
"<emphasis>assembly phase</emphasis> to avoid problems with unfetched data."
msgstr "" msgstr ""
"使用<emphasis>open session in view</emphasis>模式,或者执行严格的<emphasis>装"
"配期(assembly phase)</emphasis>策略来避免再次抓取数据带来的问题"
#: index.docbook:177 #. Tag: para
msgid "Hibernate frees the developer from writing tedious <emphasis>Data Transfer Objects</emphasis> (DTO). In a traditional EJB architecture, DTOs serve dual purposes: first, they work around the problem that entity beans are not serializable; second, they implicitly define an assembly phase where all data to be used by the view is fetched and marshalled into the DTOs before returning control to the presentation tier. Hibernate eliminates the first purpose. However, you will still need an assembly phase (think of your business methods as having a strict contract with the presentation tier about what data is available in the detached objects) unless you are prepared to hold the persistence context (the session) open across the view rendering process. This is not a limitation of Hibernate! It is a fundamental requirement of safe transactional data access." #: best_practices.xml:177
#, no-c-format
msgid ""
"Hibernate frees the developer from writing tedious <emphasis>Data Transfer "
"Objects</emphasis> (DTO). In a traditional EJB architecture, DTOs serve dual "
"purposes: first, they work around the problem that entity beans are not "
"serializable; second, they implicitly define an assembly phase where all "
"data to be used by the view is fetched and marshalled into the DTOs before "
"returning control to the presentation tier. Hibernate eliminates the first "
"purpose. However, you will still need an assembly phase (think of your "
"business methods as having a strict contract with the presentation tier "
"about what data is available in the detached objects) unless you are "
"prepared to hold the persistence context (the session) open across the view "
"rendering process. This is not a limitation of Hibernate! It is a "
"fundamental requirement of safe transactional data access."
msgstr "" msgstr ""
"Hibernate让开发者们摆脱了繁琐的<emphasis>Data Transfer Objects</emphasis> "
"(DTO)。在传统的EJB结构中DTO有双重作用首先他们解决了entity bean无法序列"
"化的问题其次他们隐含地定义了一个装配期在此期间所有在view层需要用到的"
"数据都被抓取、集中到了DTO中然后控制才被装到表示层。Hibernate终结了第一个"
"作用。然而,除非你做好了在整个渲染过程中都维护一个打开的持久化上下文(session)"
"的准备,你仍然需要一个装配期(想象一下,你的业务方法与你的表示层有严格的契"
"约数据总是被放置到托管对象中。这并非是Hibernate的限制这是实现安全的事务"
"化数据访问的基本需求。"
#: index.docbook:191 #. Tag: term
#: best_practices.xml:191
#, no-c-format
msgid "Consider abstracting your business logic from Hibernate." msgid "Consider abstracting your business logic from Hibernate."
msgstr "" msgstr "考虑把Hibernate代码从业务逻辑代码中抽象出来"
#: index.docbook:193 #. Tag: para
msgid "Hide (Hibernate) data-access code behind an interface. Combine the <emphasis>DAO</emphasis> and <emphasis>Thread Local Session</emphasis> patterns. You can even have some classes persisted by handcoded JDBC, associated to Hibernate via a <literal>UserType</literal>. (This advice is intended for \"sufficiently large\" applications; it is not appropriate for an application with five tables!)" #: best_practices.xml:193
#, no-c-format
msgid ""
"Hide (Hibernate) data-access code behind an interface. Combine the "
"<emphasis>DAO</emphasis> and <emphasis>Thread Local Session</emphasis> "
"patterns. You can even have some classes persisted by handcoded JDBC, "
"associated to Hibernate via a <literal>UserType</literal>. (This advice is "
"intended for \"sufficiently large\" applications; it is not appropriate for "
"an application with five tables!)"
msgstr "" msgstr ""
"把Hibernate的数据存取代码隐藏到接口(interface)的后面,组合使用<emphasis>DAO</"
"emphasis>和<emphasis>Thread Local Session</emphasis>模式。通过Hibernate的"
"<literal>UserType</literal>你甚至可以用硬编码的JDBC来持久化那些本该被"
"Hibernate持久化的类。 (该建议更适用于规模足够大应用软件中对于那些只有5张表"
"的应用程序并不适合。)"
#: index.docbook:203 #. Tag: term
#: best_practices.xml:203
#, no-c-format
msgid "Don't use exotic association mappings." msgid "Don't use exotic association mappings."
msgstr "" msgstr "不要用怪异的连接映射"
#: index.docbook:205 #. Tag: para
msgid "Good usecases for a real many-to-many associations are rare. Most of the time you need additional information stored in the \"link table\". In this case, it is much better to use two one-to-many associations to an intermediate link class. In fact, we think that most associations are one-to-many and many-to-one, you should be careful when using any other association style and ask yourself if it is really neccessary." #: best_practices.xml:205
#, no-c-format
msgid ""
"Good usecases for a real many-to-many associations are rare. Most of the "
"time you need additional information stored in the \"link table\". In this "
"case, it is much better to use two one-to-many associations to an "
"intermediate link class. In fact, we think that most associations are one-to-"
"many and many-to-one, you should be careful when using any other association "
"style and ask yourself if it is really neccessary."
msgstr "" msgstr ""
"多对多连接用得好的例子实际上相当少见。大多数时候你在“连接表”中需要保存额外的"
"信息。这种情况下,用两个指向中介类的一对多的连接比较好。实际上,我们认为绝大"
"多数的连接是一对多和多对一的,你应该谨慎使用其它连接风格,用之前问自己一句,"
"是否真的必须这么做。"
#: index.docbook:215 #. Tag: term
#: best_practices.xml:215
#, no-c-format
msgid "Prefer bidirectional associations." msgid "Prefer bidirectional associations."
msgstr "偏爱双向关联"
#. Tag: para
#: best_practices.xml:217
#, no-c-format
msgid ""
"Unidirectional associations are more difficult to query. In a large "
"application, almost all associations must be navigable in both directions in "
"queries."
msgstr "" msgstr ""
"单向关联更加难于查询。在大型应用中,几乎所有的关联必须在查询中可以双向导航。"
#: index.docbook:217
msgid "Unidirectional associations are more difficult to query. In a large application, almost all associations must be navigable in both directions in queries."
msgstr ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,26 +1,54 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: component_mapping.xml:5
#, no-c-format
msgid "Component Mapping" msgid "Component Mapping"
msgstr "" msgstr "组件Component映射"
#: index.docbook:7 #. Tag: para
msgid "The notion of a <emphasis>component</emphasis> is re-used in several different contexts, for different purposes, throughout Hibernate." #: component_mapping.xml:7
#, no-c-format
msgid ""
"The notion of a <emphasis>component</emphasis> is re-used in several "
"different contexts, for different purposes, throughout Hibernate."
msgstr "" msgstr ""
"<emphasis>组件</emphasis>(Component)这个概念在Hibernate中几处不同的地方为了不"
"同的目的被重复使用."
#: index.docbook:13 #. Tag: title
#: component_mapping.xml:13
#, no-c-format
msgid "Dependent objects" msgid "Dependent objects"
msgstr "" msgstr "依赖对象Dependent objects"
#: index.docbook:15 #. Tag: para
msgid "A component is a contained object that is persisted as a value type, not an entity reference. The term \"component\" refers to the object-oriented notion of composition (not to architecture-level components). For example, you might model a person like this:" #: component_mapping.xml:15
#, no-c-format
msgid ""
"A component is a contained object that is persisted as a value type, not an "
"entity reference. The term \"component\" refers to the object-oriented "
"notion of composition (not to architecture-level components). For example, "
"you might model a person like this:"
msgstr "" msgstr ""
"组件(Component)是一个被包含的对象,在持久化的过程中,它被当作值类型,而并非一"
"个实体的引用。在这篇文档中,组件这一术语指的是面向对象的合成概念(而并不是系"
"统构架层次上的组件的概念)。举个例子, 你对人(Person)这个概念可以像下面这样来"
"建模:"
#: index.docbook:21 #. Tag: programlisting
#: component_mapping.xml:21
#, no-c-format
msgid "" msgid ""
"<![CDATA[public class Person {\n" "<![CDATA[public class Person {\n"
" private java.util.Date birthday;\n" " private java.util.Date birthday;\n"
@ -49,7 +77,9 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:23 #. Tag: programlisting
#: component_mapping.xml:23
#, no-c-format
msgid "" msgid ""
"<![CDATA[public class Name {\n" "<![CDATA[public class Name {\n"
" char initial;\n" " char initial;\n"
@ -76,22 +106,36 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:25 #. Tag: para
msgid "Now <literal>Name</literal> may be persisted as a component of <literal>Person</literal>. Notice that <literal>Name</literal> defines getter and setter methods for its persistent properties, but doesn't need to declare any interfaces or identifier properties." #: component_mapping.xml:25
#, no-c-format
msgid ""
"Now <literal>Name</literal> may be persisted as a component of "
"<literal>Person</literal>. Notice that <literal>Name</literal> defines "
"getter and setter methods for its persistent properties, but doesn't need to "
"declare any interfaces or identifier properties."
msgstr "" msgstr ""
"在持久化的过程中,<literal>姓名(Name)</literal>可以作为<literal>人(Person)</"
"literal>的一个组件。需要注意的是:你应该为<literal>姓名</literal>的持久化属性"
"定义getter和setter方法,但是你不需要实现任何的接口或申明标识符字段。"
#: index.docbook:32 #. Tag: para
#: component_mapping.xml:32
#, no-c-format
msgid "Our Hibernate mapping would look like:" msgid "Our Hibernate mapping would look like:"
msgstr "" msgstr "以下是这个例子的Hibernate映射文件:"
#: index.docbook:36 #. Tag: programlisting
#: component_mapping.xml:36
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n" "<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
" <id name=\"Key\" column=\"pid\" type=\"string\">\n" " <id name=\"Key\" column=\"pid\" type=\"string\">\n"
" <generator class=\"uuid\"/>\n" " <generator class=\"uuid\"/>\n"
" </id>\n" " </id>\n"
" <property name=\"birthday\" type=\"date\"/>\n" " <property name=\"birthday\" type=\"date\"/>\n"
" <component name=\"Name\" class=\"eg.Name\"> <!-- class attribute optional -->\n" " <component name=\"Name\" class=\"eg.Name\"> <!-- class attribute "
"optional -->\n"
" <property name=\"initial\"/>\n" " <property name=\"initial\"/>\n"
" <property name=\"first\"/>\n" " <property name=\"first\"/>\n"
" <property name=\"last\"/>\n" " <property name=\"last\"/>\n"
@ -99,23 +143,64 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:38 #. Tag: para
msgid "The person table would have the columns <literal>pid</literal>, <literal>birthday</literal>, <literal>initial</literal>, <literal>first</literal> and <literal>last</literal>." #: component_mapping.xml:38
#, no-c-format
msgid ""
"The person table would have the columns <literal>pid</literal>, "
"<literal>birthday</literal>, <literal>initial</literal>, <literal>first</"
"literal> and <literal>last</literal>."
msgstr "" msgstr ""
"人员(Person)表中将包括<literal>pid</literal>, <literal>birthday</literal>, "
"<literal>initial</literal>, <literal>first</literal>和 <literal>last</"
"literal>等字段。"
#: index.docbook:46 #. Tag: para
msgid "Like all value types, components do not support shared references. In other words, two persons could have the same name, but the two person objects would contain two independent name ojects, only \"the same\" by value. The null value semantics of a component are <emphasis>ad hoc</emphasis>. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This should be okay for most purposes." #: component_mapping.xml:46
#, no-c-format
msgid ""
"Like all value types, components do not support shared references. In other "
"words, two persons could have the same name, but the two person objects "
"would contain two independent name ojects, only \"the same\" by value. The "
"null value semantics of a component are <emphasis>ad hoc</emphasis>. When "
"reloading the containing object, Hibernate will assume that if all component "
"columns are null, then the entire component is null. This should be okay for "
"most purposes."
msgstr "" msgstr ""
"就像所有的值类型一样, 组件不支持共享引用。 换句话说,两个人可能重名,但是两个"
"Person对象应该包含两个独立的Name对象只不过这两个Name对象具有“同样”的值。 组"
"件的值可以为空,其定义如下。 每当Hibernate重新加载一个包含组件的对象,如果该组"
"件的所有字段为空Hibernate将假定整个组件为空。 在大多数情况下,这样假定应该是"
"没有问题的。"
#: index.docbook:55 #. Tag: para
msgid "The properties of a component may be of any Hibernate type (collections, many-to-one associations, other components, etc). Nested components should <emphasis>not</emphasis> be considered an exotic usage. Hibernate is intended to support a very fine-grained object model." #: component_mapping.xml:55
#, no-c-format
msgid ""
"The properties of a component may be of any Hibernate type (collections, "
"many-to-one associations, other components, etc). Nested components should "
"<emphasis>not</emphasis> be considered an exotic usage. Hibernate is "
"intended to support a very fine-grained object model."
msgstr "" msgstr ""
"组件的属性可以是任意一种Hibernate类型包括集合, 多对多关联, 以及其它组件等"
"等)。嵌套组件不应该被当作一种特殊的应用(Nested components should not be "
"considered an exotic usage)。 Hibernate倾向于支持细致的(fine-grained)对象模"
"型。"
#: index.docbook:62 #. Tag: para
msgid "The <literal>&lt;component&gt;</literal> element allows a <literal>&lt;parent&gt;</literal> subelement that maps a property of the component class as a reference back to the containing entity." #: component_mapping.xml:62
#, no-c-format
msgid ""
"The <literal>&lt;component&gt;</literal> element allows a <literal>&lt;"
"parent&gt;</literal> subelement that maps a property of the component class "
"as a reference back to the containing entity."
msgstr "" msgstr ""
"<literal>&lt;component&gt;</literal> 元素还允许有 <literal>&lt;parent&gt;</"
"literal>子元素用来表明component类中的一个属性是指向包含它的实体的引用。"
#: index.docbook:68 #. Tag: programlisting
#: component_mapping.xml:68
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n" "<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
" <id name=\"Key\" column=\"pid\" type=\"string\">\n" " <id name=\"Key\" column=\"pid\" type=\"string\">\n"
@ -123,7 +208,8 @@ msgid ""
" </id>\n" " </id>\n"
" <property name=\"birthday\" type=\"date\"/>\n" " <property name=\"birthday\" type=\"date\"/>\n"
" <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n" " <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n"
" <parent name=\"namedPerson\"/> <!-- reference back to the Person -->\n" " <parent name=\"namedPerson\"/> <!-- reference back to the Person --"
">\n"
" <property name=\"initial\"/>\n" " <property name=\"initial\"/>\n"
" <property name=\"first\"/>\n" " <property name=\"first\"/>\n"
" <property name=\"last\"/>\n" " <property name=\"last\"/>\n"
@ -131,15 +217,28 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:73 #. Tag: title
#: component_mapping.xml:73
#, no-c-format
msgid "Collections of dependent objects" msgid "Collections of dependent objects"
msgstr "" msgstr "在集合中出现的依赖对象 (Collections of dependent objects)"
#: index.docbook:75 #. Tag: para
msgid "Collections of components are supported (eg. an array of type <literal>Name</literal>). Declare your component collection by replacing the <literal>&lt;element&gt;</literal> tag with a <literal>&lt;composite-element&gt;</literal> tag." #: component_mapping.xml:75
#, no-c-format
msgid ""
"Collections of components are supported (eg. an array of type <literal>Name</"
"literal>). Declare your component collection by replacing the <literal>&lt;"
"element&gt;</literal> tag with a <literal>&lt;composite-element&gt;</"
"literal> tag."
msgstr "" msgstr ""
"Hibernate支持组件的集合(例如: 一个元素是姓名(Name)这种类型的数组)。 你可以使"
"用<literal>&lt;composite-element&gt;</literal>标签替代<literal>&lt;"
"element&gt;</literal>标签来定义你的组件集合。"
#: index.docbook:82 #. Tag: programlisting
#: component_mapping.xml:82
#, no-c-format
msgid "" msgid ""
"<![CDATA[<set name=\"someNames\" table=\"some_names\" lazy=\"true\">\n" "<![CDATA[<set name=\"someNames\" table=\"some_names\" lazy=\"true\">\n"
" <key column=\"id\"/>\n" " <key column=\"id\"/>\n"
@ -151,23 +250,81 @@ msgid ""
"</set>]]>" "</set>]]>"
msgstr "" msgstr ""
#: index.docbook:84 #. Tag: para
msgid "Note: if you define a <literal>Set</literal> of composite elements, it is very important to implement <literal>equals()</literal> and <literal>hashCode()</literal> correctly." #: component_mapping.xml:84
#, no-c-format
msgid ""
"Note: if you define a <literal>Set</literal> of composite elements, it is "
"very important to implement <literal>equals()</literal> and <literal>hashCode"
"()</literal> correctly."
msgstr "" msgstr ""
"注意如果你定义的Set包含组合元素(composite-element),正确地实现"
"<literal>equals()</literal>和<literal>hashCode()</literal>是非常重要的。"
#: index.docbook:90 #. Tag: para
msgid "Composite elements may contain components but not collections. If your composite element itself contains components, use the <literal>&lt;nested-composite-element&gt;</literal> tag. This is a pretty exotic case - a collection of components which themselves have components. By this stage you should be asking yourself if a one-to-many association is more appropriate. Try remodelling the composite element as an entity - but note that even though the Java model is the same, the relational model and persistence semantics are still slightly different." #: component_mapping.xml:90
#, no-c-format
msgid ""
"Composite elements may contain components but not collections. If your "
"composite element itself contains components, use the <literal>&lt;nested-"
"composite-element&gt;</literal> tag. This is a pretty exotic case - a "
"collection of components which themselves have components. By this stage you "
"should be asking yourself if a one-to-many association is more appropriate. "
"Try remodelling the composite element as an entity - but note that even "
"though the Java model is the same, the relational model and persistence "
"semantics are still slightly different."
msgstr "" msgstr ""
"组合元素可以包含组件,但是不能包含集合。如果你的组合元素自身包含组件, 你必须"
"使用<literal>&lt;nested-composite-element&gt;</literal>标签。这是一个相当特殊"
"的案例 - 在一个组件的集合里,那些组件本身又可以包含其他的组件。这个时候你就应"
"该考虑一下使用one-to-many关联是否会更恰当。 尝试对这个组合元素重新建模为一个"
"实体但是需要注意的是虽然Java模型和重新建模前是一样的关系模型和持久性语"
"义会有细微的变化。"
#: index.docbook:102 #. Tag: para
msgid "Please note that a composite element mapping doesn't support null-able properties if you're using a <literal>&lt;set&gt;</literal>. Hibernate has to use each columns value to identify a record when deleting objects (there is no separate primary key column in the composite element table), which is not possible with null values. You have to either use only not-null properties in a composite-element or choose a <literal>&lt;list&gt;</literal>, <literal>&lt;map&gt;</literal>, <literal>&lt;bag&gt;</literal> or <literal>&lt;idbag&gt;</literal>." #: component_mapping.xml:102
#, no-c-format
msgid ""
"Please note that a composite element mapping doesn't support null-able "
"properties if you're using a <literal>&lt;set&gt;</literal>. Hibernate has "
"to use each columns value to identify a record when deleting objects (there "
"is no separate primary key column in the composite element table), which is "
"not possible with null values. You have to either use only not-null "
"properties in a composite-element or choose a <literal>&lt;list&gt;</"
"literal>, <literal>&lt;map&gt;</literal>, <literal>&lt;bag&gt;</literal> or "
"<literal>&lt;idbag&gt;</literal>."
msgstr "" msgstr ""
"请注意如果你使用<literal>&lt;set&gt;</literal>标签,一个组合元素的映射不支持可"
"能为空的属性. 当删除对象时, Hibernate必须使用每一个字段的值来确定一条记录(在"
"组合元素表中,没有单独的关键字段) 如果有为null的字段这样做就不可能了。你"
"必须作出一个选择,要么在组合元素中使用不能为空的属性,要么选择使用"
"<literal>&lt;list&gt;</literal>,<literal>&lt;map&gt;</literal>,<literal>&lt;"
"bag&gt;</literal> 或者 <literal>&lt;idbag&gt;</literal>而不是 <literal>&lt;"
"set&gt;</literal>。"
#: index.docbook:113 #. Tag: para
msgid "A special case of a composite element is a composite element with a nested <literal>&lt;many-to-one&gt;</literal> element. A mapping like this allows you to map extra columns of a many-to-many association table to the composite element class. The following is a many-to-many association from <literal>Order</literal> to <literal>Item</literal> where <literal>purchaseDate</literal>, <literal>price</literal> and <literal>quantity</literal> are properties of the association:" #: component_mapping.xml:113
#, no-c-format
msgid ""
"A special case of a composite element is a composite element with a nested "
"<literal>&lt;many-to-one&gt;</literal> element. A mapping like this allows "
"you to map extra columns of a many-to-many association table to the "
"composite element class. The following is a many-to-many association from "
"<literal>Order</literal> to <literal>Item</literal> where "
"<literal>purchaseDate</literal>, <literal>price</literal> and "
"<literal>quantity</literal> are properties of the association:"
msgstr "" msgstr ""
"组合元素有个特别的用法是它可以包含一个<literal>&lt;many-to-one&gt;</literal>"
"元素。类似这样的映射允许你将一个many-to-many关联表映射为组合元素的集合。(A "
"mapping like this allows you to map extra columns of a many-to-many "
"association table to the composite element class.) 接下来的的例子是从"
"<literal>Order</literal>到<literal>Item</literal>的一个多对多的关联关系, 关联"
"属性是 <literal>purchaseDate</literal>, <literal>price</literal> 和 "
"<literal>quantity</literal> 。"
#: index.docbook:123 #. Tag: programlisting
#: component_mapping.xml:123
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"eg.Order\" .... >\n" "<![CDATA[<class name=\"eg.Order\" .... >\n"
" ....\n" " ....\n"
@ -177,21 +334,37 @@ msgid ""
" <property name=\"purchaseDate\"/>\n" " <property name=\"purchaseDate\"/>\n"
" <property name=\"price\"/>\n" " <property name=\"price\"/>\n"
" <property name=\"quantity\"/>\n" " <property name=\"quantity\"/>\n"
" <many-to-one name=\"item\" class=\"eg.Item\"/> <!-- class attribute is optional -->\n" " <many-to-one name=\"item\" class=\"eg.Item\"/> <!-- class "
"attribute is optional -->\n"
" </composite-element>\n" " </composite-element>\n"
" </set>\n" " </set>\n"
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:125 #. Tag: para
msgid "Of course, there can't be a reference to the purchae on the other side, for bidirectional association navigation. Remember that components are value types and don't allow shared references. A single <literal>Purchase</literal> can be in the set of an <literal>Order</literal>, but it can't be referenced by the <literal>Item</literal> at the same time." #: component_mapping.xml:125
#, no-c-format
msgid ""
"Of course, there can't be a reference to the purchae on the other side, for "
"bidirectional association navigation. Remember that components are value "
"types and don't allow shared references. A single <literal>Purchase</"
"literal> can be in the set of an <literal>Order</literal>, but it can't be "
"referenced by the <literal>Item</literal> at the same time."
msgstr "" msgstr ""
"当然当你定义Item时你无法引用这些purchase因此你无法实现双向关联查询。记"
"住组件是值类型,并且不允许共享引用。某一个特定的<literal>Purchase</literal> "
"可以放在<literal>Order</literal>的集合中,但它不能同时被<literal>Item</"
"literal>所引用。"
#: index.docbook:133 #. Tag: para
#: component_mapping.xml:133
#, no-c-format
msgid "Even ternary (or quaternary, etc) associations are possible:" msgid "Even ternary (or quaternary, etc) associations are possible:"
msgstr "" msgstr "其实组合元素的这个用法可以扩展到三重或多重关联:"
#: index.docbook:135 #. Tag: programlisting
#: component_mapping.xml:135
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"eg.Order\" .... >\n" "<![CDATA[<class name=\"eg.Order\" .... >\n"
" ....\n" " ....\n"
@ -205,47 +378,101 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:137 #. Tag: para
msgid "Composite elements may appear in queries using the same syntax as associations to other entities." #: component_mapping.xml:137
msgstr "" #, no-c-format
msgid ""
"Composite elements may appear in queries using the same syntax as "
"associations to other entities."
msgstr "在查询中,表达组合元素的语法和关联到其他实体的语法是一样的。"
#: index.docbook:145 #. Tag: title
#: component_mapping.xml:145
#, no-c-format
msgid "Components as Map indices" msgid "Components as Map indices"
msgstr "" msgstr "组件作为Map的索引Components as Map indices "
#: index.docbook:147 #. Tag: para
msgid "The <literal>&lt;composite-map-key&gt;</literal> element lets you map a component class as the key of a <literal>Map</literal>. Make sure you override <literal>hashCode()</literal> and <literal>equals()</literal> correctly on the component class." #: component_mapping.xml:147
#, no-c-format
msgid ""
"The <literal>&lt;composite-map-key&gt;</literal> element lets you map a "
"component class as the key of a <literal>Map</literal>. Make sure you "
"override <literal>hashCode()</literal> and <literal>equals()</literal> "
"correctly on the component class."
msgstr "" msgstr ""
"<literal>&lt;composite-map-key&gt;</literal>元素允许你映射一个组件类作为一个"
"<literal>Map</literal>的key前提是你必须正确的在这个类中重写了"
"<literal>hashCode()</literal> 和 <literal>equals()</literal>方法。"
#: index.docbook:156 #. Tag: title
#: component_mapping.xml:156
#, no-c-format
msgid "Components as composite identifiers" msgid "Components as composite identifiers"
msgstr "" msgstr "组件作为联合标识符(Components as composite identifiers)"
#: index.docbook:158 #. Tag: para
msgid "You may use a component as an identifier of an entity class. Your component class must satisfy certain requirements:" #: component_mapping.xml:158
#, no-c-format
msgid ""
"You may use a component as an identifier of an entity class. Your component "
"class must satisfy certain requirements:"
msgstr "" msgstr ""
"你可以使用一个组件作为一个实体类的标识符。 你的组件类必须满足以下要求:"
#: index.docbook:165 #. Tag: para
#: component_mapping.xml:165
#, no-c-format
msgid "It must implement <literal>java.io.Serializable</literal>." msgid "It must implement <literal>java.io.Serializable</literal>."
msgstr "" msgstr "它必须实现<literal>java.io.Serializable</literal>接口"
#: index.docbook:170 #. Tag: para
msgid "It must re-implement <literal>equals()</literal> and <literal>hashCode()</literal>, consistently with the database's notion of composite key equality." #: component_mapping.xml:170
#, no-c-format
msgid ""
"It must re-implement <literal>equals()</literal> and <literal>hashCode()</"
"literal>, consistently with the database's notion of composite key equality."
msgstr "" msgstr ""
"它必须重新实现<literal>equals()</literal>和<literal>hashCode()</literal>方"
"法, 始终和组合关键字在数据库中的概念保持一致"
#: index.docbook:179 #. Tag: emphasis
msgid "Note: in Hibernate3, the second requirement is not an absolutely hard requirement of Hibernate. But do it anyway." #: component_mapping.xml:179
#, no-c-format
msgid ""
"Note: in Hibernate3, the second requirement is not an absolutely hard "
"requirement of Hibernate. But do it anyway."
msgstr "" msgstr ""
"注意在Hibernate3中第二个要求并非是Hibernate强制必须的。但最好这样做。"
#: index.docbook:183 #. Tag: para
msgid "You can't use an <literal>IdentifierGenerator</literal> to generate composite keys. Instead the application must assign its own identifiers." #: component_mapping.xml:183
#, no-c-format
msgid ""
"You can't use an <literal>IdentifierGenerator</literal> to generate "
"composite keys. Instead the application must assign its own identifiers."
msgstr "" msgstr ""
"你不能使用一个<literal>IdentifierGenerator</literal>产生组合关键字。一个应用"
"程序必须分配它自己的标识符。"
#: index.docbook:188 #. Tag: para
msgid "Use the <literal>&lt;composite-id&gt;</literal> tag (with nested <literal>&lt;key-property&gt;</literal> elements) in place of the usual <literal>&lt;id&gt;</literal> declaration. For example, the <literal>OrderLine</literal> class has a primary key that depends upon the (composite) primary key of <literal>Order</literal>." #: component_mapping.xml:188
#, no-c-format
msgid ""
"Use the <literal>&lt;composite-id&gt;</literal> tag (with nested "
"<literal>&lt;key-property&gt;</literal> elements) in place of the usual "
"<literal>&lt;id&gt;</literal> declaration. For example, the "
"<literal>OrderLine</literal> class has a primary key that depends upon the "
"(composite) primary key of <literal>Order</literal>."
msgstr "" msgstr ""
"使用<literal>&lt;composite-id&gt;</literal> 标签(并且内嵌<literal>&lt;key-"
"property&gt;</literal>元素)代替通常的<literal>&lt;id&gt;</literal>标签。比如,"
"<literal>OrderLine</literal>类具有一个主键,这个主键依赖于<literal>Order</"
"literal>的(联合)主键。"
#: index.docbook:196 #. Tag: programlisting
#: component_mapping.xml:196
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"OrderLine\">\n" "<![CDATA[<class name=\"OrderLine\">\n"
" \n" " \n"
@ -267,11 +494,21 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:198 #. Tag: para
msgid "Now, any foreign keys referencing the <literal>OrderLine</literal> table are also composite. You must declare this in your mappings for other classes. An association to <literal>OrderLine</literal> would be mapped like this:" #: component_mapping.xml:198
#, no-c-format
msgid ""
"Now, any foreign keys referencing the <literal>OrderLine</literal> table are "
"also composite. You must declare this in your mappings for other classes. An "
"association to <literal>OrderLine</literal> would be mapped like this:"
msgstr "" msgstr ""
"现在,任何指向<literal>OrderLine</literal>的外键都是复合的。在你的映射文件"
"中,必须为其他类也这样声明。例如,一个指向<literal>OrderLine</literal>的关联"
"可能被这样映射:"
#: index.docbook:204 #. Tag: programlisting
#: component_mapping.xml:204
#, no-c-format
msgid "" msgid ""
"<![CDATA[<many-to-one name=\"orderLine\" class=\"OrderLine\">\n" "<![CDATA[<many-to-one name=\"orderLine\" class=\"OrderLine\">\n"
"<!-- the \"class\" attribute is optional, as usual -->\n" "<!-- the \"class\" attribute is optional, as usual -->\n"
@ -281,15 +518,29 @@ msgid ""
"</many-to-one>]]>" "</many-to-one>]]>"
msgstr "" msgstr ""
#: index.docbook:206 #. Tag: para
msgid "(Note that the <literal>&lt;column&gt;</literal> tag is an alternative to the <literal>column</literal> attribute everywhere.)" #: component_mapping.xml:206
#, no-c-format
msgid ""
"(Note that the <literal>&lt;column&gt;</literal> tag is an alternative to "
"the <literal>column</literal> attribute everywhere.)"
msgstr "" msgstr ""
"(注意在各个地方<literal>&lt;column&gt;</literal>标签都是<literal>column</"
"literal>属性的替代写法。)"
#: index.docbook:211 #. Tag: para
msgid "A <literal>many-to-many</literal> association to <literal>OrderLine</literal> also uses the composite foreign key:" #: component_mapping.xml:211
#, no-c-format
msgid ""
"A <literal>many-to-many</literal> association to <literal>OrderLine</"
"literal> also uses the composite foreign key:"
msgstr "" msgstr ""
"指向<literal>OrderLine</literal>的<literal>多对多</literal>关联也使用联合外"
"键:"
#: index.docbook:216 #. Tag: programlisting
#: component_mapping.xml:216
#, no-c-format
msgid "" msgid ""
"<![CDATA[<set name=\"undeliveredOrderLines\">\n" "<![CDATA[<set name=\"undeliveredOrderLines\">\n"
" <key column name=\"warehouseId\"/>\n" " <key column name=\"warehouseId\"/>\n"
@ -301,11 +552,18 @@ msgid ""
"</set>]]>" "</set>]]>"
msgstr "" msgstr ""
#: index.docbook:218 #. Tag: para
msgid "The collection of <literal>OrderLine</literal>s in <literal>Order</literal> would use:" #: component_mapping.xml:218
#, no-c-format
msgid ""
"The collection of <literal>OrderLine</literal>s in <literal>Order</literal> "
"would use:"
msgstr "" msgstr ""
"在<literal>Order</literal>中,<literal>OrderLine</literal>的集合则是这样:"
#: index.docbook:223 #. Tag: programlisting
#: component_mapping.xml:223
#, no-c-format
msgid "" msgid ""
"<![CDATA[<set name=\"orderLines\" inverse=\"true\">\n" "<![CDATA[<set name=\"orderLines\" inverse=\"true\">\n"
" <key>\n" " <key>\n"
@ -316,15 +574,25 @@ msgid ""
"</set>]]>" "</set>]]>"
msgstr "" msgstr ""
#: index.docbook:225 #. Tag: para
msgid "(The <literal>&lt;one-to-many&gt;</literal> element, as usual, declares no columns.)" #: component_mapping.xml:225
msgstr "" #, no-c-format
msgid ""
"(The <literal>&lt;one-to-many&gt;</literal> element, as usual, declares no "
"columns.)"
msgstr "(与通常一样,<literal>&lt;one-to-many&gt;</literal>元素不声明任何列.)"
#: index.docbook:229 #. Tag: para
msgid "If <literal>OrderLine</literal> itself owns a collection, it also has a composite foreign key." #: component_mapping.xml:229
msgstr "" #, no-c-format
msgid ""
"If <literal>OrderLine</literal> itself owns a collection, it also has a "
"composite foreign key."
msgstr "假若<literal>OrderLine</literal>本身拥有一个集合,它也具有组合外键。"
#: index.docbook:234 #. Tag: programlisting
#: component_mapping.xml:234
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"OrderLine\">\n" "<![CDATA[<class name=\"OrderLine\">\n"
" ....\n" " ....\n"
@ -343,15 +611,21 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:239 #. Tag: title
#: component_mapping.xml:239
#, no-c-format
msgid "Dynamic components" msgid "Dynamic components"
msgstr "" msgstr "动态组件 Dynamic components"
#: index.docbook:241 #. Tag: para
#: component_mapping.xml:241
#, no-c-format
msgid "You may even map a property of type <literal>Map</literal>:" msgid "You may even map a property of type <literal>Map</literal>:"
msgstr "" msgstr "你甚至可以映射<literal>Map</literal>类型的属性:"
#: index.docbook:245 #. Tag: programlisting
#: component_mapping.xml:245
#, no-c-format
msgid "" msgid ""
"<![CDATA[<dynamic-component name=\"userAttributes\">\n" "<![CDATA[<dynamic-component name=\"userAttributes\">\n"
" <property name=\"foo\" column=\"FOO\" type=\"string\"/>\n" " <property name=\"foo\" column=\"FOO\" type=\"string\"/>\n"
@ -360,13 +634,20 @@ msgid ""
"</dynamic-component>]]>" "</dynamic-component>]]>"
msgstr "" msgstr ""
#: index.docbook:247 #. Tag: para
msgid "The semantics of a <literal>&lt;dynamic-component&gt;</literal> mapping are identical to <literal>&lt;component&gt;</literal>. The advantage of this kind of mapping is the ability to determine the actual properties of the bean at deployment time, just by editing the mapping document. Runtime manipulation of the mapping document is also possible, using a DOM parser. Even better, you can access (and change) Hibernate's configuration-time metamodel via the <literal>Configuration</literal> object." #: component_mapping.xml:247
#, no-c-format
msgid ""
"The semantics of a <literal>&lt;dynamic-component&gt;</literal> mapping are "
"identical to <literal>&lt;component&gt;</literal>. The advantage of this "
"kind of mapping is the ability to determine the actual properties of the "
"bean at deployment time, just by editing the mapping document. Runtime "
"manipulation of the mapping document is also possible, using a DOM parser. "
"Even better, you can access (and change) Hibernate's configuration-time "
"metamodel via the <literal>Configuration</literal> object."
msgstr "" msgstr ""
"从<literal>&lt;dynamic-component&gt;</literal>映射的语义上来讲,它和"
msgid "ROLES_OF_TRANSLATORS" "<literal>&lt;component&gt;</literal>是相同的。 这种映射类型的优点在于通过修改"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->" "映射文件就可以具有在部署时检测真实属性的能力。利用一个DOM解析器也可以在程"
"序运行时操作映射文件。 更好的是,你可以通过<literal>Configuration</literal>对"
msgid "CREDIT_FOR_TRANSLATORS" "象来访问或者修改Hibernate的运行时元模型。"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,30 +1,74 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: events.xml:5
#, no-c-format
msgid "Interceptors and events" msgid "Interceptors and events"
msgstr "" msgstr "拦截器与事件(Interceptors and events)"
#: index.docbook:7 #. Tag: para
msgid "It is often useful for the application to react to certain events that occur inside Hibernate. This allows implementation of certain kinds of generic functionality, and extension of Hibernate functionality." #: events.xml:7
#, no-c-format
msgid ""
"It is often useful for the application to react to certain events that occur "
"inside Hibernate. This allows implementation of certain kinds of generic "
"functionality, and extension of Hibernate functionality."
msgstr "" msgstr ""
"应用程序能够响应Hibernate内部产生的特定事件是非常有用的。这样就允许实现某些通"
"用的功能 以及允许对Hibernate功能进行扩展。"
#: index.docbook:14 #. Tag: title
#: events.xml:14
#, no-c-format
msgid "Interceptors" msgid "Interceptors"
msgstr "" msgstr "拦截器(Interceptors)"
#: index.docbook:16 #. Tag: para
msgid "The <literal>Interceptor</literal> interface provides callbacks from the session to the application allowing the application to inspect and/or manipulate properties of a persistent object before it is saved, updated, deleted or loaded. One possible use for this is to track auditing information. For example, the following <literal>Interceptor</literal> automatically sets the <literal>createTimestamp</literal> when an <literal>Auditable</literal> is created and updates the <literal>lastUpdateTimestamp</literal> property when an <literal>Auditable</literal> is updated." #: events.xml:16
#, no-c-format
msgid ""
"The <literal>Interceptor</literal> interface provides callbacks from the "
"session to the application allowing the application to inspect and/or "
"manipulate properties of a persistent object before it is saved, updated, "
"deleted or loaded. One possible use for this is to track auditing "
"information. For example, the following <literal>Interceptor</literal> "
"automatically sets the <literal>createTimestamp</literal> when an "
"<literal>Auditable</literal> is created and updates the "
"<literal>lastUpdateTimestamp</literal> property when an <literal>Auditable</"
"literal> is updated."
msgstr "" msgstr ""
"<literal>Interceptor</literal>接口提供了从会话(session)回调(callback)应用程序"
"(application)的机制, 这种回调机制可以允许应用程序在持久化对象被保存、更新、"
"删除或是加载之前,检查并(或)修改其 属性。一个可能的用途,就是用来跟踪审核"
"(auditing)信息。例如:下面的这个<literal>拦截器</literal>,会在一个实现了 "
"<literal>Auditable</literal>接口的对象被创建时自动地设置"
"<literal>createTimestamp</literal>属性,并在实现了 <literal>Auditable</"
"literal>接口的对象被更新时,同步更新<literal>lastUpdateTimestamp</literal>属"
"性。"
#: index.docbook:27 #. Tag: para
msgid "You may either implement <literal>Interceptor</literal> directly or (better) extend <literal>EmptyInterceptor</literal>." #: events.xml:27
#, no-c-format
msgid ""
"You may either implement <literal>Interceptor</literal> directly or (better) "
"extend <literal>EmptyInterceptor</literal>."
msgstr "" msgstr ""
"你可以直接实现<literal>Interceptor</literal>接口,也可以(最好)继承自"
"<literal>EmptyInterceptor</literal>。"
#: index.docbook:32 #. Tag: programlisting
#: events.xml:32
#, no-c-format
msgid "" msgid ""
"<![CDATA[package org.hibernate.test;\n" "<![CDATA[package org.hibernate.test;\n"
"\n" "\n"
@ -100,7 +144,8 @@ msgid ""
"\n" "\n"
" public void afterTransactionCompletion(Transaction tx) {\n" " public void afterTransactionCompletion(Transaction tx) {\n"
" if ( tx.wasCommitted() ) {\n" " if ( tx.wasCommitted() ) {\n"
" System.out.println(\"Creations: \" + creates + \", Updates: \" + updates, \"Loads: \" + loads);\n" " System.out.println(\"Creations: \" + creates + \", Updates: \" + "
"updates, \"Loads: \" + loads);\n"
" }\n" " }\n"
" updates=0;\n" " updates=0;\n"
" creates=0;\n" " creates=0;\n"
@ -110,136 +155,303 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:34 #. Tag: para
msgid "Interceptors come in two flavors: <literal>Session</literal>-scoped and <literal>SessionFactory</literal>-scoped." #: events.xml:34
#, no-c-format
msgid ""
"Interceptors come in two flavors: <literal>Session</literal>-scoped and "
"<literal>SessionFactory</literal>-scoped."
msgstr "" msgstr ""
"拦截器可以有两种:<literal>Session</literal>范围内的,和"
"<literal>SessionFactory</literal>范围内的。"
#: index.docbook:39 #. Tag: para
msgid "A <literal>Session</literal>-scoped interceptor is specified when a session is opened using one of the overloaded SessionFactory.openSession() methods accepting an <literal>Interceptor</literal>." #: events.xml:39
#, no-c-format
msgid ""
"A <literal>Session</literal>-scoped interceptor is specified when a session "
"is opened using one of the overloaded SessionFactory.openSession() methods "
"accepting an <literal>Interceptor</literal>."
msgstr "" msgstr ""
"当使用某个重载的SessionFactory.openSession()使用<literal>Interceptor</"
"literal>作为参数调用打开一个session的时候就指定了<literal>Session</literal>"
"范围内的拦截器。"
#: index.docbook:45 #. Tag: programlisting
#: events.xml:45
#, no-c-format
msgid "<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>" msgid "<![CDATA[Session session = sf.openSession( new AuditInterceptor() );]]>"
msgstr "" msgstr ""
#: index.docbook:47 #. Tag: para
msgid "A <literal>SessionFactory</literal>-scoped interceptor is registered with the <literal>Configuration</literal> object prior to building the <literal>SessionFactory</literal>. In this case, the supplied interceptor will be applied to all sessions opened from that <literal>SessionFactory</literal>; this is true unless a session is opened explicitly specifying the interceptor to use. <literal>SessionFactory</literal>-scoped interceptors must be thread safe, taking care to not store session-specific state since multiple sessions will use this interceptor (potentially) concurrently." #: events.xml:47
#, no-c-format
msgid ""
"A <literal>SessionFactory</literal>-scoped interceptor is registered with "
"the <literal>Configuration</literal> object prior to building the "
"<literal>SessionFactory</literal>. In this case, the supplied interceptor "
"will be applied to all sessions opened from that <literal>SessionFactory</"
"literal>; this is true unless a session is opened explicitly specifying the "
"interceptor to use. <literal>SessionFactory</literal>-scoped interceptors "
"must be thread safe, taking care to not store session-specific state since "
"multiple sessions will use this interceptor (potentially) concurrently."
msgstr ""
"<literal>SessionFactory</literal>范围内的拦截器要通过<literal>Configuration</"
"literal>中注册,而这必须在创建<literal>SessionFactory</literal>之前。在这种情"
"况下,给出的拦截器会被这个<literal>SessionFactory</literal>所打开的所有"
"session使用了除非session打开时明确指明了使用的拦截器。"
"<literal>SessionFactory</literal>范围内的拦截器,必须是线程安全的,因为多个"
"session可能并发使用这个拦截器要因此小心不要保存与session相关的状态。"
#. Tag: programlisting
#: events.xml:56
#, no-c-format
msgid ""
"<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
msgstr "" msgstr ""
#: index.docbook:56 #. Tag: title
msgid "<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>" #: events.xml:61
msgstr "" #, no-c-format
#: index.docbook:61
msgid "Event system" msgid "Event system"
msgstr "" msgstr "事件系统(Event system)"
#: index.docbook:63 #. Tag: para
msgid "If you have to react to particular events in your persistence layer, you may also use the Hibernate3 <emphasis>event</emphasis> architecture. The event system can be used in addition or as a replacement for interceptors." #: events.xml:63
#, no-c-format
msgid ""
"If you have to react to particular events in your persistence layer, you may "
"also use the Hibernate3 <emphasis>event</emphasis> architecture. The event "
"system can be used in addition or as a replacement for interceptors."
msgstr "" msgstr ""
"如果需要响应持久层的某些特殊事件你也可以使用Hibernate3的事件框架。 该事件系"
"统可以用来替代拦截器,也可以作为拦截器的补充来使用。"
#: index.docbook:69 #. Tag: para
msgid "Essentially all of the methods of the <literal>Session</literal> interface correlate to an event. You have a <literal>LoadEvent</literal>, a <literal>FlushEvent</literal>, etc (consult the XML configuration-file DTD or the <literal>org.hibernate.event</literal> package for the full list of defined event types). When a request is made of one of these methods, the Hibernate <literal>Session</literal> generates an appropriate event and passes it to the configured event listeners for that type. Out-of-the-box, these listeners implement the same processing in which those methods always resulted. However, you are free to implement a customization of one of the listener interfaces (i.e., the <literal>LoadEvent</literal> is processed by the registered implemenation of the <literal>LoadEventListener</literal> interface), in which case their implementation would be responsible for processing any <literal>load()</literal> requests made of the <literal>Session</literal>." #: events.xml:69
#, no-c-format
msgid ""
"Essentially all of the methods of the <literal>Session</literal> interface "
"correlate to an event. You have a <literal>LoadEvent</literal>, a "
"<literal>FlushEvent</literal>, etc (consult the XML configuration-file DTD "
"or the <literal>org.hibernate.event</literal> package for the full list of "
"defined event types). When a request is made of one of these methods, the "
"Hibernate <literal>Session</literal> generates an appropriate event and "
"passes it to the configured event listeners for that type. Out-of-the-box, "
"these listeners implement the same processing in which those methods always "
"resulted. However, you are free to implement a customization of one of the "
"listener interfaces (i.e., the <literal>LoadEvent</literal> is processed by "
"the registered implemenation of the <literal>LoadEventListener</literal> "
"interface), in which case their implementation would be responsible for "
"processing any <literal>load()</literal> requests made of the "
"<literal>Session</literal>."
msgstr "" msgstr ""
"基本上,<literal>Session</literal>接口的每个方法都有相对应的事件。比如 "
"<literal>LoadEvent</literal><literal>FlushEvent</literal>等等查阅XML配"
"置文件 的DTD以及<literal>org.hibernate.event</literal>包来获得所有已定义的"
"事件的列表)。当某个方 法被调用时Hibernate <literal>Session</literal>会生成"
"一个相对应的事件并激活所 有配置好的事件监听器。系统预设的监听器实现的处理过程"
"就是被监听的方法要做的(被监听的方法所做的其实仅仅是激活监听器, “实际”的工作"
"是由监听器完成的)。不过,你可以自由地选择实现 一个自己定制的监听器(比如,实"
"现并注册用来处理处理<literal>LoadEvent</literal>的"
"<literal>LoadEventListener</literal>接口), 来负责处理所有的调用"
"<literal>Session</literal>的<literal>load()</literal>方法的请求。"
#: index.docbook:84 #. Tag: para
msgid "The listeners should be considered effectively singletons; meaning, they are shared between requests, and thus should not save any state as instance variables." #: events.xml:84
#, no-c-format
msgid ""
"The listeners should be considered effectively singletons; meaning, they are "
"shared between requests, and thus should not save any state as instance "
"variables."
msgstr "" msgstr ""
"监听器应该被看作是单例(singleton)对象,也就是说,所有同类型的事件的处理共享同"
"一个监听器实例,因此监听器 不应该保存任何状态(也就是不应该使用成员变量)。"
#: index.docbook:89 #. Tag: para
msgid "A custom listener should implement the appropriate interface for the event it wants to process and/or extend one of the convenience base classes (or even the default event listeners used by Hibernate out-of-the-box as these are declared non-final for this purpose). Custom listeners can either be registered programmatically through the <literal>Configuration</literal> object, or specified in the Hibernate configuration XML (declarative configuration through the properties file is not supported). Here's an example of a custom load event listener:" #: events.xml:89
#, no-c-format
msgid ""
"A custom listener should implement the appropriate interface for the event "
"it wants to process and/or extend one of the convenience base classes (or "
"even the default event listeners used by Hibernate out-of-the-box as these "
"are declared non-final for this purpose). Custom listeners can either be "
"registered programmatically through the <literal>Configuration</literal> "
"object, or specified in the Hibernate configuration XML (declarative "
"configuration through the properties file is not supported). Here's an "
"example of a custom load event listener:"
msgstr "" msgstr ""
"用户定制的监听器应该实现与所要处理的事件相对应的接口,或者从一个合适的基类继"
"承甚至是从Hibernate自带的默认事件监听器类继承 为了方便你这样做,这些类都"
"被声明成non-final的了。用户定制的监听器可以通过编程使用"
"<literal>Configuration</literal>对象 来注册也可以在Hibernate的XML格式的配置"
"文件中进行声明不支持在Properties格式的配置文件声明监听器。 下面是一个用户"
"定制的加载事件(load event)的监听器:"
#: index.docbook:99 #. Tag: programlisting
#: events.xml:99
#, no-c-format
msgid "" msgid ""
"<![CDATA[public class MyLoadListener implements LoadEventListener {\n" "<![CDATA[public class MyLoadListener implements LoadEventListener {\n"
" // this is the single method defined by the LoadEventListener interface\n" " // this is the single method defined by the LoadEventListener interface\n"
" public void onLoad(LoadEvent event, LoadEventListener.LoadType loadType)\n" " public void onLoad(LoadEvent event, LoadEventListener.LoadType "
"loadType)\n"
" throws HibernateException {\n" " throws HibernateException {\n"
" if ( !MySecurity.isAuthorized( event.getEntityClassName(), event.getEntityId() ) ) {\n" " if ( !MySecurity.isAuthorized( event.getEntityClassName(), event."
"getEntityId() ) ) {\n"
" throw MySecurityException(\"Unauthorized access\");\n" " throw MySecurityException(\"Unauthorized access\");\n"
" }\n" " }\n"
" }\n" " }\n"
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:101 #. Tag: para
msgid "You also need a configuration entry telling Hibernate to use the listener in addition to the default listener:" #: events.xml:101
#, no-c-format
msgid ""
"You also need a configuration entry telling Hibernate to use the listener in "
"addition to the default listener:"
msgstr "" msgstr ""
"你还需要修改一处配置来告诉Hibernate除了默认的监听器还要附加选定的监听"
"器。"
#: index.docbook:106 #. Tag: programlisting
#: events.xml:106
#, no-c-format
msgid "" msgid ""
"<![CDATA[<hibernate-configuration>\n" "<![CDATA[<hibernate-configuration>\n"
" <session-factory>\n" " <session-factory>\n"
" ...\n" " ...\n"
" <event type=\"load\">\n" " <event type=\"load\">\n"
" <listener class=\"com.eg.MyLoadListener\"/>\n" " <listener class=\"com.eg.MyLoadListener\"/>\n"
" <listener class=\"org.hibernate.event.def.DefaultLoadEventListener\"/>\n" " <listener class=\"org.hibernate.event.def."
"DefaultLoadEventListener\"/>\n"
" </event>\n" " </event>\n"
" </session-factory>\n" " </session-factory>\n"
"</hibernate-configuration>]]>" "</hibernate-configuration>]]>"
msgstr "" msgstr ""
#: index.docbook:108 #. Tag: para
#: events.xml:108
#, no-c-format
msgid "Instead, you may register it programmatically:" msgid "Instead, you may register it programmatically:"
msgstr "" msgstr "看看用另一种方式,通过编程的方式来注册它。"
#: index.docbook:112 #. Tag: programlisting
#: events.xml:112
#, no-c-format
msgid "" msgid ""
"<![CDATA[Configuration cfg = new Configuration();\n" "<![CDATA[Configuration cfg = new Configuration();\n"
"LoadEventListener[] stack = { new MyLoadListener(), new DefaultLoadEventListener() };\n" "LoadEventListener[] stack = { new MyLoadListener(), new "
"DefaultLoadEventListener() };\n"
"cfg.EventListeners().setLoadEventListeners(stack);]]>" "cfg.EventListeners().setLoadEventListeners(stack);]]>"
msgstr "" msgstr ""
#: index.docbook:114 #. Tag: para
msgid "Listeners registered declaratively cannot share instances. If the same class name is used in multiple <literal>&lt;listener/&gt;</literal> elements, each reference will result in a separate instance of that class. If you need the capability to share listener instances between listener types you must use the programmatic registration approach." #: events.xml:114
#, no-c-format
msgid ""
"Listeners registered declaratively cannot share instances. If the same class "
"name is used in multiple <literal>&lt;listener/&gt;</literal> elements, each "
"reference will result in a separate instance of that class. If you need the "
"capability to share listener instances between listener types you must use "
"the programmatic registration approach."
msgstr "" msgstr ""
"通过在XML配置文件声明而注册的监听器不能共享实例。如果在多个<literal>&lt;"
"listener/&gt;</literal>节点中使用 了相同的类的名字,则每一个引用都将会产生一"
"个独立的实例。如果你需要在多个监听器类型之间共享 监听器的实例,则你必须使用编"
"程的方式来进行注册。"
#: index.docbook:122 #. Tag: para
msgid "Why implement an interface and define the specific type during configuration? Well, a listener implementation could implement multiple event listener interfaces. Having the type additionally defined during registration makes it easier to turn custom listeners on or off during configuration." #: events.xml:122
#, no-c-format
msgid ""
"Why implement an interface and define the specific type during "
"configuration? Well, a listener implementation could implement multiple "
"event listener interfaces. Having the type additionally defined during "
"registration makes it easier to turn custom listeners on or off during "
"configuration."
msgstr "" msgstr ""
"为什么我们实现了特定监听器的接口,在注册的时候还要明确指出我们要注册哪个事件"
"的监听器呢? 这是因为一个类可能实现多个监听器的接口。在注册的时候明确指定要监"
"听的事件,可以让启用或者禁用对某个事件的监听的配置工作简单些。"
#: index.docbook:132 #. Tag: title
#: events.xml:132
#, no-c-format
msgid "Hibernate declarative security" msgid "Hibernate declarative security"
msgstr "" msgstr "Hibernate的声明式安全机制"
#: index.docbook:133 #. Tag: para
msgid "Usually, declarative security in Hibernate applications is managed in a session facade layer. Now, Hibernate3 allows certain actions to be permissioned via JACC, and authorized via JAAS. This is optional functionality built on top of the event architecture." #: events.xml:133
msgstr "" #, no-c-format
#: index.docbook:139
msgid "First, you must configure the appropriate event listeners, to enable the use of JAAS authorization."
msgstr ""
#: index.docbook:144
msgid "" msgid ""
"<![CDATA[<listener type=\"pre-delete\" class=\"org.hibernate.secure.JACCPreDeleteEventListener\"/>\n" "Usually, declarative security in Hibernate applications is managed in a "
"<listener type=\"pre-update\" class=\"org.hibernate.secure.JACCPreUpdateEventListener\"/>\n" "session facade layer. Now, Hibernate3 allows certain actions to be "
"<listener type=\"pre-insert\" class=\"org.hibernate.secure.JACCPreInsertEventListener\"/>\n" "permissioned via JACC, and authorized via JAAS. This is optional "
"<listener type=\"pre-load\" class=\"org.hibernate.secure.JACCPreLoadEventListener\"/>]]>" "functionality built on top of the event architecture."
msgstr "" msgstr ""
"通常Hibernate应用程序的声明式安全机制由会话外观层(session facade)所管理。 "
"现在Hibernate3允许某些特定的行为由JACC进行许可管理由JAAS进行授权管理。 本"
"功能是一个建立在事件框架之上的可选的功能。"
#: index.docbook:146 #. Tag: para
msgid "Note that <literal>&lt;listener type=\"...\" class=\"...\"/&gt;</literal> is just a shorthand for <literal>&lt;event type=\"...\"&gt;&lt;listener class=\"...\"/&gt;&lt;/event&gt;</literal> when there is exactly one listener for a particular event type." #: events.xml:139
msgstr "" #, no-c-format
#: index.docbook:152
msgid "Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to roles:"
msgstr ""
#: index.docbook:156
msgid "" msgid ""
"<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,read\"/>\n" "First, you must configure the appropriate event listeners, to enable the use "
"of JAAS authorization."
msgstr ""
"首先你必须要配置适当的事件监听器event listener来激活使用JAAS管理授权"
"的功能。"
#. Tag: programlisting
#: events.xml:144
#, no-c-format
msgid ""
"<![CDATA[<listener type=\"pre-delete\" class=\"org.hibernate.secure."
"JACCPreDeleteEventListener\"/>\n"
"<listener type=\"pre-update\" class=\"org.hibernate.secure."
"JACCPreUpdateEventListener\"/>\n"
"<listener type=\"pre-insert\" class=\"org.hibernate.secure."
"JACCPreInsertEventListener\"/>\n"
"<listener type=\"pre-load\" class=\"org.hibernate.secure."
"JACCPreLoadEventListener\"/>]]>"
msgstr ""
#. Tag: para
#: events.xml:146
#, no-c-format
msgid ""
"Note that <literal>&lt;listener type=\"...\" class=\"...\"/&gt;</literal> is "
"just a shorthand for <literal>&lt;event type=\"...\"&gt;&lt;listener class="
"\"...\"/&gt;&lt;/event&gt;</literal> when there is exactly one listener for "
"a particular event type."
msgstr ""
"注意,<literal>&lt;listener type=\"...\" class=\"...\"/&gt;</literal>只是"
"<literal>&lt;event type=\"...\"&gt;&lt;listener class=\"...\"/&gt;&lt;/"
"event&gt;</literal>的简写,对每一个事件类型都必须严格的有一个监听器与之对应。"
#. Tag: para
#: events.xml:152
#, no-c-format
msgid ""
"Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to "
"roles:"
msgstr ""
"接下来,仍然在<literal>hibernate.cfg.xml</literal>文件中,绑定角色的权限:"
#. Tag: programlisting
#: events.xml:156
#, no-c-format
msgid ""
"<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,"
"read\"/>\n"
"<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>" "<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"
msgstr "" msgstr ""
#: index.docbook:158 #. Tag: para
#: events.xml:158
#, no-c-format
msgid "The role names are the roles understood by your JACC provider." msgid "The role names are the roles understood by your JACC provider."
msgstr "" msgstr "这些角色的名字就是你的JACC provider所定义的角色的名字。"
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,30 +1,56 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:20 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: example_mappings.xml:20
#, no-c-format
msgid "Example: Various Mappings" msgid "Example: Various Mappings"
msgstr "" msgstr "示例:复杂映射实例"
#: index.docbook:22 #. Tag: para
#: example_mappings.xml:22
#, no-c-format
msgid "This chapters shows off some more complex association mappings." msgid "This chapters shows off some more complex association mappings."
msgstr "" msgstr "本章展示了一些较为复杂的关系映射。"
#: index.docbook:27 #. Tag: title
#: example_mappings.xml:27
#, no-c-format
msgid "Employer/Employee" msgid "Employer/Employee"
msgstr "" msgstr "Employer雇主)/Employee(雇员)"
#: index.docbook:29 #. Tag: para
msgid "The following model of the relationship between <literal>Employer</literal> and <literal>Employee</literal> uses an actual entity class (<literal>Employment</literal>) to represent the association. This is done because there might be more than one period of employment for the same two parties. Components are used to model monetary values and employee names." #: example_mappings.xml:29
#, no-c-format
msgid ""
"The following model of the relationship between <literal>Employer</literal> "
"and <literal>Employee</literal> uses an actual entity class "
"(<literal>Employment</literal>) to represent the association. This is done "
"because there might be more than one period of employment for the same two "
"parties. Components are used to model monetary values and employee names."
msgstr "" msgstr ""
"下面关于<literal>Employer</literal> 和 <literal>Employee</literal>的关系模型"
"使用了一个真实的实体类 (<literal>Employment</literal>)来表述,这是因为对于相"
"同的雇员和雇主可能会有多个雇佣时间段。 对于金额和雇员姓名用Components建模。"
#: index.docbook:46 #. Tag: para
#: example_mappings.xml:46
#, no-c-format
msgid "Heres a possible mapping document:" msgid "Heres a possible mapping document:"
msgstr "" msgstr "映射文件可能是这样:"
#: index.docbook:50 #. Tag: programlisting
#: example_mappings.xml:50
#, no-c-format
msgid "" msgid ""
"<![CDATA[<hibernate-mapping>\n" "<![CDATA[<hibernate-mapping>\n"
" \n" " \n"
@ -54,8 +80,10 @@ msgid ""
" <property name=\"currency\" length=\"12\"/>\n" " <property name=\"currency\" length=\"12\"/>\n"
" </component>\n" " </component>\n"
"\n" "\n"
" <many-to-one name=\"employer\" column=\"employer_id\" not-null=\"true\"/>\n" " <many-to-one name=\"employer\" column=\"employer_id\" not-null=\"true"
" <many-to-one name=\"employee\" column=\"employee_id\" not-null=\"true\"/>\n" "\"/>\n"
" <many-to-one name=\"employee\" column=\"employee_id\" not-null=\"true"
"\"/>\n"
"\n" "\n"
" </class>\n" " </class>\n"
"\n" "\n"
@ -76,11 +104,16 @@ msgid ""
"</hibernate-mapping>]]>" "</hibernate-mapping>]]>"
msgstr "" msgstr ""
#: index.docbook:52 #. Tag: para
msgid "And heres the table schema generated by <literal>SchemaExport</literal>." #: example_mappings.xml:52
msgstr "" #, no-c-format
msgid ""
"And heres the table schema generated by <literal>SchemaExport</literal>."
msgstr "用<literal>SchemaExport</literal>生成表结构。"
#: index.docbook:56 #. Tag: programlisting
#: example_mappings.xml:56
#, no-c-format
msgid "" msgid ""
"<![CDATA[create table employers (\n" "<![CDATA[create table employers (\n"
" id BIGINT not null, \n" " id BIGINT not null, \n"
@ -109,27 +142,50 @@ msgid ""
")\n" ")\n"
"\n" "\n"
"alter table employment_periods \n" "alter table employment_periods \n"
" add constraint employment_periodsFK0 foreign key (employer_id) references employers\n" " add constraint employment_periodsFK0 foreign key (employer_id) "
"references employers\n"
"alter table employment_periods \n" "alter table employment_periods \n"
" add constraint employment_periodsFK1 foreign key (employee_id) references employees\n" " add constraint employment_periodsFK1 foreign key (employee_id) "
"references employees\n"
"create sequence employee_id_seq\n" "create sequence employee_id_seq\n"
"create sequence employment_id_seq\n" "create sequence employment_id_seq\n"
"create sequence employer_id_seq]]>" "create sequence employer_id_seq]]>"
msgstr "" msgstr ""
#: index.docbook:61 #. Tag: title
#: example_mappings.xml:61
#, no-c-format
msgid "Author/Work" msgid "Author/Work"
msgstr "" msgstr "Author(作家)/Work(作品)"
#: index.docbook:63 #. Tag: para
msgid "Consider the following model of the relationships between <literal>Work</literal>, <literal>Author</literal> and <literal>Person</literal>. We represent the relationship between <literal>Work</literal> and <literal>Author</literal> as a many-to-many association. We choose to represent the relationship between <literal>Author</literal> and <literal>Person</literal> as one-to-one association. Another possibility would be to have <literal>Author</literal> extend <literal>Person</literal>." #: example_mappings.xml:63
#, no-c-format
msgid ""
"Consider the following model of the relationships between <literal>Work</"
"literal>, <literal>Author</literal> and <literal>Person</literal>. We "
"represent the relationship between <literal>Work</literal> and "
"<literal>Author</literal> as a many-to-many association. We choose to "
"represent the relationship between <literal>Author</literal> and "
"<literal>Person</literal> as one-to-one association. Another possibility "
"would be to have <literal>Author</literal> extend <literal>Person</literal>."
msgstr "" msgstr ""
"考虑下面的<literal>Work</literal>,<literal>Author</literal> 和 "
"<literal>Person</literal>模型的关系。 我们用多对多关系来描述<literal>Work</"
"literal> 和 <literal>Author</literal> 用一对一关系来描述<literal>Author</"
"literal> 和 <literal>Person</literal> 另一种可能性是<literal>Author</"
"literal>继承<literal>Person</literal>。"
#: index.docbook:81 #. Tag: para
msgid "The following mapping document correctly represents these relationships:" #: example_mappings.xml:81
msgstr "" #, no-c-format
msgid ""
"The following mapping document correctly represents these relationships:"
msgstr "下面的映射文件正确的描述了这些关系:"
#: index.docbook:85 #. Tag: programlisting
#: example_mappings.xml:85
#, no-c-format
msgid "" msgid ""
"<![CDATA[<hibernate-mapping>\n" "<![CDATA[<hibernate-mapping>\n"
"\n" "\n"
@ -184,11 +240,24 @@ msgid ""
"</hibernate-mapping>]]>" "</hibernate-mapping>]]>"
msgstr "" msgstr ""
#: index.docbook:87 #. Tag: para
msgid "There are four tables in this mapping. <literal>works</literal>, <literal>authors</literal> and <literal>persons</literal> hold work, author and person data respectively. <literal>author_work</literal> is an association table linking authors to works. Heres the table schema, as generated by <literal>SchemaExport</literal>." #: example_mappings.xml:87
#, no-c-format
msgid ""
"There are four tables in this mapping. <literal>works</literal>, "
"<literal>authors</literal> and <literal>persons</literal> hold work, author "
"and person data respectively. <literal>author_work</literal> is an "
"association table linking authors to works. Heres the table schema, as "
"generated by <literal>SchemaExport</literal>."
msgstr "" msgstr ""
"映射中有4个表。<literal>works</literal>, <literal>authors</literal> 和 "
"<literal>persons</literal> 分别保存着workauthor和person的数据。"
"<literal>author_work</literal>是authors和works的关联表。 表结构是由"
"<literal>SchemaExport</literal>生成的。"
#: index.docbook:95 #. Tag: programlisting
#: example_mappings.xml:95
#, no-c-format
msgid "" msgid ""
"<![CDATA[create table works (\n" "<![CDATA[create table works (\n"
" id BIGINT not null generated by default as identity, \n" " id BIGINT not null generated by default as identity, \n"
@ -221,24 +290,49 @@ msgid ""
"alter table authors \n" "alter table authors \n"
" add constraint authorsFK0 foreign key (id) references persons\n" " add constraint authorsFK0 foreign key (id) references persons\n"
"alter table author_work \n" "alter table author_work \n"
" add constraint author_workFK0 foreign key (author_id) references authors\n" " add constraint author_workFK0 foreign key (author_id) references "
"authors\n"
"alter table author_work\n" "alter table author_work\n"
" add constraint author_workFK1 foreign key (work_id) references works]]>" " add constraint author_workFK1 foreign key (work_id) references works]]>"
msgstr "" msgstr ""
#: index.docbook:100 #. Tag: title
#: example_mappings.xml:100
#, no-c-format
msgid "Customer/Order/Product" msgid "Customer/Order/Product"
msgstr "" msgstr "Customer(客户)/Order(订单)/Product(产品)"
#: index.docbook:102 #. Tag: para
msgid "Now consider a model of the relationships between <literal>Customer</literal>, <literal>Order</literal> and <literal>LineItem</literal> and <literal>Product</literal>. There is a one-to-many association between <literal>Customer</literal> and <literal>Order</literal>, but how should we represent <literal>Order</literal> / <literal>LineItem</literal> / <literal>Product</literal>? I've chosen to map <literal>LineItem</literal> as an association class representing the many-to-many association between <literal>Order</literal> and <literal>Product</literal>. In Hibernate, this is called a composite element." #: example_mappings.xml:102
#, no-c-format
msgid ""
"Now consider a model of the relationships between <literal>Customer</"
"literal>, <literal>Order</literal> and <literal>LineItem</literal> and "
"<literal>Product</literal>. There is a one-to-many association between "
"<literal>Customer</literal> and <literal>Order</literal>, but how should we "
"represent <literal>Order</literal> / <literal>LineItem</literal> / "
"<literal>Product</literal>? I've chosen to map <literal>LineItem</literal> "
"as an association class representing the many-to-many association between "
"<literal>Order</literal> and <literal>Product</literal>. In Hibernate, this "
"is called a composite element."
msgstr "" msgstr ""
"现在来考虑<literal>Customer</literal>,<literal>Order</literal> "
"<literal>LineItem</literal> 和 <literal>Product</literal>关系的模型。"
"<literal>Customer</literal> 和 <literal>Order</literal>之间 是一对多的关系,"
"但是我们怎么来描述<literal>Order</literal> / <literal>LineItem</literal> / "
"<literal>Product</literal>呢? 我可以把<literal>LineItem</literal>作为描述"
"<literal>Order</literal> 和 <literal>Product</literal> 多对多关系的关联类,在"
"Hibernate这叫做组合元素。"
#: index.docbook:122 #. Tag: para
#: example_mappings.xml:122
#, no-c-format
msgid "The mapping document:" msgid "The mapping document:"
msgstr "" msgstr "映射文件如下:"
#: index.docbook:126 #. Tag: programlisting
#: example_mappings.xml:126
#, no-c-format
msgid "" msgid ""
"<![CDATA[<hibernate-mapping>\n" "<![CDATA[<hibernate-mapping>\n"
"\n" "\n"
@ -279,11 +373,23 @@ msgid ""
"</hibernate-mapping>]]>" "</hibernate-mapping>]]>"
msgstr "" msgstr ""
#: index.docbook:128 #. Tag: para
msgid "<literal>customers</literal>, <literal>orders</literal>, <literal>line_items</literal> and <literal>products</literal> hold customer, order, order line item and product data respectively. <literal>line_items</literal> also acts as an association table linking orders with products." #: example_mappings.xml:128
#, no-c-format
msgid ""
"<literal>customers</literal>, <literal>orders</literal>, "
"<literal>line_items</literal> and <literal>products</literal> hold customer, "
"order, order line item and product data respectively. <literal>line_items</"
"literal> also acts as an association table linking orders with products."
msgstr "" msgstr ""
"<literal>customers</literal>, <literal>orders</literal>, "
"<literal>line_items</literal> 和 <literal>products</literal> 分别保存着"
"customer, order, order line item 和 product的数据。 <literal>line_items</"
"literal>也作为连接orders 和 products的关联表。"
#: index.docbook:135 #. Tag: programlisting
#: example_mappings.xml:135
#, no-c-format
msgid "" msgid ""
"<![CDATA[create table customers (\n" "<![CDATA[create table customers (\n"
" id BIGINT not null generated by default as identity, \n" " id BIGINT not null generated by default as identity, \n"
@ -315,28 +421,44 @@ msgid ""
"alter table orders \n" "alter table orders \n"
" add constraint ordersFK0 foreign key (customer_id) references customers\n" " add constraint ordersFK0 foreign key (customer_id) references customers\n"
"alter table line_items\n" "alter table line_items\n"
" add constraint line_itemsFK0 foreign key (product_id) references products\n" " add constraint line_itemsFK0 foreign key (product_id) references "
"products\n"
"alter table line_items\n" "alter table line_items\n"
" add constraint line_itemsFK1 foreign key (order_id) references orders]]>" " add constraint line_itemsFK1 foreign key (order_id) references orders]]>"
msgstr "" msgstr ""
#: index.docbook:140 #. Tag: title
#: example_mappings.xml:140
#, no-c-format
msgid "Miscellaneous example mappings" msgid "Miscellaneous example mappings"
msgstr "" msgstr "杂例"
#: index.docbook:142 #. Tag: para
msgid "These examples are all taken from the Hibernate test suite. You will find many other useful example mappings there. Look in the <literal>test</literal> folder of the Hibernate distribution." #: example_mappings.xml:142
#, no-c-format
msgid ""
"These examples are all taken from the Hibernate test suite. You will find "
"many other useful example mappings there. Look in the <literal>test</"
"literal> folder of the Hibernate distribution."
msgstr "" msgstr ""
"这些例子全部来自于Hibernate的test suite同时你也可以找到其他有用的例子。 可"
"以参考Hibernate的<literal>test</literal>目录。"
#: index.docbook:148 #. Tag: para
#: example_mappings.xml:148
#, no-c-format
msgid "TODO: put words around this stuff" msgid "TODO: put words around this stuff"
msgstr "" msgstr "TODO: put words around this stuff"
#: index.docbook:151 #. Tag: title
#: example_mappings.xml:151
#, no-c-format
msgid "\"Typed\" one-to-one association" msgid "\"Typed\" one-to-one association"
msgstr "" msgstr "\"Typed\" one-to-one association"
#: index.docbook:152 #. Tag: programlisting
#: example_mappings.xml:152
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" <id name=\"name\"/>\n" " <id name=\"name\"/>\n"
@ -366,11 +488,15 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:156 #. Tag: title
#: example_mappings.xml:156
#, no-c-format
msgid "Composite key example" msgid "Composite key example"
msgstr "" msgstr "Composite key example"
#: index.docbook:157 #. Tag: programlisting
#: example_mappings.xml:157
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Customer\">\n" "<![CDATA[<class name=\"Customer\">\n"
"\n" "\n"
@ -487,11 +613,16 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:161 #. Tag: title
#: example_mappings.xml:161
#, no-c-format
msgid "Many-to-many with shared composite key attribute" msgid "Many-to-many with shared composite key attribute"
msgstr "" msgstr ""
"共有组合键属性的多对多(Many-to-many with shared composite key attribute)"
#: index.docbook:162 #. Tag: programlisting
#: example_mappings.xml:162
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"User\" table=\"`User`\">\n" "<![CDATA[<class name=\"User\" table=\"`User`\">\n"
" <composite-id>\n" " <composite-id>\n"
@ -530,11 +661,15 @@ msgid ""
"]]>" "]]>"
msgstr "" msgstr ""
#: index.docbook:166 #. Tag: title
#: example_mappings.xml:166
#, no-c-format
msgid "Content based discrimination" msgid "Content based discrimination"
msgstr "" msgstr "Content based discrimination"
#: index.docbook:167 #. Tag: programlisting
#: example_mappings.xml:167
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\"\n" "<![CDATA[<class name=\"Person\"\n"
" discriminator-value=\"P\">\n" " discriminator-value=\"P\">\n"
@ -588,11 +723,15 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:171 #. Tag: title
#: example_mappings.xml:171
#, no-c-format
msgid "Associations on alternate keys" msgid "Associations on alternate keys"
msgstr "" msgstr "Associations on alternate keys"
#: index.docbook:172 #. Tag: programlisting
#: example_mappings.xml:172
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Person\">\n" "<![CDATA[<class name=\"Person\">\n"
" \n" " \n"
@ -644,10 +783,3 @@ msgid ""
" \n" " \n"
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,50 +1,136 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: example_parentchild.xml:5
#, no-c-format
msgid "Example: Parent/Child" msgid "Example: Parent/Child"
msgstr "" msgstr "示例:父子关系(Parent Child Relationships)"
#: index.docbook:7 #. Tag: para
msgid "One of the very first things that new users try to do with Hibernate is to model a parent / child type relationship. There are two different approaches to this. For various reasons the most convenient approach, especially for new users, is to model both <literal>Parent</literal> and <literal>Child</literal> as entity classes with a <literal>&lt;one-to-many&gt;</literal> association from <literal>Parent</literal> to <literal>Child</literal>. (The alternative approach is to declare the <literal>Child</literal> as a <literal>&lt;composite-element&gt;</literal>.) Now, it turns out that default semantics of a one to many association (in Hibernate) are much less close to the usual semantics of a parent / child relationship than those of a composite element mapping. We will explain how to use a <emphasis>bidirectional one to many association with cascades</emphasis> to model a parent / child relationship efficiently and elegantly. It's not at all difficult!" #: example_parentchild.xml:7
#, no-c-format
msgid ""
"One of the very first things that new users try to do with Hibernate is to "
"model a parent / child type relationship. There are two different approaches "
"to this. For various reasons the most convenient approach, especially for "
"new users, is to model both <literal>Parent</literal> and <literal>Child</"
"literal> as entity classes with a <literal>&lt;one-to-many&gt;</literal> "
"association from <literal>Parent</literal> to <literal>Child</literal>. (The "
"alternative approach is to declare the <literal>Child</literal> as a "
"<literal>&lt;composite-element&gt;</literal>.) Now, it turns out that "
"default semantics of a one to many association (in Hibernate) are much less "
"close to the usual semantics of a parent / child relationship than those of "
"a composite element mapping. We will explain how to use a "
"<emphasis>bidirectional one to many association with cascades</emphasis> to "
"model a parent / child relationship efficiently and elegantly. It's not at "
"all difficult!"
msgstr "" msgstr ""
"刚刚接触Hibernate的人大多是从父子关系parent / child type relationship的建"
"模入手的。父子关系的建模有两种方法。由于种种原因,最方便的方法是把"
"<literal>Parent</literal>和<literal>Child</literal>都建模成实体类,并创建一个"
"从<literal>Parent</literal>指向<literal>Child</literal>的&lt;one-to-many&gt;"
"关联,对新手来说尤其如此。还有一种方法,就是将<literal>Child</literal>声明为"
"一个<literal>&lt;composite-element&gt;</literal>(组合元素)。 事实上在"
"Hibernate中one to many关联的默认语义远没有composite element贴近parent / child"
"关系的通常语义。下面我们会阐述如何使用<emphasis>带有级联的双向一对多关联"
"(bidirectional one to many association with cascades)</emphasis>去建立有效、"
"优美的parent / child关系。这一点也不难"
#: index.docbook:21 #. Tag: title
#: example_parentchild.xml:21
#, no-c-format
msgid "A note about collections" msgid "A note about collections"
msgstr "" msgstr "关于collections需要注意的一点"
#: index.docbook:23 #. Tag: para
msgid "Hibernate collections are considered to be a logical part of their owning entity; never of the contained entities. This is a crucial distinction! It has the following consequences:" #: example_parentchild.xml:23
#, no-c-format
msgid ""
"Hibernate collections are considered to be a logical part of their owning "
"entity; never of the contained entities. This is a crucial distinction! It "
"has the following consequences:"
msgstr "" msgstr ""
"Hibernate collections被当作其所属实体而不是其包含实体的一个逻辑部分。这非常重"
"要!它主要体现为以下几点:"
#: index.docbook:30 #. Tag: para
msgid "When we remove / add an object from / to a collection, the version number of the collection owner is incremented." #: example_parentchild.xml:30
#, no-c-format
msgid ""
"When we remove / add an object from / to a collection, the version number of "
"the collection owner is incremented."
msgstr "当删除或增加collection中对象的时候collection所属者的版本值会递增。"
#. Tag: para
#: example_parentchild.xml:36
#, no-c-format
msgid ""
"If an object that was removed from a collection is an instance of a value "
"type (eg, a composite element), that object will cease to be persistent and "
"its state will be completely removed from the database. Likewise, adding a "
"value type instance to the collection will cause its state to be immediately "
"persistent."
msgstr "" msgstr ""
"如果一个从collection中移除的对象是一个值类型(value type)的实例,比如"
"composite element那么这个对象的持久化状态将会终止其在数据库中对应的记录会"
"被删除。同样的向collection增加一个value type的实例将会使之立即被持久化。"
#: index.docbook:36 #. Tag: para
msgid "If an object that was removed from a collection is an instance of a value type (eg, a composite element), that object will cease to be persistent and its state will be completely removed from the database. Likewise, adding a value type instance to the collection will cause its state to be immediately persistent." #: example_parentchild.xml:44
#, no-c-format
msgid ""
"On the other hand, if an entity is removed from a collection (a one-to-many "
"or many-to-many association), it will not be deleted, by default. This "
"behaviour is completely consistent - a change to the internal state of "
"another entity should not cause the associated entity to vanish! Likewise, "
"adding an entity to a collection does not cause that entity to become "
"persistent, by default."
msgstr "" msgstr ""
"另一方面如果从一对多或多对多关联的collection中移除一个实体在缺省情况下这"
"个对象并不会被删除。这个行为是完全合乎逻辑的--改变一个实体的内部状态不应该"
"使与它关联的实体消失掉同样的向collection增加一个实体不会使之被持久化。"
#: index.docbook:44 #. Tag: para
msgid "On the other hand, if an entity is removed from a collection (a one-to-many or many-to-many association), it will not be deleted, by default. This behaviour is completely consistent - a change to the internal state of another entity should not cause the associated entity to vanish! Likewise, adding an entity to a collection does not cause that entity to become persistent, by default." #: example_parentchild.xml:54
#, no-c-format
msgid ""
"Instead, the default behaviour is that adding an entity to a collection "
"merely creates a link between the two entities, while removing it removes "
"the link. This is very appropriate for all sorts of cases. Where it is not "
"appropriate at all is the case of a parent / child relationship, where the "
"life of the child is bound to the life cycle of the parent."
msgstr "" msgstr ""
"实际上向Collection增加一个实体的缺省动作只是在两个实体之间创建一个连接而"
"已,同样移除的时候也只是删除连接。这种处理对于所有的情况都是合适的。对于父子"
"关系则是完全不适合的,在这种关系下,子对象的生存绑定于父对象的生存周期。"
#: index.docbook:54 #. Tag: title
msgid "Instead, the default behaviour is that adding an entity to a collection merely creates a link between the two entities, while removing it removes the link. This is very appropriate for all sorts of cases. Where it is not appropriate at all is the case of a parent / child relationship, where the life of the child is bound to the life cycle of the parent." #: example_parentchild.xml:64
msgstr "" #, no-c-format
#: index.docbook:64
msgid "Bidirectional one-to-many" msgid "Bidirectional one-to-many"
msgstr "" msgstr "双向的一对多关系(Bidirectional one-to-many)"
#: index.docbook:66 #. Tag: para
msgid "Suppose we start with a simple <literal>&lt;one-to-many&gt;</literal> association from <literal>Parent</literal> to <literal>Child</literal>." #: example_parentchild.xml:66
msgstr "" #, no-c-format
msgid ""
"Suppose we start with a simple <literal>&lt;one-to-many&gt;</literal> "
"association from <literal>Parent</literal> to <literal>Child</literal>."
msgstr "假设我们要实现一个简单的从Parent到Child的&lt;one-to-many&gt;关联。"
#: index.docbook:71 #. Tag: programlisting
#: example_parentchild.xml:71
#, no-c-format
msgid "" msgid ""
"<![CDATA[<set name=\"children\">\n" "<![CDATA[<set name=\"children\">\n"
" <key column=\"parent_id\"/>\n" " <key column=\"parent_id\"/>\n"
@ -52,11 +138,15 @@ msgid ""
"</set>]]>" "</set>]]>"
msgstr "" msgstr ""
#: index.docbook:73 #. Tag: para
#: example_parentchild.xml:73
#, no-c-format
msgid "If we were to execute the following code" msgid "If we were to execute the following code"
msgstr "" msgstr "如果我们运行下面的代码"
#: index.docbook:77 #. Tag: programlisting
#: example_parentchild.xml:77
#, no-c-format
msgid "" msgid ""
"<![CDATA[Parent p = .....;\n" "<![CDATA[Parent p = .....;\n"
"Child c = new Child();\n" "Child c = new Child();\n"
@ -65,23 +155,45 @@ msgid ""
"session.flush();]]>" "session.flush();]]>"
msgstr "" msgstr ""
#: index.docbook:79 #. Tag: para
#: example_parentchild.xml:79
#, no-c-format
msgid "Hibernate would issue two SQL statements:" msgid "Hibernate would issue two SQL statements:"
msgstr "" msgstr "Hibernate会产生两条SQL语句"
#: index.docbook:85 #. Tag: para
msgid "an <literal>INSERT</literal> to create the record for <literal>c</literal>" #: example_parentchild.xml:85
msgstr "" #, no-c-format
msgid ""
"an <literal>INSERT</literal> to create the record for <literal>c</literal>"
msgstr "一条<literal>INSERT</literal>语句,为<literal>c</literal>创建一条记录"
#: index.docbook:88 #. Tag: para
msgid "an <literal>UPDATE</literal> to create the link from <literal>p</literal> to <literal>c</literal>" #: example_parentchild.xml:88
#, no-c-format
msgid ""
"an <literal>UPDATE</literal> to create the link from <literal>p</literal> to "
"<literal>c</literal>"
msgstr "" msgstr ""
"一条<literal>UPDATE</literal>语句,创建从<literal>p</literal>到<literal>c</"
"literal>的连接"
#: index.docbook:95 #. Tag: para
msgid "This is not only inefficient, but also violates any <literal>NOT NULL</literal> constraint on the <literal>parent_id</literal> column. We can fix the nullability constraint violation by specifying <literal>not-null=\"true\"</literal> in the collection mapping:" #: example_parentchild.xml:95
#, no-c-format
msgid ""
"This is not only inefficient, but also violates any <literal>NOT NULL</"
"literal> constraint on the <literal>parent_id</literal> column. We can fix "
"the nullability constraint violation by specifying <literal>not-null=\"true"
"\"</literal> in the collection mapping:"
msgstr "" msgstr ""
"这样做不仅效率低,而且违反了列<literal>parent_id</literal>非空的限制。我们可"
"以通过在集合类映射上指定<literal>not-null=\"true\"</literal>来解决违反非空约"
"束的问题:"
#: index.docbook:101 #. Tag: programlisting
#: example_parentchild.xml:101
#, no-c-format
msgid "" msgid ""
"<![CDATA[<set name=\"children\">\n" "<![CDATA[<set name=\"children\">\n"
" <key column=\"parent_id\" not-null=\"true\"/>\n" " <key column=\"parent_id\" not-null=\"true\"/>\n"
@ -89,27 +201,57 @@ msgid ""
"</set>]]>" "</set>]]>"
msgstr "" msgstr ""
#: index.docbook:103 #. Tag: para
#: example_parentchild.xml:103
#, no-c-format
msgid "However, this is not the recommended solution." msgid "However, this is not the recommended solution."
msgstr "然而,这并非是推荐的解决方法。"
#. Tag: para
#: example_parentchild.xml:106
#, no-c-format
msgid ""
"The underlying cause of this behaviour is that the link (the foreign key "
"<literal>parent_id</literal>) from <literal>p</literal> to <literal>c</"
"literal> is not considered part of the state of the <literal>Child</literal> "
"object and is therefore not created in the <literal>INSERT</literal>. So the "
"solution is to make the link part of the <literal>Child</literal> mapping."
msgstr ""
"这种现象的根本原因是从<literal>p</literal>到<literal>c</literal>的连接(外键"
"parent_id没有被当作<literal>Child</literal>对象状态的一部分,因而没有在"
"INSERT语句中被创建。因此解决的办法就是把这个连接添加到Child的映射中。"
#. Tag: programlisting
#: example_parentchild.xml:113
#, no-c-format
msgid ""
"<![CDATA[<many-to-one name=\"parent\" column=\"parent_id\" not-null=\"true\"/"
">]]>"
msgstr "" msgstr ""
#: index.docbook:106 #. Tag: para
msgid "The underlying cause of this behaviour is that the link (the foreign key <literal>parent_id</literal>) from <literal>p</literal> to <literal>c</literal> is not considered part of the state of the <literal>Child</literal> object and is therefore not created in the <literal>INSERT</literal>. So the solution is to make the link part of the <literal>Child</literal> mapping." #: example_parentchild.xml:115
#, no-c-format
msgid ""
"(We also need to add the <literal>parent</literal> property to the "
"<literal>Child</literal> class.)"
msgstr "" msgstr ""
"(我们还需要为类<literal>Child</literal>添加<literal>parent</literal>属性)"
#: index.docbook:113 #. Tag: para
msgid "<![CDATA[<many-to-one name=\"parent\" column=\"parent_id\" not-null=\"true\"/>]]>" #: example_parentchild.xml:119
#, no-c-format
msgid ""
"Now that the <literal>Child</literal> entity is managing the state of the "
"link, we tell the collection not to update the link. We use the "
"<literal>inverse</literal> attribute."
msgstr "" msgstr ""
"现在实体<literal>Child</literal>在管理连接的状态为了使collection不更新连"
"接,我们使用<literal>inverse</literal>属性。"
#: index.docbook:115 #. Tag: programlisting
msgid "(We also need to add the <literal>parent</literal> property to the <literal>Child</literal> class.)" #: example_parentchild.xml:124
msgstr "" #, no-c-format
#: index.docbook:119
msgid "Now that the <literal>Child</literal> entity is managing the state of the link, we tell the collection not to update the link. We use the <literal>inverse</literal> attribute."
msgstr ""
#: index.docbook:124
msgid "" msgid ""
"<![CDATA[<set name=\"children\" inverse=\"true\">\n" "<![CDATA[<set name=\"children\" inverse=\"true\">\n"
" <key column=\"parent_id\"/>\n" " <key column=\"parent_id\"/>\n"
@ -117,11 +259,15 @@ msgid ""
"</set>]]>" "</set>]]>"
msgstr "" msgstr ""
#: index.docbook:126 #. Tag: para
#: example_parentchild.xml:126
#, no-c-format
msgid "The following code would be used to add a new <literal>Child</literal>" msgid "The following code would be used to add a new <literal>Child</literal>"
msgstr "" msgstr "下面的代码是用来添加一个新的<literal>Child</literal>"
#: index.docbook:130 #. Tag: programlisting
#: example_parentchild.xml:130
#, no-c-format
msgid "" msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n" "<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = new Child();\n" "Child c = new Child();\n"
@ -131,15 +277,25 @@ msgid ""
"session.flush();]]>" "session.flush();]]>"
msgstr "" msgstr ""
#: index.docbook:132 #. Tag: para
#: example_parentchild.xml:132
#, no-c-format
msgid "And now, only one SQL <literal>INSERT</literal> would be issued!" msgid "And now, only one SQL <literal>INSERT</literal> would be issued!"
msgstr "" msgstr "现在,只会有一条<literal>INSERT</literal>语句被执行!"
#: index.docbook:136 #. Tag: para
msgid "To tighten things up a bit, we could create an <literal>addChild()</literal> method of <literal>Parent</literal>." #: example_parentchild.xml:136
#, no-c-format
msgid ""
"To tighten things up a bit, we could create an <literal>addChild()</literal> "
"method of <literal>Parent</literal>."
msgstr "" msgstr ""
"为了让事情变得井井有条,可以为<literal>Parent</literal>加一个"
"<literal>addChild()</literal>方法。"
#: index.docbook:141 #. Tag: programlisting
#: example_parentchild.xml:141
#, no-c-format
msgid "" msgid ""
"<![CDATA[public void addChild(Child c) {\n" "<![CDATA[public void addChild(Child c) {\n"
" c.setParent(this);\n" " c.setParent(this);\n"
@ -147,11 +303,15 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:143 #. Tag: para
#: example_parentchild.xml:143
#, no-c-format
msgid "Now, the code to add a <literal>Child</literal> looks like" msgid "Now, the code to add a <literal>Child</literal> looks like"
msgstr "" msgstr "现在,添加<literal>Child</literal>的代码就是这样"
#: index.docbook:147 #. Tag: programlisting
#: example_parentchild.xml:147
#, no-c-format
msgid "" msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n" "<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = new Child();\n" "Child c = new Child();\n"
@ -160,15 +320,25 @@ msgid ""
"session.flush();]]>" "session.flush();]]>"
msgstr "" msgstr ""
#: index.docbook:152 #. Tag: title
#: example_parentchild.xml:152
#, no-c-format
msgid "Cascading life cycle" msgid "Cascading life cycle"
msgstr "" msgstr "级联生命周期Cascading life cycle"
#: index.docbook:154 #. Tag: para
msgid "The explicit call to <literal>save()</literal> is still annoying. We will address this by using cascades." #: example_parentchild.xml:154
#, no-c-format
msgid ""
"The explicit call to <literal>save()</literal> is still annoying. We will "
"address this by using cascades."
msgstr "" msgstr ""
"需要显式调用<literal>save()</literal>仍然很麻烦,我们可以用级联来解决这个问"
"题。"
#: index.docbook:159 #. Tag: programlisting
#: example_parentchild.xml:159
#, no-c-format
msgid "" msgid ""
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all\">\n" "<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all\">\n"
" <key column=\"parent_id\"/>\n" " <key column=\"parent_id\"/>\n"
@ -176,11 +346,15 @@ msgid ""
"</set>]]>" "</set>]]>"
msgstr "" msgstr ""
#: index.docbook:161 #. Tag: para
#: example_parentchild.xml:161
#, no-c-format
msgid "This simplifies the code above to" msgid "This simplifies the code above to"
msgstr "" msgstr "这样上面的代码可以简化为:"
#: index.docbook:165 #. Tag: programlisting
#: example_parentchild.xml:165
#, no-c-format
msgid "" msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n" "<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = new Child();\n" "Child c = new Child();\n"
@ -188,22 +362,35 @@ msgid ""
"session.flush();]]>" "session.flush();]]>"
msgstr "" msgstr ""
#: index.docbook:167 #. Tag: para
msgid "Similarly, we don't need to iterate over the children when saving or deleting a <literal>Parent</literal>. The following removes <literal>p</literal> and all its children from the database." #: example_parentchild.xml:167
#, no-c-format
msgid ""
"Similarly, we don't need to iterate over the children when saving or "
"deleting a <literal>Parent</literal>. The following removes <literal>p</"
"literal> and all its children from the database."
msgstr "" msgstr ""
"同样的,保存或删除<literal>Parent</literal>对象的时候并不需要遍历其子对象。 "
"下面的代码会删除对象<literal>p</literal>及其所有子对象对应的数据库记录。"
#: index.docbook:172 #. Tag: programlisting
#: example_parentchild.xml:172
#, no-c-format
msgid "" msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n" "<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"session.delete(p);\n" "session.delete(p);\n"
"session.flush();]]>" "session.flush();]]>"
msgstr "" msgstr ""
#: index.docbook:174 #. Tag: para
#: example_parentchild.xml:174
#, no-c-format
msgid "However, this code" msgid "However, this code"
msgstr "" msgstr "然而,这段代码"
#: index.docbook:178 #. Tag: programlisting
#: example_parentchild.xml:178
#, no-c-format
msgid "" msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n" "<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = (Child) p.getChildren().iterator().next();\n" "Child c = (Child) p.getChildren().iterator().next();\n"
@ -212,11 +399,22 @@ msgid ""
"session.flush();]]>" "session.flush();]]>"
msgstr "" msgstr ""
#: index.docbook:180 #. Tag: para
msgid "will not remove <literal>c</literal> from the database; it will ony remove the link to <literal>p</literal> (and cause a <literal>NOT NULL</literal> constraint violation, in this case). You need to explicitly <literal>delete()</literal> the <literal>Child</literal>." #: example_parentchild.xml:180
#, no-c-format
msgid ""
"will not remove <literal>c</literal> from the database; it will ony remove "
"the link to <literal>p</literal> (and cause a <literal>NOT NULL</literal> "
"constraint violation, in this case). You need to explicitly <literal>delete()"
"</literal> the <literal>Child</literal>."
msgstr "" msgstr ""
"不会从数据库删除<literal>c</literal>;它只会删除与<literal>p</literal>之间的"
"连接(并且会导致违反<literal>NOT NULL</literal>约束,在这个例子中)。你需要显"
"式调用<literal>delete()</literal>来删除<literal>Child</literal>。"
#: index.docbook:186 #. Tag: programlisting
#: example_parentchild.xml:186
#, no-c-format
msgid "" msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n" "<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = (Child) p.getChildren().iterator().next();\n" "Child c = (Child) p.getChildren().iterator().next();\n"
@ -225,35 +423,94 @@ msgid ""
"session.flush();]]>" "session.flush();]]>"
msgstr "" msgstr ""
#: index.docbook:188 #. Tag: para
msgid "Now, in our case, a <literal>Child</literal> can't really exist without its parent. So if we remove a <literal>Child</literal> from the collection, we really do want it to be deleted. For this, we must use <literal>cascade=\"all-delete-orphan\"</literal>." #: example_parentchild.xml:188
msgstr "" #, no-c-format
#: index.docbook:194
msgid "" msgid ""
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all-delete-orphan\">\n" "Now, in our case, a <literal>Child</literal> can't really exist without its "
"parent. So if we remove a <literal>Child</literal> from the collection, we "
"really do want it to be deleted. For this, we must use <literal>cascade="
"\"all-delete-orphan\"</literal>."
msgstr ""
"在我们的例子中如果没有父对象子对象就不应该存在如果将子对象从collection"
"中移除,实际上我们是想删除它。要实现这种要求,就必须使用<literal>cascade="
"\"all-delete-orphan\"</literal>。"
#. Tag: programlisting
#: example_parentchild.xml:194
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all-delete-orphan"
"\">\n"
" <key column=\"parent_id\"/>\n" " <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n" " <one-to-many class=\"Child\"/>\n"
"</set>]]>" "</set>]]>"
msgstr "" msgstr ""
#: index.docbook:196 #. Tag: para
msgid "Note: even though the collection mapping specifies <literal>inverse=\"true\"</literal>, cascades are still processed by iterating the collection elements. So if you require that an object be saved, deleted or updated by cascade, you must add it to the collection. It is not enough to simply call <literal>setParent()</literal>." #: example_parentchild.xml:196
#, no-c-format
msgid ""
"Note: even though the collection mapping specifies <literal>inverse=\"true"
"\"</literal>, cascades are still processed by iterating the collection "
"elements. So if you require that an object be saved, deleted or updated by "
"cascade, you must add it to the collection. It is not enough to simply call "
"<literal>setParent()</literal>."
msgstr "" msgstr ""
"注意即使在collection一方的映射中指定<literal>inverse=\"true\"</literal>,级"
"联仍然是通过遍历collection中的元素来处理的。如果你想要通过级联进行子对象的插"
"入、删除、更新操作就必须把它加到collection中只调用<literal>setParent()</"
"literal>是不够的。"
#: index.docbook:206 #. Tag: title
#: example_parentchild.xml:206
#, no-c-format
msgid "Cascades and <literal>unsaved-value</literal>" msgid "Cascades and <literal>unsaved-value</literal>"
msgstr "" msgstr ""
"级联与<literal>未保存值</literal>Cascades and <literal>unsaved-value</"
"literal>"
#: index.docbook:208 #. Tag: para
msgid "Suppose we loaded up a <literal>Parent</literal> in one <literal>Session</literal>, made some changes in a UI action and wish to persist these changes in a new session by calling <literal>update()</literal>. The <literal>Parent</literal> will contain a collection of childen and, since cascading update is enabled, Hibernate needs to know which children are newly instantiated and which represent existing rows in the database. Lets assume that both <literal>Parent</literal> and <literal>Child</literal> have genenerated identifier properties of type <literal>Long</literal>. Hibernate will use the identifier and version/timestamp property value to determine which of the children are new. (See <xref linkend=\"objectstate-saveorupdate\"/>.) <emphasis>In Hibernate3, it is no longer necessary to specify an <literal>unsaved-value</literal> explicitly.</emphasis>" #: example_parentchild.xml:208
#, no-c-format
msgid ""
"Suppose we loaded up a <literal>Parent</literal> in one <literal>Session</"
"literal>, made some changes in a UI action and wish to persist these changes "
"in a new session by calling <literal>update()</literal>. The "
"<literal>Parent</literal> will contain a collection of childen and, since "
"cascading update is enabled, Hibernate needs to know which children are "
"newly instantiated and which represent existing rows in the database. Lets "
"assume that both <literal>Parent</literal> and <literal>Child</literal> have "
"genenerated identifier properties of type <literal>Long</literal>. Hibernate "
"will use the identifier and version/timestamp property value to determine "
"which of the children are new. (See <xref linkend=\"objectstate-saveorupdate"
"\"/>.) <emphasis>In Hibernate3, it is no longer necessary to specify an "
"<literal>unsaved-value</literal> explicitly.</emphasis>"
msgstr "" msgstr ""
"假设我们从<literal>Session</literal>中装入了一个<literal>Parent</literal>对"
"象用户界面对其进行了修改然后希望在一个新的Session里面调用<literal>update"
"()</literal>来保存这些修改。对象<literal>Parent</literal>包含了子对象的集合,"
"由于打开了级联更新Hibernate需要知道哪些Child对象是新实例化的哪些代表数据"
"库中已经存在的记录。我们假设<literal>Parent</literal>和<literal>Child</"
"literal>对象的标识属性都是自动生成的,类型为<literal>java.lang.Long</"
"literal>。Hibernate会使用标识属性的值和version 或 timestamp 属性,来判断哪"
"些子对象是新的。(参见<xref linkend=\"objectstate-saveorupdate\"/>.) "
"<emphasis>在 Hibernate3 中,显式指定<literal>unsaved-value</literal>不再是必须"
"的了。</emphasis>"
#: index.docbook:220 #. Tag: para
msgid "The following code will update <literal>parent</literal> and <literal>child</literal> and insert <literal>newChild</literal>." #: example_parentchild.xml:220
#, no-c-format
msgid ""
"The following code will update <literal>parent</literal> and <literal>child</"
"literal> and insert <literal>newChild</literal>."
msgstr "" msgstr ""
"下面的代码会更新<literal>parent</literal>和<literal>child</literal>对象,并且"
"插入<literal>newChild</literal>对象。"
#: index.docbook:225 #. Tag: programlisting
#: example_parentchild.xml:225
#, no-c-format
msgid "" msgid ""
"<![CDATA[//parent and child were both loaded in a previous session\n" "<![CDATA[//parent and child were both loaded in a previous session\n"
"parent.addChild(child);\n" "parent.addChild(child);\n"
@ -263,25 +520,53 @@ msgid ""
"session.flush();]]>" "session.flush();]]>"
msgstr "" msgstr ""
#: index.docbook:227 #. Tag: para
msgid "Well, that's all very well for the case of a generated identifier, but what about assigned identifiers and composite identifiers? This is more difficult, since Hibernate can't use the identifier property to distinguish between a newly instantiated object (with an identifier assigned by the user) and an object loaded in a previous session. In this case, Hibernate will either use the timestamp or version property, or will actually query the second-level cache or, worst case, the database, to see if the row exists." #: example_parentchild.xml:227
#, no-c-format
msgid ""
"Well, that's all very well for the case of a generated identifier, but what "
"about assigned identifiers and composite identifiers? This is more "
"difficult, since Hibernate can't use the identifier property to distinguish "
"between a newly instantiated object (with an identifier assigned by the "
"user) and an object loaded in a previous session. In this case, Hibernate "
"will either use the timestamp or version property, or will actually query "
"the second-level cache or, worst case, the database, to see if the row "
"exists."
msgstr "" msgstr ""
"这对于自动生成标识的情况是非常好的,但是自分配的标识和复合标识怎么办呢?这是"
"有点麻烦因为Hibernate没有办法区分新实例化的对象标识被用户指定了和前一个"
"Session装入的对象。在这种情况下Hibernate会使用timestamp或version属性或者"
"查询第二级缓存,或者最坏的情况,查询数据库,来确认是否此行存在。"
#: index.docbook:260 #. Tag: title
#: example_parentchild.xml:260
#, no-c-format
msgid "Conclusion" msgid "Conclusion"
msgstr "结论"
#. Tag: para
#: example_parentchild.xml:262
#, no-c-format
msgid ""
"There is quite a bit to digest here and it might look confusing first time "
"around. However, in practice, it all works out very nicely. Most Hibernate "
"applications use the parent / child pattern in many places."
msgstr "" msgstr ""
"这里有不少东西需要融会贯通,可能会让新手感到迷惑。但是在实践中它们都工作地非"
"常好。大部分Hibernate应用程序都会经常用到父子对象模式。"
#: index.docbook:262 #. Tag: para
msgid "There is quite a bit to digest here and it might look confusing first time around. However, in practice, it all works out very nicely. Most Hibernate applications use the parent / child pattern in many places." #: example_parentchild.xml:267
#, no-c-format
msgid ""
"We mentioned an alternative in the first paragraph. None of the above issues "
"exist in the case of <literal>&lt;composite-element&gt;</literal> mappings, "
"which have exactly the semantics of a parent / child relationship. "
"Unfortunately, there are two big limitations to composite element classes: "
"composite elements may not own collections, and they should not be the child "
"of any entity other than the unique parent."
msgstr "" msgstr ""
"在第一段中我们曾经提到另一个方案。上面的这些问题都不会出现在<literal>&lt;"
#: index.docbook:267 "composite-element&gt;</literal>映射中,它准确地表达了父子关系的语义。很不幸复"
msgid "We mentioned an alternative in the first paragraph. None of the above issues exist in the case of <literal>&lt;composite-element&gt;</literal> mappings, which have exactly the semantics of a parent / child relationship. Unfortunately, there are two big limitations to composite element classes: composite elements may not own collections, and they should not be the child of any entity other than the unique parent." "合元素还有两个重大限制:复合元素不能拥有collections并且除了用于惟一的父对"
msgstr "" "象外,它们不能再作为其它任何实体的子对象。"
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,22 +1,41 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: example_weblog.xml:5
#, no-c-format
msgid "Example: Weblog Application" msgid "Example: Weblog Application"
msgstr "" msgstr "示例Weblog 应用程序"
#: index.docbook:8 #. Tag: title
#: example_weblog.xml:8
#, no-c-format
msgid "Persistent Classes" msgid "Persistent Classes"
msgstr "" msgstr "持久化类"
#: index.docbook:10 #. Tag: para
msgid "The persistent classes represent a weblog, and an item posted in a weblog. They are to be modelled as a standard parent/child relationship, but we will use an ordered bag, instead of a set." #: example_weblog.xml:10
#, no-c-format
msgid ""
"The persistent classes represent a weblog, and an item posted in a weblog. "
"They are to be modelled as a standard parent/child relationship, but we will "
"use an ordered bag, instead of a set."
msgstr "" msgstr ""
"下面的持久化类表示一个weblog和在其中张贴的一个贴子。他们是标准的父/子关系模"
"型但是我们会用一个有序包ordered bag)而非集合(set)。"
#: index.docbook:16 #. Tag: programlisting
#: example_weblog.xml:16
#, no-c-format
msgid "" msgid ""
"<![CDATA[package eg;\n" "<![CDATA[package eg;\n"
"\n" "\n"
@ -48,7 +67,9 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:18 #. Tag: programlisting
#: example_weblog.xml:18
#, no-c-format
msgid "" msgid ""
"<![CDATA[package eg;\n" "<![CDATA[package eg;\n"
"\n" "\n"
@ -95,15 +116,21 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:23 #. Tag: title
#: example_weblog.xml:23
#, no-c-format
msgid "Hibernate Mappings" msgid "Hibernate Mappings"
msgstr "" msgstr "Hibernate 映射"
#: index.docbook:25 #. Tag: para
#: example_weblog.xml:25
#, no-c-format
msgid "The XML mappings should now be quite straightforward." msgid "The XML mappings should now be quite straightforward."
msgstr "" msgstr "下列的XML映射应该是很直白的。"
#: index.docbook:29 #. Tag: programlisting
#: example_weblog.xml:29
#, no-c-format
msgid "" msgid ""
"<![CDATA[<?xml version=\"1.0\"?>\n" "<![CDATA[<?xml version=\"1.0\"?>\n"
"<!DOCTYPE hibernate-mapping PUBLIC\n" "<!DOCTYPE hibernate-mapping PUBLIC\n"
@ -146,7 +173,9 @@ msgid ""
"</hibernate-mapping>]]>" "</hibernate-mapping>]]>"
msgstr "" msgstr ""
#: index.docbook:31 #. Tag: programlisting
#: example_weblog.xml:31
#, no-c-format
msgid "" msgid ""
"<![CDATA[<?xml version=\"1.0\"?>\n" "<![CDATA[<?xml version=\"1.0\"?>\n"
"<!DOCTYPE hibernate-mapping PUBLIC\n" "<!DOCTYPE hibernate-mapping PUBLIC\n"
@ -193,15 +222,23 @@ msgid ""
"</hibernate-mapping>]]>" "</hibernate-mapping>]]>"
msgstr "" msgstr ""
#: index.docbook:36 #. Tag: title
#: example_weblog.xml:36
#, no-c-format
msgid "Hibernate Code" msgid "Hibernate Code"
msgstr "" msgstr "Hibernate 代码"
#: index.docbook:38 #. Tag: para
msgid "The following class demonstrates some of the kinds of things we can do with these classes, using Hibernate." #: example_weblog.xml:38
msgstr "" #, no-c-format
msgid ""
"The following class demonstrates some of the kinds of things we can do with "
"these classes, using Hibernate."
msgstr "下面的类演示了我们可以使用Hibernate对这些类进行的一些操作。"
#: index.docbook:43 #. Tag: programlisting
#: example_weblog.xml:43
#, no-c-format
msgid "" msgid ""
"<![CDATA[package eg;\n" "<![CDATA[package eg;\n"
"\n" "\n"
@ -341,7 +378,8 @@ msgid ""
" Transaction tx = null;\n" " Transaction tx = null;\n"
" try {\n" " try {\n"
" tx = session.beginTransaction();\n" " tx = session.beginTransaction();\n"
" BlogItem item = (BlogItem) session.load(BlogItem.class, itemid);\n" " BlogItem item = (BlogItem) session.load(BlogItem.class, "
"itemid);\n"
" item.setText(text);\n" " item.setText(text);\n"
" tx.commit();\n" " tx.commit();\n"
" }\n" " }\n"
@ -441,10 +479,3 @@ msgid ""
" }\n" " }\n"
"}]]>" "}]]>"
msgstr "" msgstr ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,80 +1,170 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: filters.xml:5
#, no-c-format
msgid "Filtering data" msgid "Filtering data"
msgstr "" msgstr "过滤数据"
#: index.docbook:7 #. Tag: para
msgid "Hibernate3 provides an innovative new approach to handling data with \"visibility\" rules. A <emphasis>Hibernate filter</emphasis> is a global, named, parameterized filter that may be enabled or disabled for a particular Hibernate session." #: filters.xml:7
#, no-c-format
msgid ""
"Hibernate3 provides an innovative new approach to handling data with "
"\"visibility\" rules. A <emphasis>Hibernate filter</emphasis> is a global, "
"named, parameterized filter that may be enabled or disabled for a particular "
"Hibernate session."
msgstr "" msgstr ""
"Hibernate3 提供了一种创新的方式来处理具有“显性(visibility)”规则的数据,那就是"
"使用<emphasis>Hibernate filter</emphasis>。 <emphasis>Hibernate filter</"
"emphasis>是全局有效的、具有名字、可以带参数的过滤器, 对于某个特定的"
"Hibernate session您可以选择是否启用或禁用某个过滤器。"
#: index.docbook:14 #. Tag: title
#: filters.xml:14
#, no-c-format
msgid "Hibernate filters" msgid "Hibernate filters"
msgstr "" msgstr "Hibernate 过滤器(filters)"
#: index.docbook:16 #. Tag: para
msgid "Hibernate3 adds the ability to pre-define filter criteria and attach those filters at both a class and a collection level. A filter criteria is the ability to define a restriction clause very similiar to the existing \"where\" attribute available on the class and various collection elements. Except these filter conditions can be parameterized. The application can then make the decision at runtime whether given filters should be enabled and what their parameter values should be. Filters can be used like database views, but parameterized inside the application." #: filters.xml:16
#, no-c-format
msgid ""
"Hibernate3 adds the ability to pre-define filter criteria and attach those "
"filters at both a class and a collection level. A filter criteria is the "
"ability to define a restriction clause very similiar to the existing \"where"
"\" attribute available on the class and various collection elements. Except "
"these filter conditions can be parameterized. The application can then make "
"the decision at runtime whether given filters should be enabled and what "
"their parameter values should be. Filters can be used like database views, "
"but parameterized inside the application."
msgstr "" msgstr ""
"Hibernate3新增了对某个类或者集合使用预先定义的过滤器条件(filter criteria)的功"
"能。过滤器条件相当于定义一个 非常类似于类和各种集合上的“where”属性的约束子"
"句,但是过滤器条件可以带参数。 应用程序可以在运行时决定是否启用给定的过滤器,"
"以及使用什么样的参数值。 过滤器的用法很像数据库视图,只不过是在应用程序中确定"
"使用什么样的参数的。"
#: index.docbook:26 #. Tag: para
msgid "In order to use filters, they must first be defined and then attached to the appropriate mapping elements. To define a filter, use the <literal>&lt;filter-def/&gt;</literal> element within a <literal>&lt;hibernate-mapping/&gt;</literal> element:" #: filters.xml:26
#, no-c-format
msgid ""
"In order to use filters, they must first be defined and then attached to the "
"appropriate mapping elements. To define a filter, use the <literal>&lt;"
"filter-def/&gt;</literal> element within a <literal>&lt;hibernate-mapping/"
"&gt;</literal> element:"
msgstr "" msgstr ""
"要使用过滤器,必须首先在相应的映射节点中定义。而定义一个过滤器,要用到位于"
"<literal>&lt;hibernate-mapping/&gt;</literal> 节点之内的<literal>&lt;filter-"
"def/&gt;</literal>节点:"
#: index.docbook:32 #. Tag: programlisting
#: filters.xml:32
#, no-c-format
msgid "" msgid ""
"<![CDATA[<filter-def name=\"myFilter\">\n" "<![CDATA[<filter-def name=\"myFilter\">\n"
" <filter-param name=\"myFilterParam\" type=\"string\"/>\n" " <filter-param name=\"myFilterParam\" type=\"string\"/>\n"
"</filter-def>]]>" "</filter-def>]]>"
msgstr "" msgstr ""
#: index.docbook:34 #. Tag: para
#: filters.xml:34
#, no-c-format
msgid "Then, this filter can be attached to a class:" msgid "Then, this filter can be attached to a class:"
msgstr "" msgstr "定义好之后,就可以在某个类中使用这个过滤器:"
#: index.docbook:38 #. Tag: programlisting
#: filters.xml:38
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"myClass\" ...>\n" "<![CDATA[<class name=\"myClass\" ...>\n"
" ...\n" " ...\n"
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN\"/>\n" " <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
"\"/>\n"
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:40 #. Tag: para
#: filters.xml:40
#, no-c-format
msgid "or, to a collection:" msgid "or, to a collection:"
msgstr "" msgstr "也可以在某个集合使用它:"
#: index.docbook:44 #. Tag: programlisting
#: filters.xml:44
#, no-c-format
msgid "" msgid ""
"<![CDATA[<set ...>\n" "<![CDATA[<set ...>\n"
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN\"/>\n" " <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
"\"/>\n"
"</set>]]>" "</set>]]>"
msgstr "" msgstr ""
#: index.docbook:46 #. Tag: para
#: filters.xml:46
#, no-c-format
msgid "or, even to both (or multiples of each) at the same time." msgid "or, even to both (or multiples of each) at the same time."
msgstr "" msgstr ""
"可以在多个类或集合中使用某个过滤器;某个类或者集合中也可以使用多个过滤器。"
#: index.docbook:50 #. Tag: para
msgid "The methods on <literal>Session</literal> are: <literal>enableFilter(String filterName)</literal>, <literal>getEnabledFilter(String filterName)</literal>, and <literal>disableFilter(String filterName)</literal>. By default, filters are <emphasis>not</emphasis> enabled for a given session; they must be explcitly enabled through use of the <literal>Session.enabledFilter()</literal> method, which returns an instance of the <literal>Filter</literal> interface. Using the simple filter defined above, this would look like:" #: filters.xml:50
#, no-c-format
msgid ""
"The methods on <literal>Session</literal> are: <literal>enableFilter(String "
"filterName)</literal>, <literal>getEnabledFilter(String filterName)</"
"literal>, and <literal>disableFilter(String filterName)</literal>. By "
"default, filters are <emphasis>not</emphasis> enabled for a given session; "
"they must be explcitly enabled through use of the <literal>Session."
"enabledFilter()</literal> method, which returns an instance of the "
"<literal>Filter</literal> interface. Using the simple filter defined above, "
"this would look like:"
msgstr ""
"<literal>Session</literal>对象中会用到的方法有:<literal>enableFilter(String "
"filterName)</literal>, <literal>getEnabledFilter(String filterName)</"
"literal>, 和 <literal>disableFilter(String filterName)</literal>. Session中默"
"认是<emphasis>不</emphasis>启用过滤器的,必须通过<literal>Session."
"enabledFilter()</literal>方法显式的启用。 该方法返回被启用的<literal>Filter</"
"literal>的实例。以上文定义的过滤器为例:"
#. Tag: programlisting
#: filters.xml:59
#, no-c-format
msgid ""
"<![CDATA[session.enableFilter(\"myFilter\").setParameter(\"myFilterParam\", "
"\"some-value\");]]>"
msgstr "" msgstr ""
#: index.docbook:59 #. Tag: para
msgid "<![CDATA[session.enableFilter(\"myFilter\").setParameter(\"myFilterParam\", \"some-value\");]]>" #: filters.xml:61
#, no-c-format
msgid ""
"Note that methods on the org.hibernate.Filter interface do allow the method-"
"chaining common to much of Hibernate."
msgstr "" msgstr ""
"注意org.hibernate.Filter的方法允许链式方法调用。类似上面例子中启用Filter"
"之后设定Filter参数这个“方法链” Hibernate的其他部分也大多有这个特性。"
#: index.docbook:61 #. Tag: para
msgid "Note that methods on the org.hibernate.Filter interface do allow the method-chaining common to much of Hibernate." #: filters.xml:65
msgstr "" #, no-c-format
msgid ""
"A full example, using temporal data with an effective record date pattern:"
msgstr "下面是一个比较完整的例子,使用了记录生效日期模式过滤有时效的数据:"
#: index.docbook:65 #. Tag: programlisting
msgid "A full example, using temporal data with an effective record date pattern:" #: filters.xml:69
msgstr "" #, no-c-format
#: index.docbook:69
msgid "" msgid ""
"<![CDATA[<filter-def name=\"effectiveDate\">\n" "<![CDATA[<filter-def name=\"effectiveDate\">\n"
" <filter-param name=\"asOfDate\" type=\"date\"/>\n" " <filter-param name=\"asOfDate\" type=\"date\"/>\n"
@ -82,12 +172,16 @@ msgid ""
"\n" "\n"
"<class name=\"Employee\" ...>\n" "<class name=\"Employee\" ...>\n"
"...\n" "...\n"
" <many-to-one name=\"department\" column=\"dept_id\" class=\"Department\"/>\n" " <many-to-one name=\"department\" column=\"dept_id\" class=\"Department\"/"
" <property name=\"effectiveStartDate\" type=\"date\" column=\"eff_start_dt\"/>\n" ">\n"
" <property name=\"effectiveEndDate\" type=\"date\" column=\"eff_end_dt\"/>\n" " <property name=\"effectiveStartDate\" type=\"date\" column=\"eff_start_dt"
"\"/>\n"
" <property name=\"effectiveEndDate\" type=\"date\" column=\"eff_end_dt\"/"
">\n"
"...\n" "...\n"
" <!--\n" " <!--\n"
" Note that this assumes non-terminal records have an eff_end_dt set to\n" " Note that this assumes non-terminal records have an eff_end_dt set "
"to\n"
" a max db date for simplicity-sake\n" " a max db date for simplicity-sake\n"
" -->\n" " -->\n"
" <filter name=\"effectiveDate\"\n" " <filter name=\"effectiveDate\"\n"
@ -100,50 +194,93 @@ msgid ""
" <key column=\"dept_id\"/>\n" " <key column=\"dept_id\"/>\n"
" <one-to-many class=\"Employee\"/>\n" " <one-to-many class=\"Employee\"/>\n"
" <filter name=\"effectiveDate\"\n" " <filter name=\"effectiveDate\"\n"
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/>\n" " condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/"
">\n"
" </set>\n" " </set>\n"
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:71 #. Tag: para
msgid "Then, in order to ensure that you always get back currently effective records, simply enable the filter on the session prior to retrieving employee data:" #: filters.xml:71
#, no-c-format
msgid ""
"Then, in order to ensure that you always get back currently effective "
"records, simply enable the filter on the session prior to retrieving "
"employee data:"
msgstr "" msgstr ""
"定义好后,如果想要保证取回的都是目前处于生效期的记录,只需在获取雇员数据的操"
"作之前先开启过滤器即可:"
#: index.docbook:76 #. Tag: programlisting
#: filters.xml:76
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session session = ...;\n" "<![CDATA[Session session = ...;\n"
"session.enabledFilter(\"effectiveDate\").setParameter(\"asOfDate\", new Date());\n" "session.enabledFilter(\"effectiveDate\").setParameter(\"asOfDate\", new Date"
"List results = session.createQuery(\"from Employee as e where e.salary > :targetSalary\")\n" "());\n"
"List results = session.createQuery(\"from Employee as e where e.salary > :"
"targetSalary\")\n"
" .setLong(\"targetSalary\", new Long(1000000))\n" " .setLong(\"targetSalary\", new Long(1000000))\n"
" .list();\n" " .list();\n"
"]]>" "]]>"
msgstr "" msgstr ""
#: index.docbook:78 #. Tag: para
msgid "In the HQL above, even though we only explicitly mentioned a salary constraint on the results, because of the enabled filter the query will return only currently active employees who have a salary greater than a million dollars." #: filters.xml:78
msgstr "" #, no-c-format
#: index.docbook:84
msgid "Note: if you plan on using filters with outer joining (either through HQL or load fetching) be careful of the direction of the condition expression. Its safest to set this up for left outer joining; in general, place the parameter first followed by the column name(s) after the operator."
msgstr ""
#: index.docbook:91
msgid "After being defined a filter might be attached to multiple entities and/or collections each with its own condition. That can be tedious when the conditions are the same each time. Thus <literal>&lt;filter-def/&gt;</literal> allows defining a default condition, either as an attribute or CDATA:"
msgstr ""
#: index.docbook:98
msgid "" msgid ""
"<![CDATA[<filter-def name=\"myFilter\" condition=\"abc > xyz\">...</filter-def>\n" "In the HQL above, even though we only explicitly mentioned a salary "
"constraint on the results, because of the enabled filter the query will "
"return only currently active employees who have a salary greater than a "
"million dollars."
msgstr ""
"在上面的HQL中虽然我们仅仅显式的使用了一个薪水条件但因为启用了过滤器查询"
"将仅返回那些目前雇用 关系处于生效期的,并且薪水高于一百万美刀的雇员的数据。"
#. Tag: para
#: filters.xml:84
#, no-c-format
msgid ""
"Note: if you plan on using filters with outer joining (either through HQL or "
"load fetching) be careful of the direction of the condition expression. Its "
"safest to set this up for left outer joining; in general, place the "
"parameter first followed by the column name(s) after the operator."
msgstr ""
"注意如果你打算在使用外连接或者通过HQL或load fetching的同时使用过滤器"
"要注意条件表达式的方向(左还是右)。 最安全的方式是使用左外连接left outer "
"joining。并且通常来说先写参数 然后是操作符,最后写数据库字段名。"
#. Tag: para
#: filters.xml:91
#, no-c-format
msgid ""
"After being defined a filter might be attached to multiple entities and/or "
"collections each with its own condition. That can be tedious when the "
"conditions are the same each time. Thus <literal>&lt;filter-def/&gt;</"
"literal> allows defining a default condition, either as an attribute or "
"CDATA:"
msgstr ""
"在Filter定义之后,它可能被附加到多个实体和/或集合类,每个都有自己的条件。假若这"
"些条件都是一样的,每次都要定义就显得很繁琐。因此,<literal>&lt;filter-def/"
"&gt;</literal>被用来定义一个默认条件它可能作为属性或者CDATA出现"
#. Tag: programlisting
#: filters.xml:98
#, no-c-format
msgid ""
"<![CDATA[<filter-def name=\"myFilter\" condition=\"abc > xyz\">...</filter-"
"def>\n"
"<filter-def name=\"myOtherFilter\">abc=xyz</filter-def>]]>" "<filter-def name=\"myOtherFilter\">abc=xyz</filter-def>]]>"
msgstr "" msgstr ""
#: index.docbook:100 #. Tag: para
msgid "This default condition will then be used whenever the filter is attached to something without specifying a condition. Note that this means you can give a specific condition as part of the attachment of the filter which overrides the default condition in that particular case." #: filters.xml:100
#, no-c-format
msgid ""
"This default condition will then be used whenever the filter is attached to "
"something without specifying a condition. Note that this means you can give "
"a specific condition as part of the attachment of the filter which overrides "
"the default condition in that particular case."
msgstr "" msgstr ""
"当这个filter被附加到任何目的地而又没有指明条件时这个条件就会被使用。注"
msgid "ROLES_OF_TRANSLATORS" "意换句话说你可以通过给filter附加特别的条件来重载默认条件。"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,68 +1,152 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: inheritance_mapping.xml:5
#, no-c-format
msgid "Inheritance Mapping" msgid "Inheritance Mapping"
msgstr "" msgstr "继承映射(Inheritance Mappings)"
#: index.docbook:8 #. Tag: title
#: inheritance_mapping.xml:8
#, no-c-format
msgid "The Three Strategies" msgid "The Three Strategies"
msgstr "" msgstr "三种策略"
#: index.docbook:10 #. Tag: para
#: inheritance_mapping.xml:10
#, no-c-format
msgid "Hibernate supports the three basic inheritance mapping strategies:" msgid "Hibernate supports the three basic inheritance mapping strategies:"
msgstr "" msgstr "Hibernate支持三种基本的继承映射策略"
#: index.docbook:16 #. Tag: para
#: inheritance_mapping.xml:16
#, no-c-format
msgid "table per class hierarchy" msgid "table per class hierarchy"
msgstr "" msgstr "每个类分层结构一张表(table per class hierarchy)"
#: index.docbook:21 #. Tag: para
#: inheritance_mapping.xml:21
#, fuzzy, no-c-format
msgid "<para>table per subclass</para>" msgid "<para>table per subclass</para>"
msgstr "" msgstr ""
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"每个子类一张表(table per subclass)\n"
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"每个子类一张表"
#: index.docbook:26 #. Tag: para
#: inheritance_mapping.xml:26
#, no-c-format
msgid "table per concrete class" msgid "table per concrete class"
msgstr "" msgstr "每个具体类一张表(table per concrete class)"
#: index.docbook:32 #. Tag: para
msgid "In addition, Hibernate supports a fourth, slightly different kind of polymorphism:" #: inheritance_mapping.xml:32
msgstr "" #, no-c-format
msgid ""
"In addition, Hibernate supports a fourth, slightly different kind of "
"polymorphism:"
msgstr "此外Hibernate还支持第四种稍有不同的多态映射策略"
#: index.docbook:39 #. Tag: para
#: inheritance_mapping.xml:39
#, no-c-format
msgid "implicit polymorphism" msgid "implicit polymorphism"
msgstr "" msgstr "隐式多态(implicit polymorphism)"
#: index.docbook:45 #. Tag: para
msgid "It is possible to use different mapping strategies for different branches of the same inheritance hierarchy, and then make use of implicit polymorphism to achieve polymorphism across the whole hierarchy. However, Hibernate does not support mixing <literal>&lt;subclass&gt;</literal>, and <literal>&lt;joined-subclass&gt;</literal> and <literal>&lt;union-subclass&gt;</literal> mappings under the same root <literal>&lt;class&gt;</literal> element. It is possible to mix together the table per hierarchy and table per subclass strategies, under the the same <literal>&lt;class&gt;</literal> element, by combining the <literal>&lt;subclass&gt;</literal> and <literal>&lt;join&gt;</literal> elements (see below)." #: inheritance_mapping.xml:45
#, no-c-format
msgid ""
"It is possible to use different mapping strategies for different branches of "
"the same inheritance hierarchy, and then make use of implicit polymorphism "
"to achieve polymorphism across the whole hierarchy. However, Hibernate does "
"not support mixing <literal>&lt;subclass&gt;</literal>, and <literal>&lt;"
"joined-subclass&gt;</literal> and <literal>&lt;union-subclass&gt;</literal> "
"mappings under the same root <literal>&lt;class&gt;</literal> element. It is "
"possible to mix together the table per hierarchy and table per subclass "
"strategies, under the the same <literal>&lt;class&gt;</literal> element, by "
"combining the <literal>&lt;subclass&gt;</literal> and <literal>&lt;join&gt;</"
"literal> elements (see below)."
msgstr "" msgstr ""
"对于同一个继承层次内的不同分支,可以采用不同的映射策略,然后用隐式多 态来完成"
"跨越整个层次的多态。但是在同一个<literal>&lt;class&gt;</literal>根元素 下,"
"Hibernate不支持混合了元素<literal>&lt;subclass&gt;</literal>、 <literal>&lt;"
"joined-subclass&gt;</literal>和<literal>&lt;union-subclass&gt;</literal> 的映"
"射。在同一个<literal>&lt;class&gt;</literal>元素下,可以混合使用 “每个类分层"
"结构一张表”table per hierarchy 和“每个子类一张表”table per subclass "
"这两种映射策略,这是通过结合元素<literal>&lt;subclass&gt;</literal>和 "
"<literal>&lt;join&gt;</literal>来实现的(见后)。"
#: index.docbook:59 #. Tag: para
msgid "It is possible to define <literal>subclass</literal>, <literal>union-subclass</literal>, and <literal>joined-subclass</literal> mappings in separate mapping documents, directly beneath <literal>hibernate-mapping</literal>. This allows you to extend a class hierachy just by adding a new mapping file. You must specify an <literal>extends</literal> attribute in the subclass mapping, naming a previously mapped superclass. Note: Previously this feature made the ordering of the mapping documents important. Since Hibernate3, the ordering of mapping files does not matter when using the extends keyword. The ordering inside a single mapping file still needs to be defined as superclasses before subclasses." #: inheritance_mapping.xml:59
#, no-c-format
msgid ""
"It is possible to define <literal>subclass</literal>, <literal>union-"
"subclass</literal>, and <literal>joined-subclass</literal> mappings in "
"separate mapping documents, directly beneath <literal>hibernate-mapping</"
"literal>. This allows you to extend a class hierachy just by adding a new "
"mapping file. You must specify an <literal>extends</literal> attribute in "
"the subclass mapping, naming a previously mapped superclass. Note: "
"Previously this feature made the ordering of the mapping documents "
"important. Since Hibernate3, the ordering of mapping files does not matter "
"when using the extends keyword. The ordering inside a single mapping file "
"still needs to be defined as superclasses before subclasses."
msgstr "" msgstr ""
"在多个映射文件中,可以直接在<literal>hibernate-mapping</literal>根下定义"
"<literal>subclass</literal><literal>union-subclass</literal>和"
"<literal>joined-subclass</literal>。也就是说,你可以仅加入一个新的映射文件来"
"扩展类层次。你必须在subclass的映射中指明<literal>extends</literal>属性,给出"
"一个之前定义的超类的名字。注意,在以前,这一功能对映射文件的顺序有严格的要"
"求从Hibernate 3开始使用extends关键字的时侯对映射文件的顺序不再有要求"
"但在每个映射文件里,超类必须在子类之前定义。"
#: index.docbook:70 #. Tag: programlisting
#: inheritance_mapping.xml:70
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
" <hibernate-mapping>\n" " <hibernate-mapping>\n"
" <subclass name=\"DomesticCat\" extends=\"Cat\" discriminator-value=\"D\">\n" " <subclass name=\"DomesticCat\" extends=\"Cat\" discriminator-value=\"D"
"\">\n"
" <property name=\"name\" type=\"string\"/>\n" " <property name=\"name\" type=\"string\"/>\n"
" </subclass>\n" " </subclass>\n"
" </hibernate-mapping>]]>" " </hibernate-mapping>]]>"
msgstr "" msgstr ""
#: index.docbook:74 #. Tag: title
#: inheritance_mapping.xml:74
#, no-c-format
msgid "Table per class hierarchy" msgid "Table per class hierarchy"
msgstr "" msgstr "每个类分层结构一张表(Table per class hierarchy)"
#: index.docbook:76 #. Tag: para
msgid "Suppose we have an interface <literal>Payment</literal>, with implementors <literal>CreditCardPayment</literal>, <literal>CashPayment</literal>, <literal>ChequePayment</literal>. The table per hierarchy mapping would look like:" #: inheritance_mapping.xml:76
#, no-c-format
msgid ""
"Suppose we have an interface <literal>Payment</literal>, with implementors "
"<literal>CreditCardPayment</literal>, <literal>CashPayment</literal>, "
"<literal>ChequePayment</literal>. The table per hierarchy mapping would look "
"like:"
msgstr "" msgstr ""
"假设我们有接口<literal>Payment</literal>和它的几个实现类: "
"<literal>CreditCardPayment</literal>, <literal>CashPayment</literal>, 和"
"<literal>ChequePayment</literal>。则“每个类分层结构一张表”(Table per class "
"hierarchy)的映射代码如下所示:"
#: index.docbook:83 #. Tag: programlisting
#: inheritance_mapping.xml:83
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n" "<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n" " <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
@ -84,19 +168,32 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:85 #. Tag: para
msgid "Exactly one table is required. There is one big limitation of this mapping strategy: columns declared by the subclasses, such as <literal>CCTYPE</literal>, may not have <literal>NOT NULL</literal> constraints." #: inheritance_mapping.xml:85
#, no-c-format
msgid ""
"Exactly one table is required. There is one big limitation of this mapping "
"strategy: columns declared by the subclasses, such as <literal>CCTYPE</"
"literal>, may not have <literal>NOT NULL</literal> constraints."
msgstr "" msgstr ""
"采用这种策略只需要一张表即可。它有一个很大的限制:要求那些由子类定义的字段, "
"如<literal>CCTYPE</literal>,不能有<literal>非空(NOT NULL)</literal>约束。"
#: index.docbook:94 #. Tag: title
#: inheritance_mapping.xml:94
#, no-c-format
msgid "Table per subclass" msgid "Table per subclass"
msgstr "" msgstr "每个子类一张表(Table per subclass)"
#: index.docbook:96 #. Tag: para
#: inheritance_mapping.xml:96
#, no-c-format
msgid "A table per subclass mapping would look like:" msgid "A table per subclass mapping would look like:"
msgstr "" msgstr "对于上例中的几个类而言,采用“每个子类一张表”的映射策略,代码如下所示:"
#: index.docbook:100 #. Tag: programlisting
#: inheritance_mapping.xml:100
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n" "<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n" " <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
@ -120,19 +217,45 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:102 #. Tag: para
msgid "Four tables are required. The three subclass tables have primary key associations to the superclass table (so the relational model is actually a one-to-one association)." #: inheritance_mapping.xml:102
#, no-c-format
msgid ""
"Four tables are required. The three subclass tables have primary key "
"associations to the superclass table (so the relational model is actually a "
"one-to-one association)."
msgstr "" msgstr ""
"需要四张表。三个子类表通过主键关联到超类表(因而关系模型实际上是一对一关联)。"
#: index.docbook:111 #. Tag: title
#: inheritance_mapping.xml:111
#, no-c-format
msgid "Table per subclass, using a discriminator" msgid "Table per subclass, using a discriminator"
msgstr "" msgstr "每个子类一张表(Table per subclass),使用辨别标志(Discriminator)"
#: index.docbook:113 #. Tag: para
msgid "Note that Hibernate's implementation of table per subclass requires no discriminator column. Other object/relational mappers use a different implementation of table per subclass which requires a type discriminator column in the superclass table. The approach taken by Hibernate is much more difficult to implement but arguably more correct from a relational point of view. If you would like to use a discriminator column with the table per subclass strategy, you may combine the use of <literal>&lt;subclass&gt;</literal> and <literal>&lt;join&gt;</literal>, as follow:" #: inheritance_mapping.xml:113
#, no-c-format
msgid ""
"Note that Hibernate's implementation of table per subclass requires no "
"discriminator column. Other object/relational mappers use a different "
"implementation of table per subclass which requires a type discriminator "
"column in the superclass table. The approach taken by Hibernate is much more "
"difficult to implement but arguably more correct from a relational point of "
"view. If you would like to use a discriminator column with the table per "
"subclass strategy, you may combine the use of <literal>&lt;subclass&gt;</"
"literal> and <literal>&lt;join&gt;</literal>, as follow:"
msgstr "" msgstr ""
"注意对“每个子类一张表”的映射策略Hibernate的实现不需要辨别字段而其他 的"
"对象/关系映射工具使用了一种不同于Hibernate的实现方法该方法要求在超类 表中有"
"一个类型辨别字段(type discriminator column)。Hibernate采用的方法更 难实现,但"
"从关系(数据库)的角度来看,按理说它更正确。若你愿意使用带有辨别字 段的“每个"
"子类一张表”的策略,你可以结合使用<literal>&lt;subclass&gt;</literal> 与"
"<literal>&lt;join&gt;</literal>,如下所示:"
#: index.docbook:125 #. Tag: programlisting
#: inheritance_mapping.xml:125
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n" "<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n" " <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
@ -163,19 +286,37 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:127 #. Tag: para
msgid "The optional <literal>fetch=\"select\"</literal> declaration tells Hibernate not to fetch the <literal>ChequePayment</literal> subclass data using an outer join when querying the superclass." #: inheritance_mapping.xml:127
#, no-c-format
msgid ""
"The optional <literal>fetch=\"select\"</literal> declaration tells Hibernate "
"not to fetch the <literal>ChequePayment</literal> subclass data using an "
"outer join when querying the superclass."
msgstr "" msgstr ""
"可选的声明<literal>fetch=\"select\"</literal>是用来告诉Hibernate在查询超"
"类时, 不要使用外部连接(outer join)来抓取子类<literal>ChequePayment</literal>"
"的数据。"
#: index.docbook:136 #. Tag: title
#: inheritance_mapping.xml:136
#, no-c-format
msgid "Mixing table per class hierarchy with table per subclass" msgid "Mixing table per class hierarchy with table per subclass"
msgstr "" msgstr "混合使用“每个类分层结构一张表”和“每个子类一张表”"
#: index.docbook:138 #. Tag: para
msgid "You may even mix the table per hierarchy and table per subclass strategies using this approach:" #: inheritance_mapping.xml:138
#, no-c-format
msgid ""
"You may even mix the table per hierarchy and table per subclass strategies "
"using this approach:"
msgstr "" msgstr ""
"你甚至可以采取如下方法混和使用“每个类分层结构一张表”和“每个子类一张表”这两种"
"策略:"
#: index.docbook:143 #. Tag: programlisting
#: inheritance_mapping.xml:143
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n" "<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n"
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n" " <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
@ -199,23 +340,44 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:145 #. Tag: para
msgid "For any of these mapping strategies, a polymorphic association to the root <literal>Payment</literal> class is mapped using <literal>&lt;many-to-one&gt;</literal>." #: inheritance_mapping.xml:145
#, no-c-format
msgid ""
"For any of these mapping strategies, a polymorphic association to the root "
"<literal>Payment</literal> class is mapped using <literal>&lt;many-to-one&gt;"
"</literal>."
msgstr ""
"对上述任何一种映射策略而言,指向根类<literal>Payment</literal>的 关联是使用"
"<literal>&lt;many-to-one&gt;</literal>进行映射的。"
#. Tag: programlisting
#: inheritance_mapping.xml:151
#, no-c-format
msgid ""
"<![CDATA[<many-to-one name=\"payment\" column=\"PAYMENT_ID\" class=\"Payment"
"\"/>]]>"
msgstr "" msgstr ""
#: index.docbook:151 #. Tag: title
msgid "<![CDATA[<many-to-one name=\"payment\" column=\"PAYMENT_ID\" class=\"Payment\"/>]]>" #: inheritance_mapping.xml:156
msgstr "" #, no-c-format
#: index.docbook:156
msgid "Table per concrete class" msgid "Table per concrete class"
msgstr "" msgstr "每个具体类一张表(Table per concrete class)"
#: index.docbook:158 #. Tag: para
msgid "There are two ways we could go about mapping the table per concrete class strategy. The first is to use <literal>&lt;union-subclass&gt;</literal>." #: inheritance_mapping.xml:158
#, no-c-format
msgid ""
"There are two ways we could go about mapping the table per concrete class "
"strategy. The first is to use <literal>&lt;union-subclass&gt;</literal>."
msgstr "" msgstr ""
"对于“每个具体类一张表”的映射策略,可以采用两种方法。第一种方法是使用 "
"<literal>&lt;union-subclass&gt;</literal>。"
#: index.docbook:163 #. Tag: programlisting
#: inheritance_mapping.xml:163
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Payment\">\n" "<![CDATA[<class name=\"Payment\">\n"
" <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n" " <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n"
@ -236,27 +398,60 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:165 #. Tag: para
msgid "Three tables are involved for the subclasses. Each table defines columns for all properties of the class, including inherited properties." #: inheritance_mapping.xml:165
#, no-c-format
msgid ""
"Three tables are involved for the subclasses. Each table defines columns for "
"all properties of the class, including inherited properties."
msgstr "" msgstr ""
"这里涉及三张与子类相关的表。每张表为对应类的所有属性(包括从超类继承的属性)"
"定义相应字段。"
#: index.docbook:170 #. Tag: para
msgid "The limitation of this approach is that if a property is mapped on the superclass, the column name must be the same on all subclass tables. (We might relax this in a future release of Hibernate.) The identity generator strategy is not allowed in union subclass inheritance, indeed the primary key seed has to be shared accross all unioned subclasses of a hierarchy." #: inheritance_mapping.xml:170
#, no-c-format
msgid ""
"The limitation of this approach is that if a property is mapped on the "
"superclass, the column name must be the same on all subclass tables. (We "
"might relax this in a future release of Hibernate.) The identity generator "
"strategy is not allowed in union subclass inheritance, indeed the primary "
"key seed has to be shared accross all unioned subclasses of a hierarchy."
msgstr "" msgstr ""
"这种方式的局限在于,如果一个属性在超类中做了映射,其字段名必须与所有子类 表中"
"定义的相同。(我们可能会在Hibernate的后续发布版本中放宽此限制。) 不允许在联合"
"子类(union subclass)的继承层次中使用标识生成器策略(identity generator "
"strategy), 实际上, 主键的种子(primary key seed)不得不为同一继承层次中的全部被"
"联合子类所共用."
#: index.docbook:179 #. Tag: para
msgid "If your superclass is abstract, map it with <literal>abstract=\"true\"</literal>. Of course, if it is not abstract, an additional table (defaults to <literal>PAYMENT</literal> in the example above) is needed to hold instances of the superclass." #: inheritance_mapping.xml:179
#, no-c-format
msgid ""
"If your superclass is abstract, map it with <literal>abstract=\"true\"</"
"literal>. Of course, if it is not abstract, an additional table (defaults to "
"<literal>PAYMENT</literal> in the example above) is needed to hold instances "
"of the superclass."
msgstr "" msgstr ""
"假若超类是抽象类,请使用<literal>abstract=\"true\"</literal>。当然,假若它不"
"是抽象的,需要一个额外的表(上面的例子中,默认是<literal>PAYMENT</"
"literal>),来保存超类的实例。"
#: index.docbook:189 #. Tag: title
#: inheritance_mapping.xml:189
#, no-c-format
msgid "Table per concrete class, using implicit polymorphism" msgid "Table per concrete class, using implicit polymorphism"
msgstr "" msgstr "每个具体类一张表,使用隐式多态"
#: index.docbook:191 #. Tag: para
#: inheritance_mapping.xml:191
#, no-c-format
msgid "An alternative approach is to make use of implicit polymorphism:" msgid "An alternative approach is to make use of implicit polymorphism:"
msgstr "" msgstr "另一种可供选择的方法是采用隐式多态:"
#: index.docbook:195 #. Tag: programlisting
#: inheritance_mapping.xml:195
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n" "<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
" <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n" " <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n"
@ -283,19 +478,46 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:197 #. Tag: para
msgid "Notice that nowhere do we mention the <literal>Payment</literal> interface explicitly. Also notice that properties of <literal>Payment</literal> are mapped in each of the subclasses. If you want to avoid duplication, consider using XML entities (e.g. <literal>[ &lt;!ENTITY allproperties SYSTEM \"allproperties.xml\"&gt; ]</literal> in the <literal>DOCTYPE</literal> declartion and <literal>&amp;allproperties;</literal> in the mapping)." #: inheritance_mapping.xml:197
#, no-c-format
msgid ""
"Notice that nowhere do we mention the <literal>Payment</literal> interface "
"explicitly. Also notice that properties of <literal>Payment</literal> are "
"mapped in each of the subclasses. If you want to avoid duplication, consider "
"using XML entities (e.g. <literal>[ &lt;!ENTITY allproperties SYSTEM "
"\"allproperties.xml\"&gt; ]</literal> in the <literal>DOCTYPE</literal> "
"declartion and <literal>&amp;allproperties;</literal> in the mapping)."
msgstr "" msgstr ""
"注意,我们没有在任何地方明确的提及接口<literal>Payment</literal>。同时注意 "
"<literal>Payment</literal>的属性在每个子类中都进行了映射。如果你想避免重复, "
"可以考虑使用XML实体(例如:位于<literal>DOCTYPE</literal>声明内的 <literal>"
"[ &lt;!ENTITY allproperties SYSTEM \"allproperties.xml\"&gt; ]</literal> 和映"
"射中的<literal>&amp;allproperties;</literal>)。"
#: index.docbook:207 #. Tag: para
msgid "The disadvantage of this approach is that Hibernate does not generate SQL <literal>UNION</literal>s when performing polymorphic queries." #: inheritance_mapping.xml:207
#, no-c-format
msgid ""
"The disadvantage of this approach is that Hibernate does not generate SQL "
"<literal>UNION</literal>s when performing polymorphic queries."
msgstr "" msgstr ""
"这种方法的缺陷在于在Hibernate执行多态查询时(polymorphic queries)无法生成带 "
"<literal>UNION</literal>的SQL语句。"
#: index.docbook:212 #. Tag: para
msgid "For this mapping strategy, a polymorphic association to <literal>Payment</literal> is usually mapped using <literal>&lt;any&gt;</literal>." #: inheritance_mapping.xml:212
#, no-c-format
msgid ""
"For this mapping strategy, a polymorphic association to <literal>Payment</"
"literal> is usually mapped using <literal>&lt;any&gt;</literal>."
msgstr "" msgstr ""
"对于这种映射策略而言,通常用<literal>&lt;any&gt;</literal>来实现到 "
"<literal>Payment</literal>的多态关联映射。"
#: index.docbook:217 #. Tag: programlisting
#: inheritance_mapping.xml:217
#, no-c-format
msgid "" msgid ""
"<![CDATA[<any name=\"payment\" meta-type=\"string\" id-type=\"long\">\n" "<![CDATA[<any name=\"payment\" meta-type=\"string\" id-type=\"long\">\n"
" <meta-value value=\"CREDIT\" class=\"CreditCardPayment\"/>\n" " <meta-value value=\"CREDIT\" class=\"CreditCardPayment\"/>\n"
@ -306,15 +528,31 @@ msgid ""
"</any>]]>" "</any>]]>"
msgstr "" msgstr ""
#: index.docbook:222 #. Tag: title
#: inheritance_mapping.xml:222
#, no-c-format
msgid "Mixing implicit polymorphism with other inheritance mappings" msgid "Mixing implicit polymorphism with other inheritance mappings"
msgstr "" msgstr "隐式多态和其他继承映射混合使用"
#: index.docbook:224 #. Tag: para
msgid "There is one further thing to notice about this mapping. Since the subclasses are each mapped in their own <literal>&lt;class&gt;</literal> element (and since <literal>Payment</literal> is just an interface), each of the subclasses could easily be part of another inheritance hierarchy! (And you can still use polymorphic queries against the <literal>Payment</literal> interface.)" #: inheritance_mapping.xml:224
#, no-c-format
msgid ""
"There is one further thing to notice about this mapping. Since the "
"subclasses are each mapped in their own <literal>&lt;class&gt;</literal> "
"element (and since <literal>Payment</literal> is just an interface), each of "
"the subclasses could easily be part of another inheritance hierarchy! (And "
"you can still use polymorphic queries against the <literal>Payment</literal> "
"interface.)"
msgstr "" msgstr ""
"对这一映射还有一点需要注意。因为每个子类都在各自独立的元素<literal>&lt;"
"class&gt;</literal> 中映射(并且<literal>Payment</literal>只是一个接口),每个"
"子类可以很容易的成为另一 个继承体系中的一部分!(你仍然可以对接口"
"<literal>Payment</literal>使用多态查询。)"
#: index.docbook:232 #. Tag: programlisting
#: inheritance_mapping.xml:232
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n" "<![CDATA[<class name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n"
" <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n" " <id name=\"id\" type=\"long\" column=\"CREDIT_PAYMENT_ID\">\n"
@ -345,133 +583,238 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:234 #. Tag: para
msgid "Once again, we don't mention <literal>Payment</literal> explicitly. If we execute a query against the <literal>Payment</literal> interface - for example, <literal>from Payment</literal> - Hibernate automatically returns instances of <literal>CreditCardPayment</literal> (and its subclasses, since they also implement <literal>Payment</literal>), <literal>CashPayment</literal> and <literal>ChequePayment</literal> but not instances of <literal>NonelectronicTransaction</literal>." #: inheritance_mapping.xml:234
#, no-c-format
msgid ""
"Once again, we don't mention <literal>Payment</literal> explicitly. If we "
"execute a query against the <literal>Payment</literal> interface - for "
"example, <literal>from Payment</literal> - Hibernate automatically returns "
"instances of <literal>CreditCardPayment</literal> (and its subclasses, since "
"they also implement <literal>Payment</literal>), <literal>CashPayment</"
"literal> and <literal>ChequePayment</literal> but not instances of "
"<literal>NonelectronicTransaction</literal>."
msgstr "" msgstr ""
"我们还是没有明确的提到<literal>Payment</literal>。 如果我们针对接口"
"<literal>Payment</literal>执行查询 ——如<literal>from Payment</literal>—— "
"Hibernate 自动返回<literal>CreditCardPayment</literal>(和它的子类,因为 它们"
"也实现了接口<literal>Payment</literal>)、 <literal>CashPayment</literal>和"
"<literal>Chequepayment</literal>的实例, 但不返回"
"<literal>NonelectronicTransaction</literal>的实例。"
#: index.docbook:249 #. Tag: title
#: inheritance_mapping.xml:249
#, no-c-format
msgid "Limitations" msgid "Limitations"
msgstr "" msgstr "限制"
#: index.docbook:251 #. Tag: para
msgid "There are certain limitations to the \"implicit polymorphism\" approach to the table per concrete-class mapping strategy. There are somewhat less restrictive limitations to <literal>&lt;union-subclass&gt;</literal> mappings." #: inheritance_mapping.xml:251
#, no-c-format
msgid ""
"There are certain limitations to the \"implicit polymorphism\" approach to "
"the table per concrete-class mapping strategy. There are somewhat less "
"restrictive limitations to <literal>&lt;union-subclass&gt;</literal> "
"mappings."
msgstr "" msgstr ""
"对“每个具体类映射一张表”table per concrete-class的映射策略而言隐式多态"
"的 方式有一定的限制。而<literal>&lt;union-subclass&gt;</literal>映射的限制则"
"没有那 么严格。"
#: index.docbook:258 #. Tag: para
msgid "The following table shows the limitations of table per concrete-class mappings, and of implicit polymorphism, in Hibernate." #: inheritance_mapping.xml:258
msgstr "" #, no-c-format
msgid ""
"The following table shows the limitations of table per concrete-class "
"mappings, and of implicit polymorphism, in Hibernate."
msgstr "下面表格中列出了在Hibernte中“每个具体类一张表”的策略和隐式多态的限制。"
#: index.docbook:264 #. Tag: title
#: inheritance_mapping.xml:264
#, no-c-format
msgid "Features of inheritance mappings" msgid "Features of inheritance mappings"
msgstr "" msgstr "继承映射特性(Features of inheritance mappings)"
#: index.docbook:276 #. Tag: entry
#: inheritance_mapping.xml:276
#, no-c-format
msgid "Inheritance strategy" msgid "Inheritance strategy"
msgstr "" msgstr "继承策略(Inheritance strategy)"
#: index.docbook:277 #. Tag: entry
#: inheritance_mapping.xml:277
#, no-c-format
msgid "Polymorphic many-to-one" msgid "Polymorphic many-to-one"
msgstr "" msgstr "多态多对一"
#: index.docbook:278 #. Tag: entry
#: inheritance_mapping.xml:278
#, no-c-format
msgid "Polymorphic one-to-one" msgid "Polymorphic one-to-one"
msgstr "" msgstr "多态一对一"
#: index.docbook:279 #. Tag: entry
#: inheritance_mapping.xml:279
#, no-c-format
msgid "Polymorphic one-to-many" msgid "Polymorphic one-to-many"
msgstr "" msgstr "多态一对多"
#: index.docbook:280 #. Tag: entry
#: inheritance_mapping.xml:280
#, no-c-format
msgid "Polymorphic many-to-many" msgid "Polymorphic many-to-many"
msgstr "" msgstr "多态多对多"
#: index.docbook:281 #. Tag: entry
#: inheritance_mapping.xml:281
#, no-c-format
msgid "Polymorphic <literal>load()/get()</literal>" msgid "Polymorphic <literal>load()/get()</literal>"
msgstr "" msgstr ""
#: index.docbook:282 #. Tag: entry
#: inheritance_mapping.xml:282
#, no-c-format
msgid "Polymorphic queries" msgid "Polymorphic queries"
msgstr "" msgstr "多态查询"
#: index.docbook:283 #. Tag: entry
#: inheritance_mapping.xml:283
#, no-c-format
msgid "Polymorphic joins" msgid "Polymorphic joins"
msgstr "" msgstr "多态连接(join)"
#: index.docbook:284 #. Tag: entry
#: inheritance_mapping.xml:284
#, no-c-format
msgid "Outer join fetching" msgid "Outer join fetching"
msgstr "" msgstr "外连接(Outer join)读取"
#: index.docbook:289 #. Tag: entry
#: inheritance_mapping.xml:289
#, no-c-format
msgid "table per class-hierarchy" msgid "table per class-hierarchy"
msgstr "" msgstr "每个类分层结构一张表"
#: index.docbook:290, index.docbook:301, index.docbook:312 #. Tag: literal
#: inheritance_mapping.xml:290 inheritance_mapping.xml:301
#: inheritance_mapping.xml:312
#, no-c-format
msgid "&lt;many-to-one&gt;" msgid "&lt;many-to-one&gt;"
msgstr "" msgstr "&lt;many-to-one&gt;"
#: index.docbook:291, index.docbook:302, index.docbook:313 #. Tag: literal
#: inheritance_mapping.xml:291 inheritance_mapping.xml:302
#: inheritance_mapping.xml:313
#, no-c-format
msgid "&lt;one-to-one&gt;" msgid "&lt;one-to-one&gt;"
msgstr "" msgstr "&lt;one-to-one&gt;"
#: index.docbook:292, index.docbook:303 #. Tag: literal
#: inheritance_mapping.xml:292 inheritance_mapping.xml:303
#, no-c-format
msgid "&lt;one-to-many&gt;" msgid "&lt;one-to-many&gt;"
msgstr "" msgstr "&lt;one-to-many&gt;"
#: index.docbook:293, index.docbook:304, index.docbook:315 #. Tag: literal
#: inheritance_mapping.xml:293 inheritance_mapping.xml:304
#: inheritance_mapping.xml:315
#, no-c-format
msgid "&lt;many-to-many&gt;" msgid "&lt;many-to-many&gt;"
msgstr "" msgstr "&lt;many-to-many&gt;"
#: index.docbook:294, index.docbook:305, index.docbook:316 #. Tag: literal
#: inheritance_mapping.xml:294 inheritance_mapping.xml:305
#: inheritance_mapping.xml:316
#, no-c-format
msgid "s.get(Payment.class, id)" msgid "s.get(Payment.class, id)"
msgstr "" msgstr "s.get(Payment.class, id)"
#: index.docbook:295, index.docbook:306, index.docbook:317, index.docbook:328 #. Tag: literal
#: inheritance_mapping.xml:295 inheritance_mapping.xml:306
#: inheritance_mapping.xml:317 inheritance_mapping.xml:328
#, no-c-format
msgid "from Payment p" msgid "from Payment p"
msgstr "" msgstr "from Payment p"
#: index.docbook:296, index.docbook:307, index.docbook:318 #. Tag: literal
#: inheritance_mapping.xml:296 inheritance_mapping.xml:307
#: inheritance_mapping.xml:318
#, no-c-format
msgid "from Order o join o.payment p" msgid "from Order o join o.payment p"
msgstr "" msgstr "from Order o join o.payment p"
#: index.docbook:297, index.docbook:308, index.docbook:319 #. Tag: emphasis
#: inheritance_mapping.xml:297 inheritance_mapping.xml:308
#: inheritance_mapping.xml:319
#, no-c-format
msgid "supported" msgid "supported"
msgstr "" msgstr "支持"
#: index.docbook:300 #. Tag: entry
#: inheritance_mapping.xml:300
#, fuzzy, no-c-format
msgid "<entry>table per subclass</entry>" msgid "<entry>table per subclass</entry>"
msgstr "" msgstr ""
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"每个子类一张表(table per subclass)\n"
"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n"
"每个子类一张表"
#: index.docbook:311 #. Tag: entry
#: inheritance_mapping.xml:311
#, no-c-format
msgid "table per concrete-class (union-subclass)" msgid "table per concrete-class (union-subclass)"
msgstr "每个具体类一张表(union-subclass)"
#. Tag: entry
#: inheritance_mapping.xml:314
#, no-c-format
msgid ""
"<literal>&lt;one-to-many&gt;</literal> (for <literal>inverse=\"true\"</"
"literal> only)"
msgstr "" msgstr ""
#: index.docbook:314 #. Tag: entry
msgid "<literal>&lt;one-to-many&gt;</literal> (for <literal>inverse=\"true\"</literal> only)" #: inheritance_mapping.xml:322
msgstr "" #, no-c-format
#: index.docbook:322
msgid "table per concrete class (implicit polymorphism)" msgid "table per concrete class (implicit polymorphism)"
msgstr "" msgstr "每个具体类一张表(隐式多态)"
#: index.docbook:323 #. Tag: literal
#: inheritance_mapping.xml:323
#, no-c-format
msgid "&lt;any&gt;" msgid "&lt;any&gt;"
msgstr "" msgstr "&lt;any&gt;"
#: index.docbook:324, index.docbook:325, index.docbook:329, index.docbook:330 #. Tag: emphasis
#: inheritance_mapping.xml:324 inheritance_mapping.xml:325
#: inheritance_mapping.xml:329 inheritance_mapping.xml:330
#, no-c-format
msgid "not supported" msgid "not supported"
msgstr "" msgstr "不支持"
#: index.docbook:326 #. Tag: literal
#: inheritance_mapping.xml:326
#, no-c-format
msgid "&lt;many-to-any&gt;" msgid "&lt;many-to-any&gt;"
msgstr "&lt;many-to-any&gt;"
#. Tag: literal
#: inheritance_mapping.xml:327
#, no-c-format
msgid ""
"s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()"
msgstr "" msgstr ""
"s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()"
#: index.docbook:327 #~ msgid "load()/get()"
msgid "s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()" #~ msgstr "load()/get()"
msgstr ""
msgid "ROLES_OF_TRANSLATORS" #~ msgid "Polymorphic <placeholder-1/>"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->" #~ msgstr "多态 <placeholder-1/>"
msgid "CREDIT_FOR_TRANSLATORS" #~ msgid "inverse=\"true\""
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->" #~ msgstr "inverse=\"true\""
#~ msgid "<placeholder-1/> (for <placeholder-2/> only)"
#~ msgstr "<placeholder-1/> (仅对于<placeholder-2/>的情况)"

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,64 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: persistent_classes.xml:5
#, no-c-format
msgid "Persistent Classes" msgid "Persistent Classes"
msgstr "" msgstr "持久化类(Persistent Classes)"
#: index.docbook:7 #. Tag: para
msgid "Persistent classes are classes in an application that implement the entities of the business problem (e.g. Customer and Order in an E-commerce application). Not all instances of a persistent class are considered to be in the persistent state - an instance may instead be transient or detached." #: persistent_classes.xml:7
#, no-c-format
msgid ""
"Persistent classes are classes in an application that implement the entities "
"of the business problem (e.g. Customer and Order in an E-commerce "
"application). Not all instances of a persistent class are considered to be "
"in the persistent state - an instance may instead be transient or detached."
msgstr "" msgstr ""
"在应用程序中用来实现业务问题实体的在电子商务应用程序中的Customer和"
"Order 类就是持久化类。不能认为所有的持久化类的实例都是持久的状态——一个实例"
"的状态也可能 是瞬时的或脱管的。"
#: index.docbook:14 #. Tag: para
msgid "Hibernate works best if these classes follow some simple rules, also known as the Plain Old Java Object (POJO) programming model. However, none of these rules are hard requirements. Indeed, Hibernate3 assumes very little about the nature of your persistent objects. You may express a domain model in other ways: using trees of <literal>Map</literal> instances, for example." #: persistent_classes.xml:14
#, no-c-format
msgid ""
"Hibernate works best if these classes follow some simple rules, also known "
"as the Plain Old Java Object (POJO) programming model. However, none of "
"these rules are hard requirements. Indeed, Hibernate3 assumes very little "
"about the nature of your persistent objects. You may express a domain model "
"in other ways: using trees of <literal>Map</literal> instances, for example."
msgstr "" msgstr ""
"如果这些持久化类遵循一些简单的规则Hibernate能够工作得更好这些规则也被称"
"作 简单传统Java对象(POJO:Plain Old Java Object)编程模型。但是这些规则并不是必"
"需的。 实际上Hibernate3对于你的持久化类几乎不做任何设想。你可以用其他的方法"
"来表达领域模型: 比如,使用<literal>Map</literal>实例的树型结构。"
#: index.docbook:23 #. Tag: title
#: persistent_classes.xml:23
#, no-c-format
msgid "A simple POJO example" msgid "A simple POJO example"
msgstr "" msgstr "一个简单的POJO例子"
#: index.docbook:25 #. Tag: para
#: persistent_classes.xml:25
#, no-c-format
msgid "Most Java applications require a persistent class representing felines." msgid "Most Java applications require a persistent class representing felines."
msgstr "" msgstr "大多数Java程序需要用一个持久化类来表示猫科动物。"
#: index.docbook:29 #. Tag: programlisting
#: persistent_classes.xml:29
#, no-c-format
msgid "" msgid ""
"<![CDATA[package eg;\n" "<![CDATA[package eg;\n"
"import java.util.Set;\n" "import java.util.Set;\n"
@ -106,87 +140,209 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:31 #. Tag: para
#: persistent_classes.xml:31
#, no-c-format
msgid "There are four main rules to follow here:" msgid "There are four main rules to follow here:"
msgstr "" msgstr "这里要遵循四条主要的规则:"
#: index.docbook:37 #. Tag: title
#: persistent_classes.xml:37
#, no-c-format
msgid "Implement a no-argument constructor" msgid "Implement a no-argument constructor"
msgstr "" msgstr "实现一个默认的即无参数的构造方法constructor"
#: index.docbook:39 #. Tag: para
msgid "<literal>Cat</literal> has a no-argument constructor. All persistent classes must have a default constructor (which may be non-public) so that Hibernate can instantiate them using <literal>Constructor.newInstance()</literal>. We strongly recommend having a default constructor with at least <emphasis>package</emphasis> visibility for runtime proxy generation in Hibernate." #: persistent_classes.xml:39
#, no-c-format
msgid ""
"<literal>Cat</literal> has a no-argument constructor. All persistent classes "
"must have a default constructor (which may be non-public) so that Hibernate "
"can instantiate them using <literal>Constructor.newInstance()</literal>. We "
"strongly recommend having a default constructor with at least "
"<emphasis>package</emphasis> visibility for runtime proxy generation in "
"Hibernate."
msgstr "" msgstr ""
"<literal>Cat</literal>有一个无参数的构造方法。所有的持久化类都必须有一个 默认"
"的构造方法可以不是public的这样的话Hibernate就可以使用 "
"<literal>Constructor.newInstance()</literal>来实例化它们。 我们强烈建议,在"
"Hibernate中为了运行期代理的生成构造方法至少是 <emphasis>包(package)</"
"emphasis>内可见的。"
#: index.docbook:49 #. Tag: title
#: persistent_classes.xml:49
#, no-c-format
msgid "Provide an identifier property (optional)" msgid "Provide an identifier property (optional)"
msgstr "" msgstr "提供一个标识属性identifier property可选"
#: index.docbook:51 #. Tag: para
msgid "<literal>Cat</literal> has a property called <literal>id</literal>. This property maps to the primary key column of a database table. The property might have been called anything, and its type might have been any primitive type, any primitive \"wrapper\" type, <literal>java.lang.String</literal> or <literal>java.util.Date</literal>. (If your legacy database table has composite keys, you can even use a user-defined class with properties of these types - see the section on composite identifiers later.)" #: persistent_classes.xml:51
#, no-c-format
msgid ""
"<literal>Cat</literal> has a property called <literal>id</literal>. This "
"property maps to the primary key column of a database table. The property "
"might have been called anything, and its type might have been any primitive "
"type, any primitive \"wrapper\" type, <literal>java.lang.String</literal> or "
"<literal>java.util.Date</literal>. (If your legacy database table has "
"composite keys, you can even use a user-defined class with properties of "
"these types - see the section on composite identifiers later.)"
msgstr "" msgstr ""
"<literal>Cat</literal>有一个属性叫做<literal>id</literal>。这个属性映射数据库"
"表的主 键字段。这个属性可以叫任何名字,其类型可以是任何的原始类型、原始类型的"
"包装类型、 <literal>java.lang.String</literal> 或者是 <literal>java.util."
"Date</literal>。 (如果你的遗留数据库表有联合主键,你甚至可以用一个用户自定义"
"的类,该类拥有这些类型 的属性。参见后面的关于联合标识符的章节。)"
#: index.docbook:60 #. Tag: para
msgid "The identifier property is strictly optional. You can leave them off and let Hibernate keep track of object identifiers internally. We do not recommend this, however." #: persistent_classes.xml:60
#, no-c-format
msgid ""
"The identifier property is strictly optional. You can leave them off and let "
"Hibernate keep track of object identifiers internally. We do not recommend "
"this, however."
msgstr "" msgstr ""
"标识符属性是可选的。可以不用管它让Hibernate内部来追踪对象的识别。 但是我们"
"并不推荐这样做。"
#: index.docbook:65 #. Tag: para
msgid "In fact, some functionality is available only to classes which declare an identifier property:" #: persistent_classes.xml:65
#, no-c-format
msgid ""
"In fact, some functionality is available only to classes which declare an "
"identifier property:"
msgstr "实际上,一些功能只对那些声明了标识符属性的类起作用:"
#. Tag: para
#: persistent_classes.xml:72
#, fuzzy, no-c-format
msgid ""
"Transitive reattachment for detached objects (cascade update or cascade "
"merge) - see"
msgstr "" msgstr ""
"托管对象的传播性再连接(级联更新或级联合并) ——参阅 <xref linkend="
"\"objectstate-transitive\"/>"
#: index.docbook:72 #. Tag: literal
msgid "Transitive reattachment for detached objects (cascade update or cascade merge) - see" #: persistent_classes.xml:79
msgstr "" #, no-c-format
#: index.docbook:79
msgid "Session.saveOrUpdate()" msgid "Session.saveOrUpdate()"
msgstr "" msgstr "Session.saveOrUpdate()"
#: index.docbook:84 #. Tag: literal
#: persistent_classes.xml:84
#, no-c-format
msgid "Session.merge()" msgid "Session.merge()"
msgstr "" msgstr "Session.merge()"
#: index.docbook:89 #. Tag: para
msgid "We recommend you declare consistently-named identifier properties on persistent classes. We further recommend that you use a nullable (ie. non-primitive) type." #: persistent_classes.xml:89
#, no-c-format
msgid ""
"We recommend you declare consistently-named identifier properties on "
"persistent classes. We further recommend that you use a nullable (ie. non-"
"primitive) type."
msgstr "" msgstr ""
"我们建议你对持久化类声明命名一致的标识属性。我们还建议你使用一 个可以为空(也"
"就是说,不是原始类型)的类型。"
#: index.docbook:96 #. Tag: title
#: persistent_classes.xml:96
#, no-c-format
msgid "Prefer non-final classes (optional)" msgid "Prefer non-final classes (optional)"
msgstr "" msgstr "使用非final的类 (可选)"
#: index.docbook:97 #. Tag: para
msgid "A central feature of Hibernate, <emphasis>proxies</emphasis>, depends upon the persistent class being either non-final, or the implementation of an interface that declares all public methods." #: persistent_classes.xml:97
#, no-c-format
msgid ""
"A central feature of Hibernate, <emphasis>proxies</emphasis>, depends upon "
"the persistent class being either non-final, or the implementation of an "
"interface that declares all public methods."
msgstr "" msgstr ""
"<emphasis>代理proxies</emphasis>是Hibernate的一个重要的功能它依赖的条件"
"是,持久 化类或者是非final的或者是实现了一个所有方法都声明为public的接口。"
#: index.docbook:102 #. Tag: para
msgid "You can persist <literal>final</literal> classes that do not implement an interface with Hibernate, but you won't be able to use proxies for lazy association fetching - which will limit your options for performance tuning." #: persistent_classes.xml:102
#, no-c-format
msgid ""
"You can persist <literal>final</literal> classes that do not implement an "
"interface with Hibernate, but you won't be able to use proxies for lazy "
"association fetching - which will limit your options for performance tuning."
msgstr "" msgstr ""
"你可以用Hibernate持久化一个没有实现任何接口的<literal>final</literal>类,但是"
"你 不能使用代理来延迟关联加载,这会限制你进行性能优化的选择。"
#: index.docbook:107 #. Tag: para
msgid "You should also avoid declaring <literal>public final</literal> methods on the non-final classes. If you want to use a class with a <literal>public final</literal> method, you must explicitly disable proxying by setting <literal>lazy=\"false\"</literal>." #: persistent_classes.xml:107
#, no-c-format
msgid ""
"You should also avoid declaring <literal>public final</literal> methods on "
"the non-final classes. If you want to use a class with a <literal>public "
"final</literal> method, you must explicitly disable proxying by setting "
"<literal>lazy=\"false\"</literal>."
msgstr "" msgstr ""
"你也应该避免在非final类中声明 <literal>public final</literal>的方法。如果你想"
"使用一 个有<literal>public final</literal>方法的类,你必须通过设置"
"<literal>lazy=\"false\"</literal> 来明确地禁用代理。"
#: index.docbook:115 #. Tag: title
#: persistent_classes.xml:115
#, no-c-format
msgid "Declare accessors and mutators for persistent fields (optional)" msgid "Declare accessors and mutators for persistent fields (optional)"
msgstr "" msgstr "为持久化字段声明访问器(accessors)和是否可变的标志(mutators)(可选)"
#: index.docbook:117 #. Tag: para
msgid "<literal>Cat</literal> declares accessor methods for all its persistent fields. Many other ORM tools directly persist instance variables. We believe it is better to provide an indirection between the relational schema and internal data structures of the class. By default, Hibernate persists JavaBeans style properties, and recognizes method names of the form <literal>getFoo</literal>, <literal>isFoo</literal> and <literal>setFoo</literal>. You may switch to direct field access for particular properties, if needed." #: persistent_classes.xml:117
#, no-c-format
msgid ""
"<literal>Cat</literal> declares accessor methods for all its persistent "
"fields. Many other ORM tools directly persist instance variables. We believe "
"it is better to provide an indirection between the relational schema and "
"internal data structures of the class. By default, Hibernate persists "
"JavaBeans style properties, and recognizes method names of the form "
"<literal>getFoo</literal>, <literal>isFoo</literal> and <literal>setFoo</"
"literal>. You may switch to direct field access for particular properties, "
"if needed."
msgstr "" msgstr ""
"<literal>Cat</literal>为它的所有持久化字段声明了访问方法。很多其他ORM工具直接"
"对 实例变量进行持久化。我们相信在关系数据库schema和类的内部数据结构之间引入"
"间接层(原文为\"非直接\"indirection)会好一些。默认情况下Hibernate持久化"
"JavaBeans风格的属性认可 <literal>getFoo</literal><literal>isFoo</"
"literal> 和 <literal>setFoo</literal>这种形式的方法名。 如果需要,你可以对某"
"些特定属性实行直接字段访问。"
#: index.docbook:127 #. Tag: para
msgid "Properties need <emphasis>not</emphasis> be declared public - Hibernate can persist a property with a default, <literal>protected</literal> or <literal>private</literal> get / set pair." #: persistent_classes.xml:127
#, no-c-format
msgid ""
"Properties need <emphasis>not</emphasis> be declared public - Hibernate can "
"persist a property with a default, <literal>protected</literal> or "
"<literal>private</literal> get / set pair."
msgstr "" msgstr ""
"属性<emphasis>不需要</emphasis>要声明为public的。Hibernate可以持久化一个有 "
"<literal>default</literal>、<literal>protected</literal>或<literal>private</"
"literal>的get/set方法对 的属性进行持久化。"
#: index.docbook:138 #. Tag: title
#: persistent_classes.xml:138
#, no-c-format
msgid "Implementing inheritance" msgid "Implementing inheritance"
msgstr "" msgstr "实现继承Inheritance"
#: index.docbook:140 #. Tag: para
msgid "A subclass must also observe the first and second rules. It inherits its identifier property from the superclass, <literal>Cat</literal>." #: persistent_classes.xml:140
#, no-c-format
msgid ""
"A subclass must also observe the first and second rules. It inherits its "
"identifier property from the superclass, <literal>Cat</literal>."
msgstr "" msgstr ""
"子类也必须遵守第一条和第二条规则。它从超类<literal>Cat</literal>继承了标识属"
"性。"
#: index.docbook:145 #. Tag: programlisting
#: persistent_classes.xml:145
#, no-c-format
msgid "" msgid ""
"<![CDATA[package eg;\n" "<![CDATA[package eg;\n"
"\n" "\n"
@ -202,35 +358,103 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:149 #. Tag: title
msgid "Implementing <literal>equals()</literal> and <literal>hashCode()</literal>" #: persistent_classes.xml:149
msgstr "" #, no-c-format
msgid ""
"Implementing <literal>equals()</literal> and <literal>hashCode()</literal>"
msgstr "实现<literal>equals()</literal>和<literal>hashCode()</literal>"
#: index.docbook:151 #. Tag: para
msgid "You have to override the <literal>equals()</literal> and <literal>hashCode()</literal> methods if you" #: persistent_classes.xml:151
#, no-c-format
msgid ""
"You have to override the <literal>equals()</literal> and <literal>hashCode()"
"</literal> methods if you"
msgstr "" msgstr ""
"如果你有如下需求,你必须重载 <literal>equals()</literal> 和 <literal>hashCode"
"()</literal>方法:"
#: index.docbook:157 #. Tag: para
msgid "intend to put instances of persistent classes in a <literal>Set</literal> (the recommended way to represent many-valued associations) <emphasis>and</emphasis>" #: persistent_classes.xml:157
#, no-c-format
msgid ""
"intend to put instances of persistent classes in a <literal>Set</literal> "
"(the recommended way to represent many-valued associations) <emphasis>and</"
"emphasis>"
msgstr "" msgstr ""
"想把持久类的实例放入<literal>Set</literal>中(当表示多值关联时,推荐这么做)"
#: index.docbook:164 #. Tag: para
#: persistent_classes.xml:164
#, no-c-format
msgid "intend to use reattachment of detached instances" msgid "intend to use reattachment of detached instances"
msgstr "" msgstr "想重用脱管实例"
#: index.docbook:170 #. Tag: para
msgid "Hibernate guarantees equivalence of persistent identity (database row) and Java identity only inside a particular session scope. So as soon as we mix instances retrieved in different sessions, we must implement <literal>equals()</literal> and <literal>hashCode()</literal> if we wish to have meaningful semantics for <literal>Set</literal>s." #: persistent_classes.xml:170
#, no-c-format
msgid ""
"Hibernate guarantees equivalence of persistent identity (database row) and "
"Java identity only inside a particular session scope. So as soon as we mix "
"instances retrieved in different sessions, we must implement <literal>equals"
"()</literal> and <literal>hashCode()</literal> if we wish to have meaningful "
"semantics for <literal>Set</literal>s."
msgstr "" msgstr ""
"Hibernate保证仅在特定会话范围内持久化标识数据库的行和Java标识是等价"
"的。因此,一旦 我们混合了从不同会话中获取的实例,如果希望<literal>Set</"
"literal>有明确的语义,就必 须实现<literal>equals()</literal> 和"
"<literal>hashCode()</literal>。"
#: index.docbook:178 #. Tag: para
msgid "The most obvious way is to implement <literal>equals()</literal>/<literal>hashCode()</literal> by comparing the identifier value of both objects. If the value is the same, both must be the same database row, they are therefore equal (if both are added to a <literal>Set</literal>, we will only have one element in the <literal>Set</literal>). Unfortunately, we can't use that approach with generated identifiers! Hibernate will only assign identifier values to objects that are persistent, a newly created instance will not have any identifier value! Furthermore, if an instance is unsaved and currently in a <literal>Set</literal>, saving it will assign an identifier value to the object. If <literal>equals()</literal> and <literal>hashCode()</literal> are based on the identifier value, the hash code would change, breaking the contract of the <literal>Set</literal>. See the Hibernate website for a full discussion of this problem. Note that this is not a Hibernate issue, but normal Java semantics of object identity and equality." #: persistent_classes.xml:178
#, no-c-format
msgid ""
"The most obvious way is to implement <literal>equals()</literal>/"
"<literal>hashCode()</literal> by comparing the identifier value of both "
"objects. If the value is the same, both must be the same database row, they "
"are therefore equal (if both are added to a <literal>Set</literal>, we will "
"only have one element in the <literal>Set</literal>). Unfortunately, we "
"can't use that approach with generated identifiers! Hibernate will only "
"assign identifier values to objects that are persistent, a newly created "
"instance will not have any identifier value! Furthermore, if an instance is "
"unsaved and currently in a <literal>Set</literal>, saving it will assign an "
"identifier value to the object. If <literal>equals()</literal> and "
"<literal>hashCode()</literal> are based on the identifier value, the hash "
"code would change, breaking the contract of the <literal>Set</literal>. See "
"the Hibernate website for a full discussion of this problem. Note that this "
"is not a Hibernate issue, but normal Java semantics of object identity and "
"equality."
msgstr "" msgstr ""
"实现<literal>equals()</literal>/<literal>hashCode()</literal>最显而易见的方法"
"是比较两个对象 标识符的值。如果值相同,则两个对象对应于数据库的同一行,因此它"
"们是相等的(如果都被添加到 <literal>Set</literal>,则在<literal>Set</literal>"
"中只有一个元素)。不幸的是,对生成的标识不能 使用这种方法。Hibernate仅对那些"
"持久化对象赋标识值,一个新创建的实例将不会有任何标识值。此外, 如果一个实例没"
"有被保存(unsaved),并且它当前正在一个<literal>Set</literal>中,保存它将会给这"
"个对象 赋一个标识值。如果<literal>equals()</literal> 和 <literal>hashCode()</"
"literal>是基于标识值 实现的,则其哈希码将会改变,这违反了<literal>Set</"
"literal>的契约。建议去Hibernate的站点阅读关于这个 问题的全部讨论。注意,这不"
"是Hibernate的问题而是一般的Java对象标识和Java对象等价的语义问题。"
#: index.docbook:192 #. Tag: para
msgid "We recommend implementing <literal>equals()</literal> and <literal>hashCode()</literal> using <emphasis>Business key equality</emphasis>. Business key equality means that the <literal>equals()</literal> method compares only the properties that form the business key, a key that would identify our instance in the real world (a <emphasis>natural</emphasis> candidate key):" #: persistent_classes.xml:192
#, no-c-format
msgid ""
"We recommend implementing <literal>equals()</literal> and <literal>hashCode()"
"</literal> using <emphasis>Business key equality</emphasis>. Business key "
"equality means that the <literal>equals()</literal> method compares only the "
"properties that form the business key, a key that would identify our "
"instance in the real world (a <emphasis>natural</emphasis> candidate key):"
msgstr "" msgstr ""
"我们建议使用<emphasis>业务键值相等(Business key equality)</emphasis>来实现"
"<literal>equals()</literal> 和 <literal>hashCode()</literal>。业务键值相等的"
"意思是,<literal>equals()</literal>方法 仅仅比较形成业务键的属性,它能在现实"
"世界里标识我们的实例(是一个<emphasis>自然的</emphasis>候选码)。"
#: index.docbook:200 #. Tag: programlisting
#: persistent_classes.xml:200
#, no-c-format
msgid "" msgid ""
"<![CDATA[public class Cat {\n" "<![CDATA[public class Cat {\n"
"\n" "\n"
@ -257,31 +481,75 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:202 #. Tag: para
msgid "Note that a business key does not have to be as solid as a database primary key candidate (see <xref linkend=\"transactions-basics-identity\"/>). Immutable or unique properties are usually good candidates for a business key." #: persistent_classes.xml:202
#, no-c-format
msgid ""
"Note that a business key does not have to be as solid as a database primary "
"key candidate (see <xref linkend=\"transactions-basics-identity\"/>). "
"Immutable or unique properties are usually good candidates for a business "
"key."
msgstr "" msgstr ""
"注意,业务键不必像数据库的主键那样固定不变(参见<xref linkend=\"transactions-"
"basics-identity\"/>)。 对业务键而言,不可变或唯一的属性是不错的选择。"
#: index.docbook:212 #. Tag: title
#: persistent_classes.xml:212
#, no-c-format
msgid "Dynamic models" msgid "Dynamic models"
msgstr "" msgstr "动态模型(Dynamic models)"
#: index.docbook:215 #. Tag: emphasis
msgid "Note that the following features are currently considered experimental and may change in the near future." #: persistent_classes.xml:215
msgstr "" #, no-c-format
msgid ""
"Note that the following features are currently considered experimental and "
"may change in the near future."
msgstr "注意,以下特性在当前处于试验阶段,将来可能会有变化。"
#: index.docbook:219 #. Tag: para
msgid "Persistent entities don't necessarily have to be represented as POJO classes or as JavaBean objects at runtime. Hibernate also supports dynamic models (using <literal>Map</literal>s of <literal>Map</literal>s at runtime) and the representation of entities as DOM4J trees. With this approach, you don't write persistent classes, only mapping files." #: persistent_classes.xml:219
#, no-c-format
msgid ""
"Persistent entities don't necessarily have to be represented as POJO classes "
"or as JavaBean objects at runtime. Hibernate also supports dynamic models "
"(using <literal>Map</literal>s of <literal>Map</literal>s at runtime) and "
"the representation of entities as DOM4J trees. With this approach, you don't "
"write persistent classes, only mapping files."
msgstr "" msgstr ""
"运行期的持久化实体没有必要一定表示为像POJO类或JavaBean对象那样的形式。"
"Hibernate也支持动态模型 (在运行期使用<literal>Map</literal>的<literal>Map</"
"literal>和象DOM4J的树模型那 样的实体表示。使用这种方法,你不用写持久化类,"
"只写映射文件就行了。"
#: index.docbook:227 #. Tag: para
msgid "By default, Hibernate works in normal POJO mode. You may set a default entity representation mode for a particular <literal>SessionFactory</literal> using the <literal>default_entity_mode</literal> configuration option (see <xref linkend=\"configuration-optional-properties\"/>." #: persistent_classes.xml:227
#, no-c-format
msgid ""
"By default, Hibernate works in normal POJO mode. You may set a default "
"entity representation mode for a particular <literal>SessionFactory</"
"literal> using the <literal>default_entity_mode</literal> configuration "
"option (see <xref linkend=\"configuration-optional-properties\"/>."
msgstr "" msgstr ""
"Hibernate默认工作在普通POJO模式。你可以使用配置选项"
"<literal>default_entity_mode</literal> 对特定的<literal>SessionFactory</"
"literal>,设置一个默认的实体表示模式。 (参见<xref linkend=\"configuration-"
"optional-properties\"/>。)"
#: index.docbook:234 #. Tag: para
msgid "The following examples demonstrates the representation using <literal>Map</literal>s. First, in the mapping file, an <literal>entity-name</literal> has to be declared instead of (or in addition to) a class name:" #: persistent_classes.xml:234
#, no-c-format
msgid ""
"The following examples demonstrates the representation using <literal>Map</"
"literal>s. First, in the mapping file, an <literal>entity-name</literal> has "
"to be declared instead of (or in addition to) a class name:"
msgstr "" msgstr ""
"下面是用<literal>Map</literal>来表示的例子。首先,在映射文件中,要声明 "
"<literal>entity-name</literal>来代替一个类名(或作为一种附属)。"
#: index.docbook:240 #. Tag: programlisting
#: persistent_classes.xml:240
#, no-c-format
msgid "" msgid ""
"<![CDATA[<hibernate-mapping>\n" "<![CDATA[<hibernate-mapping>\n"
"\n" "\n"
@ -318,15 +586,32 @@ msgid ""
"</hibernate-mapping>]]>" "</hibernate-mapping>]]>"
msgstr "" msgstr ""
#: index.docbook:242 #. Tag: para
msgid "Note that even though associations are declared using target class names, the target type of an associations may also be a dynamic entity instead of a POJO." #: persistent_classes.xml:242
#, no-c-format
msgid ""
"Note that even though associations are declared using target class names, "
"the target type of an associations may also be a dynamic entity instead of a "
"POJO."
msgstr "" msgstr ""
"注意虽然是用目标类名来声明关联的但是关联的目标类型除了是POJO之外也可以 "
"是一个动态的实体。"
#: index.docbook:249 #. Tag: para
msgid "After setting the default entity mode to <literal>dynamic-map</literal> for the <literal>SessionFactory</literal>, we can at runtime work with <literal>Map</literal>s of <literal>Map</literal>s:" #: persistent_classes.xml:249
#, no-c-format
msgid ""
"After setting the default entity mode to <literal>dynamic-map</literal> for "
"the <literal>SessionFactory</literal>, we can at runtime work with "
"<literal>Map</literal>s of <literal>Map</literal>s:"
msgstr "" msgstr ""
"在使用<literal>dynamic-map</literal>为<literal>SessionFactory</literal> 设置"
"了默认的实体模式之后,可以在运行期使用<literal>Map</literal>的 <literal>Map</"
"literal>。"
#: index.docbook:255 #. Tag: programlisting
#: persistent_classes.xml:255
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session s = openSession();\n" "<![CDATA[Session s = openSession();\n"
"Transaction tx = s.beginTransaction();\n" "Transaction tx = s.beginTransaction();\n"
@ -351,15 +636,33 @@ msgid ""
"s.close();]]>" "s.close();]]>"
msgstr "" msgstr ""
#: index.docbook:257 #. Tag: para
msgid "The advantages of a dynamic mapping are quick turnaround time for prototyping without the need for entity class implementation. However, you lose compile-time type checking and will very likely deal with many exceptions at runtime. Thanks to the Hibernate mapping, the database schema can easily be normalized and sound, allowing to add a proper domain model implementation on top later on." #: persistent_classes.xml:257
#, no-c-format
msgid ""
"The advantages of a dynamic mapping are quick turnaround time for "
"prototyping without the need for entity class implementation. However, you "
"lose compile-time type checking and will very likely deal with many "
"exceptions at runtime. Thanks to the Hibernate mapping, the database schema "
"can easily be normalized and sound, allowing to add a proper domain model "
"implementation on top later on."
msgstr "" msgstr ""
"动态映射的好处是,变化所需要的时间少了,因为原型不需要实现实体类。然而,你无"
"法进行 编译期的类型检查并可能由此会处理很多的运行期异常。幸亏有了Hibernate"
"映射,它使得数 据库的schema能容易的规格化和合理化并允许稍后在此之上添加合适"
"的领域模型实现。"
#: index.docbook:265 #. Tag: para
msgid "Entity representation modes can also be set on a per <literal>Session</literal> basis:" #: persistent_classes.xml:265
msgstr "" #, no-c-format
msgid ""
"Entity representation modes can also be set on a per <literal>Session</"
"literal> basis:"
msgstr "实体表示模式也能在每个<literal>Session</literal>的基础上设置:"
#: index.docbook:270 #. Tag: programlisting
#: persistent_classes.xml:270
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session dynamicSession = pojoSession.getSession(EntityMode.MAP);\n" "<![CDATA[Session dynamicSession = pojoSession.getSession(EntityMode.MAP);\n"
"\n" "\n"
@ -375,27 +678,91 @@ msgid ""
"]]>" "]]>"
msgstr "" msgstr ""
#: index.docbook:273 #. Tag: para
msgid "Please note that the call to <literal>getSession()</literal> using an <literal>EntityMode</literal> is on the <literal>Session</literal> API, not the <literal>SessionFactory</literal>. That way, the new <literal>Session</literal> shares the underlying JDBC connection, transaction, and other context information. This means you don't have tocall <literal>flush()</literal> and <literal>close()</literal> on the secondary <literal>Session</literal>, and also leave the transaction and connection handling to the primary unit of work." #: persistent_classes.xml:273
#, no-c-format
msgid ""
"Please note that the call to <literal>getSession()</literal> using an "
"<literal>EntityMode</literal> is on the <literal>Session</literal> API, not "
"the <literal>SessionFactory</literal>. That way, the new <literal>Session</"
"literal> shares the underlying JDBC connection, transaction, and other "
"context information. This means you don't have tocall <literal>flush()</"
"literal> and <literal>close()</literal> on the secondary <literal>Session</"
"literal>, and also leave the transaction and connection handling to the "
"primary unit of work."
msgstr "" msgstr ""
"请注意,用<literal>EntityMode</literal>调用<literal>getSession()</literal>是"
"在 <literal>Session</literal>的API中而不是<literal>SessionFactory</"
"literal>。 这样,新的<literal>Session</literal>共享底层的JDBC连接事务和其"
"他的上下文信 息。这意味着,你不需要在第二个<literal>Session</literal>中调用 "
"<literal>flush()</literal>和<literal>close()</literal>,同样的,把事务和连接"
"的处理 交给原来的工作单元。"
#: index.docbook:283 #. Tag: para
msgid "More information about the XML representation capabilities can be found in <xref linkend=\"xml\"/>." #: persistent_classes.xml:283
msgstr "" #, no-c-format
msgid ""
"More information about the XML representation capabilities can be found in "
"<xref linkend=\"xml\"/>."
msgstr "关于XML表示能力的更多信息可以在<xref linkend=\"xml\"/>中找到。"
#: index.docbook:291 #. Tag: title
#: persistent_classes.xml:291
#, no-c-format
msgid "Tuplizers" msgid "Tuplizers"
msgstr "" msgstr "元组片断映射(Tuplizers)"
#: index.docbook:293 #. Tag: para
msgid "<literal>org.hibernate.tuple.Tuplizer</literal>, and its sub-interfaces, are responsible for managing a particular representation of a piece of data, given that representation's <literal>org.hibernate.EntityMode</literal>. If a given piece of data is thought of as a data structure, then a tuplizer is the thing which knows how to create such a data structure and how to extract values from and inject values into such a data structure. For example, for the POJO entity mode, the correpsonding tuplizer knows how create the POJO through its constructor and how to access the POJO properties using the defined property accessors. There are two high-level types of Tuplizers, represented by the <literal>org.hibernate.tuple.entity.EntityTuplizer</literal> and <literal>org.hibernate.tuple.component.ComponentTuplizer</literal> interfaces. <literal>EntityTuplizer</literal>s are responsible for managing the above mentioned contracts in regards to entities, while <literal>ComponentTuplizer</literal>s do the same for components." #: persistent_classes.xml:293
#, no-c-format
msgid ""
"<literal>org.hibernate.tuple.Tuplizer</literal>, and its sub-interfaces, are "
"responsible for managing a particular representation of a piece of data, "
"given that representation's <literal>org.hibernate.EntityMode</literal>. If "
"a given piece of data is thought of as a data structure, then a tuplizer is "
"the thing which knows how to create such a data structure and how to extract "
"values from and inject values into such a data structure. For example, for "
"the POJO entity mode, the correpsonding tuplizer knows how create the POJO "
"through its constructor and how to access the POJO properties using the "
"defined property accessors. There are two high-level types of Tuplizers, "
"represented by the <literal>org.hibernate.tuple.entity.EntityTuplizer</"
"literal> and <literal>org.hibernate.tuple.component.ComponentTuplizer</"
"literal> interfaces. <literal>EntityTuplizer</literal>s are responsible for "
"managing the above mentioned contracts in regards to entities, while "
"<literal>ComponentTuplizer</literal>s do the same for components."
msgstr "" msgstr ""
"<literal>org.hibernate.tuple.Tuplizer</literal>,以及其子接口,负责根据给定的"
"<literal>org.hibernate.EntityMode</literal>,来复现片断数据。如果给定的片断数"
"据被认为其是一种数据结构,\"tuplizer\"就是一个知道如何创建这样的数据结构,以"
"及如何给这个数据结构赋值的东西。比如说对于POJO这种Entity Mode对应的"
"tuplizer知道通过其构造方法来创建一个POJO再通过其属性访问器来访问POJO属性。"
"有两大类高层Tuplizer分别是<literal>org.hibernate.tuple.entity."
"EntityTuplizer</literal> 和<literal>org.hibernate.tuple.entity."
"ComponentTuplizer</literal>接口。<literal>EntityTuplizer</literal>负责管理上"
"面提到的实体的契约,而<literal>ComponentTuplizer</literal>则是针对组件的。"
#: index.docbook:308 #. Tag: para
msgid "Users may also plug in their own tuplizers. Perhaps you require that a <literal>java.util.Map</literal> implementation other than <literal>java.util.HashMap</literal> be used while in the dynamic-map entity-mode; or perhaps you need to define a different proxy generation strategy than the one used by default. Both would be achieved by defining a custom tuplizer implementation. Tuplizers definitions are attached to the entity or component mapping they are meant to manage. Going back to the example of our customer entity:" #: persistent_classes.xml:308
#, no-c-format
msgid ""
"Users may also plug in their own tuplizers. Perhaps you require that a "
"<literal>java.util.Map</literal> implementation other than <literal>java."
"util.HashMap</literal> be used while in the dynamic-map entity-mode; or "
"perhaps you need to define a different proxy generation strategy than the "
"one used by default. Both would be achieved by defining a custom tuplizer "
"implementation. Tuplizers definitions are attached to the entity or "
"component mapping they are meant to manage. Going back to the example of our "
"customer entity:"
msgstr "" msgstr ""
"用户也可以插入其自定义的tuplizer。或许您需要一种不同于dynamic-map entity-mode"
"中使用的<literal>java.util.HashMap</literal>的<literal>java.util.Map</"
"literal>实现;或许您需要与默认策略不同的代理生成策略(proxy generation "
"strategy)。通过自定义tuplizer实现这两个目标您都可以达到。Tuplizer定义被附加"
"到它们期望管理的entity或者component映射中。回到我们的customer entity例子"
#: index.docbook:317 #. Tag: programlisting
#: persistent_classes.xml:317
#, no-c-format
msgid "" msgid ""
"<![CDATA[<hibernate-mapping>\n" "<![CDATA[<hibernate-mapping>\n"
" <class entity-name=\"Customer\">\n" " <class entity-name=\"Customer\">\n"
@ -434,13 +801,9 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:322 #. Tag: para
msgid "TODO: Document user-extension framework in the property and proxy packages" #: persistent_classes.xml:322
msgstr "" #, no-c-format
msgid ""
msgid "ROLES_OF_TRANSLATORS" "TODO: Document user-extension framework in the property and proxy packages"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->" msgstr "TODOproperty和proxy包里的用户扩展框架文档。"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,68 +1,180 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:21 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: preface.xml:21
#, no-c-format
msgid "Preface" msgid "Preface"
msgstr "<title>前言</title>" msgstr "前言"
#: index.docbook:23 #. Tag: para
msgid "Working with object-oriented software and a relational database can be cumbersome and time consuming in today's enterprise environments. Hibernate is an object/relational mapping tool for Java environments. The term object/relational mapping (ORM) refers to the technique of mapping a data representation from an object model to a relational data model with a SQL-based schema." #: preface.xml:23
msgstr "在今日的企业环境中把面向对象的软件和关系数据库一起使用可能是相当麻烦、浪费时间的。Hibernate是一个面向Java环境的对象/关系数据库映射工具。对象/关系数据库映射(object/relational mapping (ORM))这个术语表示一种技术用来把对象模型表示的对象映射到基于SQL的关系模型数据结构中去。" #, no-c-format
msgid ""
"Working with object-oriented software and a relational database can be "
"cumbersome and time consuming in today's enterprise environments. Hibernate "
"is an object/relational mapping tool for Java environments. The term object/"
"relational mapping (ORM) refers to the technique of mapping a data "
"representation from an object model to a relational data model with a SQL-"
"based schema."
msgstr ""
"在今日的企业环境中,把面向对象的软件和关系数据库一起使用可能是相当麻烦、浪费"
"时间的。Hibernate是一个面向Java环境的对象/关系数据库映射工具。对象/关系数据库"
"映射(object/relational mapping (ORM))这个术语表示一种技术,用来把对象模型表示"
"的对象映射到基于SQL的关系模型数据结构中去。"
#: index.docbook:31 #. Tag: para
msgid "Hibernate not only takes care of the mapping from Java classes to database tables (and from Java data types to SQL data types), but also provides data query and retrieval facilities and can significantly reduce development time otherwise spent with manual data handling in SQL and JDBC." #: preface.xml:31
msgstr "Hibernate不仅仅管理Java类到数据库表的映射包括Java数据类型到SQL数据类型的映射还提供数据查询和获取数据的方法可以大幅度减少开发时人工使用SQL和JDBC处理数据的时间。" #, no-c-format
msgid ""
"Hibernate not only takes care of the mapping from Java classes to database "
"tables (and from Java data types to SQL data types), but also provides data "
"query and retrieval facilities and can significantly reduce development time "
"otherwise spent with manual data handling in SQL and JDBC."
msgstr ""
"Hibernate不仅仅管理Java类到数据库表的映射包括Java数据类型到SQL数据类型的映"
"射还提供数据查询和获取数据的方法可以大幅度减少开发时人工使用SQL和JDBC处"
"理数据的时间。"
#: index.docbook:38 #. Tag: para
msgid "Hibernates goal is to relieve the developer from 95 percent of common data persistence related programming tasks. Hibernate may not be the best solution for data-centric applications that only use stored-procedures to implement the business logic in the database, it is most useful with object-oriented domain models and business logic in the Java-based middle-tier. However, Hibernate can certainly help you to remove or encapsulate vendor-specific SQL code and will help with the common task of result set translation from a tabular representation to a graph of objects." #: preface.xml:38
msgstr "Hibernate的目标是对于开发者通常的数据持久化相关的编程任务解放其中的95%。对于以数据为中心的程序来说,它们往往只在数据库中使用存储过程来实现商业逻辑,Hibernate可能不是最好的解决方案;对于那些在基于Java的中间层应用中它们实现面向对象的业务模型和商业逻辑的应用Hibernate是最有用的。不管怎样Hibernate一定可以帮助你消除或者包装那些针对特定厂商的SQL代码并且帮你把结果集从表格式的表示形式转换到一系列的对象去。" #, no-c-format
msgid ""
"Hibernates goal is to relieve the developer from 95 percent of common data "
"persistence related programming tasks. Hibernate may not be the best "
"solution for data-centric applications that only use stored-procedures to "
"implement the business logic in the database, it is most useful with object-"
"oriented domain models and business logic in the Java-based middle-tier. "
"However, Hibernate can certainly help you to remove or encapsulate vendor-"
"specific SQL code and will help with the common task of result set "
"translation from a tabular representation to a graph of objects."
msgstr ""
"Hibernate的目标是对于开发者通常的数据持久化相关的编程任务解放其中的95%。对"
"于以数据为中心的程序来说,它们往往只在数据库中使用存储过程来实现商业逻辑,"
"Hibernate可能不是最好的解决方案;对于那些在基于Java的中间层应用中它们实现面"
"向对象的业务模型和商业逻辑的应用Hibernate是最有用的。不管怎样Hibernate一"
"定可以帮助你消除或者包装那些针对特定厂商的SQL代码并且帮你把结果集从表格式的"
"表示形式转换到一系列的对象去。"
#: index.docbook:48 #. Tag: para
msgid "If you are new to Hibernate and Object/Relational Mapping or even Java, please follow these steps:" #: preface.xml:48
msgstr "如果你对Hibernate和对象/关系数据库映射还是个新手或者甚至对Java也不熟悉请按照下面的步骤来学习。" #, no-c-format
msgid ""
"If you are new to Hibernate and Object/Relational Mapping or even Java, "
"please follow these steps:"
msgstr ""
"如果你对Hibernate和对象/关系数据库映射还是个新手或者甚至对Java也不熟悉请"
"按照下面的步骤来学习。"
#: index.docbook:55 #. Tag: para
msgid "Read <xref linkend=\"tutorial\"/> for a tutorial with step-by-step instructions. The source code for the tutorial is included in the distribution in the <literal>doc/reference/tutorial/</literal> directory." #: preface.xml:55
msgstr "阅读<xref linkend=\"tutorial\"/>,这是一篇包含详细的逐步指导的指南。本指南的源代码包含在发行包中,你可以在<literal>doc/reference/tutorial/</literal>目录下找到。" #, no-c-format
msgid ""
"Read <xref linkend=\"tutorial\"/> for a tutorial with step-by-step "
"instructions. The source code for the tutorial is included in the "
"distribution in the <literal>doc/reference/tutorial/</literal> directory."
msgstr ""
"阅读<xref linkend=\"tutorial\"/>,这是一篇包含详细的逐步指导的指南。本指南的"
"源代码包含在发行包中,你可以在<literal>doc/reference/tutorial/</literal>目录"
"下找到。"
#: index.docbook:63 #. Tag: para
msgid "Read <xref linkend=\"architecture\"/> to understand the environments where Hibernate can be used." #: preface.xml:63
#, no-c-format
msgid ""
"Read <xref linkend=\"architecture\"/> to understand the environments where "
"Hibernate can be used."
msgstr "阅读<xref linkend=\"architecture\"/>来理解Hibernate可以使用的环境。" msgstr "阅读<xref linkend=\"architecture\"/>来理解Hibernate可以使用的环境。"
#: index.docbook:69 #. Tag: para
msgid "Have a look at the <literal>eg/</literal> directory in the Hibernate distribution, it contains a simple standalone application. Copy your JDBC driver to the <literal>lib/</literal> directory and edit <literal>etc/hibernate.properties</literal>, specifying correct values for your database. From a command prompt in the distribution directory, type <literal>ant eg</literal> (using Ant), or under Windows, type <literal>build eg</literal>." #: preface.xml:69
msgstr "查看Hibernate发行包中的<literal>eg/</literal>目录里面有一个简单的独立运行的程序。把你的JDBC驱动拷贝到<literal>lib/</literal>目录下,修改一下<literal>src/hibernate.properties</literal>,指定其中你的数据库的信息。进入命令行,切换到你的发行包的目录,输入<literal>ant eg</literal>(使用了Ant或者在Windows操作系统中使用<literal>build eg</literal>。" #, no-c-format
msgid ""
"Have a look at the <literal>eg/</literal> directory in the Hibernate "
"distribution, it contains a simple standalone application. Copy your JDBC "
"driver to the <literal>lib/</literal> directory and edit <literal>etc/"
"hibernate.properties</literal>, specifying correct values for your database. "
"From a command prompt in the distribution directory, type <literal>ant eg</"
"literal> (using Ant), or under Windows, type <literal>build eg</literal>."
msgstr ""
"查看Hibernate发行包中的<literal>eg/</literal>目录,里面有一个简单的独立运行的"
"程序。把你的JDBC驱动拷贝到<literal>lib/</literal>目录下,修改一下"
"<literal>src/hibernate.properties</literal>,指定其中你的数据库的信息。进入命"
"令行,切换到你的发行包的目录,输入<literal>ant eg</literal>(使用了Ant或者"
"在Windows操作系统中使用<literal>build eg</literal>。"
#: index.docbook:80 #. Tag: para
msgid "Use this reference documentation as your primary source of information. Consider reading <emphasis>Java Persistence with Hibernate</emphasis> (http://www.manning.com/bauer2) if you need more help with application design or if you prefer a step-by-step tutorial. Also visit http://caveatemptor.hibernate.org and download the example application for Java Persistence with Hibernate." #: preface.xml:80
#, no-c-format
msgid ""
"Use this reference documentation as your primary source of information. "
"Consider reading <emphasis>Java Persistence with Hibernate</emphasis> "
"(http://www.manning.com/bauer2) if you need more help with application "
"design or if you prefer a step-by-step tutorial. Also visit http://"
"caveatemptor.hibernate.org and download the example application for Java "
"Persistence with Hibernate."
msgstr "把这份参考文档作为你学习的主要信息来源。" msgstr "把这份参考文档作为你学习的主要信息来源。"
#: index.docbook:90 #. Tag: para
#: preface.xml:90
#, no-c-format
msgid "FAQs are answered on the Hibernate website." msgid "FAQs are answered on the Hibernate website."
msgstr "在Hibernate 的网站上可以找到经常提问的问题与解答(FAQ)。" msgstr "在Hibernate 的网站上可以找到经常提问的问题与解答(FAQ)。"
#: index.docbook:95 #. Tag: para
msgid "Third party demos, examples, and tutorials are linked on the Hibernate website." #: preface.xml:95
#, no-c-format
msgid ""
"Third party demos, examples, and tutorials are linked on the Hibernate "
"website."
msgstr "在Hibernate网站上还有第三方的演示、示例和教程的链接。" msgstr "在Hibernate网站上还有第三方的演示、示例和教程的链接。"
#: index.docbook:101 #. Tag: para
msgid "The Community Area on the Hibernate website is a good resource for design patterns and various integration solutions (Tomcat, JBoss AS, Struts, EJB, etc.)." #: preface.xml:101
msgstr "Hibernate网站的“社区(Community Area)”是讨论关于设计模式以及很多整合方案(Tomcat, JBoss AS, Struts, EJB,等等)的好地方。" #, no-c-format
msgid ""
"The Community Area on the Hibernate website is a good resource for design "
"patterns and various integration solutions (Tomcat, JBoss AS, Struts, EJB, "
"etc.)."
msgstr ""
"Hibernate网站的“社区(Community Area)”是讨论关于设计模式以及很多整合方案"
"(Tomcat, JBoss AS, Struts, EJB,等等)的好地方。"
#: index.docbook:109 #. Tag: para
msgid "If you have questions, use the user forum linked on the Hibernate website. We also provide a JIRA issue trackings system for bug reports and feature requests. If you are interested in the development of Hibernate, join the developer mailing list. If you are interested in translating this documentation into your language, contact us on the developer mailing list." #: preface.xml:109
msgstr "如果你有问题请使用Hibernate网站上链接的用户论坛。我们也提供一个JIRA问题追踪系统来搜集bug报告和新功能请求。如果你对开发Hibernate有兴趣请加入开发者的邮件列表。Hibernate网站上的用户论坛有一个中文版面JavaEye也有Hibernate中文版面,您可以在那里交流问题与经验。)" #, no-c-format
msgid ""
#: index.docbook:117 "If you have questions, use the user forum linked on the Hibernate website. "
msgid "Commercial development support, production support, and training for Hibernate is available through JBoss Inc. (see http://www.hibernate.org/SupportTraining/). Hibernate is a Professional Open Source project and a critical component of the JBoss Enterprise Middleware System (JEMS) suite of products." "We also provide a JIRA issue trackings system for bug reports and feature "
msgstr "商业开发、产品支持和Hibernate培训可以通过JBoss Inc.获得。请查阅http://www.hibernate.org/SupportTraining/)。 Hibernate是一个专业的开放源代码项目(Professional Open Source project)也是JBoss Enterprise Middleware System(JEMS),JBoss企业级中间件系统的一个核心组件。" "requests. If you are interested in the development of Hibernate, join the "
"developer mailing list. If you are interested in translating this "
msgid "ROLES_OF_TRANSLATORS" "documentation into your language, contact us on the developer mailing list."
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->" msgstr ""
"如果你有问题请使用Hibernate网站上链接的用户论坛。我们也提供一个JIRA问题追踪"
msgid "CREDIT_FOR_TRANSLATORS" "系统来搜集bug报告和新功能请求。如果你对开发Hibernate有兴趣请加入开发者的"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->" "邮件列表。Hibernate网站上的用户论坛有一个中文版面JavaEye也有Hibernate中文"
"版面,您可以在那里交流问题与经验。)"
#. Tag: para
#: preface.xml:117
#, no-c-format
msgid ""
"Commercial development support, production support, and training for "
"Hibernate is available through JBoss Inc. (see http://www.hibernate.org/"
"SupportTraining/). Hibernate is a Professional Open Source project and a "
"critical component of the JBoss Enterprise Middleware System (JEMS) suite of "
"products."
msgstr ""
"商业开发、产品支持和Hibernate培训可以通过JBoss Inc.获得。请查阅http://"
"www.hibernate.org/SupportTraining/)。 Hibernate是一个专业的开放源代码项目"
"(Professional Open Source project)也是JBoss Enterprise Middleware System"
"(JEMS),JBoss企业级中间件系统的一个核心组件。"

View File

@ -1,41 +1,75 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: query_criteria.xml:5
#, no-c-format
msgid "Criteria Queries" msgid "Criteria Queries"
msgstr "" msgstr "条件查询(Criteria Queries)"
#: index.docbook:7 #. Tag: para
#: query_criteria.xml:7
#, no-c-format
msgid "Hibernate features an intuitive, extensible criteria query API." msgid "Hibernate features an intuitive, extensible criteria query API."
msgstr "" msgstr "具有一个直观的、可扩展的条件查询API是Hibernate的特色。"
#: index.docbook:12 #. Tag: title
#: query_criteria.xml:12
#, no-c-format
msgid "Creating a <literal>Criteria</literal> instance" msgid "Creating a <literal>Criteria</literal> instance"
msgstr "" msgstr "创建一个<literal>Criteria</literal> 实例"
#: index.docbook:14 #. Tag: para
msgid "The interface <literal>org.hibernate.Criteria</literal> represents a query against a particular persistent class. The <literal>Session</literal> is a factory for <literal>Criteria</literal> instances." #: query_criteria.xml:14
#, no-c-format
msgid ""
"The interface <literal>org.hibernate.Criteria</literal> represents a query "
"against a particular persistent class. The <literal>Session</literal> is a "
"factory for <literal>Criteria</literal> instances."
msgstr "" msgstr ""
"<literal>org.hibernate.Criteria</literal>接口表示特定持久类的一个查询。"
"<literal>Session</literal>是 <literal>Criteria</literal>实例的工厂。"
#: index.docbook:20 #. Tag: programlisting
#: query_criteria.xml:20
#, no-c-format
msgid "" msgid ""
"<![CDATA[Criteria crit = sess.createCriteria(Cat.class);\n" "<![CDATA[Criteria crit = sess.createCriteria(Cat.class);\n"
"crit.setMaxResults(50);\n" "crit.setMaxResults(50);\n"
"List cats = crit.list();]]>" "List cats = crit.list();]]>"
msgstr "" msgstr ""
#: index.docbook:25 #. Tag: title
#: query_criteria.xml:25
#, no-c-format
msgid "Narrowing the result set" msgid "Narrowing the result set"
msgstr "" msgstr "限制结果集内容"
#: index.docbook:27 #. Tag: para
msgid "An individual query criterion is an instance of the interface <literal>org.hibernate.criterion.Criterion</literal>. The class <literal>org.hibernate.criterion.Restrictions</literal> defines factory methods for obtaining certain built-in <literal>Criterion</literal> types." #: query_criteria.xml:27
#, no-c-format
msgid ""
"An individual query criterion is an instance of the interface <literal>org."
"hibernate.criterion.Criterion</literal>. The class <literal>org.hibernate."
"criterion.Restrictions</literal> defines factory methods for obtaining "
"certain built-in <literal>Criterion</literal> types."
msgstr "" msgstr ""
"一个单独的查询条件是<literal>org.hibernate.criterion.Criterion</literal> 接口"
"的一个实例。<literal>org.hibernate.criterion.Restrictions</literal>类 定义了"
"获得某些内置<literal>Criterion</literal>类型的工厂方法。"
#: index.docbook:35 #. Tag: programlisting
#: query_criteria.xml:35
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n" " .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
@ -43,11 +77,15 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:37 #. Tag: para
#: query_criteria.xml:37
#, no-c-format
msgid "Restrictions may be grouped logically." msgid "Restrictions may be grouped logically."
msgstr "" msgstr "约束可以按逻辑分组。"
#: index.docbook:41 #. Tag: programlisting
#: query_criteria.xml:41
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n" " .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
@ -58,10 +96,13 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:43 #. Tag: programlisting
#: query_criteria.xml:43
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .add( Restrictions.in( \"name\", new String[] { \"Fritz\", \"Izi\", \"Pk\" } ) )\n" " .add( Restrictions.in( \"name\", new String[] { \"Fritz\", \"Izi\", \"Pk"
"\" } ) )\n"
" .add( Restrictions.disjunction()\n" " .add( Restrictions.disjunction()\n"
" .add( Restrictions.isNull(\"age\") )\n" " .add( Restrictions.isNull(\"age\") )\n"
" .add( Restrictions.eq(\"age\", new Integer(0) ) )\n" " .add( Restrictions.eq(\"age\", new Integer(0) ) )\n"
@ -71,26 +112,49 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:45 #. Tag: para
msgid "There are quite a range of built-in criterion types (<literal>Restrictions</literal> subclasses), but one that is especially useful lets you specify SQL directly." #: query_criteria.xml:45
#, no-c-format
msgid ""
"There are quite a range of built-in criterion types (<literal>Restrictions</"
"literal> subclasses), but one that is especially useful lets you specify SQL "
"directly."
msgstr "" msgstr ""
"Hibernate提供了相当多的内置criterion类型(<literal>Restrictions</literal> 子"
"类), 但是尤其有用的是可以允许你直接使用SQL。"
#: index.docbook:50 #. Tag: programlisting
#: query_criteria.xml:50
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .add( Restrictions.sqlRestriction(\"lower({alias}.name) like lower(?)\", \"Fritz%\", Hibernate.STRING) )\n" " .add( Restrictions.sqlRestriction(\"lower({alias}.name) like lower(?)\", "
"\"Fritz%\", Hibernate.STRING) )\n"
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:52 #. Tag: para
msgid "The <literal>{alias}</literal> placeholder with be replaced by the row alias of the queried entity." #: query_criteria.xml:52
msgstr "" #, no-c-format
msgid ""
"The <literal>{alias}</literal> placeholder with be replaced by the row alias "
"of the queried entity."
msgstr "<literal>{alias}</literal>占位符应当被替换为被查询实体的列别名。"
#: index.docbook:57 #. Tag: para
msgid "An alternative approach to obtaining a criterion is to get it from a <literal>Property</literal> instance. You can create a <literal>Property</literal> by calling <literal>Property.forName()</literal>." #: query_criteria.xml:57
#, no-c-format
msgid ""
"An alternative approach to obtaining a criterion is to get it from a "
"<literal>Property</literal> instance. You can create a <literal>Property</"
"literal> by calling <literal>Property.forName()</literal>."
msgstr "" msgstr ""
"<literal>Property</literal>实例是获得一个条件的另外一种途径。你可以通过调用"
"<literal>Property.forName()</literal> 创建一个<literal>Property</literal>。"
#: index.docbook:63 #. Tag: programlisting
#: query_criteria.xml:63
#, no-c-format
msgid "" msgid ""
"<![CDATA[\n" "<![CDATA[\n"
"Property age = Property.forName(\"age\");\n" "Property age = Property.forName(\"age\");\n"
@ -101,19 +165,29 @@ msgid ""
" .add( age.eq( new Integer(1) ) )\n" " .add( age.eq( new Integer(1) ) )\n"
" .add( age.eq( new Integer(2) ) )\n" " .add( age.eq( new Integer(2) ) )\n"
" ) )\n" " ) )\n"
" .add( Property.forName(\"name\").in( new String[] { \"Fritz\", \"Izi\", \"Pk\" } ) )\n" " .add( Property.forName(\"name\").in( new String[] { \"Fritz\", \"Izi\", "
"\"Pk\" } ) )\n"
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:68 #. Tag: title
#: query_criteria.xml:68
#, no-c-format
msgid "Ordering the results" msgid "Ordering the results"
msgstr "" msgstr "结果集排序"
#: index.docbook:70 #. Tag: para
msgid "You may order the results using <literal>org.hibernate.criterion.Order</literal>." #: query_criteria.xml:70
#, no-c-format
msgid ""
"You may order the results using <literal>org.hibernate.criterion.Order</"
"literal>."
msgstr "" msgstr ""
"你可以使用<literal>org.hibernate.criterion.Order</literal>来为查询结果排序。"
#: index.docbook:74 #. Tag: programlisting
#: query_criteria.xml:74
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .add( Restrictions.like(\"name\", \"F%\")\n" " .add( Restrictions.like(\"name\", \"F%\")\n"
@ -123,7 +197,9 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:76 #. Tag: programlisting
#: query_criteria.xml:76
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .add( Property.forName(\"name\").like(\"F%\") )\n" " .add( Property.forName(\"name\").like(\"F%\") )\n"
@ -133,15 +209,25 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:81 #. Tag: title
#: query_criteria.xml:81
#, no-c-format
msgid "Associations" msgid "Associations"
msgstr "" msgstr "关联"
#: index.docbook:83 #. Tag: para
msgid "You may easily specify constraints upon related entities by navigating associations using <literal>createCriteria()</literal>." #: query_criteria.xml:83
#, no-c-format
msgid ""
"You may easily specify constraints upon related entities by navigating "
"associations using <literal>createCriteria()</literal>."
msgstr "" msgstr ""
"你可以使用<literal>createCriteria()</literal>非常容易的在互相关联的实体间建"
"立 约束。"
#: index.docbook:88 #. Tag: programlisting
#: query_criteria.xml:88
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .add( Restrictions.like(\"name\", \"F%\") )\n" " .add( Restrictions.like(\"name\", \"F%\") )\n"
@ -150,15 +236,27 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:90 #. Tag: para
msgid "note that the second <literal>createCriteria()</literal> returns a new instance of <literal>Criteria</literal>, which refers to the elements of the <literal>kittens</literal> collection." #: query_criteria.xml:90
#, no-c-format
msgid ""
"note that the second <literal>createCriteria()</literal> returns a new "
"instance of <literal>Criteria</literal>, which refers to the elements of the "
"<literal>kittens</literal> collection."
msgstr "" msgstr ""
"注意第二个 <literal>createCriteria()</literal>返回一个新的 "
"<literal>Criteria</literal>实例,该实例引用<literal>kittens</literal> 集合中"
"的元素。"
#: index.docbook:96 #. Tag: para
#: query_criteria.xml:96
#, no-c-format
msgid "The following, alternate form is useful in certain circumstances." msgid "The following, alternate form is useful in certain circumstances."
msgstr "" msgstr "接下来,替换形态在某些情况下也是很有用的。"
#: index.docbook:100 #. Tag: programlisting
#: query_criteria.xml:100
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .createAlias(\"kittens\", \"kt\")\n" " .createAlias(\"kittens\", \"kt\")\n"
@ -167,15 +265,32 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:102 #. Tag: para
msgid "(<literal>createAlias()</literal> does not create a new instance of <literal>Criteria</literal>.)" #: query_criteria.xml:102
#, no-c-format
msgid ""
"(<literal>createAlias()</literal> does not create a new instance of "
"<literal>Criteria</literal>.)"
msgstr "" msgstr ""
"(<literal>createAlias()</literal>并不创建一个新的 <literal>Criteria</literal>"
"实例。)"
#: index.docbook:107 #. Tag: para
msgid "Note that the kittens collections held by the <literal>Cat</literal> instances returned by the previous two queries are <emphasis>not</emphasis> pre-filtered by the criteria! If you wish to retrieve just the kittens that match the criteria, you must use a <literal>ResultTransformer</literal>." #: query_criteria.xml:107
#, no-c-format
msgid ""
"Note that the kittens collections held by the <literal>Cat</literal> "
"instances returned by the previous two queries are <emphasis>not</emphasis> "
"pre-filtered by the criteria! If you wish to retrieve just the kittens that "
"match the criteria, you must use a <literal>ResultTransformer</literal>."
msgstr "" msgstr ""
"<literal>Cat</literal>实例所保存的之前两次查询所返回的kittens集合是 "
"<emphasis>没有</emphasis>被条件预过滤的。如果你希望只获得符合条件的kittens "
"你必须使用<literal>ResultTransformer</literal>。"
#: index.docbook:114 #. Tag: programlisting
#: query_criteria.xml:114
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .createCriteria(\"kittens\", \"kt\")\n" " .createCriteria(\"kittens\", \"kt\")\n"
@ -190,15 +305,24 @@ msgid ""
"}]]>" "}]]>"
msgstr "" msgstr ""
#: index.docbook:119 #. Tag: title
#: query_criteria.xml:119
#, no-c-format
msgid "Dynamic association fetching" msgid "Dynamic association fetching"
msgstr "" msgstr "动态关联抓取"
#: index.docbook:121 #. Tag: para
msgid "You may specify association fetching semantics at runtime using <literal>setFetchMode()</literal>." #: query_criteria.xml:121
#, no-c-format
msgid ""
"You may specify association fetching semantics at runtime using "
"<literal>setFetchMode()</literal>."
msgstr "" msgstr ""
"你可以使用<literal>setFetchMode()</literal>在运行时定义动态关联抓取的语义。"
#: index.docbook:126 #. Tag: programlisting
#: query_criteria.xml:126
#, no-c-format
msgid "" msgid ""
"<![CDATA[List cats = sess.createCriteria(Cat.class)\n" "<![CDATA[List cats = sess.createCriteria(Cat.class)\n"
" .add( Restrictions.like(\"name\", \"Fritz%\") )\n" " .add( Restrictions.like(\"name\", \"Fritz%\") )\n"
@ -207,19 +331,36 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:128 #. Tag: para
msgid "This query will fetch both <literal>mate</literal> and <literal>kittens</literal> by outer join. See <xref linkend=\"performance-fetching\"/> for more information." #: query_criteria.xml:128
#, no-c-format
msgid ""
"This query will fetch both <literal>mate</literal> and <literal>kittens</"
"literal> by outer join. See <xref linkend=\"performance-fetching\"/> for "
"more information."
msgstr "" msgstr ""
"这个查询可以通过外连接抓取<literal>mate</literal>和<literal>kittens</"
"literal>。 查看<xref linkend=\"performance-fetching\"/>可以获得更多信息。"
#: index.docbook:136 #. Tag: title
#: query_criteria.xml:136
#, no-c-format
msgid "Example queries" msgid "Example queries"
msgstr "" msgstr "查询示例"
#: index.docbook:138 #. Tag: para
msgid "The class <literal>org.hibernate.criterion.Example</literal> allows you to construct a query criterion from a given instance." #: query_criteria.xml:138
#, no-c-format
msgid ""
"The class <literal>org.hibernate.criterion.Example</literal> allows you to "
"construct a query criterion from a given instance."
msgstr "" msgstr ""
"<literal>org.hibernate.criterion.Example</literal>类允许你通过一个给定实例 构"
"建一个条件查询。"
#: index.docbook:143 #. Tag: programlisting
#: query_criteria.xml:143
#, no-c-format
msgid "" msgid ""
"<![CDATA[Cat cat = new Cat();\n" "<![CDATA[Cat cat = new Cat();\n"
"cat.setSex('F');\n" "cat.setSex('F');\n"
@ -229,31 +370,44 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:145 #. Tag: para
msgid "Version properties, identifiers and associations are ignored. By default, null valued properties are excluded." #: query_criteria.xml:145
msgstr "" #, no-c-format
msgid ""
"Version properties, identifiers and associations are ignored. By default, "
"null valued properties are excluded."
msgstr "版本属性、标识符和关联被忽略。默认情况下值为null的属性将被排除。"
#: index.docbook:150 #. Tag: para
#: query_criteria.xml:150
#, no-c-format
msgid "You can adjust how the <literal>Example</literal> is applied." msgid "You can adjust how the <literal>Example</literal> is applied."
msgstr "" msgstr "你可以自行调整<literal>Example</literal>使之更实用。"
#: index.docbook:154 #. Tag: programlisting
#: query_criteria.xml:154
#, no-c-format
msgid "" msgid ""
"<![CDATA[Example example = Example.create(cat)\n" "<![CDATA[Example example = Example.create(cat)\n"
" .excludeZeroes() //exclude zero valued properties\n" " .excludeZeroes() //exclude zero valued properties\n"
" .excludeProperty(\"color\") //exclude the property named \"color\"\n" " .excludeProperty(\"color\") //exclude the property named \"color\"\n"
" .ignoreCase() //perform case insensitive string comparisons\n" " .ignoreCase() //perform case insensitive string "
"comparisons\n"
" .enableLike(); //use like for string comparisons\n" " .enableLike(); //use like for string comparisons\n"
"List results = session.createCriteria(Cat.class)\n" "List results = session.createCriteria(Cat.class)\n"
" .add(example)\n" " .add(example)\n"
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:156 #. Tag: para
#: query_criteria.xml:156
#, no-c-format
msgid "You can even use examples to place criteria upon associated objects." msgid "You can even use examples to place criteria upon associated objects."
msgstr "" msgstr "你甚至可以使用examples在关联对象上放置条件。"
#: index.docbook:160 #. Tag: programlisting
#: query_criteria.xml:160
#, no-c-format
msgid "" msgid ""
"<![CDATA[List results = session.createCriteria(Cat.class)\n" "<![CDATA[List results = session.createCriteria(Cat.class)\n"
" .add( Example.create(cat) )\n" " .add( Example.create(cat) )\n"
@ -262,15 +416,27 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:165 #. Tag: title
#: query_criteria.xml:165
#, no-c-format
msgid "Projections, aggregation and grouping" msgid "Projections, aggregation and grouping"
msgstr "" msgstr "投影(Projections)、聚合aggregation和分组grouping"
#: index.docbook:166 #. Tag: para
msgid "The class <literal>org.hibernate.criterion.Projections</literal> is a factory for <literal>Projection</literal> instances. We apply a projection to a query by calling <literal>setProjection()</literal>." #: query_criteria.xml:166
#, no-c-format
msgid ""
"The class <literal>org.hibernate.criterion.Projections</literal> is a "
"factory for <literal>Projection</literal> instances. We apply a projection "
"to a query by calling <literal>setProjection()</literal>."
msgstr "" msgstr ""
"<literal>org.hibernate.criterion.Projections</literal>是 "
"<literal>Projection</literal> 的实例工厂。我们通过调用 <literal>setProjection"
"()</literal>应用投影到一个查询。"
#: index.docbook:172 #. Tag: programlisting
#: query_criteria.xml:172
#, no-c-format
msgid "" msgid ""
"<![CDATA[List results = session.createCriteria(Cat.class)\n" "<![CDATA[List results = session.createCriteria(Cat.class)\n"
" .setProjection( Projections.rowCount() )\n" " .setProjection( Projections.rowCount() )\n"
@ -278,7 +444,9 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:174 #. Tag: programlisting
#: query_criteria.xml:174
#, no-c-format
msgid "" msgid ""
"<![CDATA[List results = session.createCriteria(Cat.class)\n" "<![CDATA[List results = session.createCriteria(Cat.class)\n"
" .setProjection( Projections.projectionList()\n" " .setProjection( Projections.projectionList()\n"
@ -290,23 +458,43 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:176 #. Tag: para
msgid "There is no explicit \"group by\" necessary in a criteria query. Certain projection types are defined to be <emphasis>grouping projections</emphasis>, which also appear in the SQL <literal>group by</literal> clause." #: query_criteria.xml:176
#, no-c-format
msgid ""
"There is no explicit \"group by\" necessary in a criteria query. Certain "
"projection types are defined to be <emphasis>grouping projections</"
"emphasis>, which also appear in the SQL <literal>group by</literal> clause."
msgstr "" msgstr ""
"在一个条件查询中没有必要显式的使用 \"group by\" 。某些投影类型就是被定义为"
"<emphasis> 分组投影</emphasis>他们也出现在SQL的<literal>group by</literal>"
"子句中。"
#: index.docbook:182 #. Tag: para
msgid "An alias may optionally be assigned to a projection, so that the projected value may be referred to in restrictions or orderings. Here are two different ways to do this:" #: query_criteria.xml:182
#, no-c-format
msgid ""
"An alias may optionally be assigned to a projection, so that the projected "
"value may be referred to in restrictions or orderings. Here are two "
"different ways to do this:"
msgstr "" msgstr ""
"你可以选择把一个别名指派给一个投影,这样可以使投影值被约束或排序所引用。下面"
"是两种不同的实现方式:"
#: index.docbook:188 #. Tag: programlisting
#: query_criteria.xml:188
#, no-c-format
msgid "" msgid ""
"<![CDATA[List results = session.createCriteria(Cat.class)\n" "<![CDATA[List results = session.createCriteria(Cat.class)\n"
" .setProjection( Projections.alias( Projections.groupProperty(\"color\"), \"colr\" ) )\n" " .setProjection( Projections.alias( Projections.groupProperty(\"color\"), "
"\"colr\" ) )\n"
" .addOrder( Order.asc(\"colr\") )\n" " .addOrder( Order.asc(\"colr\") )\n"
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:190 #. Tag: programlisting
#: query_criteria.xml:190
#, no-c-format
msgid "" msgid ""
"<![CDATA[List results = session.createCriteria(Cat.class)\n" "<![CDATA[List results = session.createCriteria(Cat.class)\n"
" .setProjection( Projections.groupProperty(\"color\").as(\"colr\") )\n" " .setProjection( Projections.groupProperty(\"color\").as(\"colr\") )\n"
@ -314,11 +502,22 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:192 #. Tag: para
msgid "The <literal>alias()</literal> and <literal>as()</literal> methods simply wrap a projection instance in another, aliased, instance of <literal>Projection</literal>. As a shortcut, you can assign an alias when you add the projection to a projection list:" #: query_criteria.xml:192
#, no-c-format
msgid ""
"The <literal>alias()</literal> and <literal>as()</literal> methods simply "
"wrap a projection instance in another, aliased, instance of "
"<literal>Projection</literal>. As a shortcut, you can assign an alias when "
"you add the projection to a projection list:"
msgstr "" msgstr ""
"<literal>alias()</literal>和<literal>as()</literal>方法简便的将一个投影实例包"
"装到另外一个 别名的<literal>Projection</literal>实例中。简而言之,当你添加一"
"个投影到一个投影列表中时 你可以为它指定一个别名:"
#: index.docbook:199 #. Tag: programlisting
#: query_criteria.xml:199
#, no-c-format
msgid "" msgid ""
"<![CDATA[List results = session.createCriteria(Cat.class)\n" "<![CDATA[List results = session.createCriteria(Cat.class)\n"
" .setProjection( Projections.projectionList()\n" " .setProjection( Projections.projectionList()\n"
@ -332,7 +531,9 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:201 #. Tag: programlisting
#: query_criteria.xml:201
#, no-c-format
msgid "" msgid ""
"<![CDATA[List results = session.createCriteria(Domestic.class, \"cat\")\n" "<![CDATA[List results = session.createCriteria(Domestic.class, \"cat\")\n"
" .createAlias(\"kittens\", \"kit\")\n" " .createAlias(\"kittens\", \"kit\")\n"
@ -345,11 +546,17 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:203 #. Tag: para
msgid "You can also use <literal>Property.forName()</literal> to express projections:" #: query_criteria.xml:203
msgstr "" #, no-c-format
msgid ""
"You can also use <literal>Property.forName()</literal> to express "
"projections:"
msgstr "你也可以使用<literal>Property.forName()</literal>来表示投影:"
#: index.docbook:207 #. Tag: programlisting
#: query_criteria.xml:207
#, no-c-format
msgid "" msgid ""
"<![CDATA[List results = session.createCriteria(Cat.class)\n" "<![CDATA[List results = session.createCriteria(Cat.class)\n"
" .setProjection( Property.forName(\"name\") )\n" " .setProjection( Property.forName(\"name\") )\n"
@ -357,7 +564,9 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:209 #. Tag: programlisting
#: query_criteria.xml:209
#, no-c-format
msgid "" msgid ""
"<![CDATA[List results = session.createCriteria(Cat.class)\n" "<![CDATA[List results = session.createCriteria(Cat.class)\n"
" .setProjection( Projections.projectionList()\n" " .setProjection( Projections.projectionList()\n"
@ -371,31 +580,52 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:214 #. Tag: title
#: query_criteria.xml:214
#, no-c-format
msgid "Detached queries and subqueries" msgid "Detached queries and subqueries"
msgstr "" msgstr "离线(detached)查询和子查询"
#: index.docbook:215 #. Tag: para
msgid "The <literal>DetachedCriteria</literal> class lets you create a query outside the scope of a session, and then later execute it using some arbitrary <literal>Session</literal>." #: query_criteria.xml:215
#, no-c-format
msgid ""
"The <literal>DetachedCriteria</literal> class lets you create a query "
"outside the scope of a session, and then later execute it using some "
"arbitrary <literal>Session</literal>."
msgstr "" msgstr ""
"<literal>DetachedCriteria</literal>类使你在一个session范围之外创建一个查询"
"并且可以使用任意的 <literal>Session</literal>来执行它。"
#: index.docbook:220 #. Tag: programlisting
#: query_criteria.xml:220
#, no-c-format
msgid "" msgid ""
"<![CDATA[DetachedCriteria query = DetachedCriteria.forClass(Cat.class)\n" "<![CDATA[DetachedCriteria query = DetachedCriteria.forClass(Cat.class)\n"
" .add( Property.forName(\"sex\").eq('F') );\n" " .add( Property.forName(\"sex\").eq('F') );\n"
" \n" " \n"
"Session session = ....;\n" "Session session = ....;\n"
"Transaction txn = session.beginTransaction();\n" "Transaction txn = session.beginTransaction();\n"
"List results = query.getExecutableCriteria(session).setMaxResults(100).list();\n" "List results = query.getExecutableCriteria(session).setMaxResults(100).list"
"();\n"
"txn.commit();\n" "txn.commit();\n"
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:222 #. Tag: para
msgid "A <literal>DetachedCriteria</literal> may also be used to express a subquery. Criterion instances involving subqueries may be obtained via <literal>Subqueries</literal> or <literal>Property</literal>." #: query_criteria.xml:222
#, no-c-format
msgid ""
"A <literal>DetachedCriteria</literal> may also be used to express a "
"subquery. Criterion instances involving subqueries may be obtained via "
"<literal>Subqueries</literal> or <literal>Property</literal>."
msgstr "" msgstr ""
"<literal>DetachedCriteria</literal>也可以用以表示子查询。条件实例包含子查询可"
"以通过 <literal>Subqueries</literal>或者<literal>Property</literal>获得。"
#: index.docbook:228 #. Tag: programlisting
#: query_criteria.xml:228
#, no-c-format
msgid "" msgid ""
"<![CDATA[DetachedCriteria avgWeight = DetachedCriteria.forClass(Cat.class)\n" "<![CDATA[DetachedCriteria avgWeight = DetachedCriteria.forClass(Cat.class)\n"
" .setProjection( Property.forName(\"weight\").avg() );\n" " .setProjection( Property.forName(\"weight\").avg() );\n"
@ -404,7 +634,9 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:230 #. Tag: programlisting
#: query_criteria.xml:230
#, no-c-format
msgid "" msgid ""
"<![CDATA[DetachedCriteria weights = DetachedCriteria.forClass(Cat.class)\n" "<![CDATA[DetachedCriteria weights = DetachedCriteria.forClass(Cat.class)\n"
" .setProjection( Property.forName(\"weight\") );\n" " .setProjection( Property.forName(\"weight\") );\n"
@ -413,13 +645,18 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:232 #. Tag: para
#: query_criteria.xml:232
#, no-c-format
msgid "Even correlated subqueries are possible:" msgid "Even correlated subqueries are possible:"
msgstr "" msgstr "甚至相互关联的子查询也是有可能的:"
#: index.docbook:236 #. Tag: programlisting
#: query_criteria.xml:236
#, no-c-format
msgid "" msgid ""
"<![CDATA[DetachedCriteria avgWeightForSex = DetachedCriteria.forClass(Cat.class, \"cat2\")\n" "<![CDATA[DetachedCriteria avgWeightForSex = DetachedCriteria.forClass(Cat."
"class, \"cat2\")\n"
" .setProjection( Property.forName(\"weight\").avg() )\n" " .setProjection( Property.forName(\"weight\").avg() )\n"
" .add( Property.forName(\"cat2.sex\").eqProperty(\"cat.sex\") );\n" " .add( Property.forName(\"cat2.sex\").eqProperty(\"cat.sex\") );\n"
"session.createCriteria(Cat.class, \"cat\")\n" "session.createCriteria(Cat.class, \"cat\")\n"
@ -427,19 +664,41 @@ msgid ""
" .list();]]>" " .list();]]>"
msgstr "" msgstr ""
#: index.docbook:245 #. Tag: title
#: query_criteria.xml:245
#, no-c-format
msgid "Queries by natural identifier" msgid "Queries by natural identifier"
msgstr "" msgstr "根据自然标识查询(Queries by natural identifier)"
#: index.docbook:247 #. Tag: para
msgid "For most queries, including criteria queries, the query cache is not very efficient, because query cache invalidation occurs too frequently. However, there is one special kind of query where we can optimize the cache invalidation algorithm: lookups by a constant natural key. In some applications, this kind of query occurs frequently. The criteria API provides special provision for this use case." #: query_criteria.xml:247
#, no-c-format
msgid ""
"For most queries, including criteria queries, the query cache is not very "
"efficient, because query cache invalidation occurs too frequently. However, "
"there is one special kind of query where we can optimize the cache "
"invalidation algorithm: lookups by a constant natural key. In some "
"applications, this kind of query occurs frequently. The criteria API "
"provides special provision for this use case."
msgstr "" msgstr ""
"对大多数查询,包括条件查询而言,因为查询缓存的失效(invalidation)发生得太频"
"繁,查询缓存不是非常高效。然而,有一种特别的查询,可以通过不变的自然键优化缓"
"存的失效算法。在某些应用中这种类型的查询比较常见。条件查询API对这种用例提供"
"了特别规约。"
#: index.docbook:255 #. Tag: para
msgid "First, you should map the natural key of your entity using <literal>&lt;natural-id&gt;</literal>, and enable use of the second-level cache." #: query_criteria.xml:255
#, no-c-format
msgid ""
"First, you should map the natural key of your entity using <literal>&lt;"
"natural-id&gt;</literal>, and enable use of the second-level cache."
msgstr "" msgstr ""
"首先你应该对你的entity使用<literal>&lt;natural-id&gt;</literal>来映射自然"
"键,然后打开第二级缓存。"
#: index.docbook:260 #. Tag: programlisting
#: query_criteria.xml:260
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"User\">\n" "<![CDATA[<class name=\"User\">\n"
" <cache usage=\"read-write\"/>\n" " <cache usage=\"read-write\"/>\n"
@ -454,19 +713,33 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:262 #. Tag: para
msgid "Note that this functionality is not intended for use with entities with <emphasis>mutable</emphasis> natural keys." #: query_criteria.xml:262
msgstr "" #, no-c-format
msgid ""
"Note that this functionality is not intended for use with entities with "
"<emphasis>mutable</emphasis> natural keys."
msgstr "注意,此功能对具有<emphasis>mutable</emphasis>自然键的entity并不适用。"
#: index.docbook:267 #. Tag: para
#: query_criteria.xml:267
#, no-c-format
msgid "Next, enable the Hibernate query cache." msgid "Next, enable the Hibernate query cache."
msgstr "" msgstr "然后打开Hibernate 查询缓存。"
#: index.docbook:271 #. Tag: para
msgid "Now, <literal>Restrictions.naturalId()</literal> allows us to make use of the more efficient cache algorithm." #: query_criteria.xml:271
#, no-c-format
msgid ""
"Now, <literal>Restrictions.naturalId()</literal> allows us to make use of "
"the more efficient cache algorithm."
msgstr "" msgstr ""
"现在,我们可以用<literal>Restrictions.naturalId()</literal>来使用更加高效的缓"
"存算法。"
#: index.docbook:276 #. Tag: programlisting
#: query_criteria.xml:276
#, no-c-format
msgid "" msgid ""
"<![CDATA[session.createCriteria(User.class)\n" "<![CDATA[session.createCriteria(User.class)\n"
" .add( Restrictions.naturalId()\n" " .add( Restrictions.naturalId()\n"
@ -475,10 +748,3 @@ msgid ""
" ).setCacheable(true)\n" " ).setCacheable(true)\n"
" .uniqueResult();]]>" " .uniqueResult();]]>"
msgstr "" msgstr ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,46 +1,101 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2007-10-25 01:01+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n" "Language-Team: LANGUAGE <LL@li.org>\n"
#: index.docbook:5 "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: xml.xml:5
#, no-c-format
msgid "XML Mapping" msgid "XML Mapping"
msgstr "" msgstr "XML映射"
#: index.docbook:7 #. Tag: emphasis
msgid "Note that this is an experimental feature in Hibernate 3.0 and is under extremely active development." #: xml.xml:7
msgstr "" #, no-c-format
msgid ""
"Note that this is an experimental feature in Hibernate 3.0 and is under "
"extremely active development."
msgstr "注意这是Hibernate 3.0的一个实验性的特性。这一特性仍在积极开发中。"
#: index.docbook:13 #. Tag: title
#: xml.xml:13
#, no-c-format
msgid "Working with XML data" msgid "Working with XML data"
msgstr "" msgstr "用XML数据进行工作"
#: index.docbook:15 #. Tag: para
msgid "Hibernate lets you work with persistent XML data in much the same way you work with persistent POJOs. A parsed XML tree can be thought of as just another way to represent the relational data at the object level, instead of POJOs." #: xml.xml:15
#, no-c-format
msgid ""
"Hibernate lets you work with persistent XML data in much the same way you "
"work with persistent POJOs. A parsed XML tree can be thought of as just "
"another way to represent the relational data at the object level, instead of "
"POJOs."
msgstr "" msgstr ""
"Hibernate使得你可以用XML数据来进行工作恰如你用持久化的POJO进行工作那样。解"
"析过的XML树 可以被认为是代替POJO的另外一种在对象层面上表示关系型数据的途径."
#: index.docbook:22 #. Tag: para
msgid "Hibernate supports dom4j as API for manipulating XML trees. You can write queries that retrieve dom4j trees from the database and have any modification you make to the tree automatically synchronized to the database. You can even take an XML document, parse it using dom4j, and write it to the database with any of Hibernate's basic operations: <literal>persist(), saveOrUpdate(), merge(), delete(), replicate()</literal> (merging is not yet supported)." #: xml.xml:22
#, no-c-format
msgid ""
"Hibernate supports dom4j as API for manipulating XML trees. You can write "
"queries that retrieve dom4j trees from the database and have any "
"modification you make to the tree automatically synchronized to the "
"database. You can even take an XML document, parse it using dom4j, and write "
"it to the database with any of Hibernate's basic operations: <literal>persist"
"(), saveOrUpdate(), merge(), delete(), replicate()</literal> (merging is not "
"yet supported)."
msgstr "" msgstr ""
"Hibernate支持采用dom4j作为操作XML树的API。你可以写一些查询从数据库中检索出 "
"dom4j树随后你对这颗树做的任何修改都将自动同步回数据库。你甚至可以用dom4j解"
"析 一篇XML文档然后使用Hibernate的任一基本操作将它写入数据库 "
"<literal>persist(), saveOrUpdate(), merge(), delete(), replicate()</literal> "
"(合并操作merge()目前还不支持)。"
#: index.docbook:32 #. Tag: para
msgid "This feature has many applications including data import/export, externalization of entity data via JMS or SOAP and XSLT-based reporting." #: xml.xml:32
#, no-c-format
msgid ""
"This feature has many applications including data import/export, "
"externalization of entity data via JMS or SOAP and XSLT-based reporting."
msgstr "" msgstr ""
"这一特性可以应用在很多场合包括数据导入导出通过JMS或SOAP具体化实体数据以"
"及 基于XSLT的报表。"
#: index.docbook:37 #. Tag: para
msgid "A single mapping may be used to simultaneously map properties of a class and nodes of an XML document to the database, or, if there is no class to map, it may be used to map just the XML." #: xml.xml:37
#, no-c-format
msgid ""
"A single mapping may be used to simultaneously map properties of a class and "
"nodes of an XML document to the database, or, if there is no class to map, "
"it may be used to map just the XML."
msgstr "" msgstr ""
"一个单一的映射就可以将类的属性和XML文档的节点同时映射到数据库。如果不需要映射"
"类, 它也可以用来只映射XML文档。"
#: index.docbook:44 #. Tag: title
#: xml.xml:44
#, no-c-format
msgid "Specifying XML and class mapping together" msgid "Specifying XML and class mapping together"
msgstr "" msgstr "指定同时映射XML和类"
#: index.docbook:46 #. Tag: para
#: xml.xml:46
#, no-c-format
msgid "Here is an example of mapping a POJO and XML simultaneously:" msgid "Here is an example of mapping a POJO and XML simultaneously:"
msgstr "" msgstr "这是一个同时映射POJO和XML的例子"
#: index.docbook:50 #. Tag: programlisting
#: xml.xml:50
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Account\" \n" "<![CDATA[<class name=\"Account\" \n"
" table=\"ACCOUNTS\" \n" " table=\"ACCOUNTS\" \n"
@ -64,15 +119,21 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:54 #. Tag: title
#: xml.xml:54
#, no-c-format
msgid "Specifying only an XML mapping" msgid "Specifying only an XML mapping"
msgstr "" msgstr "只定义XML映射"
#: index.docbook:56 #. Tag: para
#: xml.xml:56
#, no-c-format
msgid "Here is an example where there is no POJO class:" msgid "Here is an example where there is no POJO class:"
msgstr "" msgstr "这是一个不映射POJO的例子"
#: index.docbook:60 #. Tag: programlisting
#: xml.xml:60
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class entity-name=\"Account\" \n" "<![CDATA[<class entity-name=\"Account\" \n"
" table=\"ACCOUNTS\" \n" " table=\"ACCOUNTS\" \n"
@ -99,43 +160,97 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:62 #. Tag: para
msgid "This mapping allows you to access the data as a dom4j tree, or as a graph of property name/value pairs (java <literal>Map</literal>s). The property names are purely logical constructs that may be referred to in HQL queries." #: xml.xml:62
#, no-c-format
msgid ""
"This mapping allows you to access the data as a dom4j tree, or as a graph of "
"property name/value pairs (java <literal>Map</literal>s). The property names "
"are purely logical constructs that may be referred to in HQL queries."
msgstr "" msgstr ""
"这个映射使得你既可以把数据作为一棵dom4j树那样访问又可以作为由属性键值对"
"(java <literal>Map</literal>s) 组成的图那样访问。属性名字纯粹是逻辑上的结构,"
"你可以在HQL查询中引用它。"
#: index.docbook:73 #. Tag: title
#: xml.xml:73
#, no-c-format
msgid "XML mapping metadata" msgid "XML mapping metadata"
msgstr "" msgstr "XML映射元数据"
#: index.docbook:75 #. Tag: para
msgid "Many Hibernate mapping elements accept the <literal>node</literal> attribute. This let's you specify the name of an XML attribute or element that holds the property or entity data. The format of the <literal>node</literal> attribute must be one of the following:" #: xml.xml:75
#, no-c-format
msgid ""
"Many Hibernate mapping elements accept the <literal>node</literal> "
"attribute. This let's you specify the name of an XML attribute or element "
"that holds the property or entity data. The format of the <literal>node</"
"literal> attribute must be one of the following:"
msgstr "" msgstr ""
"许多Hibernate映射元素具有<literal>node</literal>属性。这使你可以指定用来保存 "
"属性或实体数据的XML属性或元素。<literal>node</literal>属性必须是下列格式之"
"一:"
#: index.docbook:84 #. Tag: para
#: xml.xml:84
#, no-c-format
msgid "<literal>\"element-name\"</literal> - map to the named XML element" msgid "<literal>\"element-name\"</literal> - map to the named XML element"
msgstr "" msgstr "<literal>\"element-name\"</literal> - 映射为指定的XML元素"
#: index.docbook:87 #. Tag: para
#: xml.xml:87
#, no-c-format
msgid "<literal>\"@attribute-name\"</literal> - map to the named XML attribute" msgid "<literal>\"@attribute-name\"</literal> - map to the named XML attribute"
msgstr "" msgstr "<literal>\"@attribute-name\"</literal> - 映射为指定的XML属性"
#: index.docbook:90 #. Tag: para
#: xml.xml:90
#, no-c-format
msgid "<literal>\".\"</literal> - map to the parent element" msgid "<literal>\".\"</literal> - map to the parent element"
msgstr "" msgstr "<literal>\".\"</literal> - 映射为父元素"
#: index.docbook:93 #. Tag: para
msgid "<literal>\"element-name/@attribute-name\"</literal> - map to the named attribute of the named element" #: xml.xml:93
#, no-c-format
msgid ""
"<literal>\"element-name/@attribute-name\"</literal> - map to the named "
"attribute of the named element"
msgstr "" msgstr ""
"<literal>\"element-name/@attribute-name\"</literal> - 映射为指定元素的指定属"
"性"
#: index.docbook:100 #. Tag: para
msgid "For collections and single valued associations, there is an additional <literal>embed-xml</literal> attribute. If <literal>embed-xml=\"true\"</literal>, the default, the XML tree for the associated entity (or collection of value type) will be embedded directly in the XML tree for the entity that owns the association. Otherwise, if <literal>embed-xml=\"false\"</literal>, then only the referenced identifier value will appear in the XML for single point associations and collections will simply not appear at all." #: xml.xml:100
#, no-c-format
msgid ""
"For collections and single valued associations, there is an additional "
"<literal>embed-xml</literal> attribute. If <literal>embed-xml=\"true\"</"
"literal>, the default, the XML tree for the associated entity (or collection "
"of value type) will be embedded directly in the XML tree for the entity that "
"owns the association. Otherwise, if <literal>embed-xml=\"false\"</literal>, "
"then only the referenced identifier value will appear in the XML for single "
"point associations and collections will simply not appear at all."
msgstr "" msgstr ""
"对于集合和单值的关联,有一个额外的<literal>embed-xml</literal>属性可用。 这个"
"属性的缺省值是真(<literal>embed-xml=\"true\"</literal>)。如果<literal>embed-"
"xml=\"true\"</literal> 则对应于被关联实体或值类型的集合的XML树将直接嵌入拥"
"有这些关联的实体的XML树中。 否则,如果<literal>embed-xml=\"false\"</"
"literal>,那么对于单值的关联,仅被引用的实体的标识符出现在 XML树中(被引用实体"
"本身不出现),而集合则根本不出现。"
#: index.docbook:110 #. Tag: para
msgid "You should be careful not to leave <literal>embed-xml=\"true\"</literal> for too many associations, since XML does not deal well with circularity!" #: xml.xml:110
#, no-c-format
msgid ""
"You should be careful not to leave <literal>embed-xml=\"true\"</literal> for "
"too many associations, since XML does not deal well with circularity!"
msgstr "" msgstr ""
"你应该小心不要让太多关联的embed-xml属性为真(<literal>embed-xml=\"true\"</"
"literal>)因为XML不能很好地处理 循环引用!"
#: index.docbook:115 #. Tag: programlisting
#: xml.xml:115
#, no-c-format
msgid "" msgid ""
"<![CDATA[<class name=\"Customer\" \n" "<![CDATA[<class name=\"Customer\" \n"
" table=\"CUSTOMER\" \n" " table=\"CUSTOMER\" \n"
@ -173,19 +288,33 @@ msgid ""
"</class>]]>" "</class>]]>"
msgstr "" msgstr ""
#: index.docbook:117 #. Tag: para
msgid "in this case, we have decided to embed the collection of account ids, but not the actual account data. The following HQL query:" #: xml.xml:117
#, no-c-format
msgid ""
"in this case, we have decided to embed the collection of account ids, but "
"not the actual account data. The following HQL query:"
msgstr ""
"在这个例子中,我们决定嵌入帐目号码(account id)的集合,但不嵌入实际的帐目数"
"据。下面的HQL查询"
#. Tag: programlisting
#: xml.xml:122
#, no-c-format
msgid ""
"<![CDATA[from Customer c left join fetch c.accounts where c.lastName like :"
"lastName]]>"
msgstr "" msgstr ""
#: index.docbook:122 #. Tag: para
msgid "<![CDATA[from Customer c left join fetch c.accounts where c.lastName like :lastName]]>" #: xml.xml:124
msgstr "" #, no-c-format
#: index.docbook:124
msgid "Would return datasets such as this:" msgid "Would return datasets such as this:"
msgstr "" msgstr "返回的数据集将是这样:"
#: index.docbook:128 #. Tag: programlisting
#: xml.xml:128
#, no-c-format
msgid "" msgid ""
"<![CDATA[<customer id=\"123456789\">\n" "<![CDATA[<customer id=\"123456789\">\n"
" <account short-desc=\"Savings\">987632567</account>\n" " <account short-desc=\"Savings\">987632567</account>\n"
@ -199,11 +328,19 @@ msgid ""
"</customer>]]>" "</customer>]]>"
msgstr "" msgstr ""
#: index.docbook:130 #. Tag: para
msgid "If you set <literal>embed-xml=\"true\"</literal> on the <literal>&lt;one-to-many&gt;</literal> mapping, the data might look more like this:" #: xml.xml:130
#, no-c-format
msgid ""
"If you set <literal>embed-xml=\"true\"</literal> on the <literal>&lt;one-to-"
"many&gt;</literal> mapping, the data might look more like this:"
msgstr "" msgstr ""
"如果你把一对多映射<literal>&lt;one-to-many&gt;</literal>的embed-xml属性置为真"
"(<literal>embed-xml=\"true\"</literal>) 则数据看上去就像这样:"
#: index.docbook:135 #. Tag: programlisting
#: xml.xml:135
#, no-c-format
msgid "" msgid ""
"<![CDATA[<customer id=\"123456789\">\n" "<![CDATA[<customer id=\"123456789\">\n"
" <account id=\"987632567\" short-desc=\"Savings\">\n" " <account id=\"987632567\" short-desc=\"Savings\">\n"
@ -223,15 +360,24 @@ msgid ""
"</customer>]]>" "</customer>]]>"
msgstr "" msgstr ""
#: index.docbook:141 #. Tag: title
#: xml.xml:141
#, no-c-format
msgid "Manipulating XML data" msgid "Manipulating XML data"
msgstr "" msgstr "操作XML数据"
#: index.docbook:143 #. Tag: para
msgid "Let's rearead and update XML documents in the application. We do this by obtaining a dom4j session:" #: xml.xml:143
#, no-c-format
msgid ""
"Let's rearead and update XML documents in the application. We do this by "
"obtaining a dom4j session:"
msgstr "" msgstr ""
"让我们来读入和更新应用程序中的XML文档。通过获取一个dom4j会话可以做到这一点"
#: index.docbook:148 #. Tag: programlisting
#: xml.xml:148
#, no-c-format
msgid "" msgid ""
"<![CDATA[Document doc = ....;\n" "<![CDATA[Document doc = ....;\n"
" \n" " \n"
@ -240,7 +386,8 @@ msgid ""
"Transaction tx = session.beginTransaction();\n" "Transaction tx = session.beginTransaction();\n"
"\n" "\n"
"List results = dom4jSession\n" "List results = dom4jSession\n"
" .createQuery(\"from Customer c left join fetch c.accounts where c.lastName like :lastName\")\n" " .createQuery(\"from Customer c left join fetch c.accounts where c."
"lastName like :lastName\")\n"
" .list();\n" " .list();\n"
"for ( int i=0; i<results.size(); i++ ) {\n" "for ( int i=0; i<results.size(); i++ ) {\n"
" //add the customer data to the XML document\n" " //add the customer data to the XML document\n"
@ -252,7 +399,9 @@ msgid ""
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:150 #. Tag: programlisting
#: xml.xml:150
#, no-c-format
msgid "" msgid ""
"<![CDATA[Session session = factory.openSession();\n" "<![CDATA[Session session = factory.openSession();\n"
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n" "Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
@ -272,13 +421,13 @@ msgid ""
"session.close();]]>" "session.close();]]>"
msgstr "" msgstr ""
#: index.docbook:152 #. Tag: para
msgid "It is extremely useful to combine this feature with Hibernate's <literal>replicate()</literal> operation to implement XML-based data import/export." #: xml.xml:152
#, no-c-format
msgid ""
"It is extremely useful to combine this feature with Hibernate's "
"<literal>replicate()</literal> operation to implement XML-based data import/"
"export."
msgstr "" msgstr ""
"将这一特色与Hibernate的<literal>replicate()</literal>操作结合起来对于实现的基"
msgid "ROLES_OF_TRANSLATORS" "于XML的数据导入/导出将非常有用."
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"