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 ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:21
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr ""
msgstr "体系结构(Architecture)"
#: index.docbook:24
#. Tag: title
#: architecture.xml:24
#, no-c-format
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:"
msgstr ""
msgstr "一个非常简要的Hibernate体系结构的概要图"
#: index.docbook:39
msgid "This diagram shows Hibernate using the database and configuration data to provide persistence services (and persistent objects) to the application."
#. Tag: para
#: 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 ""
"从这个图可以看出Hibernate使用数据库和配置信息来为应用程序提供持久化服务以"
"及持久的对象)。"
#: index.docbook:44
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:"
#. Tag: para
#: 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 ""
"我们来更详细地看一下Hibernate运行时体系结构。由于Hibernate非常灵活且支持多"
"种应用方案, 所以我们这只描述一下两种极端的情况。“轻型”的体系结构方案,要求应"
"用程序提供自己的JDBC 连接并管理自己的事务。这种方案使用了Hibernate API的最小"
"子集:"
#: index.docbook:61
msgid "The \"full cream\" architecture abstracts the application away from the underlying JDBC/JTA APIs and lets Hibernate take care of the details."
#. Tag: para
#: 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 ""
"“全面解决”的体系结构方案将应用层从底层的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:"
msgstr ""
msgstr "图中各个对象的定义如下: <placeholder-1/>"
#: index.docbook:80
#. Tag: term
#: architecture.xml:80
#, no-c-format
msgid "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
msgstr ""
msgstr "SessionFactory (<literal>org.hibernate.SessionFactory</literal>)"
#: index.docbook:82
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."
#. Tag: para
#: 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 ""
"针对单个数据库映射关系经过编译后的内存镜像,是线程安全的(不可变)。 它是生成"
"<literal>Session</literal>的工厂,本身要用到<literal>ConnectionProvider</"
"literal>。 该对象可以在进程或集群的级别上,为那些事务之间可以重用的数据提供可"
"选的二级缓存。"
#: index.docbook:92
#. Tag: term
#: architecture.xml:92
#, no-c-format
msgid "Session (<literal>org.hibernate.Session</literal>)"
msgstr ""
msgstr "Session (<literal>org.hibernate.Session</literal>)"
#: index.docbook:94
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."
#. Tag: para
#: 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 ""
"表示应用程序与持久储存层之间交互操作的一个单线程对象,此对象生存期很短。 其隐"
"藏了JDBC连接也是<literal>Transaction</literal>的工厂。 其会持有一个针对持久"
"化对象的必选(第一级)缓存,在遍历对象图或者根据持久化标识查找对象时会用到。"
#: index.docbook:104
#. Tag: term
#: architecture.xml:104
#, no-c-format
msgid "Persistent objects and collections"
msgstr ""
msgstr "持久的对象及其集合"
#: index.docbook:106
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)."
#. Tag: para
#: 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 ""
"带有持久化状态的、具有业务功能的单线程对象,此对象生存期很短。 这些对象可能是"
"普通的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"
msgstr ""
msgstr "瞬态(transient)和脱管(detached)的对象及其集合"
#: index.docbook:119
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>."
#. Tag: para
#: 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 ""
"那些目前没有与session关联的持久化类实例。 他们可能是在被应用程序实例化后,尚"
"未进行持久化的对象。 也可能是因为实例化他们的<literal>Session</literal>已经被"
"关闭而脱离持久化的对象。"
#: index.docbook:128
#. Tag: term
#: architecture.xml:128
#, no-c-format
msgid "Transaction (<literal>org.hibernate.Transaction</literal>)"
msgstr ""
msgstr "事务Transaction (<literal>org.hibernate.Transaction</literal>)"
#: index.docbook:130
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!"
#. Tag: para
#: 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 ""
"(可选的)应用程序用来指定原子操作单元范围的对象,它是单线程的,生命周期很"
"短。 它通过抽象将应用从底层具体的JDBC、JTA以及CORBA事务隔离开。 某些情况下,"
"一个<literal>Session</literal>之内可能包含多个<literal>Transaction</literal>"
"对象。 尽管是否使用该对象是可选的但无论是使用底层的API还是使用"
"<literal>Transaction</literal>对象,事务边界的开启与关闭是必不可少的。"
#: index.docbook:141
msgid "ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</literal>)"
#. Tag: term
#: architecture.xml:141
#, no-c-format
msgid ""
"ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</"
"literal>)"
msgstr ""
"ConnectionProvider (<literal>org.hibernate.connection.ConnectionProvider</"
"literal>)"
#: index.docbook:143
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."
#. Tag: para
#: 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 ""
"可选的生成JDBC连接的工厂同时也起到连接池的作用。 它通过抽象将应用从底"
"层的<literal>Datasource</literal>或<literal>DriverManager</literal>隔离开。 "
"仅供开发者扩展/实现用,并不暴露给应用程序使用。"
#: index.docbook:151
msgid "TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
#. Tag: term
#: architecture.xml:151
#, no-c-format
msgid ""
"TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
msgstr ""
"TransactionFactory (<literal>org.hibernate.TransactionFactory</literal>)"
#: index.docbook:153
msgid "(Optional) A factory for <literal>Transaction</literal> instances. Not exposed to the application, but can be extended/implemented by the developer."
#. Tag: para
#: 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 ""
"(可选的)生成<literal>Transaction</literal>对象实例的工厂。 仅供开发者扩展/"
"实现用,并不暴露给应用程序使用。"
#: index.docbook:160
#. Tag: emphasis
#: architecture.xml:160
#, no-c-format
msgid "Extension Interfaces"
msgstr ""
msgstr "扩展接口"
#: index.docbook:162
msgid "Hibernate offers many optional extension interfaces you can implement to customize the behavior of your persistence layer. See the API documentation for details."
#. Tag: para
#: 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 ""
"Hibernate提供了很多可选的扩展接口你可以通过实现它们来定制你的持久层的行"
"为。 具体请参考API文档。"
#: index.docbook:171
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."
#. Tag: para
#: 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 ""
"在特定“轻型”的体系结构中,应用程序可能绕过 <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"
msgstr ""
msgstr "实例状态"
#: index.docbook:180
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:"
#. Tag: para
#: 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 ""
"一个持久化类的实例可能处于三种不同状态中的某一种。 这三种状态的定义则与所谓的"
"<emphasis>持久化上下文(persistence context)</emphasis>有关。 Hibernate的"
"<literal>Session</literal>对象就是这个所谓的持久化上下文:"
#: index.docbook:188
#. Tag: term
#: architecture.xml:188
#, no-c-format
msgid "transient"
msgstr ""
msgstr "瞬态transient"
#: index.docbook:190
msgid "The instance is not, and has never been associated with any persistence context. It has no persistent identity (primary key value)."
msgstr ""
#. Tag: para
#: architecture.xml:190
#, 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"
msgstr ""
msgstr "持久化(persistent)"
#: index.docbook:200
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)."
#. Tag: para
#: 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 ""
"实例目前与某个持久化上下文有关联。 它拥有持久化标识(相当于主键值),并且可能"
"在数据库中有一个对应的行。 对于某一个特定的持久化上下文Hibernate<emphasis>"
"保证</emphasis>持久化标识与Java标识其值代表对象在内存中的位置等价。"
#: index.docbook:212
#. Tag: term
#: architecture.xml:212
#, no-c-format
msgid "detached"
msgstr ""
msgstr "脱管(detached)"
#: index.docbook:214
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."
#. Tag: para
#: 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 ""
"实例曾经与某个持久化上下文发生过关联,不过那个上下文被关闭了, 或者这个实例是"
"被序列化(serialize)到另外的进程。 它拥有持久化标识,并且在数据库中可能存在一"
"个对应的行。 对于脱管状态的实例Hibernate不保证任何持久化标识和Java标识的关"
"系。"
#: index.docbook:229
#. Tag: title
#: architecture.xml:229
#, no-c-format
msgid "JMX Integration"
msgstr ""
msgstr "JMX整合"
#: index.docbook:231
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>."
#. Tag: para
#: 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 ""
"JMX是管理Java组件(Java components)的J2EE标准。 Hibernate 可以通过一个JMX标准"
"服务来管理。 在这个发行版本中我们提供了一个MBean接口的实现,即 <literal>org."
"hibernate.jmx.HibernateService</literal>。"
#: index.docbook:237
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:"
#. Tag: para
#: 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 ""
"想要看如何在JBoss应用服务器上将Hibernate部署为一个JMX服务的例子您可以参考"
"JBoss用户指南。 我们现在说一下在Jboss应用服务器上使用JMX来部署Hibernate的好"
"处:"
#: index.docbook:245
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>."
#. Tag: para
#: 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 ""
"<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
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."
#. Tag: para
#: 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 ""
"<emphasis>HAR 部署:</emphasis> 通常情况下你会使用JBoss的服务部署描述符在"
"EAR或/和SAR文件中来部署Hibernate JMX服务。 这种部署方式支持所有常见的"
"Hibernate <literal>SessionFactory</literal>的配置选项。 不过,你仍需在部署描"
"述符中列出你所有的映射文件的名字。如果你使用HAR部署方式, JBoss 会自动探测出"
"你的HAR文件中所有的映射文件。"
#: index.docbook:268
msgid "Consult the JBoss AS user guide for more information about these options."
#. Tag: para
#: 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 ""
"将Hibernate以部署为JMX服务的另一个好处是可以查看Hibernate的运行时统计信息。"
"参看 <xref linkend=\"configuration-optional-statistics\"/>."
#: index.docbook:272
msgid "Another feature available as a JMX service are runtime Hibernate statistics. See <xref linkend=\"configuration-optional-statistics\"/>."
msgstr ""
#: index.docbook:279
#. Tag: title
#: architecture.xml:279
#, no-c-format
msgid "JCA Support"
msgstr ""
msgstr "对JCA的支持"
#: index.docbook:280
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."
#. Tag: para
#: 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 ""
"Hibernate也可以被配置为一个JCA连接器JCA connector。更多信息请参看网站。 "
"请注意Hibernate对JCA的支持仍处于实验性阶段。"
#: index.docbook:287
#. Tag: title
#: architecture.xml:287
#, no-c-format
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 ""
"使用Hibernate的大多数应用程序需要某种形式的“上下文相关的” session特定的"
"session在整个特定的上下文范围内始终有效。然而对不同类型的应用程序而言要为"
"什么是组成这种“上下文”下一个定义通常是困难的;不同的上下文对“当前”这个概念定"
"义了不同的范围。在3.0版本之前使用Hibernate的程序要么采用自行编写的基于"
"<literal>ThreadLocal</literal>的上下文session要么采用"
"<literal>HibernateUtil</literal>这样的辅助类要么采用第三方框架比如Spring"
"或Pico),它们提供了基于代理(proxy)或者基于拦截器(interception)的上下文相关"
"session。"
#: index.docbook:288
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."
#. Tag: para
#: 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 ""
"从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
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."
#. Tag: para
#: 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 ""
"更好的是从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
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."
#. Tag: para
#: 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 ""
"请参阅<literal>org.hibernate.context.CurrentSessionContext</literal>接口的"
"Javadoc,那里有关于它的契约的详细讨论。它定义了单一的方法,"
"<literal>currentSession()</literal>,特定的实现用它来负责跟踪当前的上下文"
"session。Hibernate内置了此接口的三种实现。"
#: index.docbook:314
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."
#. Tag: para
#: 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 ""
"<literal>org.hibernate.context.JTASessionContext</literal> - 当前session根据"
"<literal>JTA</literal>来跟踪和界定。这和以前的仅支持JTA的方法是完全一样的。详"
"情请参阅Javadoc。"
#: index.docbook:324
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."
#. Tag: para
#: 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 ""
"<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - 当前"
"session通过当前执行的线程来跟踪和界定。详情也请参阅Javadoc。"
#: index.docbook:332
msgid "<literal>org.hibernate.context.ThreadLocalSessionContext</literal> - current sessions are tracked by thread of execution. Again, see the Javadocs for details."
#. Tag: para
#: 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 ""
"<literal>org.hibernate.context.ManagedSessionContext</literal> - 当前session"
"通过当前执行的线程来跟踪和界定。但是,你需要负责使用这个类的静态方法将"
"<literal>Session</literal>实例绑定、或者取消绑定,它并不会打开(open)、flush或"
"者关闭(close)任何<literal>Session</literal>。"
#: index.docbook:338
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>."
#. Tag: para
#: 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 ""
"前两种实现都提供了“每数据库事务对应一个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
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."
#. Tag: para
#: 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 ""
#: index.docbook:359
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 ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
"<literal>hibernate.current_session_context_class</literal>配置参数定义了应该"
"采用哪个<literal>org.hibernate.context.CurrentSessionContext</literal>实现。"
"注意,为了向下兼容,如果未配置此参数,但是存在<literal>org.hibernate."
"transaction.TransactionManagerLookup</literal>的配置Hibernate会采用"
"<literal>org.hibernate.context.JTASessionContext</literal>。一般而言,此参数"
"的值指明了要使用的实现类的全名,但那三种内置的实现可以使用简写,即\"jta\"、"
"\"thread\"和\"managed\"。"

View File

@ -1,281 +1,608 @@
#, fuzzy
msgid ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:5
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr ""
msgstr "批量处理Batch processing"
#: index.docbook:7
msgid "A naive approach to inserting 100 000 rows in the database using Hibernate might look like this:"
msgstr ""
#: index.docbook:12
#. Tag: para
#: batch.xml:7
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"for ( int i=0; i<100000; i++ ) {\n"
" Customer customer = new Customer(.....);\n"
" session.save(customer);\n"
"}\n"
"tx.commit();\n"
"session.close();]]>"
"A naive approach to inserting 100 000 rows in the database using Hibernate "
"might look like this:"
msgstr ""
"使用Hibernate将 100 000 条记录插入到数据库的一个很自然的做法可能是这样的"
#. Tag: programlisting
#: batch.xml:12
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"for ( int i=0; i<100000; i++ ) {\n"
" Customer customer = new Customer(.....);\n"
" session.save(customer);\n"
"}\n"
"tx.commit();\n"
"session.close();]]>"
msgstr ""
#: index.docbook:14
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."
#. Tag: para
#: 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 ""
"这段程序大概运行到 50 000 条记录左右会失败并抛出 <literal>内存溢出异常"
"OutOfMemoryException</literal> 。 这是因为 Hibernate 把所有新插入的 "
"<literal>客户Customer</literal>实例在 session级别的缓存区进行了缓存的缘"
"故。"
#: index.docbook:20
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):"
#. Tag: para
#: 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 ""
"我们会在本章告诉你如何避免此类问题。首先,如果你要执行批量处理并且想要达到一"
"个理想的性能, 那么使用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]]>"
msgstr ""
#: index.docbook:29
msgid "Note that Hibernate disables insert batching at the JDBC level transparently if you use an <literal>identiy</literal> identifier generator."
#. Tag: para
#: 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 ""
"注意,假若你使用了<literal>identiy</literal>标识符生成器,Hibernate在JDBC级别透"
"明的关闭插入语句的批量执行。"
#: index.docbook:34
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 ""
#. Tag: para
#: batch.xml:34
#, 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]]>"
msgstr ""
#: index.docbook:41
msgid "However, this is not absolutely necessary, since we can explicitly set the <literal>CacheMode</literal> to disable interaction with the second-level cache."
#. Tag: para
#: 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 ""
"但是,这不是绝对必须的,因为我们可以显式设置<literal>CacheMode</literal>来关"
"闭与二级缓存的交互。"
#: index.docbook:47
#. Tag: title
#: batch.xml:47
#, no-c-format
msgid "Batch inserts"
msgstr ""
msgstr "批量插入Batch inserts"
#: index.docbook:49
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 ""
#: index.docbook:55
#. Tag: para
#: batch.xml:49
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
" \n"
"for ( int i=0; i<100000; i++ ) {\n"
" Customer customer = new Customer(.....);\n"
" session.save(customer);\n"
" if ( i % 20 == 0 ) { //20, same as the JDBC batch size\n"
" //flush a batch of inserts and release memory:\n"
" session.flush();\n"
" session.clear();\n"
" }\n"
"}\n"
" \n"
"tx.commit();\n"
"session.close();]]>"
"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 ""
"如果要将很多对象持久化,你必须通过经常的调用 <literal>flush()</literal> 以及"
"稍后调用 <literal>clear()</literal> 来控制第一级缓存的大小。"
#. Tag: programlisting
#: batch.xml:55
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
" \n"
"for ( int i=0; i<100000; i++ ) {\n"
" Customer customer = new Customer(.....);\n"
" session.save(customer);\n"
" if ( i % 20 == 0 ) { //20, same as the JDBC batch size\n"
" //flush a batch of inserts and release memory:\n"
" session.flush();\n"
" session.clear();\n"
" }\n"
"}\n"
" \n"
"tx.commit();\n"
"session.close();]]>"
msgstr ""
#: index.docbook:60
#. Tag: title
#: batch.xml:60
#, no-c-format
msgid "Batch updates"
msgstr ""
msgstr "批量更新Batch updates"
#: index.docbook:62
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 ""
#: index.docbook:68
#. Tag: para
#: batch.xml:62
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
" \n"
"ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
" .setCacheMode(CacheMode.IGNORE)\n"
" .scroll(ScrollMode.FORWARD_ONLY);\n"
"int count=0;\n"
"while ( customers.next() ) {\n"
" Customer customer = (Customer) customers.get(0);\n"
" customer.updateStuff(...);\n"
" if ( ++count % 20 == 0 ) {\n"
" //flush a batch of updates and release memory:\n"
" session.flush();\n"
" session.clear();\n"
" }\n"
"}\n"
" \n"
"tx.commit();\n"
"session.close();]]>"
"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 ""
"此方法同样适用于检索和更新数据。此外,在进行会返回很多行数据的查询时, 你需要"
"使用 <literal>scroll()</literal> 方法以便充分利用服务器端游标所带来的好处。"
#. Tag: programlisting
#: batch.xml:68
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
" \n"
"ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
" .setCacheMode(CacheMode.IGNORE)\n"
" .scroll(ScrollMode.FORWARD_ONLY);\n"
"int count=0;\n"
"while ( customers.next() ) {\n"
" Customer customer = (Customer) customers.get(0);\n"
" customer.updateStuff(...);\n"
" if ( ++count % 20 == 0 ) {\n"
" //flush a batch of updates and release memory:\n"
" session.flush();\n"
" session.clear();\n"
" }\n"
"}\n"
" \n"
"tx.commit();\n"
"session.close();]]>"
msgstr ""
#: index.docbook:73
#. Tag: title
#: batch.xml:73
#, no-c-format
msgid "The StatelessSession interface"
msgstr ""
msgstr "StatelessSession (无状态session)接口"
#: index.docbook:74
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 ""
#: index.docbook:89
#. Tag: para
#: batch.xml:74
#, no-c-format
msgid ""
"<![CDATA[StatelessSession session = sessionFactory.openStatelessSession();\n"
"Transaction tx = session.beginTransaction();\n"
" \n"
"ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
" .scroll(ScrollMode.FORWARD_ONLY);\n"
"while ( customers.next() ) {\n"
" Customer customer = (Customer) customers.get(0);\n"
" customer.updateStuff(...);\n"
" session.update(customer);\n"
"}\n"
" \n"
"tx.commit();\n"
"session.close();]]>"
"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 ""
"作为选择Hibernate提供了基于命令的API可以用detached object的形式把数据以流"
"的方法加入到数据库,或从数据库输出。<literal>StatelessSession</literal>没有持"
"久化上下文也不提供多少高层的生命周期语义。特别是无状态session不实现第一级"
"cache,也不和第二级缓存,或者查询缓存交互。它不实现事务化写,也不实现脏数据检"
"查。用stateless session进行的操作甚至不级联到关联实例。stateless session忽略"
"集合类(Collections)。通过stateless session进行的操作不触发Hibernate的事件模型"
"和拦截器。无状态session对数据的混淆现象免疫因为它没有第一级缓存。无状态"
"session是低层的抽象和低层JDBC相当接近。"
#. Tag: programlisting
#: batch.xml:89
#, no-c-format
msgid ""
"<![CDATA[StatelessSession session = sessionFactory.openStatelessSession();\n"
"Transaction tx = session.beginTransaction();\n"
" \n"
"ScrollableResults customers = session.getNamedQuery(\"GetCustomers\")\n"
" .scroll(ScrollMode.FORWARD_ONLY);\n"
"while ( customers.next() ) {\n"
" Customer customer = (Customer) customers.get(0);\n"
" customer.updateStuff(...);\n"
" session.update(customer);\n"
"}\n"
" \n"
"tx.commit();\n"
"session.close();]]>"
msgstr ""
#: index.docbook:91
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."
#. Tag: para
#: 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 ""
"注意在上面的例子中,查询返回的<literal>Customer</literal>实例立即被脱管"
"(detach)。它们与任何持久化上下文都没有关系。"
#: index.docbook:97
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."
#. Tag: para
#: 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 ""
"<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"
msgstr ""
msgstr "DML(数据操作语言)风格的操作(DML-style operations)"
#: index.docbook:112
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)."
#. Tag: para
#: 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 ""
"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
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:"
#. Tag: para
#: 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 ""
"<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"
msgstr ""
msgstr "在FROM子句from-clauseFROM关键字是可选的"
#: index.docbook:135
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."
#. Tag: para
#: 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 ""
"在FROM子句from-clause中只能有一个实体名它可以是别名。如果实体名是别名"
"那么任何被引用的属性都必须加上此别名的前缀;如果不是别名,那么任何有前缀的属"
"性引用都是非法的。"
#: index.docbook:143
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."
#. Tag: para
#: 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 ""
"不能在大批量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."
msgstr ""
msgstr "整个WHERE子句是可选的。"
#: index.docbook:156
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 ""
#: index.docbook:162
#. Tag: para
#: batch.xml:156
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"String hqlUpdate = \"update Customer c set c.name = :newName where c.name = :oldName\";\n"
"// or String hqlUpdate = \"update Customer set name = :newName where name = :oldName\";\n"
"int updatedEntities = s.createQuery( hqlUpdate )\n"
" .setString( \"newName\", newName )\n"
" .setString( \"oldName\", oldName )\n"
" .executeUpdate();\n"
"tx.commit();\n"
"session.close();]]>"
"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 ""
"举个例子,使用<literal>Query.executeUpdate()</literal>方法执行一个HQL "
"<literal>UPDATE</literal>语句( (方法命名是来源于JDBC's "
"<literal>PreparedStatement.executeUpdate()</literal>):"
#: index.docbook:164
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 ""
#: index.docbook:174
#. Tag: programlisting
#: batch.xml:162
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"String hqlVersionedUpdate = \"update versioned Customer set name = :newName where name = :oldName\";\n"
"int updatedEntities = s.createQuery( hqlUpdate )\n"
" .setString( \"newName\", newName )\n"
" .setString( \"oldName\", oldName )\n"
" .executeUpdate();\n"
"tx.commit();\n"
"session.close();]]>"
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"String hqlUpdate = \"update Customer c set c.name = :newName where c.name = :"
"oldName\";\n"
"// or String hqlUpdate = \"update Customer set name = :newName where name = :"
"oldName\";\n"
"int updatedEntities = s.createQuery( hqlUpdate )\n"
" .setString( \"newName\", newName )\n"
" .setString( \"oldName\", oldName )\n"
" .executeUpdate();\n"
"tx.commit();\n"
"session.close();]]>"
msgstr ""
#: index.docbook:176
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 ""
#: index.docbook:181
msgid "To execute an HQL <literal>DELETE</literal>, use the same <literal>Query.executeUpdate()</literal> method:"
msgstr ""
#: index.docbook:186
#. Tag: para
#: batch.xml:164
#, fuzzy, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"String hqlDelete = \"delete Customer c where c.name = :oldName\";\n"
"// or String hqlDelete = \"delete Customer where name = :oldName\";\n"
"int deletedEntities = s.createQuery( hqlDelete )\n"
" .setString( \"oldName\", oldName )\n"
" .executeUpdate();\n"
"tx.commit();\n"
"session.close();]]>"
"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 ""
"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>关键字来实"
"现的。"
#. Tag: programlisting
#: batch.xml:174
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"String hqlVersionedUpdate = \"update versioned Customer set name = :newName "
"where name = :oldName\";\n"
"int updatedEntities = s.createQuery( hqlUpdate )\n"
" .setString( \"newName\", newName )\n"
" .setString( \"oldName\", oldName )\n"
" .executeUpdate();\n"
"tx.commit();\n"
"session.close();]]>"
msgstr ""
#: index.docbook:188
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."
#. Tag: para
#: 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 ""
"注意,自定义的版本类型(<literal>org.hibernate.usertype.UserVersionType</"
"literal>)不允许和<literal>update versioned</literal>语句联用。"
#. Tag: para
#: batch.xml:181
#, no-c-format
msgid ""
"To execute an HQL <literal>DELETE</literal>, use the same <literal>Query."
"executeUpdate()</literal> method:"
msgstr ""
"执行一个HQL <literal>DELETE</literal>,同样使用 <literal>Query.executeUpdate"
"()</literal> 方法:"
#. Tag: programlisting
#: batch.xml:186
#, no-c-format
msgid ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"String hqlDelete = \"delete Customer c where c.name = :oldName\";\n"
"// or String hqlDelete = \"delete Customer where name = :oldName\";\n"
"int deletedEntities = s.createQuery( hqlDelete )\n"
" .setString( \"oldName\", oldName )\n"
" .executeUpdate();\n"
"tx.commit();\n"
"session.close();]]>"
msgstr ""
#: index.docbook:199
msgid "The pseudo-syntax for <literal>INSERT</literal> statements is: <literal>INSERT INTO EntityName properties_list select_statement</literal>. Some points to note:"
#. Tag: para
#: 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 ""
"由<literal>Query.executeUpdate()</literal>方法返回的<literal>整型</literal>值"
"表明了受此操作影响的记录数量。 注意这个数值可能与数据库中被最后一条SQL语"
"句影响了的“行”数有关也可能没有。一个大批量HQL操作可能导致多条实际的SQL语"
"句被执行, 举个例子对joined-subclass映射方式的类进行的此类操作。这个返回值"
"代表了实际被语句影响了的记录数量。在那个joined-subclass的例子中 对一个子类"
"的删除实际上可能不仅仅会删除子类映射到的表而且会影响“根”表,还有可能影响与之"
"有继承关系的joined-subclass映射方式的子类的表。"
#: index.docbook:207
msgid "Only the INSERT INTO ... SELECT ... form is supported; not the INSERT INTO ... VALUES ... form."
#. Tag: para
#: 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 ""
"<literal>INSERT</literal>语句的伪码是: <literal>INSERT INTO EntityName "
"properties_list select_statement</literal>. 要注意的是:"
#: index.docbook:210
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."
#. Tag: para
#: batch.xml:207
#, no-c-format
msgid ""
"Only the INSERT INTO ... SELECT ... form is supported; not the INSERT "
"INTO ... VALUES ... form."
msgstr ""
"只支持INSERT INTO ... SELECT ...形式,不支持INSERT INTO ... VALUES ...形式."
#: index.docbook:220
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."
#. Tag: para
#: 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 ""
"properties_list和SQL <literal>INSERT</literal>语句中的<literal>字段定义"
"(column speficiation)</literal>类似。对参与继承树映射的实体而言,只有直接定义"
"在给定的类级别的属性才能直接在properties_list中使用。超类的属性不被支持子类"
"的属性无意义。换句话说,<literal>INSERT</literal>天生不支持多态。"
#: index.docbook:232
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."
#. Tag: para
#: 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 ""
"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:247
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)."
#. Tag: para
#: 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 ""
"对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:257
#. Tag: para
#: 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 ""
"对映射为<literal>version</literal> 或 <literal>timestamp</literal>的属性来"
"说insert语句也给你两个选择你可以在properties_list表中指定此时其值从对应"
"的select表达式中获得或者在properties_list中省略它此时使用在"
"<literal>org.hibernate.type.VersionType</literal> 中定义的<literal>seed value"
"(种子值)</literal>)。"
#. Tag: para
#: batch.xml:257
#, no-c-format
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 ""
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"String hqlInsert = \"insert into DelinquentAccount (id, name) select c.id, c.name from Customer c where ...\";\n"
"int createdEntities = s.createQuery( hqlInsert )\n"
" .executeUpdate();\n"
"tx.commit();\n"
"session.close();]]>"
"<![CDATA[Session session = sessionFactory.openSession();\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"String hqlInsert = \"insert into DelinquentAccount (id, name) select c.id, c."
"name from Customer c where ...\";\n"
"int createdEntities = s.createQuery( hqlInsert )\n"
" .executeUpdate();\n"
"tx.commit();\n"
"session.close();]]>"
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 ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:5
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr ""
msgstr "最佳实践(Best Practices)"
#: index.docbook:9
msgid "Write fine-grained classes and map them using <literal>&lt;component&gt;</literal>."
#. Tag: term
#: best_practices.xml:9
#, no-c-format
msgid ""
"Write fine-grained classes and map them using <literal>&lt;component&gt;</"
"literal>."
msgstr ""
"设计细颗粒度的持久类并且使用<literal>&lt;component&gt;</literal>来实现映射。"
#: index.docbook:11
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."
#. Tag: para
#: 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 ""
"使用一个<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."
msgstr ""
msgstr "对持久类声明标识符属性( identifier properties)。"
#: index.docbook:21
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)."
#. Tag: para
#: 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 ""
"Hibernate中标识符属性是可选的不过有很多原因来说明你应该使用标识符属性。我们"
"建议标识符应该是“人造”的(自动生成,不涉及业务含义)。"
#: index.docbook:29
#. Tag: term
#: best_practices.xml:29
#, no-c-format
msgid "Identify natural keys."
msgstr ""
msgstr "使用自然键(natural keys)标识"
#: index.docbook:31
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."
#. Tag: para
#: 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 ""
"对所有的实体都标识出自然键,用<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."
msgstr ""
msgstr "为每个持久类写一个映射文件"
#: index.docbook:41
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."
#. Tag: para
#: 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 ""
"不要把所有的持久类映射都写到一个大文件中。把 <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."
msgstr ""
msgstr "把映射文件作为资源加载"
#: index.docbook:51
#. Tag: para
#: best_practices.xml:51
#, no-c-format
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."
msgstr ""
msgstr "考虑把查询字符串放在程序外面"
#: index.docbook:59
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."
#. Tag: para
#: 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 ""
"如果你的查询中调用了非ANSI标准的SQL函数那么这条实践经验对你适用。把查询字符"
"串放在映射文件中可以让程序具有更好的可移植性。"
#: index.docbook:67
#. Tag: term
#: best_practices.xml:67
#, no-c-format
msgid "Use bind variables."
msgstr ""
msgstr "使用绑定变量"
#: index.docbook:69
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."
#. Tag: para
#: 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 ""
"就像在JDBC编程中一样应该总是用占位符\"?\"来替换非常量值,不要在查询中用字符"
"串值来构造非常量值!更好的办法是在查询中使用命名参数。"
#: index.docbook:77
#. Tag: term
#: best_practices.xml:77
#, no-c-format
msgid "Don't manage your own JDBC connections."
msgstr ""
msgstr "不要自己来管理JDBC connections"
#: index.docbook:79
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>."
#. Tag: para
#: 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 ""
"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."
msgstr ""
msgstr "考虑使用用户自定义类型(custom type)"
#: index.docbook:89
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."
#. Tag: para
#: 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 ""
"假设你有一个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."
msgstr ""
msgstr "在性能瓶颈的地方使用硬编码的JDBC"
#: index.docbook:100
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."
#. Tag: para
#: 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 ""
"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."
msgstr ""
msgstr "理解<literal>Session</literal>清洗( flushing"
#: index.docbook:112
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."
#. Tag: para
#: 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 ""
"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."
msgstr ""
msgstr "在三层结构中考虑使用托管对象detached object"
#: index.docbook:123
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."
#. Tag: para
#: 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 ""
"当使用一个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."
msgstr ""
msgstr "在两层结构中,考虑使用长持久上下文(long persistence contexts)."
#: index.docbook:134
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."
#. Tag: para
#: 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 ""
"为了得到最佳的可伸缩性,数据库事务(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."
msgstr ""
msgstr "不要把异常看成可恢复的"
#: index.docbook:150
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."
#. Tag: para
#: 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 ""
"这一点甚至比“最佳实践”还要重要,这是“必备常识”。当异常发生的时候,必须要回滚 "
"<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."
msgstr ""
msgstr "对于关联优先考虑lazy fetching"
#: index.docbook:162
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>."
#. Tag: para
#: 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 ""
"谨慎的使用主动抓取(eager fetching)。对于关联来说,若其目标是无法在第二级缓存"
"中完全缓存所有实例的类,应该使用代理(proxies)与/或具有延迟加载属性的集合"
"(lazy collections)。若目标是可以被缓存的,尤其是缓存的命中率非常高的情况下,"
"应该使用<literal>lazy=\"false\"</literal>明确的禁止掉eager fetching。如果那"
"些特殊的确实适合使用join fetch 的场合,请在查询中使用<literal>left join "
"fetch</literal>。"
#: index.docbook:172
msgid "Use the <emphasis>open session in view</emphasis> pattern, or a disciplined <emphasis>assembly phase</emphasis> to avoid problems with unfetched data."
#. Tag: term
#: 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 ""
"使用<emphasis>open session in view</emphasis>模式,或者执行严格的<emphasis>装"
"配期(assembly phase)</emphasis>策略来避免再次抓取数据带来的问题"
#: index.docbook:177
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."
#. Tag: para
#: 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 ""
"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."
msgstr ""
msgstr "考虑把Hibernate代码从业务逻辑代码中抽象出来"
#: index.docbook:193
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!)"
#. Tag: para
#: 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 ""
"把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."
msgstr ""
msgstr "不要用怪异的连接映射"
#: index.docbook:205
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."
#. Tag: para
#: 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 ""
"多对多连接用得好的例子实际上相当少见。大多数时候你在“连接表”中需要保存额外的"
"信息。这种情况下,用两个指向中介类的一对多的连接比较好。实际上,我们认为绝大"
"多数的连接是一对多和多对一的,你应该谨慎使用其它连接风格,用之前问自己一句,"
"是否真的必须这么做。"
#: index.docbook:215
#. Tag: term
#: best_practices.xml:215
#, no-c-format
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 ""
#: 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,372 +1,653 @@
#, fuzzy
msgid ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:5
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr ""
msgstr "组件Component映射"
#: index.docbook:7
msgid "The notion of a <emphasis>component</emphasis> is re-used in several different contexts, for different purposes, throughout Hibernate."
#. Tag: para
#: 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 ""
"<emphasis>组件</emphasis>(Component)这个概念在Hibernate中几处不同的地方为了不"
"同的目的被重复使用."
#: index.docbook:13
#. Tag: title
#: component_mapping.xml:13
#, no-c-format
msgid "Dependent objects"
msgstr ""
msgstr "依赖对象Dependent objects"
#: index.docbook:15
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 ""
#: index.docbook:21
#. Tag: para
#: component_mapping.xml:15
#, no-c-format
msgid ""
"<![CDATA[public class Person {\n"
" private java.util.Date birthday;\n"
" private Name name;\n"
" private String key;\n"
" public String getKey() {\n"
" return key;\n"
" }\n"
" private void setKey(String key) {\n"
" this.key=key;\n"
" }\n"
" public java.util.Date getBirthday() {\n"
" return birthday;\n"
" }\n"
" public void setBirthday(java.util.Date birthday) {\n"
" this.birthday = birthday;\n"
" }\n"
" public Name getName() {\n"
" return name;\n"
" }\n"
" public void setName(Name name) {\n"
" this.name = name;\n"
" }\n"
" ......\n"
" ......\n"
"}]]>"
"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 ""
"组件(Component)是一个被包含的对象,在持久化的过程中,它被当作值类型,而并非一"
"个实体的引用。在这篇文档中,组件这一术语指的是面向对象的合成概念(而并不是系"
"统构架层次上的组件的概念)。举个例子, 你对人(Person)这个概念可以像下面这样来"
"建模:"
#: index.docbook:23
#. Tag: programlisting
#: component_mapping.xml:21
#, no-c-format
msgid ""
"<![CDATA[public class Name {\n"
" char initial;\n"
" String first;\n"
" String last;\n"
" public String getFirst() {\n"
" return first;\n"
" }\n"
" void setFirst(String first) {\n"
" this.first = first;\n"
" }\n"
" public String getLast() {\n"
" return last;\n"
" }\n"
" void setLast(String last) {\n"
" this.last = last;\n"
" }\n"
" public char getInitial() {\n"
" return initial;\n"
" }\n"
" void setInitial(char initial) {\n"
" this.initial = initial;\n"
" }\n"
"}]]>"
"<![CDATA[public class Person {\n"
" private java.util.Date birthday;\n"
" private Name name;\n"
" private String key;\n"
" public String getKey() {\n"
" return key;\n"
" }\n"
" private void setKey(String key) {\n"
" this.key=key;\n"
" }\n"
" public java.util.Date getBirthday() {\n"
" return birthday;\n"
" }\n"
" public void setBirthday(java.util.Date birthday) {\n"
" this.birthday = birthday;\n"
" }\n"
" public Name getName() {\n"
" return name;\n"
" }\n"
" public void setName(Name name) {\n"
" this.name = name;\n"
" }\n"
" ......\n"
" ......\n"
"}]]>"
msgstr ""
#: index.docbook:25
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."
#. Tag: programlisting
#: component_mapping.xml:23
#, no-c-format
msgid ""
"<![CDATA[public class Name {\n"
" char initial;\n"
" String first;\n"
" String last;\n"
" public String getFirst() {\n"
" return first;\n"
" }\n"
" void setFirst(String first) {\n"
" this.first = first;\n"
" }\n"
" public String getLast() {\n"
" return last;\n"
" }\n"
" void setLast(String last) {\n"
" this.last = last;\n"
" }\n"
" public char getInitial() {\n"
" return initial;\n"
" }\n"
" void setInitial(char initial) {\n"
" this.initial = initial;\n"
" }\n"
"}]]>"
msgstr ""
#: index.docbook:32
#. Tag: para
#: 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 ""
"在持久化的过程中,<literal>姓名(Name)</literal>可以作为<literal>人(Person)</"
"literal>的一个组件。需要注意的是:你应该为<literal>姓名</literal>的持久化属性"
"定义getter和setter方法,但是你不需要实现任何的接口或申明标识符字段。"
#. Tag: para
#: component_mapping.xml:32
#, no-c-format
msgid "Our Hibernate mapping would look like:"
msgstr ""
msgstr "以下是这个例子的Hibernate映射文件:"
#: index.docbook:36
#. Tag: programlisting
#: component_mapping.xml:36
#, no-c-format
msgid ""
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
" <generator class=\"uuid\"/>\n"
" </id>\n"
" <property name=\"birthday\" type=\"date\"/>\n"
" <component name=\"Name\" class=\"eg.Name\"> <!-- class attribute optional -->\n"
" <property name=\"initial\"/>\n"
" <property name=\"first\"/>\n"
" <property name=\"last\"/>\n"
" </component>\n"
"</class>]]>"
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
" <generator class=\"uuid\"/>\n"
" </id>\n"
" <property name=\"birthday\" type=\"date\"/>\n"
" <component name=\"Name\" class=\"eg.Name\"> <!-- class attribute "
"optional -->\n"
" <property name=\"initial\"/>\n"
" <property name=\"first\"/>\n"
" <property name=\"last\"/>\n"
" </component>\n"
"</class>]]>"
msgstr ""
#: index.docbook:38
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 ""
#: index.docbook:46
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 ""
#: index.docbook:55
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 ""
#: index.docbook:62
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 ""
#: index.docbook:68
#. Tag: para
#: component_mapping.xml:38
#, no-c-format
msgid ""
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
" <generator class=\"uuid\"/>\n"
" </id>\n"
" <property name=\"birthday\" type=\"date\"/>\n"
" <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n"
" <parent name=\"namedPerson\"/> <!-- reference back to the Person -->\n"
" <property name=\"initial\"/>\n"
" <property name=\"first\"/>\n"
" <property name=\"last\"/>\n"
" </component>\n"
"</class>]]>"
"The person table would have the columns <literal>pid</literal>, "
"<literal>birthday</literal>, <literal>initial</literal>, <literal>first</"
"literal> and <literal>last</literal>."
msgstr ""
"人员(Person)表中将包括<literal>pid</literal>, <literal>birthday</literal>, "
"<literal>initial</literal>, <literal>first</literal>和 <literal>last</"
"literal>等字段。"
#. Tag: para
#: 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 ""
"就像所有的值类型一样, 组件不支持共享引用。 换句话说,两个人可能重名,但是两个"
"Person对象应该包含两个独立的Name对象只不过这两个Name对象具有“同样”的值。 组"
"件的值可以为空,其定义如下。 每当Hibernate重新加载一个包含组件的对象,如果该组"
"件的所有字段为空Hibernate将假定整个组件为空。 在大多数情况下,这样假定应该是"
"没有问题的。"
#. Tag: para
#: 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 ""
"组件的属性可以是任意一种Hibernate类型包括集合, 多对多关联, 以及其它组件等"
"等)。嵌套组件不应该被当作一种特殊的应用(Nested components should not be "
"considered an exotic usage)。 Hibernate倾向于支持细致的(fine-grained)对象模"
"型。"
#. Tag: para
#: 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 ""
"<literal>&lt;component&gt;</literal> 元素还允许有 <literal>&lt;parent&gt;</"
"literal>子元素用来表明component类中的一个属性是指向包含它的实体的引用。"
#. Tag: programlisting
#: component_mapping.xml:68
#, no-c-format
msgid ""
"<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"
" <id name=\"Key\" column=\"pid\" type=\"string\">\n"
" <generator class=\"uuid\"/>\n"
" </id>\n"
" <property name=\"birthday\" type=\"date\"/>\n"
" <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n"
" <parent name=\"namedPerson\"/> <!-- reference back to the Person --"
">\n"
" <property name=\"initial\"/>\n"
" <property name=\"first\"/>\n"
" <property name=\"last\"/>\n"
" </component>\n"
"</class>]]>"
msgstr ""
#: index.docbook:73
#. Tag: title
#: component_mapping.xml:73
#, no-c-format
msgid "Collections of dependent objects"
msgstr ""
msgstr "在集合中出现的依赖对象 (Collections of dependent objects)"
#: index.docbook:75
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 ""
#: index.docbook:82
#. Tag: para
#: component_mapping.xml:75
#, no-c-format
msgid ""
"<![CDATA[<set name=\"someNames\" table=\"some_names\" lazy=\"true\">\n"
" <key column=\"id\"/>\n"
" <composite-element class=\"eg.Name\"> <!-- class attribute required -->\n"
" <property name=\"initial\"/>\n"
" <property name=\"first\"/>\n"
" <property name=\"last\"/>\n"
" </composite-element>\n"
"</set>]]>"
"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 ""
"Hibernate支持组件的集合(例如: 一个元素是姓名(Name)这种类型的数组)。 你可以使"
"用<literal>&lt;composite-element&gt;</literal>标签替代<literal>&lt;"
"element&gt;</literal>标签来定义你的组件集合。"
#: index.docbook:84
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 ""
#: index.docbook:90
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 ""
#: index.docbook:102
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 ""
#: index.docbook:113
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 ""
#: index.docbook:123
#. Tag: programlisting
#: component_mapping.xml:82
#, no-c-format
msgid ""
"<![CDATA[<class name=\"eg.Order\" .... >\n"
" ....\n"
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
" <key column=\"order_id\">\n"
" <composite-element class=\"eg.Purchase\">\n"
" <property name=\"purchaseDate\"/>\n"
" <property name=\"price\"/>\n"
" <property name=\"quantity\"/>\n"
" <many-to-one name=\"item\" class=\"eg.Item\"/> <!-- class attribute is optional -->\n"
" </composite-element>\n"
" </set>\n"
"</class>]]>"
"<![CDATA[<set name=\"someNames\" table=\"some_names\" lazy=\"true\">\n"
" <key column=\"id\"/>\n"
" <composite-element class=\"eg.Name\"> <!-- class attribute required -->\n"
" <property name=\"initial\"/>\n"
" <property name=\"first\"/>\n"
" <property name=\"last\"/>\n"
" </composite-element>\n"
"</set>]]>"
msgstr ""
#: index.docbook:125
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."
#. Tag: para
#: 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 ""
"注意如果你定义的Set包含组合元素(composite-element),正确地实现"
"<literal>equals()</literal>和<literal>hashCode()</literal>是非常重要的。"
#. Tag: para
#: 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 ""
"组合元素可以包含组件,但是不能包含集合。如果你的组合元素自身包含组件, 你必须"
"使用<literal>&lt;nested-composite-element&gt;</literal>标签。这是一个相当特殊"
"的案例 - 在一个组件的集合里,那些组件本身又可以包含其他的组件。这个时候你就应"
"该考虑一下使用one-to-many关联是否会更恰当。 尝试对这个组合元素重新建模为一个"
"实体但是需要注意的是虽然Java模型和重新建模前是一样的关系模型和持久性语"
"义会有细微的变化。"
#. Tag: para
#: 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 ""
"请注意如果你使用<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>。"
#. Tag: para
#: 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 ""
"组合元素有个特别的用法是它可以包含一个<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> 。"
#. Tag: programlisting
#: component_mapping.xml:123
#, no-c-format
msgid ""
"<![CDATA[<class name=\"eg.Order\" .... >\n"
" ....\n"
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
" <key column=\"order_id\">\n"
" <composite-element class=\"eg.Purchase\">\n"
" <property name=\"purchaseDate\"/>\n"
" <property name=\"price\"/>\n"
" <property name=\"quantity\"/>\n"
" <many-to-one name=\"item\" class=\"eg.Item\"/> <!-- class "
"attribute is optional -->\n"
" </composite-element>\n"
" </set>\n"
"</class>]]>"
msgstr ""
#: index.docbook:133
#. Tag: para
#: 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 ""
"当然当你定义Item时你无法引用这些purchase因此你无法实现双向关联查询。记"
"住组件是值类型,并且不允许共享引用。某一个特定的<literal>Purchase</literal> "
"可以放在<literal>Order</literal>的集合中,但它不能同时被<literal>Item</"
"literal>所引用。"
#. Tag: para
#: component_mapping.xml:133
#, no-c-format
msgid "Even ternary (or quaternary, etc) associations are possible:"
msgstr ""
msgstr "其实组合元素的这个用法可以扩展到三重或多重关联:"
#: index.docbook:135
#. Tag: programlisting
#: component_mapping.xml:135
#, no-c-format
msgid ""
"<![CDATA[<class name=\"eg.Order\" .... >\n"
" ....\n"
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
" <key column=\"order_id\">\n"
" <composite-element class=\"eg.OrderLine\">\n"
" <many-to-one name=\"purchaseDetails class=\"eg.Purchase\"/>\n"
" <many-to-one name=\"item\" class=\"eg.Item\"/>\n"
" </composite-element>\n"
" </set>\n"
"</class>]]>"
"<![CDATA[<class name=\"eg.Order\" .... >\n"
" ....\n"
" <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"
" <key column=\"order_id\">\n"
" <composite-element class=\"eg.OrderLine\">\n"
" <many-to-one name=\"purchaseDetails class=\"eg.Purchase\"/>\n"
" <many-to-one name=\"item\" class=\"eg.Item\"/>\n"
" </composite-element>\n"
" </set>\n"
"</class>]]>"
msgstr ""
#: index.docbook:137
msgid "Composite elements may appear in queries using the same syntax as associations to other entities."
msgstr ""
#. Tag: para
#: component_mapping.xml:137
#, 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"
msgstr ""
msgstr "组件作为Map的索引Components as Map indices "
#: index.docbook:147
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."
#. Tag: para
#: 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 ""
"<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"
msgstr ""
msgstr "组件作为联合标识符(Components as composite identifiers)"
#: index.docbook:158
msgid "You may use a component as an identifier of an entity class. Your component class must satisfy certain requirements:"
#. Tag: para
#: 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 ""
"你可以使用一个组件作为一个实体类的标识符。 你的组件类必须满足以下要求:"
#: index.docbook:165
#. Tag: para
#: component_mapping.xml:165
#, no-c-format
msgid "It must implement <literal>java.io.Serializable</literal>."
msgstr ""
msgstr "它必须实现<literal>java.io.Serializable</literal>接口"
#: index.docbook:170
msgid "It must re-implement <literal>equals()</literal> and <literal>hashCode()</literal>, consistently with the database's notion of composite key equality."
msgstr ""
#: index.docbook:179
msgid "Note: in Hibernate3, the second requirement is not an absolutely hard requirement of Hibernate. But do it anyway."
msgstr ""
#: index.docbook:183
msgid "You can't use an <literal>IdentifierGenerator</literal> to generate composite keys. Instead the application must assign its own identifiers."
msgstr ""
#: index.docbook:188
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 ""
#: index.docbook:196
#. Tag: para
#: component_mapping.xml:170
#, no-c-format
msgid ""
"<![CDATA[<class name=\"OrderLine\">\n"
" \n"
" <composite-id name=\"id\" class=\"OrderLineId\">\n"
" <key-property name=\"lineId\"/>\n"
" <key-property name=\"orderId\"/>\n"
" <key-property name=\"customerId\"/>\n"
" </composite-id>\n"
" \n"
" <property name=\"name\"/>\n"
" \n"
" <many-to-one name=\"order\" class=\"Order\"\n"
" insert=\"false\" update=\"false\">\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
" </many-to-one>\n"
" ....\n"
" \n"
"</class>]]>"
"It must re-implement <literal>equals()</literal> and <literal>hashCode()</"
"literal>, consistently with the database's notion of composite key equality."
msgstr ""
"它必须重新实现<literal>equals()</literal>和<literal>hashCode()</literal>方"
"法, 始终和组合关键字在数据库中的概念保持一致"
#: index.docbook:198
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 ""
#: index.docbook:204
#. Tag: emphasis
#: component_mapping.xml:179
#, no-c-format
msgid ""
"<![CDATA[<many-to-one name=\"orderLine\" class=\"OrderLine\">\n"
"<!-- the \"class\" attribute is optional, as usual -->\n"
" <column name=\"lineId\"/>\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
"</many-to-one>]]>"
"Note: in Hibernate3, the second requirement is not an absolutely hard "
"requirement of Hibernate. But do it anyway."
msgstr ""
"注意在Hibernate3中第二个要求并非是Hibernate强制必须的。但最好这样做。"
#: index.docbook:206
msgid "(Note that the <literal>&lt;column&gt;</literal> tag is an alternative to the <literal>column</literal> attribute everywhere.)"
msgstr ""
#: index.docbook:211
msgid "A <literal>many-to-many</literal> association to <literal>OrderLine</literal> also uses the composite foreign key:"
msgstr ""
#: index.docbook:216
#. Tag: para
#: component_mapping.xml:183
#, no-c-format
msgid ""
"<![CDATA[<set name=\"undeliveredOrderLines\">\n"
" <key column name=\"warehouseId\"/>\n"
" <many-to-many class=\"OrderLine\">\n"
" <column name=\"lineId\"/>\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
" </many-to-many>\n"
"</set>]]>"
"You can't use an <literal>IdentifierGenerator</literal> to generate "
"composite keys. Instead the application must assign its own identifiers."
msgstr ""
"你不能使用一个<literal>IdentifierGenerator</literal>产生组合关键字。一个应用"
"程序必须分配它自己的标识符。"
#: index.docbook:218
msgid "The collection of <literal>OrderLine</literal>s in <literal>Order</literal> would use:"
msgstr ""
#: index.docbook:223
#. Tag: para
#: component_mapping.xml:188
#, no-c-format
msgid ""
"<![CDATA[<set name=\"orderLines\" inverse=\"true\">\n"
" <key>\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
" </key>\n"
" <one-to-many class=\"OrderLine\"/>\n"
"</set>]]>"
"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 ""
"使用<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:225
msgid "(The <literal>&lt;one-to-many&gt;</literal> element, as usual, declares no columns.)"
msgstr ""
#: index.docbook:229
msgid "If <literal>OrderLine</literal> itself owns a collection, it also has a composite foreign key."
msgstr ""
#: index.docbook:234
#. Tag: programlisting
#: component_mapping.xml:196
#, no-c-format
msgid ""
"<![CDATA[<class name=\"OrderLine\">\n"
" ....\n"
" ....\n"
" <list name=\"deliveryAttempts\">\n"
" <key> <!-- a collection inherits the composite key type -->\n"
" <column name=\"lineId\"/>\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
" </key>\n"
" <list-index column=\"attemptId\" base=\"1\"/>\n"
" <composite-element class=\"DeliveryAttempt\">\n"
" ...\n"
" </composite-element>\n"
" </set>\n"
"</class>]]>"
"<![CDATA[<class name=\"OrderLine\">\n"
" \n"
" <composite-id name=\"id\" class=\"OrderLineId\">\n"
" <key-property name=\"lineId\"/>\n"
" <key-property name=\"orderId\"/>\n"
" <key-property name=\"customerId\"/>\n"
" </composite-id>\n"
" \n"
" <property name=\"name\"/>\n"
" \n"
" <many-to-one name=\"order\" class=\"Order\"\n"
" insert=\"false\" update=\"false\">\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
" </many-to-one>\n"
" ....\n"
" \n"
"</class>]]>"
msgstr ""
#: index.docbook:239
#. Tag: para
#: 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 ""
"现在,任何指向<literal>OrderLine</literal>的外键都是复合的。在你的映射文件"
"中,必须为其他类也这样声明。例如,一个指向<literal>OrderLine</literal>的关联"
"可能被这样映射:"
#. Tag: programlisting
#: component_mapping.xml:204
#, no-c-format
msgid ""
"<![CDATA[<many-to-one name=\"orderLine\" class=\"OrderLine\">\n"
"<!-- the \"class\" attribute is optional, as usual -->\n"
" <column name=\"lineId\"/>\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
"</many-to-one>]]>"
msgstr ""
#. Tag: para
#: 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 ""
"(注意在各个地方<literal>&lt;column&gt;</literal>标签都是<literal>column</"
"literal>属性的替代写法。)"
#. Tag: para
#: 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 ""
"指向<literal>OrderLine</literal>的<literal>多对多</literal>关联也使用联合外"
"键:"
#. Tag: programlisting
#: component_mapping.xml:216
#, no-c-format
msgid ""
"<![CDATA[<set name=\"undeliveredOrderLines\">\n"
" <key column name=\"warehouseId\"/>\n"
" <many-to-many class=\"OrderLine\">\n"
" <column name=\"lineId\"/>\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
" </many-to-many>\n"
"</set>]]>"
msgstr ""
#. Tag: para
#: component_mapping.xml:218
#, no-c-format
msgid ""
"The collection of <literal>OrderLine</literal>s in <literal>Order</literal> "
"would use:"
msgstr ""
"在<literal>Order</literal>中,<literal>OrderLine</literal>的集合则是这样:"
#. Tag: programlisting
#: component_mapping.xml:223
#, no-c-format
msgid ""
"<![CDATA[<set name=\"orderLines\" inverse=\"true\">\n"
" <key>\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
" </key>\n"
" <one-to-many class=\"OrderLine\"/>\n"
"</set>]]>"
msgstr ""
#. Tag: para
#: component_mapping.xml:225
#, 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>元素不声明任何列.)"
#. Tag: para
#: component_mapping.xml:229
#, no-c-format
msgid ""
"If <literal>OrderLine</literal> itself owns a collection, it also has a "
"composite foreign key."
msgstr "假若<literal>OrderLine</literal>本身拥有一个集合,它也具有组合外键。"
#. Tag: programlisting
#: component_mapping.xml:234
#, no-c-format
msgid ""
"<![CDATA[<class name=\"OrderLine\">\n"
" ....\n"
" ....\n"
" <list name=\"deliveryAttempts\">\n"
" <key> <!-- a collection inherits the composite key type -->\n"
" <column name=\"lineId\"/>\n"
" <column name=\"orderId\"/>\n"
" <column name=\"customerId\"/>\n"
" </key>\n"
" <list-index column=\"attemptId\" base=\"1\"/>\n"
" <composite-element class=\"DeliveryAttempt\">\n"
" ...\n"
" </composite-element>\n"
" </set>\n"
"</class>]]>"
msgstr ""
#. Tag: title
#: component_mapping.xml:239
#, no-c-format
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>:"
msgstr ""
msgstr "你甚至可以映射<literal>Map</literal>类型的属性:"
#: index.docbook:245
#. Tag: programlisting
#: component_mapping.xml:245
#, no-c-format
msgid ""
"<![CDATA[<dynamic-component name=\"userAttributes\">\n"
" <property name=\"foo\" column=\"FOO\" type=\"string\"/>\n"
" <property name=\"bar\" column=\"BAR\" type=\"integer\"/>\n"
" <many-to-one name=\"baz\" class=\"Baz\" column=\"BAZ_ID\"/>\n"
"</dynamic-component>]]>"
"<![CDATA[<dynamic-component name=\"userAttributes\">\n"
" <property name=\"foo\" column=\"FOO\" type=\"string\"/>\n"
" <property name=\"bar\" column=\"BAR\" type=\"integer\"/>\n"
" <many-to-one name=\"baz\" class=\"Baz\" column=\"BAZ_ID\"/>\n"
"</dynamic-component>]]>"
msgstr ""
#: index.docbook:247
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."
#. Tag: para
#: 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 ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
"从<literal>&lt;dynamic-component&gt;</literal>映射的语义上来讲,它和"
"<literal>&lt;component&gt;</literal>是相同的。 这种映射类型的优点在于通过修改"
"映射文件就可以具有在部署时检测真实属性的能力。利用一个DOM解析器也可以在程"
"序运行时操作映射文件。 更好的是,你可以通过<literal>Configuration</literal>对"
"象来访问或者修改Hibernate的运行时元模型。"

View File

@ -1,245 +1,457 @@
#, fuzzy
msgid ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:5
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr ""
msgstr "拦截器与事件(Interceptors and events)"
#: index.docbook:7
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 ""
#: index.docbook:14
msgid "Interceptors"
msgstr ""
#: index.docbook:16
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 ""
#: index.docbook:27
msgid "You may either implement <literal>Interceptor</literal> directly or (better) extend <literal>EmptyInterceptor</literal>."
msgstr ""
#: index.docbook:32
#. Tag: para
#: events.xml:7
#, no-c-format
msgid ""
"<![CDATA[package org.hibernate.test;\n"
"\n"
"import java.io.Serializable;\n"
"import java.util.Date;\n"
"import java.util.Iterator;\n"
"\n"
"import org.hibernate.EmptyInterceptor;\n"
"import org.hibernate.Transaction;\n"
"import org.hibernate.type.Type;\n"
"\n"
"public class AuditInterceptor extends EmptyInterceptor {\n"
"\n"
" private int updates;\n"
" private int creates;\n"
" private int loads;\n"
"\n"
" public void onDelete(Object entity,\n"
" Serializable id,\n"
" Object[] state,\n"
" String[] propertyNames,\n"
" Type[] types) {\n"
" // do nothing\n"
" }\n"
"\n"
" public boolean onFlushDirty(Object entity,\n"
" Serializable id,\n"
" Object[] currentState,\n"
" Object[] previousState,\n"
" String[] propertyNames,\n"
" Type[] types) {\n"
"\n"
" if ( entity instanceof Auditable ) {\n"
" updates++;\n"
" for ( int i=0; i < propertyNames.length; i++ ) {\n"
" if ( \"lastUpdateTimestamp\".equals( propertyNames[i] ) ) {\n"
" currentState[i] = new Date();\n"
" return true;\n"
" }\n"
" }\n"
" }\n"
" return false;\n"
" }\n"
"\n"
" public boolean onLoad(Object entity,\n"
" Serializable id,\n"
" Object[] state,\n"
" String[] propertyNames,\n"
" Type[] types) {\n"
" if ( entity instanceof Auditable ) {\n"
" loads++;\n"
" }\n"
" return false;\n"
" }\n"
"\n"
" public boolean onSave(Object entity,\n"
" Serializable id,\n"
" Object[] state,\n"
" String[] propertyNames,\n"
" Type[] types) {\n"
"\n"
" if ( entity instanceof Auditable ) {\n"
" creates++;\n"
" for ( int i=0; i<propertyNames.length; i++ ) {\n"
" if ( \"createTimestamp\".equals( propertyNames[i] ) ) {\n"
" state[i] = new Date();\n"
" return true;\n"
" }\n"
" }\n"
" }\n"
" return false;\n"
" }\n"
"\n"
" public void afterTransactionCompletion(Transaction tx) {\n"
" if ( tx.wasCommitted() ) {\n"
" System.out.println(\"Creations: \" + creates + \", Updates: \" + updates, \"Loads: \" + loads);\n"
" }\n"
" updates=0;\n"
" creates=0;\n"
" loads=0;\n"
" }\n"
"\n"
"}]]>"
"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 ""
"应用程序能够响应Hibernate内部产生的特定事件是非常有用的。这样就允许实现某些通"
"用的功能 以及允许对Hibernate功能进行扩展。"
#. Tag: title
#: events.xml:14
#, no-c-format
msgid "Interceptors"
msgstr "拦截器(Interceptors)"
#. Tag: para
#: 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 ""
"<literal>Interceptor</literal>接口提供了从会话(session)回调(callback)应用程序"
"(application)的机制, 这种回调机制可以允许应用程序在持久化对象被保存、更新、"
"删除或是加载之前,检查并(或)修改其 属性。一个可能的用途,就是用来跟踪审核"
"(auditing)信息。例如:下面的这个<literal>拦截器</literal>,会在一个实现了 "
"<literal>Auditable</literal>接口的对象被创建时自动地设置"
"<literal>createTimestamp</literal>属性,并在实现了 <literal>Auditable</"
"literal>接口的对象被更新时,同步更新<literal>lastUpdateTimestamp</literal>属"
"性。"
#. Tag: para
#: events.xml:27
#, no-c-format
msgid ""
"You may either implement <literal>Interceptor</literal> directly or (better) "
"extend <literal>EmptyInterceptor</literal>."
msgstr ""
"你可以直接实现<literal>Interceptor</literal>接口,也可以(最好)继承自"
"<literal>EmptyInterceptor</literal>。"
#. Tag: programlisting
#: events.xml:32
#, no-c-format
msgid ""
"<![CDATA[package org.hibernate.test;\n"
"\n"
"import java.io.Serializable;\n"
"import java.util.Date;\n"
"import java.util.Iterator;\n"
"\n"
"import org.hibernate.EmptyInterceptor;\n"
"import org.hibernate.Transaction;\n"
"import org.hibernate.type.Type;\n"
"\n"
"public class AuditInterceptor extends EmptyInterceptor {\n"
"\n"
" private int updates;\n"
" private int creates;\n"
" private int loads;\n"
"\n"
" public void onDelete(Object entity,\n"
" Serializable id,\n"
" Object[] state,\n"
" String[] propertyNames,\n"
" Type[] types) {\n"
" // do nothing\n"
" }\n"
"\n"
" public boolean onFlushDirty(Object entity,\n"
" Serializable id,\n"
" Object[] currentState,\n"
" Object[] previousState,\n"
" String[] propertyNames,\n"
" Type[] types) {\n"
"\n"
" if ( entity instanceof Auditable ) {\n"
" updates++;\n"
" for ( int i=0; i < propertyNames.length; i++ ) {\n"
" if ( \"lastUpdateTimestamp\".equals( propertyNames[i] ) ) {\n"
" currentState[i] = new Date();\n"
" return true;\n"
" }\n"
" }\n"
" }\n"
" return false;\n"
" }\n"
"\n"
" public boolean onLoad(Object entity,\n"
" Serializable id,\n"
" Object[] state,\n"
" String[] propertyNames,\n"
" Type[] types) {\n"
" if ( entity instanceof Auditable ) {\n"
" loads++;\n"
" }\n"
" return false;\n"
" }\n"
"\n"
" public boolean onSave(Object entity,\n"
" Serializable id,\n"
" Object[] state,\n"
" String[] propertyNames,\n"
" Type[] types) {\n"
"\n"
" if ( entity instanceof Auditable ) {\n"
" creates++;\n"
" for ( int i=0; i<propertyNames.length; i++ ) {\n"
" if ( \"createTimestamp\".equals( propertyNames[i] ) ) {\n"
" state[i] = new Date();\n"
" return true;\n"
" }\n"
" }\n"
" }\n"
" return false;\n"
" }\n"
"\n"
" public void afterTransactionCompletion(Transaction tx) {\n"
" if ( tx.wasCommitted() ) {\n"
" System.out.println(\"Creations: \" + creates + \", Updates: \" + "
"updates, \"Loads: \" + loads);\n"
" }\n"
" updates=0;\n"
" creates=0;\n"
" loads=0;\n"
" }\n"
"\n"
"}]]>"
msgstr ""
#: index.docbook:34
msgid "Interceptors come in two flavors: <literal>Session</literal>-scoped and <literal>SessionFactory</literal>-scoped."
#. Tag: para
#: events.xml:34
#, no-c-format
msgid ""
"Interceptors come in two flavors: <literal>Session</literal>-scoped and "
"<literal>SessionFactory</literal>-scoped."
msgstr ""
"拦截器可以有两种:<literal>Session</literal>范围内的,和"
"<literal>SessionFactory</literal>范围内的。"
#: index.docbook:39
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>."
#. Tag: para
#: 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 ""
"当使用某个重载的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() );]]>"
msgstr ""
#: index.docbook:47
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."
#. Tag: para
#: 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 ""
#: index.docbook:56
msgid "<![CDATA[new Configuration().setInterceptor( new AuditInterceptor() );]]>"
msgstr ""
#: index.docbook:61
#. Tag: title
#: events.xml:61
#, no-c-format
msgid "Event system"
msgstr ""
msgstr "事件系统(Event system)"
#: index.docbook:63
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 ""
#: index.docbook:69
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 ""
#: index.docbook:84
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 ""
#: index.docbook:89
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 ""
#: index.docbook:99
#. Tag: para
#: events.xml:63
#, no-c-format
msgid ""
"<![CDATA[public class MyLoadListener implements LoadEventListener {\n"
" // this is the single method defined by the LoadEventListener interface\n"
" public void onLoad(LoadEvent event, LoadEventListener.LoadType loadType)\n"
" throws HibernateException {\n"
" if ( !MySecurity.isAuthorized( event.getEntityClassName(), event.getEntityId() ) ) {\n"
" throw MySecurityException(\"Unauthorized access\");\n"
" }\n"
" }\n"
"}]]>"
"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 ""
"如果需要响应持久层的某些特殊事件你也可以使用Hibernate3的事件框架。 该事件系"
"统可以用来替代拦截器,也可以作为拦截器的补充来使用。"
#: index.docbook:101
msgid "You also need a configuration entry telling Hibernate to use the listener in addition to the default listener:"
msgstr ""
#: index.docbook:106
#. Tag: para
#: events.xml:69
#, no-c-format
msgid ""
"<![CDATA[<hibernate-configuration>\n"
" <session-factory>\n"
" ...\n"
" <event type=\"load\">\n"
" <listener class=\"com.eg.MyLoadListener\"/>\n"
" <listener class=\"org.hibernate.event.def.DefaultLoadEventListener\"/>\n"
" </event>\n"
" </session-factory>\n"
"</hibernate-configuration>]]>"
"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 ""
"基本上,<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>方法的请求。"
#. Tag: para
#: 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 ""
"监听器应该被看作是单例(singleton)对象,也就是说,所有同类型的事件的处理共享同"
"一个监听器实例,因此监听器 不应该保存任何状态(也就是不应该使用成员变量)。"
#. Tag: para
#: 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 ""
"用户定制的监听器应该实现与所要处理的事件相对应的接口,或者从一个合适的基类继"
"承甚至是从Hibernate自带的默认事件监听器类继承 为了方便你这样做,这些类都"
"被声明成non-final的了。用户定制的监听器可以通过编程使用"
"<literal>Configuration</literal>对象 来注册也可以在Hibernate的XML格式的配置"
"文件中进行声明不支持在Properties格式的配置文件声明监听器。 下面是一个用户"
"定制的加载事件(load event)的监听器:"
#. Tag: programlisting
#: events.xml:99
#, no-c-format
msgid ""
"<![CDATA[public class MyLoadListener implements LoadEventListener {\n"
" // this is the single method defined by the LoadEventListener interface\n"
" public void onLoad(LoadEvent event, LoadEventListener.LoadType "
"loadType)\n"
" throws HibernateException {\n"
" if ( !MySecurity.isAuthorized( event.getEntityClassName(), event."
"getEntityId() ) ) {\n"
" throw MySecurityException(\"Unauthorized access\");\n"
" }\n"
" }\n"
"}]]>"
msgstr ""
#: index.docbook:108
#. Tag: para
#: 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 ""
"你还需要修改一处配置来告诉Hibernate除了默认的监听器还要附加选定的监听"
"器。"
#. Tag: programlisting
#: events.xml:106
#, no-c-format
msgid ""
"<![CDATA[<hibernate-configuration>\n"
" <session-factory>\n"
" ...\n"
" <event type=\"load\">\n"
" <listener class=\"com.eg.MyLoadListener\"/>\n"
" <listener class=\"org.hibernate.event.def."
"DefaultLoadEventListener\"/>\n"
" </event>\n"
" </session-factory>\n"
"</hibernate-configuration>]]>"
msgstr ""
#. Tag: para
#: events.xml:108
#, no-c-format
msgid "Instead, you may register it programmatically:"
msgstr ""
msgstr "看看用另一种方式,通过编程的方式来注册它。"
#: index.docbook:112
#. Tag: programlisting
#: events.xml:112
#, no-c-format
msgid ""
"<![CDATA[Configuration cfg = new Configuration();\n"
"LoadEventListener[] stack = { new MyLoadListener(), new DefaultLoadEventListener() };\n"
"cfg.EventListeners().setLoadEventListeners(stack);]]>"
"<![CDATA[Configuration cfg = new Configuration();\n"
"LoadEventListener[] stack = { new MyLoadListener(), new "
"DefaultLoadEventListener() };\n"
"cfg.EventListeners().setLoadEventListeners(stack);]]>"
msgstr ""
#: index.docbook:114
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."
#. Tag: para
#: 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 ""
"通过在XML配置文件声明而注册的监听器不能共享实例。如果在多个<literal>&lt;"
"listener/&gt;</literal>节点中使用 了相同的类的名字,则每一个引用都将会产生一"
"个独立的实例。如果你需要在多个监听器类型之间共享 监听器的实例,则你必须使用编"
"程的方式来进行注册。"
#: index.docbook:122
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."
#. Tag: para
#: 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 ""
"为什么我们实现了特定监听器的接口,在注册的时候还要明确指出我们要注册哪个事件"
"的监听器呢? 这是因为一个类可能实现多个监听器的接口。在注册的时候明确指定要监"
"听的事件,可以让启用或者禁用对某个事件的监听的配置工作简单些。"
#: index.docbook:132
#. Tag: title
#: events.xml:132
#, no-c-format
msgid "Hibernate declarative security"
msgstr ""
msgstr "Hibernate的声明式安全机制"
#: index.docbook:133
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."
msgstr ""
#: index.docbook:139
msgid "First, you must configure the appropriate event listeners, to enable the use of JAAS authorization."
msgstr ""
#: index.docbook:144
#. Tag: para
#: events.xml:133
#, 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\"/>]]>"
"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."
msgstr ""
"通常Hibernate应用程序的声明式安全机制由会话外观层(session facade)所管理。 "
"现在Hibernate3允许某些特定的行为由JACC进行许可管理由JAAS进行授权管理。 本"
"功能是一个建立在事件框架之上的可选的功能。"
#: index.docbook:146
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 ""
#: index.docbook:152
msgid "Next, still in <literal>hibernate.cfg.xml</literal>, bind the permissions to roles:"
msgstr ""
#: index.docbook:156
#. Tag: para
#: events.xml:139
#, no-c-format
msgid ""
"<![CDATA[<grant role=\"admin\" entity-name=\"User\" actions=\"insert,update,read\"/>\n"
"<grant role=\"su\" entity-name=\"User\" actions=\"*\"/>]]>"
"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 ""
#: index.docbook:158
#. 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=\"*\"/>]]>"
msgstr ""
#. Tag: para
#: events.xml:158
#, no-c-format
msgid "The role names are the roles understood by your JACC provider."
msgstr ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
msgstr "这些角色的名字就是你的JACC provider所定义的角色的名字。"

View File

@ -1,287 +1,572 @@
#, fuzzy
msgid ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:5
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr ""
msgstr "示例:父子关系(Parent Child Relationships)"
#: index.docbook:7
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!"
#. Tag: para
#: 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 ""
"刚刚接触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"
msgstr ""
msgstr "关于collections需要注意的一点"
#: index.docbook:23
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:"
#. Tag: para
#: 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 ""
"Hibernate collections被当作其所属实体而不是其包含实体的一个逻辑部分。这非常重"
"要!它主要体现为以下几点:"
#: index.docbook:30
msgid "When we remove / add an object from / to a collection, the version number of the collection owner is incremented."
#. Tag: para
#: 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 ""
"如果一个从collection中移除的对象是一个值类型(value type)的实例,比如"
"composite element那么这个对象的持久化状态将会终止其在数据库中对应的记录会"
"被删除。同样的向collection增加一个value type的实例将会使之立即被持久化。"
#: index.docbook:36
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."
#. Tag: para
#: 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 ""
"另一方面如果从一对多或多对多关联的collection中移除一个实体在缺省情况下这"
"个对象并不会被删除。这个行为是完全合乎逻辑的--改变一个实体的内部状态不应该"
"使与它关联的实体消失掉同样的向collection增加一个实体不会使之被持久化。"
#: index.docbook:44
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."
#. Tag: para
#: 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 ""
"实际上向Collection增加一个实体的缺省动作只是在两个实体之间创建一个连接而"
"已,同样移除的时候也只是删除连接。这种处理对于所有的情况都是合适的。对于父子"
"关系则是完全不适合的,在这种关系下,子对象的生存绑定于父对象的生存周期。"
#: index.docbook:54
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 ""
#: index.docbook:64
#. Tag: title
#: example_parentchild.xml:64
#, no-c-format
msgid "Bidirectional one-to-many"
msgstr ""
msgstr "双向的一对多关系(Bidirectional one-to-many)"
#: index.docbook:66
msgid "Suppose we start with a simple <literal>&lt;one-to-many&gt;</literal> association from <literal>Parent</literal> to <literal>Child</literal>."
msgstr ""
#: index.docbook:71
#. Tag: para
#: example_parentchild.xml:66
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\">\n"
" <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
"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;关联。"
#. Tag: programlisting
#: example_parentchild.xml:71
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\">\n"
" <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
msgstr ""
#: index.docbook:73
#. Tag: para
#: example_parentchild.xml:73
#, no-c-format
msgid "If we were to execute the following code"
msgstr ""
msgstr "如果我们运行下面的代码"
#: index.docbook:77
#. Tag: programlisting
#: example_parentchild.xml:77
#, no-c-format
msgid ""
"<![CDATA[Parent p = .....;\n"
"Child c = new Child();\n"
"p.getChildren().add(c);\n"
"session.save(c);\n"
"session.flush();]]>"
"<![CDATA[Parent p = .....;\n"
"Child c = new Child();\n"
"p.getChildren().add(c);\n"
"session.save(c);\n"
"session.flush();]]>"
msgstr ""
#: index.docbook:79
#. Tag: para
#: example_parentchild.xml:79
#, no-c-format
msgid "Hibernate would issue two SQL statements:"
msgstr ""
msgstr "Hibernate会产生两条SQL语句"
#: index.docbook:85
msgid "an <literal>INSERT</literal> to create the record for <literal>c</literal>"
msgstr ""
#: index.docbook:88
msgid "an <literal>UPDATE</literal> to create the link from <literal>p</literal> to <literal>c</literal>"
msgstr ""
#: index.docbook:95
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 ""
#: index.docbook:101
#. Tag: para
#: example_parentchild.xml:85
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\">\n"
" <key column=\"parent_id\" not-null=\"true\"/>\n"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
"an <literal>INSERT</literal> to create the record for <literal>c</literal>"
msgstr "一条<literal>INSERT</literal>语句,为<literal>c</literal>创建一条记录"
#. Tag: para
#: 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 ""
"一条<literal>UPDATE</literal>语句,创建从<literal>p</literal>到<literal>c</"
"literal>的连接"
#. Tag: para
#: 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 ""
"这样做不仅效率低,而且违反了列<literal>parent_id</literal>非空的限制。我们可"
"以通过在集合类映射上指定<literal>not-null=\"true\"</literal>来解决违反非空约"
"束的问题:"
#. Tag: programlisting
#: example_parentchild.xml:101
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\">\n"
" <key column=\"parent_id\" not-null=\"true\"/>\n"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
msgstr ""
#: index.docbook:103
#. Tag: para
#: example_parentchild.xml:103
#, no-c-format
msgid "However, this is not the recommended solution."
msgstr ""
msgstr "然而,这并非是推荐的解决方法。"
#: index.docbook:106
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 ""
#: index.docbook:113
msgid "<![CDATA[<many-to-one name=\"parent\" column=\"parent_id\" not-null=\"true\"/>]]>"
msgstr ""
#: index.docbook:115
msgid "(We also need to add the <literal>parent</literal> property to the <literal>Child</literal> class.)"
msgstr ""
#: 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
#. Tag: para
#: example_parentchild.xml:106
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\" inverse=\"true\">\n"
" <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
"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 ""
#: index.docbook:126
#. Tag: para
#: 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 ""
"(我们还需要为类<literal>Child</literal>添加<literal>parent</literal>属性)"
#. Tag: para
#: 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 ""
"现在实体<literal>Child</literal>在管理连接的状态为了使collection不更新连"
"接,我们使用<literal>inverse</literal>属性。"
#. Tag: programlisting
#: example_parentchild.xml:124
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\" inverse=\"true\">\n"
" <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
msgstr ""
#. Tag: para
#: example_parentchild.xml:126
#, no-c-format
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 ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = new Child();\n"
"c.setParent(p);\n"
"p.getChildren().add(c);\n"
"session.save(c);\n"
"session.flush();]]>"
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = new Child();\n"
"c.setParent(p);\n"
"p.getChildren().add(c);\n"
"session.save(c);\n"
"session.flush();]]>"
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!"
msgstr ""
msgstr "现在,只会有一条<literal>INSERT</literal>语句被执行!"
#: index.docbook:136
msgid "To tighten things up a bit, we could create an <literal>addChild()</literal> method of <literal>Parent</literal>."
msgstr ""
#: index.docbook:141
#. Tag: para
#: example_parentchild.xml:136
#, no-c-format
msgid ""
"<![CDATA[public void addChild(Child c) {\n"
" c.setParent(this);\n"
" children.add(c);\n"
"}]]>"
"To tighten things up a bit, we could create an <literal>addChild()</literal> "
"method of <literal>Parent</literal>."
msgstr ""
"为了让事情变得井井有条,可以为<literal>Parent</literal>加一个"
"<literal>addChild()</literal>方法。"
#. Tag: programlisting
#: example_parentchild.xml:141
#, no-c-format
msgid ""
"<![CDATA[public void addChild(Child c) {\n"
" c.setParent(this);\n"
" children.add(c);\n"
"}]]>"
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"
msgstr ""
msgstr "现在,添加<literal>Child</literal>的代码就是这样"
#: index.docbook:147
#. Tag: programlisting
#: example_parentchild.xml:147
#, no-c-format
msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = new Child();\n"
"p.addChild(c);\n"
"session.save(c);\n"
"session.flush();]]>"
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = new Child();\n"
"p.addChild(c);\n"
"session.save(c);\n"
"session.flush();]]>"
msgstr ""
#: index.docbook:152
#. Tag: title
#: example_parentchild.xml:152
#, no-c-format
msgid "Cascading life cycle"
msgstr ""
msgstr "级联生命周期Cascading life cycle"
#: index.docbook:154
msgid "The explicit call to <literal>save()</literal> is still annoying. We will address this by using cascades."
msgstr ""
#: index.docbook:159
#. Tag: para
#: example_parentchild.xml:154
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all\">\n"
" <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
"The explicit call to <literal>save()</literal> is still annoying. We will "
"address this by using cascades."
msgstr ""
"需要显式调用<literal>save()</literal>仍然很麻烦,我们可以用级联来解决这个问"
"题。"
#. Tag: programlisting
#: example_parentchild.xml:159
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all\">\n"
" <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
msgstr ""
#: index.docbook:161
#. Tag: para
#: example_parentchild.xml:161
#, no-c-format
msgid "This simplifies the code above to"
msgstr ""
msgstr "这样上面的代码可以简化为:"
#: index.docbook:165
#. Tag: programlisting
#: example_parentchild.xml:165
#, no-c-format
msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = new Child();\n"
"p.addChild(c);\n"
"session.flush();]]>"
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = new Child();\n"
"p.addChild(c);\n"
"session.flush();]]>"
msgstr ""
#: index.docbook:167
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 ""
#: index.docbook:172
#. Tag: para
#: example_parentchild.xml:167
#, no-c-format
msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"session.delete(p);\n"
"session.flush();]]>"
"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 ""
"同样的,保存或删除<literal>Parent</literal>对象的时候并不需要遍历其子对象。 "
"下面的代码会删除对象<literal>p</literal>及其所有子对象对应的数据库记录。"
#. Tag: programlisting
#: example_parentchild.xml:172
#, no-c-format
msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"session.delete(p);\n"
"session.flush();]]>"
msgstr ""
#: index.docbook:174
#. Tag: para
#: example_parentchild.xml:174
#, no-c-format
msgid "However, this code"
msgstr ""
msgstr "然而,这段代码"
#: index.docbook:178
#. Tag: programlisting
#: example_parentchild.xml:178
#, no-c-format
msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = (Child) p.getChildren().iterator().next();\n"
"p.getChildren().remove(c);\n"
"c.setParent(null);\n"
"session.flush();]]>"
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = (Child) p.getChildren().iterator().next();\n"
"p.getChildren().remove(c);\n"
"c.setParent(null);\n"
"session.flush();]]>"
msgstr ""
#: index.docbook:180
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 ""
#: index.docbook:186
#. Tag: para
#: example_parentchild.xml:180
#, no-c-format
msgid ""
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = (Child) p.getChildren().iterator().next();\n"
"p.getChildren().remove(c);\n"
"session.delete(c);\n"
"session.flush();]]>"
"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 ""
"不会从数据库删除<literal>c</literal>;它只会删除与<literal>p</literal>之间的"
"连接(并且会导致违反<literal>NOT NULL</literal>约束,在这个例子中)。你需要显"
"式调用<literal>delete()</literal>来删除<literal>Child</literal>。"
#: index.docbook:188
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>."
msgstr ""
#: index.docbook:194
#. Tag: programlisting
#: example_parentchild.xml:186
#, no-c-format
msgid ""
"<![CDATA[<set name=\"children\" inverse=\"true\" cascade=\"all-delete-orphan\">\n"
" <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
"<![CDATA[Parent p = (Parent) session.load(Parent.class, pid);\n"
"Child c = (Child) p.getChildren().iterator().next();\n"
"p.getChildren().remove(c);\n"
"session.delete(c);\n"
"session.flush();]]>"
msgstr ""
#: index.docbook:196
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>."
#. Tag: para
#: example_parentchild.xml:188
#, no-c-format
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>."
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"
" <one-to-many class=\"Child\"/>\n"
"</set>]]>"
msgstr ""
#: index.docbook:206
#. Tag: para
#: 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 ""
"注意即使在collection一方的映射中指定<literal>inverse=\"true\"</literal>,级"
"联仍然是通过遍历collection中的元素来处理的。如果你想要通过级联进行子对象的插"
"入、删除、更新操作就必须把它加到collection中只调用<literal>setParent()</"
"literal>是不够的。"
#. Tag: title
#: example_parentchild.xml:206
#, no-c-format
msgid "Cascades and <literal>unsaved-value</literal>"
msgstr ""
"级联与<literal>未保存值</literal>Cascades and <literal>unsaved-value</"
"literal>"
#: index.docbook:208
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 ""
#: index.docbook:220
msgid "The following code will update <literal>parent</literal> and <literal>child</literal> and insert <literal>newChild</literal>."
msgstr ""
#: index.docbook:225
#. Tag: para
#: example_parentchild.xml:208
#, no-c-format
msgid ""
"<![CDATA[//parent and child were both loaded in a previous session\n"
"parent.addChild(child);\n"
"Child newChild = new Child();\n"
"parent.addChild(newChild);\n"
"session.update(parent);\n"
"session.flush();]]>"
"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 ""
"假设我们从<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>"
#. Tag: para
#: 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 ""
"下面的代码会更新<literal>parent</literal>和<literal>child</literal>对象,并且"
"插入<literal>newChild</literal>对象。"
#. Tag: programlisting
#: example_parentchild.xml:225
#, no-c-format
msgid ""
"<![CDATA[//parent and child were both loaded in a previous session\n"
"parent.addChild(child);\n"
"Child newChild = new Child();\n"
"parent.addChild(newChild);\n"
"session.update(parent);\n"
"session.flush();]]>"
msgstr ""
#: index.docbook:227
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."
#. Tag: para
#: 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 ""
"这对于自动生成标识的情况是非常好的,但是自分配的标识和复合标识怎么办呢?这是"
"有点麻烦因为Hibernate没有办法区分新实例化的对象标识被用户指定了和前一个"
"Session装入的对象。在这种情况下Hibernate会使用timestamp或version属性或者"
"查询第二级缓存,或者最坏的情况,查询数据库,来确认是否此行存在。"
#: index.docbook:260
#. Tag: title
#: example_parentchild.xml:260
#, no-c-format
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 ""
"这里有不少东西需要融会贯通,可能会让新手感到迷惑。但是在实践中它们都工作地非"
"常好。大部分Hibernate应用程序都会经常用到父子对象模式。"
#: index.docbook:262
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."
#. Tag: para
#: 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 ""
#: index.docbook:267
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 ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
"在第一段中我们曾经提到另一个方案。上面的这些问题都不会出现在<literal>&lt;"
"composite-element&gt;</literal>映射中,它准确地表达了父子关系的语义。很不幸复"
"合元素还有两个重大限制:复合元素不能拥有collections并且除了用于惟一的父对"
"象外,它们不能再作为其它任何实体的子对象。"

View File

@ -1,450 +1,481 @@
#, fuzzy
msgid ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:5
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr ""
msgstr "示例Weblog 应用程序"
#: index.docbook:8
#. Tag: title
#: example_weblog.xml:8
#, no-c-format
msgid "Persistent Classes"
msgstr ""
msgstr "持久化类"
#: index.docbook:10
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 ""
#: index.docbook:16
#. Tag: para
#: example_weblog.xml:10
#, no-c-format
msgid ""
"<![CDATA[package eg;\n"
"\n"
"import java.util.List;\n"
"\n"
"public class Blog {\n"
" private Long _id;\n"
" private String _name;\n"
" private List _items;\n"
"\n"
" public Long getId() {\n"
" return _id;\n"
" }\n"
" public List getItems() {\n"
" return _items;\n"
" }\n"
" public String getName() {\n"
" return _name;\n"
" }\n"
" public void setId(Long long1) {\n"
" _id = long1;\n"
" }\n"
" public void setItems(List list) {\n"
" _items = list;\n"
" }\n"
" public void setName(String string) {\n"
" _name = string;\n"
" }\n"
"}]]>"
"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 ""
"下面的持久化类表示一个weblog和在其中张贴的一个贴子。他们是标准的父/子关系模"
"型但是我们会用一个有序包ordered bag)而非集合(set)。"
#: index.docbook:18
#. Tag: programlisting
#: example_weblog.xml:16
#, no-c-format
msgid ""
"<![CDATA[package eg;\n"
"\n"
"import java.text.DateFormat;\n"
"import java.util.Calendar;\n"
"\n"
"public class BlogItem {\n"
" private Long _id;\n"
" private Calendar _datetime;\n"
" private String _text;\n"
" private String _title;\n"
" private Blog _blog;\n"
"\n"
" public Blog getBlog() {\n"
" return _blog;\n"
" }\n"
" public Calendar getDatetime() {\n"
" return _datetime;\n"
" }\n"
" public Long getId() {\n"
" return _id;\n"
" }\n"
" public String getText() {\n"
" return _text;\n"
" }\n"
" public String getTitle() {\n"
" return _title;\n"
" }\n"
" public void setBlog(Blog blog) {\n"
" _blog = blog;\n"
" }\n"
" public void setDatetime(Calendar calendar) {\n"
" _datetime = calendar;\n"
" }\n"
" public void setId(Long long1) {\n"
" _id = long1;\n"
" }\n"
" public void setText(String string) {\n"
" _text = string;\n"
" }\n"
" public void setTitle(String string) {\n"
" _title = string;\n"
" }\n"
"}]]>"
"<![CDATA[package eg;\n"
"\n"
"import java.util.List;\n"
"\n"
"public class Blog {\n"
" private Long _id;\n"
" private String _name;\n"
" private List _items;\n"
"\n"
" public Long getId() {\n"
" return _id;\n"
" }\n"
" public List getItems() {\n"
" return _items;\n"
" }\n"
" public String getName() {\n"
" return _name;\n"
" }\n"
" public void setId(Long long1) {\n"
" _id = long1;\n"
" }\n"
" public void setItems(List list) {\n"
" _items = list;\n"
" }\n"
" public void setName(String string) {\n"
" _name = string;\n"
" }\n"
"}]]>"
msgstr ""
#: index.docbook:23
#. Tag: programlisting
#: example_weblog.xml:18
#, no-c-format
msgid ""
"<![CDATA[package eg;\n"
"\n"
"import java.text.DateFormat;\n"
"import java.util.Calendar;\n"
"\n"
"public class BlogItem {\n"
" private Long _id;\n"
" private Calendar _datetime;\n"
" private String _text;\n"
" private String _title;\n"
" private Blog _blog;\n"
"\n"
" public Blog getBlog() {\n"
" return _blog;\n"
" }\n"
" public Calendar getDatetime() {\n"
" return _datetime;\n"
" }\n"
" public Long getId() {\n"
" return _id;\n"
" }\n"
" public String getText() {\n"
" return _text;\n"
" }\n"
" public String getTitle() {\n"
" return _title;\n"
" }\n"
" public void setBlog(Blog blog) {\n"
" _blog = blog;\n"
" }\n"
" public void setDatetime(Calendar calendar) {\n"
" _datetime = calendar;\n"
" }\n"
" public void setId(Long long1) {\n"
" _id = long1;\n"
" }\n"
" public void setText(String string) {\n"
" _text = string;\n"
" }\n"
" public void setTitle(String string) {\n"
" _title = string;\n"
" }\n"
"}]]>"
msgstr ""
#. Tag: title
#: example_weblog.xml:23
#, no-c-format
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."
msgstr ""
msgstr "下列的XML映射应该是很直白的。"
#: index.docbook:29
#. Tag: programlisting
#: example_weblog.xml:29
#, no-c-format
msgid ""
"<![CDATA[<?xml version=\"1.0\"?>\n"
"<!DOCTYPE hibernate-mapping PUBLIC\n"
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
"\n"
"<hibernate-mapping package=\"eg\">\n"
"\n"
" <class\n"
" name=\"Blog\"\n"
" table=\"BLOGS\">\n"
"\n"
" <id\n"
" name=\"id\"\n"
" column=\"BLOG_ID\">\n"
"\n"
" <generator class=\"native\"/>\n"
"\n"
" </id>\n"
"\n"
" <property\n"
" name=\"name\"\n"
" column=\"NAME\"\n"
" not-null=\"true\"\n"
" unique=\"true\"/>\n"
"\n"
" <bag\n"
" name=\"items\"\n"
" inverse=\"true\"\n"
" order-by=\"DATE_TIME\"\n"
" cascade=\"all\">\n"
"\n"
" <key column=\"BLOG_ID\"/>\n"
" <one-to-many class=\"BlogItem\"/>\n"
"\n"
" </bag>\n"
"\n"
" </class>\n"
"\n"
"</hibernate-mapping>]]>"
"<![CDATA[<?xml version=\"1.0\"?>\n"
"<!DOCTYPE hibernate-mapping PUBLIC\n"
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
"\n"
"<hibernate-mapping package=\"eg\">\n"
"\n"
" <class\n"
" name=\"Blog\"\n"
" table=\"BLOGS\">\n"
"\n"
" <id\n"
" name=\"id\"\n"
" column=\"BLOG_ID\">\n"
"\n"
" <generator class=\"native\"/>\n"
"\n"
" </id>\n"
"\n"
" <property\n"
" name=\"name\"\n"
" column=\"NAME\"\n"
" not-null=\"true\"\n"
" unique=\"true\"/>\n"
"\n"
" <bag\n"
" name=\"items\"\n"
" inverse=\"true\"\n"
" order-by=\"DATE_TIME\"\n"
" cascade=\"all\">\n"
"\n"
" <key column=\"BLOG_ID\"/>\n"
" <one-to-many class=\"BlogItem\"/>\n"
"\n"
" </bag>\n"
"\n"
" </class>\n"
"\n"
"</hibernate-mapping>]]>"
msgstr ""
#: index.docbook:31
#. Tag: programlisting
#: example_weblog.xml:31
#, no-c-format
msgid ""
"<![CDATA[<?xml version=\"1.0\"?>\n"
"<!DOCTYPE hibernate-mapping PUBLIC\n"
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
"\n"
"<hibernate-mapping package=\"eg\">\n"
"\n"
" <class\n"
" name=\"BlogItem\"\n"
" table=\"BLOG_ITEMS\"\n"
" dynamic-update=\"true\">\n"
"\n"
" <id\n"
" name=\"id\"\n"
" column=\"BLOG_ITEM_ID\">\n"
"\n"
" <generator class=\"native\"/>\n"
"\n"
" </id>\n"
"\n"
" <property\n"
" name=\"title\"\n"
" column=\"TITLE\"\n"
" not-null=\"true\"/>\n"
"\n"
" <property\n"
" name=\"text\"\n"
" column=\"TEXT\"\n"
" not-null=\"true\"/>\n"
"\n"
" <property\n"
" name=\"datetime\"\n"
" column=\"DATE_TIME\"\n"
" not-null=\"true\"/>\n"
"\n"
" <many-to-one\n"
" name=\"blog\"\n"
" column=\"BLOG_ID\"\n"
" not-null=\"true\"/>\n"
"\n"
" </class>\n"
"\n"
"</hibernate-mapping>]]>"
"<![CDATA[<?xml version=\"1.0\"?>\n"
"<!DOCTYPE hibernate-mapping PUBLIC\n"
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n"
"\n"
"<hibernate-mapping package=\"eg\">\n"
"\n"
" <class\n"
" name=\"BlogItem\"\n"
" table=\"BLOG_ITEMS\"\n"
" dynamic-update=\"true\">\n"
"\n"
" <id\n"
" name=\"id\"\n"
" column=\"BLOG_ITEM_ID\">\n"
"\n"
" <generator class=\"native\"/>\n"
"\n"
" </id>\n"
"\n"
" <property\n"
" name=\"title\"\n"
" column=\"TITLE\"\n"
" not-null=\"true\"/>\n"
"\n"
" <property\n"
" name=\"text\"\n"
" column=\"TEXT\"\n"
" not-null=\"true\"/>\n"
"\n"
" <property\n"
" name=\"datetime\"\n"
" column=\"DATE_TIME\"\n"
" not-null=\"true\"/>\n"
"\n"
" <many-to-one\n"
" name=\"blog\"\n"
" column=\"BLOG_ID\"\n"
" not-null=\"true\"/>\n"
"\n"
" </class>\n"
"\n"
"</hibernate-mapping>]]>"
msgstr ""
#: index.docbook:36
#. Tag: title
#: example_weblog.xml:36
#, no-c-format
msgid "Hibernate Code"
msgstr ""
msgstr "Hibernate 代码"
#: index.docbook:38
msgid "The following class demonstrates some of the kinds of things we can do with these classes, using Hibernate."
msgstr ""
#: index.docbook:43
#. Tag: para
#: example_weblog.xml:38
#, no-c-format
msgid ""
"<![CDATA[package eg;\n"
"\n"
"import java.util.ArrayList;\n"
"import java.util.Calendar;\n"
"import java.util.Iterator;\n"
"import java.util.List;\n"
"\n"
"import org.hibernate.HibernateException;\n"
"import org.hibernate.Query;\n"
"import org.hibernate.Session;\n"
"import org.hibernate.SessionFactory;\n"
"import org.hibernate.Transaction;\n"
"import org.hibernate.cfg.Configuration;\n"
"import org.hibernate.tool.hbm2ddl.SchemaExport;\n"
"\n"
"public class BlogMain {\n"
" \n"
" private SessionFactory _sessions;\n"
" \n"
" public void configure() throws HibernateException {\n"
" _sessions = new Configuration()\n"
" .addClass(Blog.class)\n"
" .addClass(BlogItem.class)\n"
" .buildSessionFactory();\n"
" }\n"
" \n"
" public void exportTables() throws HibernateException {\n"
" Configuration cfg = new Configuration()\n"
" .addClass(Blog.class)\n"
" .addClass(BlogItem.class);\n"
" new SchemaExport(cfg).create(true, true);\n"
" }\n"
" \n"
" public Blog createBlog(String name) throws HibernateException {\n"
" \n"
" Blog blog = new Blog();\n"
" blog.setName(name);\n"
" blog.setItems( new ArrayList() );\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" session.persist(blog);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return blog;\n"
" }\n"
" \n"
" public BlogItem createBlogItem(Blog blog, String title, String text)\n"
" throws HibernateException {\n"
" \n"
" BlogItem item = new BlogItem();\n"
" item.setTitle(title);\n"
" item.setText(text);\n"
" item.setBlog(blog);\n"
" item.setDatetime( Calendar.getInstance() );\n"
" blog.getItems().add(item);\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" session.update(blog);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return item;\n"
" }\n"
" \n"
" public BlogItem createBlogItem(Long blogid, String title, String text)\n"
" throws HibernateException {\n"
" \n"
" BlogItem item = new BlogItem();\n"
" item.setTitle(title);\n"
" item.setText(text);\n"
" item.setDatetime( Calendar.getInstance() );\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" Blog blog = (Blog) session.load(Blog.class, blogid);\n"
" item.setBlog(blog);\n"
" blog.getItems().add(item);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return item;\n"
" }\n"
" \n"
" public void updateBlogItem(BlogItem item, String text)\n"
" throws HibernateException {\n"
" \n"
" item.setText(text);\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" session.update(item);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" }\n"
" \n"
" public void updateBlogItem(Long itemid, String text)\n"
" throws HibernateException {\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" BlogItem item = (BlogItem) session.load(BlogItem.class, itemid);\n"
" item.setText(text);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" }\n"
" \n"
" public List listAllBlogNamesAndItemCounts(int max)\n"
" throws HibernateException {\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" List result = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" Query q = session.createQuery(\n"
" \"select blog.id, blog.name, count(blogItem) \" +\n"
" \"from Blog as blog \" +\n"
" \"left outer join blog.items as blogItem \" +\n"
" \"group by blog.name, blog.id \" +\n"
" \"order by max(blogItem.datetime)\"\n"
" );\n"
" q.setMaxResults(max);\n"
" result = q.list();\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return result;\n"
" }\n"
" \n"
" public Blog getBlogAndAllItems(Long blogid)\n"
" throws HibernateException {\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" Blog blog = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" Query q = session.createQuery(\n"
" \"from Blog as blog \" +\n"
" \"left outer join fetch blog.items \" +\n"
" \"where blog.id = :blogid\"\n"
" );\n"
" q.setParameter(\"blogid\", blogid);\n"
" blog = (Blog) q.uniqueResult();\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return blog;\n"
" }\n"
" \n"
" public List listBlogsAndRecentItems() throws HibernateException {\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" List result = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" Query q = session.createQuery(\n"
" \"from Blog as blog \" +\n"
" \"inner join blog.items as blogItem \" +\n"
" \"where blogItem.datetime > :minDate\"\n"
" );\n"
"\n"
" Calendar cal = Calendar.getInstance();\n"
" cal.roll(Calendar.MONTH, false);\n"
" q.setCalendar(\"minDate\", cal);\n"
" \n"
" result = q.list();\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return result;\n"
" }\n"
"}]]>"
"The following class demonstrates some of the kinds of things we can do with "
"these classes, using Hibernate."
msgstr "下面的类演示了我们可以使用Hibernate对这些类进行的一些操作。"
#. Tag: programlisting
#: example_weblog.xml:43
#, no-c-format
msgid ""
"<![CDATA[package eg;\n"
"\n"
"import java.util.ArrayList;\n"
"import java.util.Calendar;\n"
"import java.util.Iterator;\n"
"import java.util.List;\n"
"\n"
"import org.hibernate.HibernateException;\n"
"import org.hibernate.Query;\n"
"import org.hibernate.Session;\n"
"import org.hibernate.SessionFactory;\n"
"import org.hibernate.Transaction;\n"
"import org.hibernate.cfg.Configuration;\n"
"import org.hibernate.tool.hbm2ddl.SchemaExport;\n"
"\n"
"public class BlogMain {\n"
" \n"
" private SessionFactory _sessions;\n"
" \n"
" public void configure() throws HibernateException {\n"
" _sessions = new Configuration()\n"
" .addClass(Blog.class)\n"
" .addClass(BlogItem.class)\n"
" .buildSessionFactory();\n"
" }\n"
" \n"
" public void exportTables() throws HibernateException {\n"
" Configuration cfg = new Configuration()\n"
" .addClass(Blog.class)\n"
" .addClass(BlogItem.class);\n"
" new SchemaExport(cfg).create(true, true);\n"
" }\n"
" \n"
" public Blog createBlog(String name) throws HibernateException {\n"
" \n"
" Blog blog = new Blog();\n"
" blog.setName(name);\n"
" blog.setItems( new ArrayList() );\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" session.persist(blog);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return blog;\n"
" }\n"
" \n"
" public BlogItem createBlogItem(Blog blog, String title, String text)\n"
" throws HibernateException {\n"
" \n"
" BlogItem item = new BlogItem();\n"
" item.setTitle(title);\n"
" item.setText(text);\n"
" item.setBlog(blog);\n"
" item.setDatetime( Calendar.getInstance() );\n"
" blog.getItems().add(item);\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" session.update(blog);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return item;\n"
" }\n"
" \n"
" public BlogItem createBlogItem(Long blogid, String title, String text)\n"
" throws HibernateException {\n"
" \n"
" BlogItem item = new BlogItem();\n"
" item.setTitle(title);\n"
" item.setText(text);\n"
" item.setDatetime( Calendar.getInstance() );\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" Blog blog = (Blog) session.load(Blog.class, blogid);\n"
" item.setBlog(blog);\n"
" blog.getItems().add(item);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return item;\n"
" }\n"
" \n"
" public void updateBlogItem(BlogItem item, String text)\n"
" throws HibernateException {\n"
" \n"
" item.setText(text);\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" session.update(item);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" }\n"
" \n"
" public void updateBlogItem(Long itemid, String text)\n"
" throws HibernateException {\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" BlogItem item = (BlogItem) session.load(BlogItem.class, "
"itemid);\n"
" item.setText(text);\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" }\n"
" \n"
" public List listAllBlogNamesAndItemCounts(int max)\n"
" throws HibernateException {\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" List result = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" Query q = session.createQuery(\n"
" \"select blog.id, blog.name, count(blogItem) \" +\n"
" \"from Blog as blog \" +\n"
" \"left outer join blog.items as blogItem \" +\n"
" \"group by blog.name, blog.id \" +\n"
" \"order by max(blogItem.datetime)\"\n"
" );\n"
" q.setMaxResults(max);\n"
" result = q.list();\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return result;\n"
" }\n"
" \n"
" public Blog getBlogAndAllItems(Long blogid)\n"
" throws HibernateException {\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" Blog blog = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" Query q = session.createQuery(\n"
" \"from Blog as blog \" +\n"
" \"left outer join fetch blog.items \" +\n"
" \"where blog.id = :blogid\"\n"
" );\n"
" q.setParameter(\"blogid\", blogid);\n"
" blog = (Blog) q.uniqueResult();\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return blog;\n"
" }\n"
" \n"
" public List listBlogsAndRecentItems() throws HibernateException {\n"
" \n"
" Session session = _sessions.openSession();\n"
" Transaction tx = null;\n"
" List result = null;\n"
" try {\n"
" tx = session.beginTransaction();\n"
" Query q = session.createQuery(\n"
" \"from Blog as blog \" +\n"
" \"inner join blog.items as blogItem \" +\n"
" \"where blogItem.datetime > :minDate\"\n"
" );\n"
"\n"
" Calendar cal = Calendar.getInstance();\n"
" cal.roll(Calendar.MONTH, false);\n"
" q.setCalendar(\"minDate\", cal);\n"
" \n"
" result = q.list();\n"
" tx.commit();\n"
" }\n"
" catch (HibernateException he) {\n"
" if (tx!=null) tx.rollback();\n"
" throw he;\n"
" }\n"
" finally {\n"
" session.close();\n"
" }\n"
" return result;\n"
" }\n"
"}]]>"
msgstr ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"

View File

@ -1,149 +1,286 @@
#, fuzzy
msgid ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:5
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr ""
msgstr "过滤数据"
#: index.docbook:7
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."
#. Tag: para
#: 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 ""
"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"
msgstr ""
msgstr "Hibernate 过滤器(filters)"
#: index.docbook:16
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 ""
#: index.docbook:26
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 ""
#: index.docbook:32
#. Tag: para
#: filters.xml:16
#, no-c-format
msgid ""
"<![CDATA[<filter-def name=\"myFilter\">\n"
" <filter-param name=\"myFilterParam\" type=\"string\"/>\n"
"</filter-def>]]>"
"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 ""
"Hibernate3新增了对某个类或者集合使用预先定义的过滤器条件(filter criteria)的功"
"能。过滤器条件相当于定义一个 非常类似于类和各种集合上的“where”属性的约束子"
"句,但是过滤器条件可以带参数。 应用程序可以在运行时决定是否启用给定的过滤器,"
"以及使用什么样的参数值。 过滤器的用法很像数据库视图,只不过是在应用程序中确定"
"使用什么样的参数的。"
#. Tag: para
#: 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 ""
"要使用过滤器,必须首先在相应的映射节点中定义。而定义一个过滤器,要用到位于"
"<literal>&lt;hibernate-mapping/&gt;</literal> 节点之内的<literal>&lt;filter-"
"def/&gt;</literal>节点:"
#. Tag: programlisting
#: filters.xml:32
#, no-c-format
msgid ""
"<![CDATA[<filter-def name=\"myFilter\">\n"
" <filter-param name=\"myFilterParam\" type=\"string\"/>\n"
"</filter-def>]]>"
msgstr ""
#: index.docbook:34
#. Tag: para
#: filters.xml:34
#, no-c-format
msgid "Then, this filter can be attached to a class:"
msgstr ""
msgstr "定义好之后,就可以在某个类中使用这个过滤器:"
#: index.docbook:38
#. Tag: programlisting
#: filters.xml:38
#, no-c-format
msgid ""
"<![CDATA[<class name=\"myClass\" ...>\n"
" ...\n"
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN\"/>\n"
"</class>]]>"
"<![CDATA[<class name=\"myClass\" ...>\n"
" ...\n"
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
"\"/>\n"
"</class>]]>"
msgstr ""
#: index.docbook:40
#. Tag: para
#: filters.xml:40
#, no-c-format
msgid "or, to a collection:"
msgstr ""
msgstr "也可以在某个集合使用它:"
#: index.docbook:44
#. Tag: programlisting
#: filters.xml:44
#, no-c-format
msgid ""
"<![CDATA[<set ...>\n"
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN\"/>\n"
"</set>]]>"
"<![CDATA[<set ...>\n"
" <filter name=\"myFilter\" condition=\":myFilterParam = MY_FILTERED_COLUMN"
"\"/>\n"
"</set>]]>"
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."
msgstr ""
"可以在多个类或集合中使用某个过滤器;某个类或者集合中也可以使用多个过滤器。"
#: index.docbook:50
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 ""
#: index.docbook:59
msgid "<![CDATA[session.enableFilter(\"myFilter\").setParameter(\"myFilterParam\", \"some-value\");]]>"
msgstr ""
#: index.docbook:61
msgid "Note that methods on the org.hibernate.Filter interface do allow the method-chaining common to much of Hibernate."
msgstr ""
#: index.docbook:65
msgid "A full example, using temporal data with an effective record date pattern:"
msgstr ""
#: index.docbook:69
#. Tag: para
#: filters.xml:50
#, no-c-format
msgid ""
"<![CDATA[<filter-def name=\"effectiveDate\">\n"
" <filter-param name=\"asOfDate\" type=\"date\"/>\n"
"</filter-def>\n"
"\n"
"<class name=\"Employee\" ...>\n"
"...\n"
" <many-to-one name=\"department\" column=\"dept_id\" class=\"Department\"/>\n"
" <property name=\"effectiveStartDate\" type=\"date\" column=\"eff_start_dt\"/>\n"
" <property name=\"effectiveEndDate\" type=\"date\" column=\"eff_end_dt\"/>\n"
"...\n"
" <!--\n"
" Note that this assumes non-terminal records have an eff_end_dt set to\n"
" a max db date for simplicity-sake\n"
" -->\n"
" <filter name=\"effectiveDate\"\n"
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/>\n"
"</class>\n"
"\n"
"<class name=\"Department\" ...>\n"
"...\n"
" <set name=\"employees\" lazy=\"true\">\n"
" <key column=\"dept_id\"/>\n"
" <one-to-many class=\"Employee\"/>\n"
" <filter name=\"effectiveDate\"\n"
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/>\n"
" </set>\n"
"</class>]]>"
"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>的实例。以上文定义的过滤器为例:"
#: index.docbook:71
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 ""
#: index.docbook:76
#. Tag: programlisting
#: filters.xml:59
#, no-c-format
msgid ""
"<![CDATA[Session session = ...;\n"
"session.enabledFilter(\"effectiveDate\").setParameter(\"asOfDate\", new Date());\n"
"List results = session.createQuery(\"from Employee as e where e.salary > :targetSalary\")\n"
" .setLong(\"targetSalary\", new Long(1000000))\n"
" .list();\n"
"]]>"
"<![CDATA[session.enableFilter(\"myFilter\").setParameter(\"myFilterParam\", "
"\"some-value\");]]>"
msgstr ""
#: index.docbook:78
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."
msgstr ""
#: 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
#. Tag: para
#: filters.xml:61
#, no-c-format
msgid ""
"<![CDATA[<filter-def name=\"myFilter\" condition=\"abc > xyz\">...</filter-def>\n"
"<filter-def name=\"myOtherFilter\">abc=xyz</filter-def>]]>"
"Note that methods on the org.hibernate.Filter interface do allow the method-"
"chaining common to much of Hibernate."
msgstr ""
"注意org.hibernate.Filter的方法允许链式方法调用。类似上面例子中启用Filter"
"之后设定Filter参数这个“方法链” Hibernate的其他部分也大多有这个特性。"
#. Tag: para
#: filters.xml:65
#, no-c-format
msgid ""
"A full example, using temporal data with an effective record date pattern:"
msgstr "下面是一个比较完整的例子,使用了记录生效日期模式过滤有时效的数据:"
#. Tag: programlisting
#: filters.xml:69
#, no-c-format
msgid ""
"<![CDATA[<filter-def name=\"effectiveDate\">\n"
" <filter-param name=\"asOfDate\" type=\"date\"/>\n"
"</filter-def>\n"
"\n"
"<class name=\"Employee\" ...>\n"
"...\n"
" <many-to-one name=\"department\" column=\"dept_id\" class=\"Department\"/"
">\n"
" <property name=\"effectiveStartDate\" type=\"date\" column=\"eff_start_dt"
"\"/>\n"
" <property name=\"effectiveEndDate\" type=\"date\" column=\"eff_end_dt\"/"
">\n"
"...\n"
" <!--\n"
" Note that this assumes non-terminal records have an eff_end_dt set "
"to\n"
" a max db date for simplicity-sake\n"
" -->\n"
" <filter name=\"effectiveDate\"\n"
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/>\n"
"</class>\n"
"\n"
"<class name=\"Department\" ...>\n"
"...\n"
" <set name=\"employees\" lazy=\"true\">\n"
" <key column=\"dept_id\"/>\n"
" <one-to-many class=\"Employee\"/>\n"
" <filter name=\"effectiveDate\"\n"
" condition=\":asOfDate BETWEEN eff_start_dt and eff_end_dt\"/"
">\n"
" </set>\n"
"</class>]]>"
msgstr ""
#: index.docbook:100
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."
#. Tag: para
#: 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 ""
"定义好后,如果想要保证取回的都是目前处于生效期的记录,只需在获取雇员数据的操"
"作之前先开启过滤器即可:"
#. Tag: programlisting
#: filters.xml:76
#, no-c-format
msgid ""
"<![CDATA[Session session = ...;\n"
"session.enabledFilter(\"effectiveDate\").setParameter(\"asOfDate\", new Date"
"());\n"
"List results = session.createQuery(\"from Employee as e where e.salary > :"
"targetSalary\")\n"
" .setLong(\"targetSalary\", new Long(1000000))\n"
" .list();\n"
"]]>"
msgstr ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
#. Tag: para
#: filters.xml:78
#, no-c-format
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."
msgstr ""
"在上面的HQL中虽然我们仅仅显式的使用了一个薪水条件但因为启用了过滤器查询"
"将仅返回那些目前雇用 关系处于生效期的,并且薪水高于一百万美刀的雇员的数据。"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
#. 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>]]>"
msgstr ""
#. Tag: para
#: 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 ""
"当这个filter被附加到任何目的地而又没有指明条件时这个条件就会被使用。注"
"意换句话说你可以通过给filter附加特别的条件来重载默认条件。"

File diff suppressed because it is too large Load Diff

View File

@ -1,68 +1,180 @@
#, fuzzy
msgid ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:21
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr "<title>前言</title>"
msgstr "前言"
#: index.docbook:23
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的关系模型数据结构中去。"
#. Tag: para
#: preface.xml:23
#, 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
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处理数据的时间。"
#. Tag: para
#: preface.xml:31
#, 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
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代码并且帮你把结果集从表格式的表示形式转换到一系列的对象去。"
#. Tag: para
#: preface.xml:38
#, 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
msgid "If you are new to Hibernate and Object/Relational Mapping or even Java, please follow these steps:"
msgstr "如果你对Hibernate和对象/关系数据库映射还是个新手或者甚至对Java也不熟悉请按照下面的步骤来学习。"
#. Tag: para
#: preface.xml:48
#, 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
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>目录下找到。"
#. Tag: para
#: preface.xml:55
#, 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
msgid "Read <xref linkend=\"architecture\"/> to understand the environments where Hibernate can be used."
#. Tag: para
#: 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可以使用的环境。"
#: index.docbook:69
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>。"
#. Tag: para
#: preface.xml:69
#, 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
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."
#. Tag: para
#: 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 "把这份参考文档作为你学习的主要信息来源。"
#: index.docbook:90
#. Tag: para
#: preface.xml:90
#, no-c-format
msgid "FAQs are answered on the Hibernate website."
msgstr "在Hibernate 的网站上可以找到经常提问的问题与解答(FAQ)。"
#: index.docbook:95
msgid "Third party demos, examples, and tutorials are linked on the Hibernate website."
#. Tag: para
#: preface.xml:95
#, no-c-format
msgid ""
"Third party demos, examples, and tutorials are linked on the Hibernate "
"website."
msgstr "在Hibernate网站上还有第三方的演示、示例和教程的链接。"
#: index.docbook:101
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,等等)的好地方。"
#. Tag: para
#: preface.xml:101
#, 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
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."
msgstr "如果你有问题请使用Hibernate网站上链接的用户论坛。我们也提供一个JIRA问题追踪系统来搜集bug报告和新功能请求。如果你对开发Hibernate有兴趣请加入开发者的邮件列表。Hibernate网站上的用户论坛有一个中文版面JavaEye也有Hibernate中文版面,您可以在那里交流问题与经验。)"
#: index.docbook:117
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企业级中间件系统的一个核心组件。"
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
#. Tag: para
#: preface.xml:109
#, no-c-format
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."
msgstr ""
"如果你有问题请使用Hibernate网站上链接的用户论坛。我们也提供一个JIRA问题追踪"
"系统来搜集bug报告和新功能请求。如果你对开发Hibernate有兴趣请加入开发者的"
"邮件列表。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企业级中间件系统的一个核心组件。"

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,284 +1,433 @@
#, fuzzy
msgid ""
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"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Content-Type: text/plain; charset=utf-8\n"
#: index.docbook:5
"Language-Team: LANGUAGE <LL@li.org>\n"
"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"
msgstr ""
msgstr "XML映射"
#: index.docbook:7
msgid "Note that this is an experimental feature in Hibernate 3.0 and is under extremely active development."
msgstr ""
#. Tag: emphasis
#: xml.xml:7
#, 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"
msgstr ""
msgstr "用XML数据进行工作"
#: index.docbook:15
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."
#. Tag: para
#: 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 ""
"Hibernate使得你可以用XML数据来进行工作恰如你用持久化的POJO进行工作那样。解"
"析过的XML树 可以被认为是代替POJO的另外一种在对象层面上表示关系型数据的途径."
#: index.docbook:22
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)."
#. Tag: para
#: 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 ""
"Hibernate支持采用dom4j作为操作XML树的API。你可以写一些查询从数据库中检索出 "
"dom4j树随后你对这颗树做的任何修改都将自动同步回数据库。你甚至可以用dom4j解"
"析 一篇XML文档然后使用Hibernate的任一基本操作将它写入数据库 "
"<literal>persist(), saveOrUpdate(), merge(), delete(), replicate()</literal> "
"(合并操作merge()目前还不支持)。"
#: index.docbook:32
msgid "This feature has many applications including data import/export, externalization of entity data via JMS or SOAP and XSLT-based reporting."
#. Tag: para
#: 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 ""
"这一特性可以应用在很多场合包括数据导入导出通过JMS或SOAP具体化实体数据以"
"及 基于XSLT的报表。"
#: index.docbook:37
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."
#. Tag: para
#: 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 ""
"一个单一的映射就可以将类的属性和XML文档的节点同时映射到数据库。如果不需要映射"
"类, 它也可以用来只映射XML文档。"
#: index.docbook:44
#. Tag: title
#: xml.xml:44
#, no-c-format
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:"
msgstr ""
msgstr "这是一个同时映射POJO和XML的例子"
#: index.docbook:50
#. Tag: programlisting
#: xml.xml:50
#, no-c-format
msgid ""
"<![CDATA[<class name=\"Account\" \n"
" table=\"ACCOUNTS\" \n"
" node=\"account\">\n"
" \n"
" <id name=\"accountId\" \n"
" column=\"ACCOUNT_ID\" \n"
" node=\"@id\"/>\n"
" \n"
" <many-to-one name=\"customer\" \n"
" column=\"CUSTOMER_ID\" \n"
" node=\"customer/@id\" \n"
" embed-xml=\"false\"/>\n"
" \n"
" <property name=\"balance\" \n"
" column=\"BALANCE\" \n"
" node=\"balance\"/>\n"
" \n"
" ...\n"
" \n"
"</class>]]>"
"<![CDATA[<class name=\"Account\" \n"
" table=\"ACCOUNTS\" \n"
" node=\"account\">\n"
" \n"
" <id name=\"accountId\" \n"
" column=\"ACCOUNT_ID\" \n"
" node=\"@id\"/>\n"
" \n"
" <many-to-one name=\"customer\" \n"
" column=\"CUSTOMER_ID\" \n"
" node=\"customer/@id\" \n"
" embed-xml=\"false\"/>\n"
" \n"
" <property name=\"balance\" \n"
" column=\"BALANCE\" \n"
" node=\"balance\"/>\n"
" \n"
" ...\n"
" \n"
"</class>]]>"
msgstr ""
#: index.docbook:54
#. Tag: title
#: xml.xml:54
#, no-c-format
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:"
msgstr ""
msgstr "这是一个不映射POJO的例子"
#: index.docbook:60
#. Tag: programlisting
#: xml.xml:60
#, no-c-format
msgid ""
"<![CDATA[<class entity-name=\"Account\" \n"
" table=\"ACCOUNTS\" \n"
" node=\"account\">\n"
" \n"
" <id name=\"id\" \n"
" column=\"ACCOUNT_ID\" \n"
" node=\"@id\" \n"
" type=\"string\"/>\n"
" \n"
" <many-to-one name=\"customerId\" \n"
" column=\"CUSTOMER_ID\" \n"
" node=\"customer/@id\" \n"
" embed-xml=\"false\" \n"
" entity-name=\"Customer\"/>\n"
" \n"
" <property name=\"balance\" \n"
" column=\"BALANCE\" \n"
" node=\"balance\" \n"
" type=\"big_decimal\"/>\n"
" \n"
" ...\n"
" \n"
"</class>]]>"
"<![CDATA[<class entity-name=\"Account\" \n"
" table=\"ACCOUNTS\" \n"
" node=\"account\">\n"
" \n"
" <id name=\"id\" \n"
" column=\"ACCOUNT_ID\" \n"
" node=\"@id\" \n"
" type=\"string\"/>\n"
" \n"
" <many-to-one name=\"customerId\" \n"
" column=\"CUSTOMER_ID\" \n"
" node=\"customer/@id\" \n"
" embed-xml=\"false\" \n"
" entity-name=\"Customer\"/>\n"
" \n"
" <property name=\"balance\" \n"
" column=\"BALANCE\" \n"
" node=\"balance\" \n"
" type=\"big_decimal\"/>\n"
" \n"
" ...\n"
" \n"
"</class>]]>"
msgstr ""
#: index.docbook:62
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."
#. Tag: para
#: 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 ""
"这个映射使得你既可以把数据作为一棵dom4j树那样访问又可以作为由属性键值对"
"(java <literal>Map</literal>s) 组成的图那样访问。属性名字纯粹是逻辑上的结构,"
"你可以在HQL查询中引用它。"
#: index.docbook:73
#. Tag: title
#: xml.xml:73
#, no-c-format
msgid "XML mapping metadata"
msgstr ""
msgstr "XML映射元数据"
#: index.docbook:75
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:"
#. Tag: para
#: 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 ""
"许多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"
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"
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"
msgstr ""
msgstr "<literal>\".\"</literal> - 映射为父元素"
#: index.docbook:93
msgid "<literal>\"element-name/@attribute-name\"</literal> - map to the named attribute of the named element"
msgstr ""
#: index.docbook:100
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 ""
#: index.docbook:110
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 ""
#: index.docbook:115
#. Tag: para
#: xml.xml:93
#, no-c-format
msgid ""
"<![CDATA[<class name=\"Customer\" \n"
" table=\"CUSTOMER\" \n"
" node=\"customer\">\n"
" \n"
" <id name=\"id\" \n"
" column=\"CUST_ID\" \n"
" node=\"@id\"/>\n"
" \n"
" <map name=\"accounts\" \n"
" node=\".\" \n"
" embed-xml=\"true\">\n"
" <key column=\"CUSTOMER_ID\" \n"
" not-null=\"true\"/>\n"
" <map-key column=\"SHORT_DESC\" \n"
" node=\"@short-desc\" \n"
" type=\"string\"/>\n"
" <one-to-many entity-name=\"Account\"\n"
" embed-xml=\"false\" \n"
" node=\"account\"/>\n"
" </map>\n"
" \n"
" <component name=\"name\" \n"
" node=\"name\">\n"
" <property name=\"firstName\" \n"
" node=\"first-name\"/>\n"
" <property name=\"initial\" \n"
" node=\"initial\"/>\n"
" <property name=\"lastName\" \n"
" node=\"last-name\"/>\n"
" </component>\n"
" \n"
" ...\n"
" \n"
"</class>]]>"
"<literal>\"element-name/@attribute-name\"</literal> - map to the named "
"attribute of the named element"
msgstr ""
"<literal>\"element-name/@attribute-name\"</literal> - 映射为指定元素的指定属"
"性"
#. Tag: para
#: 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 ""
"对于集合和单值的关联,有一个额外的<literal>embed-xml</literal>属性可用。 这个"
"属性的缺省值是真(<literal>embed-xml=\"true\"</literal>)。如果<literal>embed-"
"xml=\"true\"</literal> 则对应于被关联实体或值类型的集合的XML树将直接嵌入拥"
"有这些关联的实体的XML树中。 否则,如果<literal>embed-xml=\"false\"</"
"literal>,那么对于单值的关联,仅被引用的实体的标识符出现在 XML树中(被引用实体"
"本身不出现),而集合则根本不出现。"
#. Tag: para
#: 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 ""
"你应该小心不要让太多关联的embed-xml属性为真(<literal>embed-xml=\"true\"</"
"literal>)因为XML不能很好地处理 循环引用!"
#. Tag: programlisting
#: xml.xml:115
#, no-c-format
msgid ""
"<![CDATA[<class name=\"Customer\" \n"
" table=\"CUSTOMER\" \n"
" node=\"customer\">\n"
" \n"
" <id name=\"id\" \n"
" column=\"CUST_ID\" \n"
" node=\"@id\"/>\n"
" \n"
" <map name=\"accounts\" \n"
" node=\".\" \n"
" embed-xml=\"true\">\n"
" <key column=\"CUSTOMER_ID\" \n"
" not-null=\"true\"/>\n"
" <map-key column=\"SHORT_DESC\" \n"
" node=\"@short-desc\" \n"
" type=\"string\"/>\n"
" <one-to-many entity-name=\"Account\"\n"
" embed-xml=\"false\" \n"
" node=\"account\"/>\n"
" </map>\n"
" \n"
" <component name=\"name\" \n"
" node=\"name\">\n"
" <property name=\"firstName\" \n"
" node=\"first-name\"/>\n"
" <property name=\"initial\" \n"
" node=\"initial\"/>\n"
" <property name=\"lastName\" \n"
" node=\"last-name\"/>\n"
" </component>\n"
" \n"
" ...\n"
" \n"
"</class>]]>"
msgstr ""
#: index.docbook:117
msgid "in this case, we have decided to embed the collection of account ids, but not the actual account data. The following HQL query:"
#. Tag: para
#: 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 ""
#: index.docbook:122
msgid "<![CDATA[from Customer c left join fetch c.accounts where c.lastName like :lastName]]>"
msgstr ""
#: index.docbook:124
#. Tag: para
#: xml.xml:124
#, no-c-format
msgid "Would return datasets such as this:"
msgstr ""
msgstr "返回的数据集将是这样:"
#: index.docbook:128
#. Tag: programlisting
#: xml.xml:128
#, no-c-format
msgid ""
"<![CDATA[<customer id=\"123456789\">\n"
" <account short-desc=\"Savings\">987632567</account>\n"
" <account short-desc=\"Credit Card\">985612323</account>\n"
" <name>\n"
" <first-name>Gavin</first-name>\n"
" <initial>A</initial>\n"
" <last-name>King</last-name>\n"
" </name>\n"
" ...\n"
"</customer>]]>"
"<![CDATA[<customer id=\"123456789\">\n"
" <account short-desc=\"Savings\">987632567</account>\n"
" <account short-desc=\"Credit Card\">985612323</account>\n"
" <name>\n"
" <first-name>Gavin</first-name>\n"
" <initial>A</initial>\n"
" <last-name>King</last-name>\n"
" </name>\n"
" ...\n"
"</customer>]]>"
msgstr ""
#: index.docbook:130
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 ""
#: index.docbook:135
#. Tag: para
#: xml.xml:130
#, no-c-format
msgid ""
"<![CDATA[<customer id=\"123456789\">\n"
" <account id=\"987632567\" short-desc=\"Savings\">\n"
" <customer id=\"123456789\"/>\n"
" <balance>100.29</balance>\n"
" </account>\n"
" <account id=\"985612323\" short-desc=\"Credit Card\">\n"
" <customer id=\"123456789\"/>\n"
" <balance>-2370.34</balance>\n"
" </account>\n"
" <name>\n"
" <first-name>Gavin</first-name>\n"
" <initial>A</initial>\n"
" <last-name>King</last-name>\n"
" </name>\n"
" ...\n"
"</customer>]]>"
"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 ""
"如果你把一对多映射<literal>&lt;one-to-many&gt;</literal>的embed-xml属性置为真"
"(<literal>embed-xml=\"true\"</literal>) 则数据看上去就像这样:"
#. Tag: programlisting
#: xml.xml:135
#, no-c-format
msgid ""
"<![CDATA[<customer id=\"123456789\">\n"
" <account id=\"987632567\" short-desc=\"Savings\">\n"
" <customer id=\"123456789\"/>\n"
" <balance>100.29</balance>\n"
" </account>\n"
" <account id=\"985612323\" short-desc=\"Credit Card\">\n"
" <customer id=\"123456789\"/>\n"
" <balance>-2370.34</balance>\n"
" </account>\n"
" <name>\n"
" <first-name>Gavin</first-name>\n"
" <initial>A</initial>\n"
" <last-name>King</last-name>\n"
" </name>\n"
" ...\n"
"</customer>]]>"
msgstr ""
#: index.docbook:141
#. Tag: title
#: xml.xml:141
#, no-c-format
msgid "Manipulating XML data"
msgstr ""
msgstr "操作XML数据"
#: index.docbook:143
msgid "Let's rearead and update XML documents in the application. We do this by obtaining a dom4j session:"
msgstr ""
#: index.docbook:148
#. Tag: para
#: xml.xml:143
#, no-c-format
msgid ""
"<![CDATA[Document doc = ....;\n"
" \n"
"Session session = factory.openSession();\n"
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"List results = dom4jSession\n"
" .createQuery(\"from Customer c left join fetch c.accounts where c.lastName like :lastName\")\n"
" .list();\n"
"for ( int i=0; i<results.size(); i++ ) {\n"
" //add the customer data to the XML document\n"
" Element customer = (Element) results.get(i);\n"
" doc.add(customer);\n"
"}\n"
"\n"
"tx.commit();\n"
"session.close();]]>"
"Let's rearead and update XML documents in the application. We do this by "
"obtaining a dom4j session:"
msgstr ""
"让我们来读入和更新应用程序中的XML文档。通过获取一个dom4j会话可以做到这一点"
#: index.docbook:150
#. Tag: programlisting
#: xml.xml:148
#, no-c-format
msgid ""
"<![CDATA[Session session = factory.openSession();\n"
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"Element cust = (Element) dom4jSession.get(\"Customer\", customerId);\n"
"for ( int i=0; i<results.size(); i++ ) {\n"
" Element customer = (Element) results.get(i);\n"
" //change the customer name in the XML and database\n"
" Element name = customer.element(\"name\");\n"
" name.element(\"first-name\").setText(firstName);\n"
" name.element(\"initial\").setText(initial);\n"
" name.element(\"last-name\").setText(lastName);\n"
"}\n"
"\n"
"tx.commit();\n"
"session.close();]]>"
"<![CDATA[Document doc = ....;\n"
" \n"
"Session session = factory.openSession();\n"
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"List results = dom4jSession\n"
" .createQuery(\"from Customer c left join fetch c.accounts where c."
"lastName like :lastName\")\n"
" .list();\n"
"for ( int i=0; i<results.size(); i++ ) {\n"
" //add the customer data to the XML document\n"
" Element customer = (Element) results.get(i);\n"
" doc.add(customer);\n"
"}\n"
"\n"
"tx.commit();\n"
"session.close();]]>"
msgstr ""
#: index.docbook:152
msgid "It is extremely useful to combine this feature with Hibernate's <literal>replicate()</literal> operation to implement XML-based data import/export."
#. Tag: programlisting
#: xml.xml:150
#, no-c-format
msgid ""
"<![CDATA[Session session = factory.openSession();\n"
"Session dom4jSession = session.getSession(EntityMode.DOM4J);\n"
"Transaction tx = session.beginTransaction();\n"
"\n"
"Element cust = (Element) dom4jSession.get(\"Customer\", customerId);\n"
"for ( int i=0; i<results.size(); i++ ) {\n"
" Element customer = (Element) results.get(i);\n"
" //change the customer name in the XML and database\n"
" Element name = customer.element(\"name\");\n"
" name.element(\"first-name\").setText(firstName);\n"
" name.element(\"initial\").setText(initial);\n"
" name.element(\"last-name\").setText(lastName);\n"
"}\n"
"\n"
"tx.commit();\n"
"session.close();]]>"
msgstr ""
msgid "ROLES_OF_TRANSLATORS"
msgstr "<!--TRANS:ROLES_OF_TRANSLATORS-->"
msgid "CREDIT_FOR_TRANSLATORS"
msgstr "<!--TRANS:CREDIT_FOR_TRANSLATORS-->"
#. Tag: para
#: 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 ""
"将这一特色与Hibernate的<literal>replicate()</literal>操作结合起来对于实现的基"
"于XML的数据导入/导出将非常有用."