diff --git a/documentation/manual/translations/zh-CN/content/architecture.po b/documentation/manual/translations/zh-CN/content/architecture.po index e9cd8f8606..204a90ddbc 100644 --- a/documentation/manual/translations/zh-CN/content/architecture.po +++ b/documentation/manual/translations/zh-CN/content/architecture.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:21 +"Language-Team: LANGUAGE \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 "图中各个对象的定义如下: " -#: index.docbook:80 +#. Tag: term +#: architecture.xml:80 +#, no-c-format msgid "SessionFactory (org.hibernate.SessionFactory)" -msgstr "" +msgstr "SessionFactory (org.hibernate.SessionFactory)" -#: index.docbook:82 -msgid "A threadsafe (immutable) cache of compiled mappings for a single database. A factory for Session and a client of ConnectionProvider. 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 Session and a client of " +"ConnectionProvider. Might hold an optional (second-level) " +"cache of data that is reusable between transactions, at a process- or " +"cluster-level." msgstr "" +"针对单个数据库映射关系经过编译后的内存镜像,是线程安全的(不可变)。 它是生成" +"Session的工厂,本身要用到ConnectionProvider。 该对象可以在进程或集群的级别上,为那些事务之间可以重用的数据提供可" +"选的二级缓存。" -#: index.docbook:92 +#. Tag: term +#: architecture.xml:92 +#, no-c-format msgid "Session (org.hibernate.Session)" -msgstr "" +msgstr "Session (org.hibernate.Session)" -#: 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 Transaction. 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 Transaction. Holds a mandatory (first-level) cache of " +"persistent objects, used when navigating the object graph or looking up " +"objects by identifier." msgstr "" +"表示应用程序与持久储存层之间交互操作的一个单线程对象,此对象生存期很短。 其隐" +"藏了JDBC连接,也是Transaction的工厂。 其会持有一个针对持久" +"化对象的必选(第一级)缓存,在遍历对象图或者根据持久化标识查找对象时会用到。" -#: 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) Session. As soon as the Session 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) " +"Session. As soon as the Session 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,唯一特殊的是他们正与(仅仅一个)Session相关联。 一旦这个Session被关闭,这些对象就会脱离持" +"久化状态,这样就可被应用程序的任何层自由使用。 (例如,用作跟表示层打交道的数" +"据传输对象。)" -#: 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 Session. They may have been instantiated by the application and not (yet) persisted or they may have been instantiated by a closed Session." +#. Tag: para +#: architecture.xml:119 +#, no-c-format +msgid "" +"Instances of persistent classes that are not currently associated with a " +"Session. They may have been instantiated by the " +"application and not (yet) persisted or they may have been instantiated by a " +"closed Session." msgstr "" +"那些目前没有与session关联的持久化类实例。 他们可能是在被应用程序实例化后,尚" +"未进行持久化的对象。 也可能是因为实例化他们的Session已经被" +"关闭而脱离持久化的对象。" -#: index.docbook:128 +#. Tag: term +#: architecture.xml:128 +#, no-c-format msgid "Transaction (org.hibernate.Transaction)" -msgstr "" +msgstr "事务Transaction (org.hibernate.Transaction)" -#: 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 Session might span several Transactions in some cases. However, transaction demarcation, either using the underlying API or Transaction, 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 Session might span several " +"Transactions in some cases. However, transaction " +"demarcation, either using the underlying API or Transaction, is never optional!" msgstr "" +"(可选的)应用程序用来指定原子操作单元范围的对象,它是单线程的,生命周期很" +"短。 它通过抽象将应用从底层具体的JDBC、JTA以及CORBA事务隔离开。 某些情况下," +"一个Session之内可能包含多个Transaction" +"对象。 尽管是否使用该对象是可选的,但无论是使用底层的API还是使用" +"Transaction对象,事务边界的开启与关闭是必不可少的。" -#: index.docbook:141 -msgid "ConnectionProvider (org.hibernate.connection.ConnectionProvider)" +#. Tag: term +#: architecture.xml:141 +#, no-c-format +msgid "" +"ConnectionProvider (org.hibernate.connection.ConnectionProvider)" msgstr "" +"ConnectionProvider (org.hibernate.connection.ConnectionProvider)" -#: index.docbook:143 -msgid "(Optional) A factory for (and pool of) JDBC connections. Abstracts application from underlying Datasource or DriverManager. 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 Datasource or " +"DriverManager. Not exposed to application, but can be " +"extended/implemented by the developer." msgstr "" +"(可选的)生成JDBC连接的工厂(同时也起到连接池的作用)。 它通过抽象将应用从底" +"层的DatasourceDriverManager隔离开。 " +"仅供开发者扩展/实现用,并不暴露给应用程序使用。" -#: index.docbook:151 -msgid "TransactionFactory (org.hibernate.TransactionFactory)" +#. Tag: term +#: architecture.xml:151 +#, no-c-format +msgid "" +"TransactionFactory (org.hibernate.TransactionFactory)" msgstr "" +"TransactionFactory (org.hibernate.TransactionFactory)" -#: index.docbook:153 -msgid "(Optional) A factory for Transaction 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 Transaction instances. Not " +"exposed to the application, but can be extended/implemented by the developer." msgstr "" +"(可选的)生成Transaction对象实例的工厂。 仅供开发者扩展/" +"实现用,并不暴露给应用程序使用。" -#: 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 Transaction/TransactionFactory and/or ConnectionProvider 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 " +"Transaction/TransactionFactory and/or " +"ConnectionProvider APIs to talk to JTA or JDBC directly." msgstr "" +"在特定“轻型”的体系结构中,应用程序可能绕过 Transaction/" +"TransactionFactory 以及 ConnectionProvider 等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 persistence context. The Hibernate Session 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 persistence context. The Hibernate Session object is the " +"persistence context:" msgstr "" +"一个持久化类的实例可能处于三种不同状态中的某一种。 这三种状态的定义则与所谓的" +"持久化上下文(persistence context)有关。 Hibernate的" +"Session对象就是这个所谓的持久化上下文:" -#: 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 guarantees 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 " +"guarantees that persistent identity is equivalent to " +"Java identity (in-memory location of the object)." msgstr "" +"实例目前与某个持久化上下文有关联。 它拥有持久化标识(相当于主键值),并且可能" +"在数据库中有一个对应的行。 对于某一个特定的持久化上下文,Hibernate" +"保证持久化标识与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, org.hibernate.jmx.HibernateService." +#. 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, org.hibernate.jmx.HibernateService." msgstr "" +"JMX是管理Java组件(Java components)的J2EE标准。 Hibernate 可以通过一个JMX标准" +"服务来管理。 在这个发行版本中,我们提供了一个MBean接口的实现,即 org." +"hibernate.jmx.HibernateService。" -#: 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 "Session Management: The Hibernate Session'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 Session, 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 Transaction API for this). You call the HibernateContext to access a Session." +#. Tag: para +#: architecture.xml:245 +#, no-c-format +msgid "" +"Session Management: The Hibernate Session'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 " +"Session, 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 Transaction API for this). You " +"call the HibernateContext to access a Session." msgstr "" +"Session管理: Hibernate的Session对象" +"的生命周期可以 自动跟一个JTA事务边界绑定。这意味着你无需手工开关" +"Session了, 这项 工作会由JBoss EJB 拦截器来完成。你再也不用" +"担心你的代码中的事务边界了(除非你想利用Hibernate提供可选 的" +"Transaction API来自己写一个便于移植的的持久层)。 你通过调" +"用HibernateContext来访问Session。" -#: index.docbook:257 -msgid "HAR deployment: 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 SessionFactory. 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 "" +"HAR deployment: 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 " +"SessionFactory. 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 "" +"HAR 部署: 通常情况下,你会使用JBoss的服务部署描述符(在" +"EAR或/和SAR文件中)来部署Hibernate JMX服务。 这种部署方式支持所有常见的" +"Hibernate SessionFactory的配置选项。 不过,你仍需在部署描" +"述符中,列出你所有的映射文件的名字。如果你使用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 ." msgstr "" +"将Hibernate以部署为JMX服务的另一个好处,是可以查看Hibernate的运行时统计信息。" +"参看 ." -#: index.docbook:272 -msgid "Another feature available as a JMX service are runtime Hibernate statistics. See ." -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 "上下文相关的(Contextual)Session" + +#. 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 ThreadLocal-based contextual " +"sessions, helper classes such as HibernateUtil, or " +"utilized third-party frameworks (such as Spring or Pico) which provided " +"proxy/interception-based contextual sessions." msgstr "" +"使用Hibernate的大多数应用程序需要某种形式的“上下文相关的” session,特定的" +"session在整个特定的上下文范围内始终有效。然而,对不同类型的应用程序而言,要为" +"什么是组成这种“上下文”下一个定义通常是困难的;不同的上下文对“当前”这个概念定" +"义了不同的范围。在3.0版本之前,使用Hibernate的程序要么采用自行编写的基于" +"ThreadLocal的上下文session,要么采用" +"HibernateUtil这样的辅助类,要么采用第三方框架(比如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 ThreadLocal-based contextual sessions, helper classes such as HibernateUtil, 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 SessionFactory." +"getCurrentSession() method. Initially, this assumed usage of " +"JTA transactions, where the JTA " +"transaction defined both the scope and context of a current session. The " +"Hibernate team maintains that, given the maturity of the numerous stand-" +"alone JTA TransactionManager implementations out there, " +"most (if not all) applications should be using JTA " +"transaction management whether or not they are deployed into a " +"J2EE container. Based on that, the JTA-" +"based contextual sessions is all you should ever need to use." msgstr "" +"从3.0.1版本开始,Hibernate增加了SessionFactory.getCurrentSession()方法。一开始,它假定了采用JTA事务,JTA事务定义了当前session的范围和上下文(scope and context)。Hibernate开发" +"团队坚信,因为有好几个独立的JTA TransactionManager实现稳定" +"可用,不论是否被部署到一个J2EE容器中,大多数(假若不是所有" +"的)应用程序都应该采用JTA事务管理。基于这一点,采用" +"JTA的上下文相关session可以满足你一切需要。" -#: index.docbook:297 -msgid "Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method. Initially, this assumed usage of JTA transactions, where the JTA transaction defined both the scope and context of a current session. The Hibernate team maintains that, given the maturity of the numerous stand-alone JTA TransactionManager implementations out there, most (if not all) applications should be using JTA transaction management whether or not they are deployed into a J2EE container. Based on that, the JTA-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 SessionFactory." +"getCurrentSession() is now pluggable. To that end, a new extension " +"interface (org.hibernate.context.CurrentSessionContext) " +"and a new configuration parameter (hibernate." +"current_session_context_class) have been added to allow " +"pluggability of the scope and context of defining current sessions." msgstr "" +"更好的是,从3.1开始,SessionFactory.getCurrentSession()的" +"后台实现是可拔插的。因此,我们引入了新的扩展接口(org.hibernate." +"context.CurrentSessionContext)和新的配置参数(hibernate." +"current_session_context_class),以便对什么是“当前session”的范围和上" +"下文(scope and context)的定义进行拔插。" -#: index.docbook:307 -msgid "However, as of version 3.1, the processing behind SessionFactory.getCurrentSession() is now pluggable. To that end, a new extension interface (org.hibernate.context.CurrentSessionContext) and a new configuration parameter (hibernate.current_session_context_class) 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 org.hibernate.context." +"CurrentSessionContext interface for a detailed discussion of its " +"contract. It defines a single method, currentSession(), " +"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 "" +"请参阅org.hibernate.context.CurrentSessionContext接口的" +"Javadoc,那里有关于它的契约的详细讨论。它定义了单一的方法," +"currentSession(),特定的实现用它来负责跟踪当前的上下文" +"session。Hibernate内置了此接口的三种实现。" -#: index.docbook:314 -msgid "See the Javadocs for the org.hibernate.context.CurrentSessionContext interface for a detailed discussion of its contract. It defines a single method, currentSession(), 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 "" +"org.hibernate.context.JTASessionContext - current " +"sessions are tracked and scoped by a JTA transaction. The " +"processing here is exactly the same as in the older JTA-only approach. See " +"the Javadocs for details." msgstr "" +"org.hibernate.context.JTASessionContext - 当前session根据" +"JTA来跟踪和界定。这和以前的仅支持JTA的方法是完全一样的。详" +"情请参阅Javadoc。" -#: index.docbook:324 -msgid "org.hibernate.context.JTASessionContext - current sessions are tracked and scoped by a JTA 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 "" +"org.hibernate.context.ThreadLocalSessionContext - current " +"sessions are tracked by thread of execution. Again, see the Javadocs for " +"details." msgstr "" +"org.hibernate.context.ThreadLocalSessionContext - 当前" +"session通过当前执行的线程来跟踪和界定。详情也请参阅Javadoc。" -#: index.docbook:332 -msgid "org.hibernate.context.ThreadLocalSessionContext - current sessions are tracked by thread of execution. Again, see the Javadocs for details." +#. Tag: para +#: architecture.xml:338 +#, no-c-format +msgid "" +"org.hibernate.context.ManagedSessionContext - current " +"sessions are tracked by thread of execution. However, you are responsible to " +"bind and unbind a Session instance with static methods on " +"this class, it does never open, flush, or close a Session." msgstr "" +"org.hibernate.context.ManagedSessionContext - 当前session" +"通过当前执行的线程来跟踪和界定。但是,你需要负责使用这个类的静态方法将" +"Session实例绑定、或者取消绑定,它并不会打开(open)、flush或" +"者关闭(close)任何Session。" -#: index.docbook:338 -msgid "org.hibernate.context.ManagedSessionContext - current sessions are tracked by thread of execution. However, you are responsible to bind and unbind a Session instance with static methods on this class, it does never open, flush, or close a Session." +#. 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 session-" +"per-request. 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 Transaction 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 for more information and code examples." msgstr "" +"前两种实现都提供了“每数据库事务对应一个session”的编程模型,也称作每" +"次请求一个session。Hibernate session的起始和终结由数据库事务的生存" +"来控制。假若你在纯粹的 Java SE之上采用自行编写代码来管理事务,而不使用JTA,建" +"议你使用Hibernate Transaction API来把底层事务实现从你的代" +"码中隐藏掉。如果你使用JTA,请使用JTA借口来管理Transaction。如果你在支持CMT的" +"EJB容器中执行代码,事务边界是声明式定义的,你不需要在代码中进行任何事务或" +"session管理操作。请参阅一节来阅读更多的内容和" +"示例代码。" -#: index.docbook:347 -msgid "The first two implementations provide a \"one session - one database transaction\" programming model, also known and used as session-per-request. 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 Transaction 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 for more information and code examples." +#. Tag: para +#: architecture.xml:359 +#, no-c-format +msgid "" +"The hibernate.current_session_context_class configuration " +"parameter defines which org.hibernate.context." +"CurrentSessionContext implementation should be used. Note that for " +"backwards compatibility, if this config param is not set but a org." +"hibernate.transaction.TransactionManagerLookup is configured, " +"Hibernate will use the org.hibernate.context.JTASessionContext. 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 hibernate.current_session_context_class configuration parameter defines which org.hibernate.context.CurrentSessionContext implementation should be used. Note that for backwards compatibility, if this config param is not set but a org.hibernate.transaction.TransactionManagerLookup is configured, Hibernate will use the org.hibernate.context.JTASessionContext. 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 "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +"hibernate.current_session_context_class配置参数定义了应该" +"采用哪个org.hibernate.context.CurrentSessionContext实现。" +"注意,为了向下兼容,如果未配置此参数,但是存在org.hibernate." +"transaction.TransactionManagerLookup的配置,Hibernate会采用" +"org.hibernate.context.JTASessionContext。一般而言,此参数" +"的值指明了要使用的实现类的全名,但那三种内置的实现可以使用简写,即\"jta\"、" +"\"thread\"和\"managed\"。" diff --git a/documentation/manual/translations/zh-CN/content/association_mapping.po b/documentation/manual/translations/zh-CN/content/association_mapping.po index 9b80041e2b..4682f44b95 100644 --- a/documentation/manual/translations/zh-CN/content/association_mapping.po +++ b/documentation/manual/translations/zh-CN/content/association_mapping.po @@ -1,608 +1,871 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:6 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: association_mapping.xml:6 +#, no-c-format msgid "Association Mappings" -msgstr "" +msgstr "关联关系映射" -#: index.docbook:9 +#. Tag: title +#: association_mapping.xml:9 +#, no-c-format msgid "Introduction" -msgstr "" +msgstr "介绍" -#: index.docbook:11 -msgid "Association mappings are the often most difficult thing to get right. In this section we'll go through the canonical cases one by one, starting with unidirectional mappings, and then considering the bidirectional cases. We'll use Person and Address in all the examples." +#. Tag: para +#: association_mapping.xml:11 +#, no-c-format +msgid "" +"Association mappings are the often most difficult thing to get right. In " +"this section we'll go through the canonical cases one by one, starting with " +"unidirectional mappings, and then considering the bidirectional cases. We'll " +"use Person and Address in all the " +"examples." msgstr "" +"关联关系映射通常情况是最难配置正确的。在这个部分中,我们从单向关系映射开始," +"然后考虑双向关系映射,由浅至深讲述一遍典型的案例。在所有的例子中,我们都使用 " +"PersonAddress。" -#: index.docbook:19 -msgid "We'll classify associations by whether or not they map to an intervening join table, and by multiplicity." +#. Tag: para +#: association_mapping.xml:19 +#, no-c-format +msgid "" +"We'll classify associations by whether or not they map to an intervening " +"join table, and by multiplicity." +msgstr "我们根据映射关系是否涉及连接表以及多样性来划分关联类型。" + +#. Tag: para +#: association_mapping.xml:24 +#, no-c-format +msgid "" +"Nullable foreign keys are not considered good practice in traditional data " +"modelling, so all our examples use not null foreign keys. This is not a " +"requirement of Hibernate, and the mappings will all work if you drop the " +"nullability constraints." msgstr "" +"在传统的数据建模中,允许为Null值的外键被认为是一种不好的实践,因此我们所有的" +"例子中都使用不允许为Null的外键。这并不是Hibernate的要求,即使你删除掉不允许为" +"Null的约束,Hibernate映射一样可以工作的很好。" -#: index.docbook:24 -msgid "Nullable foreign keys are not considered good practice in traditional data modelling, so all our examples use not null foreign keys. This is not a requirement of Hibernate, and the mappings will all work if you drop the nullability constraints." -msgstr "" - -#: index.docbook:34 +#. Tag: title +#: association_mapping.xml:34 +#, no-c-format msgid "Unidirectional associations" -msgstr "" +msgstr "单向关联(Unidirectional associations)" -#: index.docbook:37, index.docbook:108 +#. Tag: title +#: association_mapping.xml:37 association_mapping.xml:108 +#, fuzzy, no-c-format msgid "many to one" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"多对一(many to one)\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"多对一(many to one)" -#: index.docbook:39 -msgid "A unidirectional many-to-one association is the most common kind of unidirectional association." -msgstr "" - -#: index.docbook:44 +#. Tag: para +#: association_mapping.xml:39 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" -msgstr "" +"A unidirectional many-to-one association is the most " +"common kind of unidirectional association." +msgstr "单向many-to-one关联是最常见的单向关联关系。" -#: index.docbook:45, index.docbook:161 +#. Tag: programlisting +#: association_mapping.xml:44 +#, no-c-format msgid "" - "" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:50, index.docbook:121, index.docbook:185, index.docbook:225 +#. Tag: programlisting +#: association_mapping.xml:45 association_mapping.xml:161 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: association_mapping.xml:50 association_mapping.xml:121 +#: association_mapping.xml:185 association_mapping.xml:225 +#, no-c-format msgid "one to one" -msgstr "" +msgstr "一对一(one to one)" -#: index.docbook:52 -msgid "A unidirectional one-to-one association on a foreign key is almost identical. The only difference is the column unique constraint." -msgstr "" - -#: index.docbook:57 +#. Tag: para +#: association_mapping.xml:52 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" +"A unidirectional one-to-one association on a foreign key is almost identical. The only difference is the column unique " +"constraint." msgstr "" +"基于外键关联的单向一对一关联单向多对一关联几乎是一样的。唯一的不同就是单向一对一关联中的外键字段具有唯一性约" +"束。" -#: index.docbook:58, index.docbook:193 +#. Tag: programlisting +#: association_mapping.xml:57 +#, no-c-format msgid "" - "" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:60 -msgid "A unidirectional one-to-one association on a primary key usually uses a special id generator. (Notice that we've reversed the direction of the association in this example.)" -msgstr "" - -#: index.docbook:66 +#. Tag: programlisting +#: association_mapping.xml:58 association_mapping.xml:193 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " person\n" - " \n" - " \n" - " \n" - "]]>" +"" msgstr "" -#: index.docbook:67, index.docbook:201 +#. Tag: para +#: association_mapping.xml:60 +#, no-c-format msgid "" - "" +"A unidirectional one-to-one association on a primary key usually uses a special id generator. (Notice that we've reversed " +"the direction of the association in this example.)" +msgstr "" +"基于主键关联的单向一对一关联通常使用一个特定的id生成器。" +"(请注意,在这个例子中我们掉换了关联的方向。)" + +#. Tag: programlisting +#: association_mapping.xml:66 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" person\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:72, index.docbook:94 +#. Tag: programlisting +#: association_mapping.xml:67 association_mapping.xml:201 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: association_mapping.xml:72 association_mapping.xml:94 +#, fuzzy, no-c-format msgid "one to many" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"一对多(one to many)\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"一对多(one to many)" -#: index.docbook:74 -msgid "A unidirectional one-to-many association on a foreign key is a very unusual case, and is not really recommended." -msgstr "" - -#: index.docbook:79 +#. Tag: para +#: association_mapping.xml:74 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" +"A unidirectional one-to-many association on a foreign key is a very unusual case, and is not really recommended." msgstr "" +"基于外键关联的单向一对多关联是一种很少见的情况,并不推荐" +"使用。" -#: index.docbook:80 +#. Tag: programlisting +#: association_mapping.xml:79 +#, no-c-format msgid "" - "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:82 +#. Tag: programlisting +#: association_mapping.xml:80 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: association_mapping.xml:82 +#, no-c-format msgid "We think it's better to use a join table for this kind of association." -msgstr "" +msgstr "我们认为对于这种关联关系最好使用连接表。" -#: index.docbook:91 +#. Tag: title +#: association_mapping.xml:91 +#, no-c-format msgid "Unidirectional associations with join tables" -msgstr "" +msgstr "使用连接表的单向关联(Unidirectional associations with join tables)" -#: index.docbook:96 -msgid "A unidirectional one-to-many association on a join table is much preferred. Notice that by specifying unique=\"true\", we have changed the multiplicity from many-to-many to one-to-many." -msgstr "" - -#: index.docbook:102 +#. Tag: para +#: association_mapping.xml:96 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" +"A unidirectional one-to-many association on a join table is much preferred. Notice that by specifying unique=\"true" +"\", we have changed the multiplicity from many-to-many to one-to-" +"many." msgstr "" +"基于连接表的单向一对多关联 应该优先被采用。请注意,通过" +"指定unique=\"true\",我们可以把多样性从多对多改变为一对" +"多。" -#: index.docbook:103 +#. Tag: programlisting +#: association_mapping.xml:102 +#, no-c-format msgid "" - "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:110 -msgid "A unidirectional many-to-one association on a join table is quite common when the association is optional." -msgstr "" - -#: index.docbook:115 +#. Tag: programlisting +#: association_mapping.xml:103 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" +"" msgstr "" -#: index.docbook:116 +#. Tag: para +#: association_mapping.xml:110 +#, no-c-format msgid "" - "" +"A unidirectional many-to-one association on a join table is quite common when the association is optional." msgstr "" +"基于连接表的单向多对一关联在关联关系可选的情况下应用也很" +"普遍。" -#: index.docbook:123 -msgid "A unidirectional one-to-one association on a join table is extremely unusual, but possible." -msgstr "" - -#: index.docbook:128 +#. Tag: programlisting +#: association_mapping.xml:115 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:129, index.docbook:233 +#. Tag: programlisting +#: association_mapping.xml:116 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:134, index.docbook:238 +#. Tag: para +#: association_mapping.xml:123 +#, no-c-format +msgid "" +"A unidirectional one-to-one association on a join table " +"is extremely unusual, but possible." +msgstr "" +"基于连接表的单向一对一关联非常少见,但也是可行的。" + +#. Tag: programlisting +#: association_mapping.xml:128 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: programlisting +#: association_mapping.xml:129 association_mapping.xml:233 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: association_mapping.xml:134 association_mapping.xml:238 +#, no-c-format msgid "many to many" -msgstr "" +msgstr "多对多(many to many)" -#: index.docbook:136 -msgid "Finally, we have a unidirectional many-to-many association." -msgstr "" - -#: index.docbook:140 +#. Tag: para +#: association_mapping.xml:136 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" -msgstr "" +"Finally, we have a unidirectional many-to-many association." +msgstr "最后,还有 单向多对多关联." -#: index.docbook:141, index.docbook:246 +#. Tag: programlisting +#: association_mapping.xml:140 +#, no-c-format msgid "" - "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:148 +#. Tag: programlisting +#: association_mapping.xml:141 association_mapping.xml:246 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: association_mapping.xml:148 +#, no-c-format msgid "Bidirectional associations" -msgstr "" +msgstr "双向关联(Bidirectional associations)" -#: index.docbook:151, index.docbook:211 +#. Tag: title +#: association_mapping.xml:151 association_mapping.xml:211 +#, fuzzy, no-c-format msgid "one to many / many to one" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"一对多(one to many) / 多对一(many to one)\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"一对多(one to many) /多对一( many to one)" -#: index.docbook:153 -msgid "A bidirectional many-to-one association is the most common kind of association. (This is the standard parent/child relationship.)" -msgstr "" - -#: index.docbook:159 +#. Tag: para +#: association_mapping.xml:153 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"A bidirectional many-to-one association is the most " +"common kind of association. (This is the standard parent/child relationship.)" msgstr "" +"双向多对一关联 是最常见的关联关系。(这也是标准的父/子关" +"联关系。)" -#: index.docbook:163 -msgid "If you use a List (or other indexed collection) you need to set the key column of the foreign key to not null, and let Hibernate manage the association from the collections side to maintain the index of each element (making the other side virtually inverse by setting update=\"false\" and insert=\"false\"):" -msgstr "" - -#: index.docbook:171 +#. Tag: programlisting +#: association_mapping.xml:159 +#, no-c-format msgid "" - "\n" - " \n" - " ...\n" - " \n" - "\n" - "\n" - "\n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:173 -msgid "It is important that you define not-null=\"true\" on the <key> element of the collection mapping if the underlying foreign key column is NOT NULL. Don't only declare not-null=\"true\" on a possible nested <column> element, but on the <key> element." -msgstr "" - -#: index.docbook:187 -msgid "A bidirectional one-to-one association on a foreign key is quite common." -msgstr "" - -#: index.docbook:192 +#. Tag: para +#: association_mapping.xml:163 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"If you use a List (or other indexed collection) you need " +"to set the key column of the foreign key to not " +"null, and let Hibernate manage the association from the " +"collections side to maintain the index of each element (making the other " +"side virtually inverse by setting update=\"false\" and " +"insert=\"false\"):" msgstr "" +"如果你使用List(或者其他有序集合类),你需要设置外键对应的" +"key列为 not null,让Hibernate来从集合端" +"管理关联,维护每个元素的索引(通过设置update=\"false\" " +"and insert=\"false\"来对另一端反向操作)。" -#: index.docbook:195 -msgid "A bidirectional one-to-one association on a primary key uses the special id generator." -msgstr "" - -#: index.docbook:200 +#. Tag: programlisting +#: association_mapping.xml:171 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " person\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" ...\n" +" \n" +"\n" +"\n" +"\n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:208 +#. Tag: para +#: association_mapping.xml:173 +#, no-c-format +msgid "" +"It is important that you define not-null=\"true\" on the " +"<key> element of the collection mapping if the " +"underlying foreign key column is NOT NULL. Don't only " +"declare not-null=\"true\" on a possible nested " +"<column> element, but on the <key> element." +msgstr "" +"假若集合映射的<key>元素对应的底层外键字段是" +"NOT NULL的,那么为这一key元素定义not-null=\"true" +"\"是很重要的。不要仅仅为可能的嵌套<column>" +"元素定义not-null=\"true\"<key>" +"元素也是需要的。" + +#. Tag: para +#: association_mapping.xml:187 +#, no-c-format +msgid "" +"A bidirectional one-to-one association on a foreign key " +"is quite common." +msgstr "基于外键关联的双向一对一关联也很常见。" + +#. Tag: programlisting +#: association_mapping.xml:192 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: association_mapping.xml:195 +#, no-c-format +msgid "" +"A bidirectional one-to-one association on a primary key " +"uses the special id generator." +msgstr "基于主键关联的一对一关联需要使用特定的id生成器。" + +#. Tag: programlisting +#: association_mapping.xml:200 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" person\n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: title +#: association_mapping.xml:208 +#, no-c-format msgid "Bidirectional associations with join tables" -msgstr "" +msgstr "使用连接表的双向关联(Bidirectional associations with join tables)" -#: index.docbook:213 -msgid "A bidirectional one-to-many association on a join table. Note that the inverse=\"true\" can go on either end of the association, on the collection, or on the join." -msgstr "" - -#: index.docbook:219 +#. Tag: para +#: association_mapping.xml:213 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"A bidirectional one-to-many association on a join table. Note that the inverse=\"true\" can go on " +"either end of the association, on the collection, or on the join." msgstr "" +"基于连接表的双向一对多关联。注意inverse=\"true" +"\"可以出现在关联的任意一端,即collection端或者join端。" -#: index.docbook:220 +#. Tag: programlisting +#: association_mapping.xml:219 +#, no-c-format msgid "" - "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:227 -msgid "A bidirectional one-to-one association on a join table is extremely unusual, but possible." -msgstr "" - -#: index.docbook:232 +#. Tag: programlisting +#: association_mapping.xml:220 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"" msgstr "" -#: index.docbook:240 -msgid "Finally, we have a bidirectional many-to-many association." -msgstr "" - -#: index.docbook:244 +#. Tag: para +#: association_mapping.xml:227 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"A bidirectional one-to-one association on a join table " +"is extremely unusual, but possible." +msgstr "" +"基于连接表的双向一对一关联极为罕见,但也是可行的。" + +#. Tag: programlisting +#: association_mapping.xml:232 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:253 +#. Tag: para +#: association_mapping.xml:240 +#, no-c-format +msgid "" +"Finally, we have a bidirectional many-to-many association." +msgstr "最后,还有 双向多对多关联." + +#. Tag: programlisting +#: association_mapping.xml:244 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: title +#: association_mapping.xml:253 +#, no-c-format msgid "More complex association mappings" -msgstr "" +msgstr "更复杂的关联映射" -#: index.docbook:255 -msgid "More complex association joins are extremely rare. Hibernate makes it possible to handle more complex situations using SQL fragments embedded in the mapping document. For example, if a table with historical account information data defines accountNumber, effectiveEndDate and effectiveStartDatecolumns, mapped as follows:" -msgstr "" - -#: index.docbook:264 +#. Tag: para +#: association_mapping.xml:255 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " case when effectiveEndDate is null then 1 else 0 end\n" - " \n" - "\n" - "\n" - "]]>" +"More complex association joins are extremely rare. " +"Hibernate makes it possible to handle more complex situations using SQL " +"fragments embedded in the mapping document. For example, if a table with " +"historical account information data defines accountNumber, effectiveEndDate and " +"effectiveStartDatecolumns, mapped as follows:" msgstr "" +"更复杂的关联连接极为罕见。 通过在映射文档中嵌入SQL片断," +"Hibernate也可以处理更为复杂的情况。比如,假若包含历史帐户数据的表定义了" +"accountNumber, effectiveEndDate 和" +"effectiveStartDate字段,按照下面映射:" -#: index.docbook:266 -msgid "Then we can map an association to the current instance (the one with null effectiveEndDate) using:" -msgstr "" - -#: index.docbook:271 +#. Tag: programlisting +#: association_mapping.xml:264 +#, no-c-format msgid "" - "\n" - " \n" - " '1'\n" - "]]>" +"\n" +" \n" +" \n" +" case when effectiveEndDate is null then 1 else 0 end\n" +" \n" +"\n" +"\n" +"]]>" msgstr "" -#: index.docbook:273 -msgid "In a more complex example, imagine that the association between Employee and Organization is maintained in an Employment table full of historical employment data. Then an association to the employee's most recent employer (the one with the most recent startDate) might be mapped this way:" -msgstr "" - -#: index.docbook:281 +#. Tag: para +#: association_mapping.xml:266 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " select employeeId, orgId \n" - " from Employments \n" - " group by orgId \n" - " having startDate = max(startDate)\n" - " \n" - " \n" - "]]>" +"Then we can map an association to the current instance " +"(the one with null effectiveEndDate) using:" +msgstr "" +"那么我们可以对目前(current)实例(其" +"effectiveEndDate为null)使用这样的关联映射:" + +#. Tag: programlisting +#: association_mapping.xml:271 +#, no-c-format +msgid "" +"\n" +" \n" +" '1'\n" +"]]>" msgstr "" -#: index.docbook:283 -msgid "You can get quite creative with this functionality, but it is usually more practical to handle these kinds of cases using HQL or a criteria query." +#. Tag: para +#: association_mapping.xml:273 +#, no-c-format +msgid "" +"In a more complex example, imagine that the association between " +"Employee and Organization is " +"maintained in an Employment table full of historical " +"employment data. Then an association to the employee's most " +"recent employer (the one with the most recent startDate) might be mapped this way:" +msgstr "" +"更复杂的例子,假想EmployeeOrganization" +"之间的关联是通过一个Employment中间表维护的,而中间表中填充" +"了很多历史雇员数据。那“雇员的最新雇主”这个关联(最新雇主" +"就是startDate最后的那个)可以这样映射:" + +#. Tag: programlisting +#: association_mapping.xml:281 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" select employeeId, orgId \n" +" from Employments \n" +" group by orgId \n" +" having startDate = max(startDate)\n" +" \n" +" \n" +"]]>" msgstr "" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +#. Tag: para +#: association_mapping.xml:283 +#, no-c-format +msgid "" +"You can get quite creative with this functionality, but it is usually more " +"practical to handle these kinds of cases using HQL or a criteria query." +msgstr "" +"使用这一功能时可以充满创意,但通常更加实用的是用HQL或条件查询来处理这些情形。" diff --git a/documentation/manual/translations/zh-CN/content/basic_mapping.po b/documentation/manual/translations/zh-CN/content/basic_mapping.po index 572e381d39..4b36985c8c 100644 --- a/documentation/manual/translations/zh-CN/content/basic_mapping.po +++ b/documentation/manual/translations/zh-CN/content/basic_mapping.po @@ -1,2459 +1,5429 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: basic_mapping.xml:5 +#, no-c-format msgid "Basic O/R Mapping" -msgstr "" +msgstr "对象/关系数据库映射基础(Basic O/R Mapping)" -#: index.docbook:8 +#. Tag: title +#: basic_mapping.xml:8 +#, no-c-format msgid "Mapping declaration" -msgstr "" +msgstr "映射定义(Mapping declaration)" -#: index.docbook:10 -msgid "Object/relational mappings are usually defined in an XML document. The mapping document is designed to be readable and hand-editable. The mapping language is Java-centric, meaning that mappings are constructed around persistent class declarations, not table declarations." +#. Tag: para +#: basic_mapping.xml:10 +#, no-c-format +msgid "" +"Object/relational mappings are usually defined in an XML document. The " +"mapping document is designed to be readable and hand-editable. The mapping " +"language is Java-centric, meaning that mappings are constructed around " +"persistent class declarations, not table declarations." msgstr "" +"对象和关系数据库之间的映射通常是用一个XML文档(XML document)来定义的。这个映射" +"文档被设计为易读的, 并且可以手工修改。映射语言是以Java为中心,这意味着映射文" +"档是按照持久化类的定义来创建的, 而非表的定义。" -#: index.docbook:17 -msgid "Note that, even though many Hibernate users choose to write the XML by hand, a number of tools exist to generate the mapping document, including XDoclet, Middlegen and AndroMDA." +#. Tag: para +#: basic_mapping.xml:17 +#, no-c-format +msgid "" +"Note that, even though many Hibernate users choose to write the XML by hand, " +"a number of tools exist to generate the mapping document, including XDoclet, " +"Middlegen and AndroMDA." msgstr "" +"请注意,虽然很多Hibernate用户选择手写XML映射文档,但也有一些工具可以用来生成" +"映射文档, 包括XDoclet,Middlegen和AndroMDA。" -#: index.docbook:23 +#. Tag: para +#: basic_mapping.xml:23 +#, no-c-format msgid "Lets kick off with an example mapping:" -msgstr "" +msgstr "让我们从一个映射的例子开始:" -#: index.docbook:27 +#. Tag: programlisting +#: basic_mapping.xml:27 +#, no-c-format msgid "" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"\n" +"\n" +"\n" +"\n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:29 -msgid "We will now discuss the content of the mapping document. We will only describe the document elements and attributes that are used by Hibernate at runtime. The mapping document also contains some extra optional attributes and elements that affect the database schemas exported by the schema export tool. (For example the not-null attribute.)" +#. Tag: para +#: basic_mapping.xml:29 +#, no-c-format +msgid "" +"We will now discuss the content of the mapping document. We will only " +"describe the document elements and attributes that are used by Hibernate at " +"runtime. The mapping document also contains some extra optional attributes " +"and elements that affect the database schemas exported by the schema export " +"tool. (For example the not-null attribute.)" msgstr "" +"我们现在开始讨论映射文档的内容。我们只描述Hibernate在运行时用到的文档元素和属" +"性。 映射文档还包括一些额外的可选属性和元素,它们在使用schema导出工具的时候会" +"影响导出的数据库schema结果。 (比如, not-null 属性。)" -#: index.docbook:40 +#. Tag: title +#: basic_mapping.xml:40 +#, no-c-format msgid "Doctype" -msgstr "" +msgstr "Doctype" -#: index.docbook:42 -msgid "All XML mappings should declare the doctype shown. The actual DTD may be found at the URL above, in the directory hibernate-x.x.x/src/org/hibernate or in hibernate3.jar. Hibernate will always look for the DTD in its classpath first. If you experience lookups of the DTD using an Internet connection, check your DTD declaration against the contents of your claspath." +#. Tag: para +#: basic_mapping.xml:42 +#, no-c-format +msgid "" +"All XML mappings should declare the doctype shown. The actual DTD may be " +"found at the URL above, in the directory hibernate-x.x.x/src/org/" +"hibernate or in hibernate3.jar. Hibernate will " +"always look for the DTD in its classpath first. If you experience lookups of " +"the DTD using an Internet connection, check your DTD declaration against the " +"contents of your claspath." msgstr "" +"所有的XML映射都需要定义如上所示的doctype。DTD可以从上述URL中获取, 也可以从" +"hibernate-x.x.x/src/net/sf/hibernate目录中、 或" +"hibernate.jar文件中找到。Hibernate总是会首先在它的" +"classptah中搜索DTD文件。 如果你发现它是通过连接Internet查找DTD文件,就对照你" +"的classpath目录检查XML文件里的DTD声明。" -#: index.docbook:52 +#. Tag: title +#: basic_mapping.xml:52 +#, no-c-format msgid "EntityResolver" -msgstr "" +msgstr "EntityResolver" -#: index.docbook:53 -msgid "As mentioned previously, Hibernate will first attempt to resolve DTDs in its classpath. The manner in which it does this is by registering a custom org.xml.sax.EntityResolver implementation with the SAXReader it uses to read in the xml files. This custom EntityResolver recognizes two different systemId namespaces." +#. Tag: para +#: basic_mapping.xml:53 +#, no-c-format +msgid "" +"As mentioned previously, Hibernate will first attempt to resolve DTDs in its " +"classpath. The manner in which it does this is by registering a custom " +"org.xml.sax.EntityResolver implementation with the " +"SAXReader it uses to read in the xml files. This custom " +"EntityResolver recognizes two different systemId " +"namespaces." msgstr "" +"As mentioned previously, Hibernate will first attempt to resolve DTDs in its " +"classpath. The manner in which it does this is by registering a custom " +"org.xml.sax.EntityResolver implementation with the " +"SAXReader it uses to read in the xml files. This custom " +"EntityResolver recognizes two different systemId " +"namespaces. 如前所述,Hibernate首先在其classpath中查找DTD。其行为是依靠在系统" +"中注册的org.xml.sax.EntityResolver的一个具体实现," +"SAXReader依靠它来读取xml文件。这一 EntityResolver 实现能辨" +"认两种不同的 systenId命名空间。" -#: index.docbook:61 -msgid "a hibernate namespace is recognized whenever the resolver encounteres a systemId starting with http://hibernate.sourceforge.net/; the resolver attempts to resolve these entities via the classlaoder which loaded the Hibernate classes." +#. Tag: para +#: basic_mapping.xml:61 +#, no-c-format +msgid "" +"a hibernate namespace is recognized whenever the resolver " +"encounteres a systemId starting with http://hibernate.sourceforge." +"net/; the resolver attempts to resolve these entities via the " +"classlaoder which loaded the Hibernate classes." msgstr "" +"若resolver遇到了一个以http://hibernate.sourceforge.net/为" +"开头的systemId,它会辨认出是hibernate namespace,resolver" +"就试图通过加载Hibernate类的classloader来查找这些实体。" -#: index.docbook:70 -msgid "a user namespace is recognized whenever the resolver encounteres a systemId using a classpath:// URL protocol; the resolver will attempt to resolve these entities via (1) the current thread context classloader and (2) the classloader which loaded the Hibernate classes." +#. Tag: para +#: basic_mapping.xml:70 +#, no-c-format +msgid "" +"a user namespace is recognized whenever the resolver " +"encounteres a systemId using a classpath:// URL protocol; " +"the resolver will attempt to resolve these entities via (1) the current " +"thread context classloader and (2) the classloader which loaded the " +"Hibernate classes." msgstr "" +"若resolver遇到了一个使用classpath://URL协议的systemId,它" +"会辨认出这是user namespace,resolver试图通过(1)当前线程上下" +"文的classloader和(2)加载Hibernate class的classloader来查找这些实体。" -#: index.docbook:79 +#. Tag: para +#: basic_mapping.xml:79 +#, no-c-format msgid "An example of utilizing user namespacing:" -msgstr "" +msgstr "使用user namespace(用户命名空间)的例子:" -#: index.docbook:82 +#. Tag: programlisting +#: basic_mapping.xml:82 +#, no-c-format msgid "" - "\n" - "\n" - "]>\n" - "\n" - "\n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " &types;\n" - "]]>" +"\n" +"\n" +"]>\n" +"\n" +"\n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" &types;\n" +"]]>" msgstr "" -#: index.docbook:83 -msgid "Where types.xml is a resource in the your.domain package and contains a custom typedef." +#. Tag: para +#: basic_mapping.xml:83 +#, fuzzy, no-c-format +msgid "" +"Where types.xml is a resource in the your." +"domain package and contains a custom typedef." msgstr "" +"types.xmlyour.domain包中的一个资源," +"它包含了一个定制的typedef。" -#: index.docbook:91 +#. Tag: title +#: basic_mapping.xml:91 +#, no-c-format msgid "hibernate-mapping" -msgstr "" +msgstr "hibernate-mapping" -#: index.docbook:93 -msgid "This element has several optional attributes. The schema and catalog attributes specify that tables referred to in this mapping belong to the named schema and/or catalog. If specified, tablenames will be qualified by the given schema and catalog names. If missing, tablenames will be unqualified. The default-cascade attribute specifies what cascade style should be assumed for properties and collections which do not specify a cascade attribute. The auto-import attribute lets us use unqualified class names in the query language, by default." -msgstr "" - -#: index.docbook:114 +#. Tag: para +#: basic_mapping.xml:93 +#, no-c-format msgid "" - "]]>" +"This element has several optional attributes. The schema " +"and catalog attributes specify that tables referred to in " +"this mapping belong to the named schema and/or catalog. If specified, " +"tablenames will be qualified by the given schema and catalog names. If " +"missing, tablenames will be unqualified. The default-cascade attribute specifies what cascade style should be assumed for " +"properties and collections which do not specify a cascade " +"attribute. The auto-import attribute lets us use " +"unqualified class names in the query language, by default." +msgstr "" +"这个元素包括一些可选的属性。schemacatalog属性, 指明了这个映射所连接(refer)的表所在的schema和/或catalog名" +"称。 假若指定了这个属性,表名会加上所指定的schema和catalog的名字扩展为全限定" +"名。假若没有指定,表名就不会使用全限定名。 default-cascade" +"指定了未明确注明cascade属性的Java属性和 集合类Hibernate会" +"采取什么样的默认级联风格。auto-import属性默认让我们在查询" +"语言中可以使用 非全限定名的类名。" + +#. Tag: programlisting +#: basic_mapping.xml:114 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:117 +#. Tag: para +#: basic_mapping.xml:117 +#, no-c-format msgid "schema (optional): The name of a database schema." -msgstr "" +msgstr "schema (可选): 数据库schema的名称。" -#: index.docbook:122 +#. Tag: para +#: basic_mapping.xml:122 +#, no-c-format msgid "catalog (optional): The name of a database catalog." -msgstr "" +msgstr "catalog (可选): 数据库catalog的名称。" -#: index.docbook:127 -msgid "default-cascade (optional - defaults to none): A default cascade style." +#. Tag: para +#: basic_mapping.xml:127 +#, no-c-format +msgid "" +"default-cascade (optional - defaults to none): A default cascade style." msgstr "" +"default-cascade (可选 - 默认为 none): " +"默认的级联风格。" -#: index.docbook:133 -msgid "default-access (optional - defaults to property): The strategy Hibernate should use for accessing all properties. Can be a custom implementation of PropertyAccessor." +#. Tag: para +#: basic_mapping.xml:133 +#, no-c-format +msgid "" +"default-access (optional - defaults to property): The strategy Hibernate should use for accessing all properties. " +"Can be a custom implementation of PropertyAccessor." msgstr "" +"default-access (可选 - 默认为 property): Hibernate用来访问所有属性的策略。可以通过实现" +"PropertyAccessor接口 自定义。" -#: index.docbook:140 -msgid "default-lazy (optional - defaults to true): The default value for unspecifed lazy attributes of class and collection mappings." +#. Tag: para +#: basic_mapping.xml:140 +#, no-c-format +msgid "" +"default-lazy (optional - defaults to true): The default value for unspecifed lazy " +"attributes of class and collection mappings." msgstr "" +"default-lazy (可选 - 默认为 true): 指定" +"了未明确注明lazy属性的Java属性和集合类, Hibernate会采取什" +"么样的默认加载风格。" -#: index.docbook:147 -msgid "auto-import (optional - defaults to true): Specifies whether we can use unqualified class names (of classes in this mapping) in the query language." +#. Tag: para +#: basic_mapping.xml:147 +#, no-c-format +msgid "" +"auto-import (optional - defaults to true): Specifies whether we can use unqualified class names (of classes " +"in this mapping) in the query language." msgstr "" +"auto-import (可选 - 默认为 true): 指定" +"我们是否可以在查询语言中使用非全限定的类名(仅限于本映射文件中的类)。" -#: index.docbook:154 -msgid "package (optional): Specifies a package prefix to assume for unqualified class names in the mapping document." +#. Tag: para +#: basic_mapping.xml:154 +#, no-c-format +msgid "" +"package (optional): Specifies a package prefix to assume " +"for unqualified class names in the mapping document." msgstr "" +"package (可选): 指定一个包前缀,如果在映射文档中没有指定全" +"限定的类名, 就使用这个作为包名。" -#: index.docbook:162 -msgid "If you have two persistent classes with the same (unqualified) name, you should set auto-import=\"false\". Hibernate will throw an exception if you attempt to assign two classes to the same \"imported\" name." +#. Tag: para +#: basic_mapping.xml:162 +#, no-c-format +msgid "" +"If you have two persistent classes with the same (unqualified) name, you " +"should set auto-import=\"false\". Hibernate will throw an " +"exception if you attempt to assign two classes to the same \"imported\" name." msgstr "" +"假若你有两个持久化类,它们的非全限定名是一样的(就是两个类的名字一样,所在的" +"包不一样--译者注), 你应该设置auto-import=\"false\"。如果" +"你把一个“import过”的名字同时对应两个类, Hibernate会抛出一个异常。" -#: index.docbook:168 -msgid "Note that the hibernate-mapping element allows you to nest several persistent <class> mappings, as shown above. It is however good practice (and expected by some tools) to map only a single persistent class (or a single class hierarchy) in one mapping file and name it after the persistent superclass, e.g. Cat.hbm.xml, Dog.hbm.xml, or if using inheritance, Animal.hbm.xml." +#. Tag: para +#: basic_mapping.xml:168 +#, no-c-format +msgid "" +"Note that the hibernate-mapping element allows you to " +"nest several persistent <class> mappings, as shown " +"above. It is however good practice (and expected by some tools) to map only " +"a single persistent class (or a single class hierarchy) in one mapping file " +"and name it after the persistent superclass, e.g. Cat.hbm.xml, Dog.hbm.xml, or if using inheritance, " +"Animal.hbm.xml." msgstr "" +"注意hibernate-mapping 元素允许你嵌套多个如上所示的 " +"<class>映射。但是最好的做法(也许一些工具需要的)是" +"一个 持久化类(或一个类的继承层次)对应一个映射文件,并以持久化的超类名称命" +"名,例如: Cat.hbm.xmlDog.hbm.xml," +"或者如果使用继承,Animal.hbm.xml。" -#: index.docbook:181 +#. Tag: title +#: basic_mapping.xml:181 +#, no-c-format msgid "class" msgstr "" -#: index.docbook:183 -msgid "You may declare a persistent class using the class element:" -msgstr "" - -#: index.docbook:211 +#. Tag: para +#: basic_mapping.xml:183 +#, no-c-format msgid "" - "]]>" +"You may declare a persistent class using the class " +"element:" +msgstr "你可以使用class元素来定义一个持久化类:" + +#. Tag: programlisting +#: basic_mapping.xml:211 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:214 -msgid "name (optional): The fully qualified Java class name of the persistent class (or interface). If this attribute is missing, it is assumed that the mapping is for a non-POJO entity." +#. Tag: para +#: basic_mapping.xml:214 +#, no-c-format +msgid "" +"name (optional): The fully qualified Java class name of " +"the persistent class (or interface). If this attribute is missing, it is " +"assumed that the mapping is for a non-POJO entity." msgstr "" +"name (可选): 持久化类(或者接口)的Java全限定名。 如果这个" +"属性不存在,Hibernate将假定这是一个非POJO的实体映射。" -#: index.docbook:221 -msgid "table (optional - defaults to the unqualified class name): The name of its database table." +#. Tag: para +#: basic_mapping.xml:221 +#, no-c-format +msgid "" +"table (optional - defaults to the unqualified class " +"name): The name of its database table." msgstr "" +"table (可选 - 默认是类的非全限定名): 对应的数据库表名。" -#: index.docbook:227 -msgid "discriminator-value (optional - defaults to the class name): A value that distiguishes individual subclasses, used for polymorphic behaviour. Acceptable values include null and not null." +#. Tag: para +#: basic_mapping.xml:227 +#, no-c-format +msgid "" +"discriminator-value (optional - defaults to the class " +"name): A value that distiguishes individual subclasses, used for polymorphic " +"behaviour. Acceptable values include null and " +"not null." msgstr "" +"discriminator-value (可选 - 默认和类名一样): 一个用于区分" +"不同的子类的值,在多态行为时使用。它可以接受的值包括 null " +"和 not null。" -#: index.docbook:234 -msgid "mutable (optional, defaults to true): Specifies that instances of the class are (not) mutable." +#. Tag: para +#: basic_mapping.xml:234 +#, no-c-format +msgid "" +"mutable (optional, defaults to true): " +"Specifies that instances of the class are (not) mutable." msgstr "" +"mutable (可选,默认值为true): 表明该类" +"的实例是可变的或者不可变的。" -#: index.docbook:240, index.docbook:2204 -msgid "schema (optional): Override the schema name specified by the root <hibernate-mapping> element." +#. Tag: para +#: basic_mapping.xml:240 basic_mapping.xml:2204 +#, fuzzy, no-c-format +msgid "" +"schema (optional): Override the schema name specified by " +"the root <hibernate-mapping> element." msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"schema (可选): 覆盖在根<hibernate-mapping>" +"元素中指定的schema名字。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"schema (可选):覆盖由根<hibernate-mapping>元素指定的模式名称。" -#: index.docbook:246, index.docbook:2210 -msgid "catalog (optional): Override the catalog name specified by the root <hibernate-mapping> element." +#. Tag: para +#: basic_mapping.xml:246 basic_mapping.xml:2210 +#, fuzzy, no-c-format +msgid "" +"catalog (optional): Override the catalog name specified " +"by the root <hibernate-mapping> element." msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"catalog (可选): 覆盖在根<hibernate-mapping>" +"元素中指定的catalog名字。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"catalog (可选): 覆盖由根 <hibernate-" +"mapping>元素指定的目录名称。" -#: index.docbook:252 -msgid "proxy (optional): Specifies an interface to use for lazy initializing proxies. You may specify the name of the class itself." +#. Tag: para +#: basic_mapping.xml:252 +#, no-c-format +msgid "" +"proxy (optional): Specifies an interface to use for lazy " +"initializing proxies. You may specify the name of the class itself." msgstr "" +"proxy (可选): 指定一个接口,在延迟装载时作为代理使用。 你" +"可以在这里使用该类自己的名字。" -#: index.docbook:258 -msgid "dynamic-update (optional, defaults to false): Specifies that UPDATE SQL should be generated at runtime and contain only those columns whose values have changed." +#. Tag: para +#: basic_mapping.xml:258 +#, no-c-format +msgid "" +"dynamic-update (optional, defaults to false): Specifies that UPDATE SQL should be generated " +"at runtime and contain only those columns whose values have changed." msgstr "" +"dynamic-update (可选, 默认为 false): 指" +"定用于UPDATE 的SQL将会在运行时动态生成,并且只更新那些改变" +"过的字段。" -#: index.docbook:265 -msgid "dynamic-insert (optional, defaults to false): Specifies that INSERT SQL should be generated at runtime and contain only the columns whose values are not null." +#. Tag: para +#: basic_mapping.xml:265 +#, no-c-format +msgid "" +"dynamic-insert (optional, defaults to false): Specifies that INSERT SQL should be generated " +"at runtime and contain only the columns whose values are not null." msgstr "" +"dynamic-insert (可选, 默认为 false): 指" +"定用于INSERT的 SQL 将会在运行时动态生成,并且只包含那些非" +"空值字段。" -#: index.docbook:272 -msgid "select-before-update (optional, defaults to false): Specifies that Hibernate should never perform an SQL UPDATE unless it is certain that an object is actually modified. In certain cases (actually, only when a transient object has been associated with a new session using update()), this means that Hibernate will perform an extra SQL SELECT to determine if an UPDATE is actually required." +#. Tag: para +#: basic_mapping.xml:272 +#, no-c-format +msgid "" +"select-before-update (optional, defaults to " +"false): Specifies that Hibernate should never perform an SQL UPDATE unless it is certain that " +"an object is actually modified. In certain cases (actually, only when a " +"transient object has been associated with a new session using update" +"()), this means that Hibernate will perform an extra SQL " +"SELECT to determine if an UPDATE is " +"actually required." msgstr "" +"select-before-update (可选, 默认为 false): 指定Hibernate除非确定对象真正被修改了(如果该值为true-译注),否" +"则不会执行SQL UPDATE操作。在特定场合" +"(实际上,它只在一个瞬时对象(transient object)关联到一个 新的session中时执" +"行的update()中生效),这说明Hibernate会在UPDATE 之前执行一" +"次额外的SQL SELECT操作,来决定是否应该执行 " +"UPDATE。" -#: index.docbook:282 -msgid "polymorphism (optional, defaults to implicit): Determines whether implicit or explicit query polymorphism is used." +#. Tag: para +#: basic_mapping.xml:282 +#, no-c-format +msgid "" +"polymorphism (optional, defaults to implicit): Determines whether implicit or explicit query polymorphism is " +"used." msgstr "" +"polymorphism(多态) (可选, 默认值为 implicit (隐" +"式) ): 界定是隐式还是显式的使用多态查询(这只在Hibernate的具体表继" +"承策略中用到-译注)。" -#: index.docbook:288 -msgid "where (optional) specify an arbitrary SQL WHERE condition to be used when retrieving objects of this class" +#. Tag: para +#: basic_mapping.xml:288 +#, no-c-format +msgid "" +"where (optional) specify an arbitrary SQL WHERE condition to be used when retrieving objects of this class" msgstr "" +"where (可选) 指定一个附加的SQLWHERE 条" +"件, 在抓取这个类的对象时会一直增加这个条件。" -#: index.docbook:294 -msgid "persister (optional): Specifies a custom ClassPersister." +#. Tag: para +#: basic_mapping.xml:294 +#, no-c-format +msgid "" +"persister (optional): Specifies a custom " +"ClassPersister." msgstr "" +"persister (可选): 指定一个定制的ClassPersister。" -#: index.docbook:299 -msgid "batch-size (optional, defaults to 1) specify a \"batch size\" for fetching instances of this class by identifier." +#. Tag: para +#: basic_mapping.xml:299 +#, no-c-format +msgid "" +"batch-size (optional, defaults to 1) " +"specify a \"batch size\" for fetching instances of this class by identifier." msgstr "" +"batch-size (可选,默认是1) 指定一个用于 " +"根据标识符(identifier)抓取实例时使用的\"batch size\"(批次抓取数量)。" -#: index.docbook:305 -msgid "optimistic-lock (optional, defaults to version): Determines the optimistic locking strategy." +#. Tag: para +#: basic_mapping.xml:305 +#, no-c-format +msgid "" +"optimistic-lock (optional, defaults to version): Determines the optimistic locking strategy." msgstr "" +"optimistic-lock(乐观锁定) (可选,默认是" +"version): 决定乐观锁定的策略。" -#: index.docbook:311 -msgid "lazy (optional): Lazy fetching may be completely disabled by setting lazy=\"false\"." +#. Tag: para +#: basic_mapping.xml:311 +#, no-c-format +msgid "" +"lazy (optional): Lazy fetching may be completely disabled " +"by setting lazy=\"false\"." msgstr "" +"lazy (可选): 通过设置lazy=\"false\", " +"所有的延迟加载(Lazy fetching)功能将被全部禁用(disabled)。" -#: index.docbook:317 -msgid "entity-name (optional, defaults to the class name): Hibernate3 allows a class to be mapped multiple times (to different tables, potentially), and allows entity mappings that are represented by Maps or XML at the Java level. In these cases, you should provide an explicit arbitrary name for the entity. See and for more information." +#. Tag: para +#: basic_mapping.xml:317 +#, no-c-format +msgid "" +"entity-name (optional, defaults to the class name): " +"Hibernate3 allows a class to be mapped multiple times (to different tables, " +"potentially), and allows entity mappings that are represented by Maps or XML " +"at the Java level. In these cases, you should provide an explicit arbitrary " +"name for the entity. See and for more information." msgstr "" +"entity-name (可选,默认为类名): Hibernate3允许一个类进行多" +"次映射( 前提是映射到不同的表),并且允许使用Maps或XML代替Java层次的实体映射 " +"(也就是实现动态领域模型,不用写持久化类-译注)。 更多信息请看 and 。" -#: index.docbook:327 -msgid "check (optional): A SQL expression used to generate a multi-row check constraint for automatic schema generation." +#. Tag: para +#: basic_mapping.xml:327 +#, no-c-format +msgid "" +"check (optional): A SQL expression used to generate a " +"multi-row check constraint for automatic schema " +"generation." msgstr "" +"check (可选): 这是一个SQL表达式, 用于为自动生成的schema添" +"加多行(multi-row)约束检查。" -#: index.docbook:333 -msgid "rowid (optional): Hibernate can use so called ROWIDs on databases which support. E.g. on Oracle, Hibernate can use the rowid extra column for fast updates if you set this option to rowid. A ROWID is an implementation detail and represents the physical location of a stored tuple." +#. Tag: para +#: basic_mapping.xml:333 +#, no-c-format +msgid "" +"rowid (optional): Hibernate can use so called ROWIDs on " +"databases which support. E.g. on Oracle, Hibernate can use the " +"rowid extra column for fast updates if you set this " +"option to rowid. A ROWID is an implementation detail and " +"represents the physical location of a stored tuple." msgstr "" +"rowid (可选): Hibernate可以使用数据库支持的所谓的ROWIDs," +"例如: Oracle数据库,如果你设置这个可选的rowid, Hibernate" +"可以使用额外的字段rowid实现快速更新。ROWID是这个功能实现的" +"重点, 它代表了一个存储元组(tuple)的物理位置。" -#: index.docbook:341 -msgid "subselect (optional): Maps an immutable and read-only entity to a database subselect. Useful if you want to have a view instead of a base table, but don't. See below for more information." +#. Tag: para +#: basic_mapping.xml:341 +#, no-c-format +msgid "" +"subselect (optional): Maps an immutable and read-only " +"entity to a database subselect. Useful if you want to have a view instead of " +"a base table, but don't. See below for more information." msgstr "" +"subselect (可选): 它将一个不可变(immutable)并且只读的实" +"体映射到一个数据库的 子查询中。当你想用视图代替一张基本表的时候,这是有用的," +"但最好不要这样做。更多的介绍请看下面内容。" -#: index.docbook:348 -msgid "abstract (optional): Used to mark abstract superclasses in <union-subclass> hierarchies." +#. Tag: para +#: basic_mapping.xml:348 +#, no-c-format +msgid "" +"abstract (optional): Used to mark abstract superclasses " +"in <union-subclass> hierarchies." msgstr "" +"abstract (可选): 用于在<union-subclass>的继承结构 (hierarchies)中标识抽象超类。" -#: index.docbook:356 -msgid "It is perfectly acceptable for the named persistent class to be an interface. You would then declare implementing classes of that interface using the <subclass> element. You may persist any static inner class. You should specify the class name using the standard form ie. eg.Foo$Bar." +#. Tag: para +#: basic_mapping.xml:356 +#, no-c-format +msgid "" +"It is perfectly acceptable for the named persistent class to be an " +"interface. You would then declare implementing classes of that interface " +"using the <subclass> element. You may persist any " +"static inner class. You should specify the class name " +"using the standard form ie. eg.Foo$Bar." msgstr "" +"若指明的持久化类实际上是一个接口,这也是完全可以接受的。 之后你可以用元素" +"<subclass>来指定该接口的实际实现类。 你可以持久化任" +"何static(静态的)内部类。 你应该使用标准的类名格式来指" +"定类名,比如:Foo$Bar。" -#: index.docbook:363 -msgid "Immutable classes, mutable=\"false\", may not be updated or deleted by the application. This allows Hibernate to make some minor performance optimizations." +#. Tag: para +#: basic_mapping.xml:363 +#, no-c-format +msgid "" +"Immutable classes, mutable=\"false\", may not be updated " +"or deleted by the application. This allows Hibernate to make some minor " +"performance optimizations." msgstr "" +"不可变类,mutable=\"false\"不可以被应用程序更新或者删除。 " +"这可以让Hibernate做一些小小的性能优化。" -#: index.docbook:368 -msgid "The optional proxy attribute enables lazy initialization of persistent instances of the class. Hibernate will initially return CGLIB proxies which implement the named interface. The actual persistent object will be loaded when a method of the proxy is invoked. See \"Initializing collections and proxies\" below." +#. Tag: para +#: basic_mapping.xml:368 +#, no-c-format +msgid "" +"The optional proxy attribute enables lazy initialization " +"of persistent instances of the class. Hibernate will initially return CGLIB " +"proxies which implement the named interface. The actual persistent object " +"will be loaded when a method of the proxy is invoked. See \"Initializing " +"collections and proxies\" below." msgstr "" +"可选的proxy属性允许延迟加载类的持久化实例。 Hibernate开始" +"会返回实现了这个命名接口的CGLIB代理。当代理的某个方法被实际调用的时候, 真实" +"的持久化对象才会被装载。参见下面的“用于延迟装载的代理”。" -#: index.docbook:375 -msgid "Implicit polymorphism means that instances of the class will be returned by a query that names any superclass or implemented interface or the class and that instances of any subclass of the class will be returned by a query that names the class itself. Explicit polymorphism means that class instances will be returned only by queries that explicitly name that class and that queries that name the class will return only instances of subclasses mapped inside this <class> declaration as a <subclass> or <joined-subclass>. For most purposes the default, polymorphism=\"implicit\", is appropriate. Explicit polymorphism is useful when two different classes are mapped to the same table (this allows a \"lightweight\" class that contains a subset of the table columns)." +#. Tag: para +#: basic_mapping.xml:375 +#, no-c-format +msgid "" +"Implicit polymorphism means that instances of the class " +"will be returned by a query that names any superclass or implemented " +"interface or the class and that instances of any subclass of the class will " +"be returned by a query that names the class itself. Explicit polymorphism means that class instances will be returned only by " +"queries that explicitly name that class and that queries that name the class " +"will return only instances of subclasses mapped inside this <" +"class> declaration as a <subclass> or " +"<joined-subclass>. For most purposes the default, " +"polymorphism=\"implicit\", is appropriate. Explicit " +"polymorphism is useful when two different classes are mapped to the same " +"table (this allows a \"lightweight\" class that contains a subset of the " +"table columns)." msgstr "" +"Implicit (隐式)的多态是指,如果查询时给出的是任何超类、" +"该类实现的接口或者该类的 名字,都会返回这个类的实例;如果查询中给出的是子类的" +"名字,则会返回子类的实例。 Explicit (显式)的多态是指," +"只有在查询时给出明确的该类名字时才会返回这个类的实例; 同时只有在这个" +"<class>的定义中作为<subclass> 或者<joined-subclass>出现的子类,才会可能返" +"回。 在大多数情况下,默认的polymorphism=\"implicit\"都是合" +"适的。 显式的多态在有两个不同的类映射到同一个表的时候很有用。(允许一个“轻" +"型”的类,只包含部分表字段)。" -#: index.docbook:387 -msgid "The persister attribute lets you customize the persistence strategy used for the class. You may, for example, specify your own subclass of org.hibernate.persister.EntityPersister or you might even provide a completely new implementation of the interface org.hibernate.persister.ClassPersister that implements persistence via, for example, stored procedure calls, serialization to flat files or LDAP. See org.hibernate.test.CustomPersister for a simple example (of \"persistence\" to a Hashtable)." +#. Tag: para +#: basic_mapping.xml:387 +#, no-c-format +msgid "" +"The persister attribute lets you customize the " +"persistence strategy used for the class. You may, for example, specify your " +"own subclass of org.hibernate.persister.EntityPersister " +"or you might even provide a completely new implementation of the interface " +"org.hibernate.persister.ClassPersister that implements " +"persistence via, for example, stored procedure calls, serialization to flat " +"files or LDAP. See org.hibernate.test.CustomPersister for " +"a simple example (of \"persistence\" to a Hashtable)." msgstr "" +"persister属性可以让你定制这个类使用的持久化策略。 你可以指" +"定你自己实现 org.hibernate.persister.EntityPersister的子" +"类,你甚至可以完全从头开始编写一个 org.hibernate.persister." +"ClassPersister接口的实现, 比如是用储存过程调用、序列化到文件或者" +"LDAP数据库来实现。 参阅org.hibernate.test.CustomPersister,这是一个简单的例子 (“持久化”到一个Hashtable)。" -#: index.docbook:398 -msgid "Note that the dynamic-update and dynamic-insert settings are not inherited by subclasses and so may also be specified on the <subclass> or <joined-subclass> elements. These settings may increase performance in some cases, but might actually decrease performance in others. Use judiciously." +#. Tag: para +#: basic_mapping.xml:398 +#, no-c-format +msgid "" +"Note that the dynamic-update and dynamic-insert settings are not inherited by subclasses and so may also be " +"specified on the <subclass> or <joined-" +"subclass> elements. These settings may increase performance in " +"some cases, but might actually decrease performance in others. Use " +"judiciously." msgstr "" +"请注意dynamic-updatedynamic-insert的" +"设置并不会继承到子类, 所以在<subclass>或者" +"<joined-subclass>元素中可能 需要再次设置。这些设置是" +"否能够提高效率要视情形而定。请用你的智慧决定是否使用。" -#: index.docbook:406 -msgid "Use of select-before-update will usually decrease performance. It is very useful to prevent a database update trigger being called unnecessarily if you reattach a graph of detached instances to a Session." +#. Tag: para +#: basic_mapping.xml:406 +#, no-c-format +msgid "" +"Use of select-before-update will usually decrease " +"performance. It is very useful to prevent a database update trigger being " +"called unnecessarily if you reattach a graph of detached instances to a " +"Session." msgstr "" +"使用select-before-update通常会降低性能。如果你重新连接一个" +"脱管(detache)对象实例 到一个Session中时,它可以防止数据" +"库不必要的触发update。 这就很有用了。" -#: index.docbook:412 -msgid "If you enable dynamic-update, you will have a choice of optimistic locking strategies:" +#. Tag: para +#: basic_mapping.xml:412 +#, no-c-format +msgid "" +"If you enable dynamic-update, you will have a choice of " +"optimistic locking strategies:" msgstr "" +"如果你打开了dynamic-update,你可以选择几种乐观锁定的策略:" -#: index.docbook:418 +#. Tag: para +#: basic_mapping.xml:418 +#, no-c-format msgid "version check the version/timestamp columns" -msgstr "" +msgstr "version(版本检查) 检查version/timestamp字段" -#: index.docbook:423 +#. Tag: para +#: basic_mapping.xml:423 +#, no-c-format msgid "all check all columns" -msgstr "" +msgstr "all(全部) 检查全部字段" -#: index.docbook:428 -msgid "dirty check the changed columns, allowing some concurrent updates" -msgstr "" - -#: index.docbook:433 -msgid "none do not use optimistic locking" -msgstr "" - -#: index.docbook:438 -msgid "We very strongly recommend that you use version/timestamp columns for optimistic locking with Hibernate. This is the optimal strategy with respect to performance and is the only strategy that correctly handles modifications made to detached instances (ie. when Session.merge() is used)." -msgstr "" - -#: index.docbook:445 -msgid "There is no difference between a view and a base table for a Hibernate mapping, as expected this is transparent at the database level (note that some DBMS don't support views properly, especially with updates). Sometimes you want to use a view, but can't create one in the database (ie. with a legacy schema). In this case, you can map an immutable and read-only entity to a given SQL subselect expression:" -msgstr "" - -#: index.docbook:453 +#. Tag: para +#: basic_mapping.xml:428 +#, no-c-format msgid "" - "\n" - " \n" - " select item.name, max(bid.amount), count(*)\n" - " from item\n" - " join bid on bid.item_id = item.id\n" - " group by item.name\n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - "]]>" +"dirty check the changed columns, allowing some concurrent " +"updates" +msgstr "dirty(脏检查)只检察修改过的字段" + +#. Tag: para +#: basic_mapping.xml:433 +#, no-c-format +msgid "none do not use optimistic locking" +msgstr "none(不检查)不使用乐观锁定" + +#. Tag: para +#: basic_mapping.xml:438 +#, no-c-format +msgid "" +"We very strongly recommend that you use version/" +"timestamp columns for optimistic locking with Hibernate. This is the optimal " +"strategy with respect to performance and is the only strategy that correctly " +"handles modifications made to detached instances (ie. when Session." +"merge() is used)." +msgstr "" +"我们非常强烈建议你在Hibernate中使用version/timestamp字段" +"来进行乐观锁定。 对性能来说,这是最好的选择,并且这也是唯一能够处理在session" +"外进行操作的策略(例如: 在使用Session.merge()的时候)。" + +#. Tag: para +#: basic_mapping.xml:445 +#, no-c-format +msgid "" +"There is no difference between a view and a base table for a Hibernate " +"mapping, as expected this is transparent at the database level (note that " +"some DBMS don't support views properly, especially with updates). Sometimes " +"you want to use a view, but can't create one in the database (ie. with a " +"legacy schema). In this case, you can map an immutable and read-only entity " +"to a given SQL subselect expression:" +msgstr "" +"对Hibernate映射来说视图和表是没有区别的,这是因为它们在数据层都是透明的( 注" +"意:一些数据库不支持视图属性,特别是更新的时候)。有时你想使用视图,但却不能" +"在数据库 中创建它(例如:在遗留的schema中)。这样的话,你可以映射一个不可变的" +"(immutable)并且是 只读的实体到一个给定的SQL子查询表达式:" + +#. Tag: programlisting +#: basic_mapping.xml:453 +#, no-c-format +msgid "" +"\n" +" \n" +" select item.name, max(bid.amount), count(*)\n" +" from item\n" +" join bid on bid.item_id = item.id\n" +" group by item.name\n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +"]]>" msgstr "" -#: index.docbook:455 -msgid "Declare the tables to synchronize this entity with, ensuring that auto-flush happens correctly, and that queries against the derived entity do not return stale data. The <subselect> is available as both as an attribute and a nested mapping element." +#. Tag: para +#: basic_mapping.xml:455 +#, no-c-format +msgid "" +"Declare the tables to synchronize this entity with, ensuring that auto-flush " +"happens correctly, and that queries against the derived entity do not return " +"stale data. The <subselect> is available as both as " +"an attribute and a nested mapping element." msgstr "" +"定义这个实体用到的表为同步(synchronize),确保自动刷新(auto-flush)正确执" +"行, 并且依赖原实体的查询不会返回过期数据。<subselect>在属性元素 和一个嵌套映射元素中都可见。" -#: index.docbook:465 +#. Tag: title +#: basic_mapping.xml:465 +#, no-c-format msgid "id" msgstr "" -#: index.docbook:467 -msgid "Mapped classes must declare the primary key column of the database table. Most classes will also have a JavaBeans-style property holding the unique identifier of an instance. The <id> element defines the mapping from that property to the primary key column." -msgstr "" - -#: index.docbook:482 +#. Tag: para +#: basic_mapping.xml:467 +#, no-c-format msgid "" - "\n" - " node=\"element-name|@attribute-name|element/@attribute|.\"\n" - "\n" - " \n" - "]]>" +"Mapped classes must declare the primary key column of " +"the database table. Most classes will also have a JavaBeans-style property " +"holding the unique identifier of an instance. The <id> element defines the mapping from that property to the primary key " +"column." +msgstr "" +"被映射的类必须定义对应数据库表主键字段。大多数类有一个" +"JavaBeans风格的属性, 为每一个实例包含唯一的标识。<id> 元素定义了该属性到数据库表主键字段的映射。" + +#. Tag: programlisting +#: basic_mapping.xml:482 +#, no-c-format +msgid "" +"\n" +" node=\"element-name|@attribute-name|element/@attribute|.\"\n" +"\n" +" \n" +"]]>" msgstr "" -#: index.docbook:485 -msgid "name (optional): The name of the identifier property." -msgstr "" +#. Tag: para +#: basic_mapping.xml:485 +#, no-c-format +msgid "" +"name (optional): The name of the identifier property." +msgstr "name (可选): 标识属性的名字。" -#: index.docbook:490 -msgid "type (optional): A name that indicates the Hibernate type." -msgstr "" +#. Tag: para +#: basic_mapping.xml:490 +#, no-c-format +msgid "" +"type (optional): A name that indicates the Hibernate type." +msgstr "type (可选): 标识Hibernate类型的名字。" -#: index.docbook:495 -msgid "column (optional - defaults to the property name): The name of the primary key column." -msgstr "" +#. Tag: para +#: basic_mapping.xml:495 +#, no-c-format +msgid "" +"column (optional - defaults to the property name): The " +"name of the primary key column." +msgstr "column (可选 - 默认为属性名): 主键字段的名字。" -#: index.docbook:501 -msgid "unsaved-value (optional - defaults to a \"sensible\" value): An identifier property value that indicates that an instance is newly instantiated (unsaved), distinguishing it from detached instances that were saved or loaded in a previous session." +#. Tag: para +#: basic_mapping.xml:501 +#, no-c-format +msgid "" +"unsaved-value (optional - defaults to a \"sensible\" " +"value): An identifier property value that indicates that an instance is " +"newly instantiated (unsaved), distinguishing it from detached instances that " +"were saved or loaded in a previous session." msgstr "" +"unsaved-value (可选 - 默认为一个切合实际(sensible)的" +"值): 一个特定的标识属性值,用来标志该实例是刚刚创建的,尚未保存。 这可以把这" +"种实例和从以前的session中装载过(可能又做过修改--译者注) 但未再次持久化的实" +"例区分开来。" -#: index.docbook:509, index.docbook:1017, index.docbook:1156, index.docbook:1238, index.docbook:1345, index.docbook:1534, index.docbook:1708, index.docbook:1878, index.docbook:2457 -msgid "access (optional - defaults to property): The strategy Hibernate should use for accessing the property value." +#. Tag: para +#: basic_mapping.xml:509 basic_mapping.xml:1017 basic_mapping.xml:1156 +#: basic_mapping.xml:1238 basic_mapping.xml:1345 basic_mapping.xml:1534 +#: basic_mapping.xml:1708 basic_mapping.xml:1878 basic_mapping.xml:2457 +#, fuzzy, no-c-format +msgid "" +"access (optional - defaults to property): The strategy Hibernate should use for accessing the property " +"value." msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"access (可选 - 默认为property): " +"Hibernate用来访问属性值的策略。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"access (可选 - 默认为property): " +"Hibernate应该使用的访问此属性值的策略\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"access (可选 - 默认是 property): " +"Hibernate用于访问属性值的策略。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"access (可选 - 默认是 property): " +"Hibernate用于访问属性值的策略。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"access (可选 - 默认值为 property): " +"Hibernate用来访问属性值的策略。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"access (可选 - 默认是 property): " +"Hibernate用来访问属性的策略。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"access (可选 - 默认是 property): " +"Hibernate用来访问属性的策略。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"access (可选 - 默认是 property): " +"Hibernate用来访问属性的策略。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"access (可选 -默认是 property): " +"Hibernate 用来访问属性值的策略。" -#: index.docbook:517 -msgid "If the name attribute is missing, it is assumed that the class has no identifier property." +#. Tag: para +#: basic_mapping.xml:517 +#, no-c-format +msgid "" +"If the name attribute is missing, it is assumed that the " +"class has no identifier property." +msgstr "如果 name属性不存在,会认为这个类没有标识属性。" + +#. Tag: para +#: basic_mapping.xml:522 +#, no-c-format +msgid "" +"The unsaved-value attribute is almost never needed in " +"Hibernate3." +msgstr "unsaved-value 属性在Hibernate3中几乎不再需要。" + +#. Tag: para +#: basic_mapping.xml:526 +#, no-c-format +msgid "" +"There is an alternative <composite-id> declaration " +"to allow access to legacy data with composite keys. We strongly discourage " +"its use for anything else." msgstr "" +"还有一个另外的<composite-id>定义可以访问旧式的多主键" +"数据。 我们强烈不建议使用这种方式。" -#: index.docbook:522 -msgid "The unsaved-value attribute is almost never needed in Hibernate3." -msgstr "" - -#: index.docbook:526 -msgid "There is an alternative <composite-id> declaration to allow access to legacy data with composite keys. We strongly discourage its use for anything else." -msgstr "" - -#: index.docbook:532 +#. Tag: title +#: basic_mapping.xml:532 +#, no-c-format msgid "Generator" -msgstr "" +msgstr "Generator" -#: index.docbook:534 -msgid "The optional <generator> child element names a Java class used to generate unique identifiers for instances of the persistent class. If any parameters are required to configure or initialize the generator instance, they are passed using the <param> element." -msgstr "" - -#: index.docbook:541 +#. Tag: para +#: basic_mapping.xml:534 +#, no-c-format msgid "" - "\n" - " \n" - " uid_table\n" - " next_hi_value_column\n" - " \n" - "]]>" +"The optional <generator> child element names a Java " +"class used to generate unique identifiers for instances of the persistent " +"class. If any parameters are required to configure or initialize the " +"generator instance, they are passed using the <param> element." +msgstr "" +"可选的<generator>子元素是一个Java类的名字, 用来为该" +"持久化类的实例生成唯一的标识。如果这个生成器实例需要某些配置值或者初始化参" +"数, 用<param>元素来传递。" + +#. Tag: programlisting +#: basic_mapping.xml:541 +#, no-c-format +msgid "" +"\n" +" \n" +" uid_table\n" +" next_hi_value_column\n" +" \n" +"]]>" msgstr "" -#: index.docbook:543 -msgid "All generators implement the interface org.hibernate.id.IdentifierGenerator. This is a very simple interface; some applications may choose to provide their own specialized implementations. However, Hibernate provides a range of built-in implementations. There are shortcut names for the built-in generators:" +#. Tag: para +#: basic_mapping.xml:543 +#, fuzzy, no-c-format +msgid "" +"All generators implement the interface org.hibernate.id." +"IdentifierGenerator. This is a very simple interface; some " +"applications may choose to provide their own specialized implementations. " +"However, Hibernate provides a range of built-in implementations. There are " +"shortcut names for the built-in generators:" msgstr "" +"所有的生成器都实现org.hibernate.id.IdentifierGenerator接" +"口。 这是一个非常简单的接口;某些应用程序可以选择提供他们自己特定的实现。当" +"然, Hibernate提供了很多内置的实现。下面是一些内置生成器的快捷名字: " +"" -#: index.docbook:551 +#. Tag: literal +#: basic_mapping.xml:551 +#, no-c-format msgid "increment" -msgstr "" +msgstr "increment" -#: index.docbook:553 -msgid "generates identifiers of type long, short or int that are unique only when no other process is inserting data into the same table. Do not use in a cluster." +#. Tag: para +#: basic_mapping.xml:553 +#, no-c-format +msgid "" +"generates identifiers of type long, short or int that are unique only when no other " +"process is inserting data into the same table. Do not use in a " +"cluster." msgstr "" +"用于为long, short或者int类型生成 唯一标识。只有在没有其他进程往同一张表中插入数据时才能使" +"用。 在集群下不要使用。" -#: index.docbook:562 +#. Tag: literal +#: basic_mapping.xml:562 +#, no-c-format msgid "identity" -msgstr "" +msgstr "identity" -#: index.docbook:564 -msgid "supports identity columns in DB2, MySQL, MS SQL Server, Sybase and HypersonicSQL. The returned identifier is of type long, short or int." +#. Tag: para +#: basic_mapping.xml:564 +#, no-c-format +msgid "" +"supports identity columns in DB2, MySQL, MS SQL Server, Sybase and " +"HypersonicSQL. The returned identifier is of type long, " +"short or int." msgstr "" +"对DB2,MySQL, MS SQL Server, Sybase和HypersonicSQL的内置标识字段提供支持。 返" +"回的标识符是long, short 或者" +"int类型的。" -#: index.docbook:572 +#. Tag: literal +#: basic_mapping.xml:572 +#, no-c-format msgid "sequence" -msgstr "" +msgstr "sequence" -#: index.docbook:574 -msgid "uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in Interbase. The returned identifier is of type long, short or int" +#. Tag: para +#: basic_mapping.xml:574 +#, no-c-format +msgid "" +"uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi or a generator in " +"Interbase. The returned identifier is of type long, " +"short or int" msgstr "" +"在DB2,PostgreSQL, Oracle, SAP DB, McKoi中使用序列(sequence), 而在Interbase" +"中使用生成器(generator)。返回的标识符是long, " +"short或者 int类型的。" -#: index.docbook:582 +#. Tag: literal +#: basic_mapping.xml:582 +#, no-c-format msgid "hilo" -msgstr "" +msgstr "hilo" -#: index.docbook:584 -msgid "uses a hi/lo algorithm to efficiently generate identifiers of type long, short or int, given a table and column (by default hibernate_unique_key and next_hi respectively) as a source of hi values. The hi/lo algorithm generates identifiers that are unique only for a particular database." +#. Tag: para +#: basic_mapping.xml:584 +#, no-c-format +msgid "" +"uses a hi/lo algorithm to efficiently generate identifiers of type " +"long, short or int, " +"given a table and column (by default hibernate_unique_key " +"and next_hi respectively) as a source of hi values. The " +"hi/lo algorithm generates identifiers that are unique only for a particular " +"database." msgstr "" +"使用一个高/低位算法高效的生成long, short 或者 int类型的标识符。给定一个表和字段(默认分别" +"是 hibernate_unique_keynext_hi)作为" +"高位值的来源。 高/低位算法生成的标识符只在一个特定的数据库中是唯一的。" -#: index.docbook:594 +#. Tag: literal +#: basic_mapping.xml:594 +#, no-c-format msgid "seqhilo" -msgstr "" +msgstr "seqhilo" -#: index.docbook:596 -msgid "uses a hi/lo algorithm to efficiently generate identifiers of type long, short or int, given a named database sequence." +#. Tag: para +#: basic_mapping.xml:596 +#, no-c-format +msgid "" +"uses a hi/lo algorithm to efficiently generate identifiers of type " +"long, short or int, " +"given a named database sequence." msgstr "" +"使用一个高/低位算法来高效的生成long, short 或者 int类型的标识符,给定一个数据库序列" +"(sequence)的名字。" -#: index.docbook:604 +#. Tag: literal +#: basic_mapping.xml:604 +#, no-c-format msgid "uuid" -msgstr "" +msgstr "uuid" -#: index.docbook:606 -msgid "uses a 128-bit UUID algorithm to generate identifiers of type string, unique within a network (the IP address is used). The UUID is encoded as a string of hexadecimal digits of length 32." +#. Tag: para +#: basic_mapping.xml:606 +#, no-c-format +msgid "" +"uses a 128-bit UUID algorithm to generate identifiers of type string, unique " +"within a network (the IP address is used). The UUID is encoded as a string " +"of hexadecimal digits of length 32." msgstr "" +"用一个128-bit的UUID算法生成字符串类型的标识符, 这在一个网络中是唯一的(使用" +"了IP地址)。UUID被编码为一个32位16进制数字的字符串。" -#: index.docbook:614 +#. Tag: literal +#: basic_mapping.xml:614 +#, no-c-format msgid "guid" -msgstr "" +msgstr "guid" -#: index.docbook:616 +#. Tag: para +#: basic_mapping.xml:616 +#, no-c-format msgid "uses a database-generated GUID string on MS SQL Server and MySQL." -msgstr "" +msgstr "在MS SQL Server 和 MySQL 中使用数据库生成的GUID字符串。" -#: index.docbook:622 +#. Tag: literal +#: basic_mapping.xml:622 +#, no-c-format msgid "native" -msgstr "" +msgstr "native" -#: index.docbook:624 -msgid "picks identity, sequence or hilo depending upon the capabilities of the underlying database." +#. Tag: para +#: basic_mapping.xml:624 +#, no-c-format +msgid "" +"picks identity, sequence or " +"hilo depending upon the capabilities of the underlying " +"database." msgstr "" +"根据底层数据库的能力选择identity, sequence 或者hilo中的一个。" -#: index.docbook:632 +#. Tag: literal +#: basic_mapping.xml:632 +#, no-c-format msgid "assigned" -msgstr "" +msgstr "assigned" -#: index.docbook:634 -msgid "lets the application to assign an identifier to the object before save() is called. This is the default strategy if no <generator> element is specified." +#. Tag: para +#: basic_mapping.xml:634 +#, no-c-format +msgid "" +"lets the application to assign an identifier to the object before " +"save() is called. This is the default strategy if no " +"<generator> element is specified." msgstr "" +"让应用程序在save()之前为对象分配一个标示符。这是 " +"<generator>元素没有指定时的默认生成策略。" -#: index.docbook:642 +#. Tag: literal +#: basic_mapping.xml:642 +#, no-c-format msgid "select" -msgstr "" +msgstr "select" -#: index.docbook:644 -msgid "retrieves a primary key assigned by a database trigger by selecting the row by some unique key and retrieving the primary key value." -msgstr "" +#. Tag: para +#: basic_mapping.xml:644 +#, no-c-format +msgid "" +"retrieves a primary key assigned by a database trigger by selecting the row " +"by some unique key and retrieving the primary key value." +msgstr "通过数据库触发器选择一些唯一主键的行并返回主键值来分配一个主键。" -#: index.docbook:651 +#. Tag: literal +#: basic_mapping.xml:651 +#, no-c-format msgid "foreign" -msgstr "" +msgstr "foreign" -#: index.docbook:653 -msgid "uses the identifier of another associated object. Usually used in conjunction with a <one-to-one> primary key association." +#. Tag: para +#: basic_mapping.xml:653 +#, no-c-format +msgid "" +"uses the identifier of another associated object. Usually used in " +"conjunction with a <one-to-one> primary key " +"association." msgstr "" +"使用另外一个相关联的对象的标识符。通常和<one-to-one>" +"联合起来使用。" -#: index.docbook:660 +#. Tag: literal +#: basic_mapping.xml:660 +#, no-c-format msgid "sequence-identity" -msgstr "" +msgstr "sequence-identity" -#: index.docbook:662 -msgid "a specialized sequence generation strategy which utilizes a database sequence for the actual value generation, but combines this with JDBC3 getGeneratedKeys to actually return the generated identifier value as part of the insert statement execution. This strategy is only known to be supported on Oracle 10g drivers targetted for JDK 1.4. Note comments on these insert statements are disabled due to a bug in the Oracle drivers." +#. Tag: para +#: basic_mapping.xml:662 +#, no-c-format +msgid "" +"a specialized sequence generation strategy which utilizes a database " +"sequence for the actual value generation, but combines this with JDBC3 " +"getGeneratedKeys to actually return the generated identifier value as part " +"of the insert statement execution. This strategy is only known to be " +"supported on Oracle 10g drivers targetted for JDK 1.4. Note comments on " +"these insert statements are disabled due to a bug in the Oracle drivers." msgstr "" +"一种特别的序列生成策略,使用数据库序列来生成实际值,但将它和JDBC3的" +"getGeneratedKeys结合在一起,使得在插入语句执行的时候就返回生成的值。目前为止只" +"有面向JDK 1.4的Oracle 10g驱动支持这一策略。注意,因为Oracle驱动程序的一个" +"bug,这些插入语句的注释被关闭了。(原文:Note comments on these insert " +"statements are disabled due to a bug in the Oracle drivers.)" -#: index.docbook:679 +#. Tag: title +#: basic_mapping.xml:679 +#, no-c-format msgid "Hi/lo algorithm" -msgstr "" +msgstr "高/低位算法(Hi/Lo Algorithm)" -#: index.docbook:680 -msgid "The hilo and seqhilo generators provide two alternate implementations of the hi/lo algorithm, a favorite approach to identifier generation. The first implementation requires a \"special\" database table to hold the next available \"hi\" value. The second uses an Oracle-style sequence (where supported)." -msgstr "" - -#: index.docbook:687 +#. Tag: para +#: basic_mapping.xml:680 +#, no-c-format msgid "" - "\n" - " \n" - " hi_value\n" - " next_value\n" - " 100\n" - " \n" - "]]>" +"The hilo and seqhilo generators " +"provide two alternate implementations of the hi/lo algorithm, a favorite " +"approach to identifier generation. The first implementation requires a " +"\"special\" database table to hold the next available \"hi\" value. The " +"second uses an Oracle-style sequence (where supported)." msgstr "" +"hiloseqhilo生成器给出了两种hi/lo算" +"法的实现, 这是一种很令人满意的标识符生成算法。第一种实现需要一个“特殊”的数据" +"库表来保存下一个可用的“hi”值。 第二种实现使用一个Oracle风格的序列(在被支持的" +"情况下)。" -#: index.docbook:689 +#. Tag: programlisting +#: basic_mapping.xml:687 +#, no-c-format msgid "" - "\n" - " \n" - " hi_value\n" - " 100\n" - " \n" - "]]>" +"\n" +" \n" +" hi_value\n" +" next_value\n" +" 100\n" +" \n" +"]]>" msgstr "" -#: index.docbook:691 -msgid "Unfortunately, you can't use hilo when supplying your own Connection to Hibernate. When Hibernate is using an application server datasource to obtain connections enlisted with JTA, you must properly configure the hibernate.transaction.manager_lookup_class." +#. Tag: programlisting +#: basic_mapping.xml:689 +#, no-c-format +msgid "" +"\n" +" \n" +" hi_value\n" +" 100\n" +" \n" +"]]>" msgstr "" -#: index.docbook:700 +#. Tag: para +#: basic_mapping.xml:691 +#, no-c-format +msgid "" +"Unfortunately, you can't use hilo when supplying your own " +"Connection to Hibernate. When Hibernate is using an " +"application server datasource to obtain connections enlisted with JTA, you " +"must properly configure the hibernate.transaction." +"manager_lookup_class." +msgstr "" +"很不幸,你在为Hibernate自行提供Connection时无法使用" +"hilo。 当Hibernate使用JTA获取应用服务器的数据源连接时,你必" +"须正确地配置 hibernate.transaction.manager_lookup_class。" + +#. Tag: title +#: basic_mapping.xml:700 +#, no-c-format msgid "UUID algorithm" -msgstr "" +msgstr "UUID算法(UUID Algorithm )" -#: index.docbook:701 -msgid "The UUID contains: IP address, startup time of the JVM (accurate to a quarter second), system time and a counter value (unique within the JVM). It's not possible to obtain a MAC address or memory address from Java code, so this is the best we can do without using JNI." +#. Tag: para +#: basic_mapping.xml:701 +#, no-c-format +msgid "" +"The UUID contains: IP address, startup time of the JVM (accurate to a " +"quarter second), system time and a counter value (unique within the JVM). " +"It's not possible to obtain a MAC address or memory address from Java code, " +"so this is the best we can do without using JNI." msgstr "" +"UUID包含:IP地址,JVM的启动时间(精确到1/4秒),系统时间和一个计数器值(在JVM" +"中唯一)。 在Java代码中不可能获得MAC地址或者内存地址,所以这已经是我们在不使" +"用JNI的前提下的能做的最好实现了。" -#: index.docbook:710 +#. Tag: title +#: basic_mapping.xml:710 +#, no-c-format msgid "Identity columns and sequences" -msgstr "" +msgstr "标识字段和序列(Identity columns and Sequences)" -#: index.docbook:711 -msgid "For databases which support identity columns (DB2, MySQL, Sybase, MS SQL), you may use identity key generation. For databases that support sequences (DB2, Oracle, PostgreSQL, Interbase, McKoi, SAP DB) you may use sequence style key generation. Both these strategies require two SQL queries to insert a new object." -msgstr "" - -#: index.docbook:719 +#. Tag: para +#: basic_mapping.xml:711 +#, no-c-format msgid "" - "\n" - " \n" - " person_id_sequence\n" - " \n" - "]]>" +"For databases which support identity columns (DB2, MySQL, Sybase, MS SQL), " +"you may use identity key generation. For databases that " +"support sequences (DB2, Oracle, PostgreSQL, Interbase, McKoi, SAP DB) you " +"may use sequence style key generation. Both these " +"strategies require two SQL queries to insert a new object." msgstr "" +"对于内部支持标识字段的数据库(DB2,MySQL,Sybase,MS SQL),你可以使用" +"identity关键字生成。 对于内部支持序列的数据库(DB2," +"Oracle, PostgreSQL, Interbase, McKoi,SAP DB), 你可以使用sequence风格的关键字生成。 这两种方式对于插入一个新的对象都需要两次SQL查询。" -#: index.docbook:721 +#. Tag: programlisting +#: basic_mapping.xml:719 +#, no-c-format msgid "" - "\n" - " \n" - "]]>" +"\n" +" \n" +" person_id_sequence\n" +" \n" +"]]>" msgstr "" -#: index.docbook:723 -msgid "For cross-platform development, the native strategy will choose from the identity, sequence and hilo strategies, dependant upon the capabilities of the underlying database." +#. Tag: programlisting +#: basic_mapping.xml:721 +#, no-c-format +msgid "" +"\n" +" \n" +"]]>" msgstr "" -#: index.docbook:732 +#. Tag: para +#: basic_mapping.xml:723 +#, no-c-format +msgid "" +"For cross-platform development, the native strategy will " +"choose from the identity, sequence and " +"hilo strategies, dependant upon the capabilities of the " +"underlying database." +msgstr "" +"对于跨平台开发,native策略会从identity, sequencehilo中进行选择,选" +"择哪一个,这取决于底层数据库的支持能力。" + +#. Tag: title +#: basic_mapping.xml:732 +#, no-c-format msgid "Assigned identifiers" -msgstr "" +msgstr "程序分配的标识符(Assigned Identifiers)" -#: index.docbook:733 -msgid "If you want the application to assign identifiers (as opposed to having Hibernate generate them), you may use the assigned generator. This special generator will use the identifier value already assigned to the object's identifier property. This generator is used when the primary key is a natural key instead of a surrogate key. This is the default behavior if you do no specify a <generator> element." +#. Tag: para +#: basic_mapping.xml:733 +#, no-c-format +msgid "" +"If you want the application to assign identifiers (as opposed to having " +"Hibernate generate them), you may use the assigned " +"generator. This special generator will use the identifier value already " +"assigned to the object's identifier property. This generator is used when " +"the primary key is a natural key instead of a surrogate key. This is the " +"default behavior if you do no specify a <generator> " +"element." msgstr "" +"如果你需要应用程序分配一个标示符(而非Hibernate来生成),你可以使用" +"assigned 生成器。这种特殊的生成器会使用已经分配给对象的标" +"识符属性的标识符值。 这个生成器使用一个自然键(natural key,有商业意义的列-" +"译注)作为主键,而不是使用一个代理键( surrogate key,没有商业意义的列-译" +"注)。这是没有指定<generator>元素时的默认行为" -#: index.docbook:742 -msgid "Choosing the assigned generator makes Hibernate use unsaved-value=\"undefined\", forcing Hibernate to go to the database to determine if an instance is transient or detached, unless there is a version or timestamp property, or you define Interceptor.isUnsaved()." +#. Tag: para +#: basic_mapping.xml:742 +#, no-c-format +msgid "" +"Choosing the assigned generator makes Hibernate use " +"unsaved-value=\"undefined\", forcing Hibernate to go to " +"the database to determine if an instance is transient or detached, unless " +"there is a version or timestamp property, or you define Interceptor." +"isUnsaved()." msgstr "" +"当选择assigned生成器时,除非有一个version或timestamp属性," +"或者你定义了 Interceptor.isUnsaved(),否则需要让Hiberante" +"使用 unsaved-value=\"undefined\",强制Hibernatet查询数据库" +"来确定一个实例是瞬时的(transient) 还是脱管的(detached)。" -#: index.docbook:752 +#. Tag: title +#: basic_mapping.xml:752 +#, no-c-format msgid "Primary keys assigned by triggers" -msgstr "" +msgstr "触发器实现的主键生成器(Primary keys assigned by triggers)" -#: index.docbook:753 -msgid "For legacy schemas only (Hibernate does not generate DDL with triggers)." -msgstr "" - -#: index.docbook:757 +#. Tag: para +#: basic_mapping.xml:753 +#, no-c-format msgid "" - "\n" - " \n" - " socialSecurityNumber\n" - " \n" - "]]>" +"For legacy schemas only (Hibernate does not generate DDL with triggers)." +msgstr "仅仅用于遗留的schema中 (Hibernate不能使用触发器生成DDL)。" + +#. Tag: programlisting +#: basic_mapping.xml:757 +#, no-c-format +msgid "" +"\n" +" \n" +" socialSecurityNumber\n" +" \n" +"]]>" msgstr "" -#: index.docbook:759 -msgid "In the above example, there is a unique valued property named socialSecurityNumber defined by the class, as a natural key, and a surrogate key named person_id whose value is generated by a trigger." +#. Tag: para +#: basic_mapping.xml:759 +#, no-c-format +msgid "" +"In the above example, there is a unique valued property named " +"socialSecurityNumber defined by the class, as a natural " +"key, and a surrogate key named person_id whose value is " +"generated by a trigger." msgstr "" +"在上面的例子中,类定义了一个命名为socialSecurityNumber的唯" +"一值属性, 它是一个自然键(natural key),命名为person_id" +"的代理键(surrogate key) 的值由触发器生成。" -#: index.docbook:771 +#. Tag: title +#: basic_mapping.xml:771 +#, no-c-format msgid "Enhanced identifier generators" -msgstr "" +msgstr "Enhanced identifier generators" -#: index.docbook:773 -msgid "Starting with release 3.2.3, there are 2 new generators which represent a re-thinking of 2 different aspects of identifier generation. The first aspect is database portability; the second is optimization (not having to query the database for every request for a new identifier value). These two new generators are intended to take the place of some of the named generators described above (starting in 3.3.x); however, they are included in the current releases and can be referenced by FQN." +#. Tag: para +#: basic_mapping.xml:773 +#, no-c-format +msgid "" +"Starting with release 3.2.3, there are 2 new generators which represent a re-" +"thinking of 2 different aspects of identifier generation. The first aspect " +"is database portability; the second is optimization (not having to query the " +"database for every request for a new identifier value). These two new " +"generators are intended to take the place of some of the named generators " +"described above (starting in 3.3.x); however, they are included in the " +"current releases and can be referenced by FQN." msgstr "" +"Starting with release 3.2.3, there are 2 new generators which represent a re-" +"thinking of 2 different aspects of identifier generation. The first aspect " +"is database portability; the second is optimization (not having to query the " +"database for every request for a new identifier value). These two new " +"generators are intended to take the place of some of the named generators " +"described above (starting in 3.3.x); however, they are included in the " +"current releases and can be referenced by FQN." -#: index.docbook:781 -msgid "The first of these new generators is org.hibernate.id.enhanced.SequenceStyleGenerator which is intended firstly as a replacement for the sequence generator and secondly as a better portability generator than native (because native (generally) chooses between identity and sequence which have largely different semantics which can cause subtle isssues in applications eyeing portability). org.hibernate.id.enhanced.SequenceStyleGenerator however achieves portability in a different manner. It chooses between using a table or a sequence in the database to store its incrementing values depending on the capabilities of the dialect being used. The difference between this and native is that table-based and sequence-based storage have the same exact semantic (in fact sequences are exactly what Hibernate tries to emmulate with its table-based generators). This generator has a number of configuration parameters:" +#. Tag: para +#: basic_mapping.xml:781 +#, fuzzy, no-c-format +msgid "" +"The first of these new generators is org.hibernate.id.enhanced." +"SequenceStyleGenerator which is intended firstly as a replacement " +"for the sequence generator and secondly as a better " +"portability generator than native (because " +"native (generally) chooses between identity and sequence which have largely different " +"semantics which can cause subtle isssues in applications eyeing " +"portability). org.hibernate.id.enhanced.SequenceStyleGenerator however achieves portability in a different manner. It chooses " +"between using a table or a sequence in the database to store its " +"incrementing values depending on the capabilities of the dialect being used. " +"The difference between this and native is that table-" +"based and sequence-based storage have the same exact semantic (in fact " +"sequences are exactly what Hibernate tries to emmulate with its table-based " +"generators). This generator has a number of configuration parameters:" msgstr "" +"The first of these new generators is org.hibernate.id.enhanced." +"SequenceStyleGenerator which is intended firstly as a replacement " +"for the sequence generator and secondly as a better " +"portability generator than native (because " +"native (generally) chooses between identity and sequence which have largely different " +"semantics which can cause subtle isssues in applications eyeing " +"portability). org.hibernate.id.enhanced.SequenceStyleGenerator however achieves portability in a different manner. It chooses " +"between using a table or a sequence in the database to store its " +"incrementing values depending on the capabilities of the dialect being used. " +"The difference between this and native is that table-" +"based and sequence-based storage have the same exact semantic (in fact " +"sequences are exactly what Hibernate tries to emmulate with its table-based " +"generators). This generator has a number of configuration parameters: " +"" -#: index.docbook:795 -msgid "sequence_name (optional, defaults to hibernate_sequence): The name of the sequence (or table) to be used." +#. Tag: para +#: basic_mapping.xml:795 +#, no-c-format +msgid "" +"sequence_name (optional, defaults to " +"hibernate_sequence): The name of the sequence (or table) " +"to be used." msgstr "" +"sequence_name (optional, defaults to " +"hibernate_sequence): The name of the sequence (or table) " +"to be used." -#: index.docbook:801 -msgid "initial_value (optional, defaults to 1): The initial value to be retrieved from the sequence/table. In sequence creation terms, this is analogous to the clause typical named \"STARTS WITH\"." +#. Tag: para +#: basic_mapping.xml:801 +#, no-c-format +msgid "" +"initial_value (optional, defaults to 1): The initial value to be retrieved from the sequence/table. In " +"sequence creation terms, this is analogous to the clause typical named " +"\"STARTS WITH\"." msgstr "" +"initial_value (optional, defaults to 1): The initial value to be retrieved from the sequence/table. In " +"sequence creation terms, this is analogous to the clause typical named " +"\"STARTS WITH\"." -#: index.docbook:808 -msgid "increment_size (optional, defaults to 1): The value by which subsequent calls to the sequence/table should differ. In sequence creation terms, this is analogous to the clause typical named \"INCREMENT BY\"." +#. Tag: para +#: basic_mapping.xml:808 +#, no-c-format +msgid "" +"increment_size (optional, defaults to 1): The value by which subsequent calls to the sequence/table should " +"differ. In sequence creation terms, this is analogous to the clause typical " +"named \"INCREMENT BY\"." msgstr "" +"increment_size (optional, defaults to 1): The value by which subsequent calls to the sequence/table should " +"differ. In sequence creation terms, this is analogous to the clause typical " +"named \"INCREMENT BY\"." -#: index.docbook:815 -msgid "force_table_use (optional, defaults to false): Should we force the use of a table as the backing structure even though the dialect might support sequence?" +#. Tag: para +#: basic_mapping.xml:815 +#, no-c-format +msgid "" +"force_table_use (optional, defaults to false): Should we force the use of a table as the backing structure even " +"though the dialect might support sequence?" msgstr "" +"force_table_use (optional, defaults to false): Should we force the use of a table as the backing structure even " +"though the dialect might support sequence?" -#: index.docbook:822 -msgid "value_column (optional, defaults to next_val): Only relevant for table structures! The name of the column on the table which is used to hold the value." +#. Tag: para +#: basic_mapping.xml:822 +#, no-c-format +msgid "" +"value_column (optional, defaults to next_val): Only relevant for table structures! The name of the column on the " +"table which is used to hold the value." msgstr "" +"value_column (optional, defaults to next_val): Only relevant for table structures! The name of the column on the " +"table which is used to hold the value." -#: index.docbook:829 -msgid "optimizer (optional, defaults to none): See" +#. Tag: para +#: basic_mapping.xml:829 +#, fuzzy, no-c-format +msgid "" +"optimizer (optional, defaults to none): See" msgstr "" +"cascade (可选 -默认是none): 级联的类型" -#: index.docbook:836 -msgid "The second of these new generators is org.hibernate.id.enhanced.TableGenerator which is intended firstly as a replacement for the table generator (although it actually functions much more like org.hibernate.id.MultipleHiLoPerTableGenerator) and secondly as a re-implementation of org.hibernate.id.MultipleHiLoPerTableGenerator utilizing the notion of pluggable optimiziers. Essentially this generator defines a table capable of holding a number of different increment values simultaneously by using multiple distinctly keyed rows. This generator has a number of configuration parameters:" +#. Tag: para +#: basic_mapping.xml:836 +#, fuzzy, no-c-format +msgid "" +"The second of these new generators is org.hibernate.id.enhanced." +"TableGenerator which is intended firstly as a replacement for the " +"table generator (although it actually functions much more " +"like org.hibernate.id.MultipleHiLoPerTableGenerator) and " +"secondly as a re-implementation of org.hibernate.id." +"MultipleHiLoPerTableGenerator utilizing the notion of pluggable " +"optimiziers. Essentially this generator defines a table capable of holding a " +"number of different increment values simultaneously by using multiple " +"distinctly keyed rows. This generator has a number of configuration " +"parameters:" msgstr "" +"The second of these new generators is org.hibernate.id.enhanced." +"TableGenerator which is intended firstly as a replacement for the " +"table generator (although it actually functions much more " +"like org.hibernate.id.MultipleHiLoPerTableGenerator) and " +"secondly as a re-implementation of org.hibernate.id." +"MultipleHiLoPerTableGenerator utilizing the notion of pluggable " +"optimiziers. Essentially this generator defines a table capable of holding a " +"number of different increment values simultaneously by using multiple " +"distinctly keyed rows. This generator has a number of configuration " +"parameters: " -#: index.docbook:846 -msgid "table_name (optional, defaults to hibernate_sequences): The name of the table to be used." +#. Tag: para +#: basic_mapping.xml:846 +#, no-c-format +msgid "" +"table_name (optional, defaults to " +"hibernate_sequences): The name of the table to be used." msgstr "" +"table_name (optional, defaults to " +"hibernate_sequences): The name of the table to be used." -#: index.docbook:852 -msgid "value_column_name (optional, defaults to next_val): The name of the column on the table which is used to hold the value." +#. Tag: para +#: basic_mapping.xml:852 +#, no-c-format +msgid "" +"value_column_name (optional, defaults to " +"next_val): The name of the column on the table which is " +"used to hold the value." msgstr "" +"value_column_name (optional, defaults to " +"next_val): The name of the column on the table which is " +"used to hold the value." -#: index.docbook:858 -msgid "segment_column_name (optional, defaults to sequence_name): The name of the column on the table which is used to hold the \"segement key\". This is the value which distinctly identifies which increment value to use." +#. Tag: para +#: basic_mapping.xml:858 +#, no-c-format +msgid "" +"segment_column_name (optional, defaults to " +"sequence_name): The name of the column on the table which " +"is used to hold the \"segement key\". This is the value which distinctly " +"identifies which increment value to use." msgstr "" +"segment_column_name (optional, defaults to " +"sequence_name): The name of the column on the table which " +"is used to hold the \"segement key\". This is the value which distinctly " +"identifies which increment value to use." -#: index.docbook:865 -msgid "segment_value (optional, defaults to default): The \"segment key\" value for the segment from which we want to pull increment values for this generator." +#. Tag: para +#: basic_mapping.xml:865 +#, no-c-format +msgid "" +"segment_value (optional, defaults to default): The \"segment key\" value for the segment from which we want to " +"pull increment values for this generator." msgstr "" +"segment_value (optional, defaults to default): The \"segment key\" value for the segment from which we want to " +"pull increment values for this generator." -#: index.docbook:872 -msgid "segment_value_length (optional, defaults to 255): Used for schema generation; the column size to create this segment key column." +#. Tag: para +#: basic_mapping.xml:872 +#, no-c-format +msgid "" +"segment_value_length (optional, defaults to 255): Used for schema generation; the column size to create this " +"segment key column." msgstr "" +"segment_value_length (optional, defaults to 255): Used for schema generation; the column size to create this " +"segment key column." -#: index.docbook:878 -msgid "initial_value (optional, defaults to 1): The initial value to be retrieved from the table." +#. Tag: para +#: basic_mapping.xml:878 +#, no-c-format +msgid "" +"initial_value (optional, defaults to 1): The initial value to be retrieved from the table." msgstr "" +"initial_value (optional, defaults to 1): The initial value to be retrieved from the table." -#: index.docbook:884 -msgid "increment_size (optional, defaults to 1): The value by which subsequent calls to the table should differ." +#. Tag: para +#: basic_mapping.xml:884 +#, no-c-format +msgid "" +"increment_size (optional, defaults to 1): The value by which subsequent calls to the table should differ." msgstr "" +"increment_size (optional, defaults to 1): The value by which subsequent calls to the table should differ." -#: index.docbook:890 -msgid "optimizer (optional, defaults to ): See" +#. Tag: para +#: basic_mapping.xml:890 +#, fuzzy, no-c-format +msgid "" +"optimizer (optional, defaults to ): See" msgstr "" +"cascade (可选 -默认是none): 级联的类型" -#: index.docbook:900 +#. Tag: title +#: basic_mapping.xml:900 +#, no-c-format msgid "Identifier generator optimization" -msgstr "" +msgstr "Identifier generator optimization" -#: index.docbook:901 -msgid "For identifier generators which store values in the database, it is inefficient for them to hit the database on each and every call to generate a new identifier value. Instead, you'd ideally want to group a bunch of them in memory and only hit the database when you have exhausted your in-memory value group. This is the role of the pluggable optimizers. Currently only the two enhanced generators ( support this notion." +#. Tag: para +#: basic_mapping.xml:901 +#, fuzzy, no-c-format +msgid "" +"For identifier generators which store values in the database, it is " +"inefficient for them to hit the database on each and every call to generate " +"a new identifier value. Instead, you'd ideally want to group a bunch of them " +"in memory and only hit the database when you have exhausted your in-memory " +"value group. This is the role of the pluggable optimizers. Currently only " +"the two enhanced generators ( support this notion." msgstr "" +"For identifier generators which store values in the database, it is " +"inefficient for them to hit the database on each and every call to generate " +"a new identifier value. Instead, you'd ideally want to group a bunch of them " +"in memory and only hit the database when you have exhausted your in-memory " +"value group. This is the role of the pluggable optimizers. Currently only " +"the two enhanced generators ( support this notion. " -#: index.docbook:909 -msgid "none (generally this is the default if no optimizer was specified): This says to not perform any optimizations, and hit the database each and every request." +#. Tag: para +#: basic_mapping.xml:909 +#, no-c-format +msgid "" +"none (generally this is the default if no optimizer was " +"specified): This says to not perform any optimizations, and hit the database " +"each and every request." msgstr "" +"none (generally this is the default if no optimizer was " +"specified): This says to not perform any optimizations, and hit the database " +"each and every request." -#: index.docbook:915 -msgid "hilo: applies a hi/lo algorithm around the database retrieved values. The values from the database for this optimizer are expected to be sequential. The values retrieved from the database structure for this optimizer indicates the \"group number\"; the increment_size is multiplied by that value in memory to define a group \"hi value\"." +#. Tag: para +#: basic_mapping.xml:915 +#, no-c-format +msgid "" +"hilo: applies a hi/lo algorithm around the database " +"retrieved values. The values from the database for this optimizer are " +"expected to be sequential. The values retrieved from the database structure " +"for this optimizer indicates the \"group number\"; the " +"increment_size is multiplied by that value in memory to " +"define a group \"hi value\"." msgstr "" +"hilo: applies a hi/lo algorithm around the database " +"retrieved values. The values from the database for this optimizer are " +"expected to be sequential. The values retrieved from the database structure " +"for this optimizer indicates the \"group number\"; the " +"increment_size is multiplied by that value in memory to " +"define a group \"hi value\"." -#: index.docbook:924 -msgid "pooled: like was discussed for hilo, this optimizers attempts to minimize the number of hits to the database. Here, however, we simply store the starting value for the \"next group\" into the database structure rather than a sequential value in combination with an in-memory grouping algorithm. increment_size here refers to the values coming from the database." +#. Tag: para +#: basic_mapping.xml:924 +#, no-c-format +msgid "" +"pooled: like was discussed for hilo, " +"this optimizers attempts to minimize the number of hits to the database. " +"Here, however, we simply store the starting value for the \"next group\" " +"into the database structure rather than a sequential value in combination " +"with an in-memory grouping algorithm. increment_size here " +"refers to the values coming from the database." msgstr "" +"pooled: like was discussed for hilo, " +"this optimizers attempts to minimize the number of hits to the database. " +"Here, however, we simply store the starting value for the \"next group\" " +"into the database structure rather than a sequential value in combination " +"with an in-memory grouping algorithm. increment_size here " +"refers to the values coming from the database." -#: index.docbook:937 +#. Tag: title +#: basic_mapping.xml:937 +#, no-c-format msgid "composite-id" -msgstr "" +msgstr "composite-id" -#: index.docbook:939 +#. Tag: programlisting +#: basic_mapping.xml:939 +#, no-c-format msgid "" - "\n" - " node=\"element-name|.\"\n" - "\n" - " \n" - " \n" - " ......\n" - "]]>" +"\n" +" node=\"element-name|.\"\n" +"\n" +" \n" +" \n" +" ......\n" +"]]>" msgstr "" -#: index.docbook:941 -msgid "For a table with a composite key, you may map multiple properties of the class as identifier properties. The <composite-id> element accepts <key-property> property mappings and <key-many-to-one> mappings as child elements." -msgstr "" - -#: index.docbook:948 +#. Tag: para +#: basic_mapping.xml:941 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"For a table with a composite key, you may map multiple properties of the " +"class as identifier properties. The <composite-id> " +"element accepts <key-property> property mappings " +"and <key-many-to-one> mappings as child elements." msgstr "" +"如果表使用联合主键,你可以映射类的多个属性为标识符属性。 <" +"composite-id>元素接受<key-property> 属" +"性映射和<key-many-to-one>属性映射作为子元素。" -#: index.docbook:950 -msgid "Your persistent class must override equals() and hashCode() to implement composite identifier equality. It must also implements Serializable." -msgstr "" - -#: index.docbook:956 -msgid "Unfortunately, this approach to composite identifiers means that a persistent object is its own identifier. There is no convenient \"handle\" other than the object itself. You must instantiate an instance of the persistent class itself and populate its identifier properties before you can load() the persistent state associated with a composite key. We call this approach an embedded composite identifier, and discourage it for serious applications." -msgstr "" - -#: index.docbook:965 -msgid "A second approach is what we call a mapped composite identifier, where the identifier properties named inside the <composite-id> element are duplicated on both the persistent class and a separate identifier class." -msgstr "" - -#: index.docbook:971 +#. Tag: programlisting +#: basic_mapping.xml:948 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:973 -msgid "In this example, both the composite identifier class, MedicareId, and the entity class itself have properties named medicareNumber and dependent. The identifier class must override equals() and hashCode() and implement. Serializable. The disadvantage of this approach is quite obvious—code duplication." +#. Tag: para +#: basic_mapping.xml:950 +#, no-c-format +msgid "" +"Your persistent class must override equals() and hashCode() to implement composite identifier " +"equality. It must also implements Serializable." +msgstr "" +"你的持久化类必须重载equals()和 " +"hashCode()方法,来实现组合的标识符的相等判断。 实现" +"Serializable接口也是必须的。" + +#. Tag: para +#: basic_mapping.xml:956 +#, no-c-format +msgid "" +"Unfortunately, this approach to composite identifiers means that a " +"persistent object is its own identifier. There is no convenient \"handle\" " +"other than the object itself. You must instantiate an instance of the " +"persistent class itself and populate its identifier properties before you " +"can load() the persistent state associated with a " +"composite key. We call this approach an embedded " +"composite identifier, and discourage it for serious applications." +msgstr "" +"不幸的是,这种组合关键字的方法意味着一个持久化类是它自己的标识。除了对象自己" +"之外, 没有什么方便的“把手”可用。你必须初始化持久化类的实例,填充它的标识符属" +"性,再load() 组合关键字关联的持久状态。我们把这种方法称为" +"embedded(嵌入式)的组合标识符,在重要的应用中不鼓励使用" +"这种用法。" + +#. Tag: para +#: basic_mapping.xml:965 +#, no-c-format +msgid "" +"A second approach is what we call a mapped composite " +"identifier, where the identifier properties named inside the <" +"composite-id> element are duplicated on both the persistent " +"class and a separate identifier class." +msgstr "" +"第二种方法我们称为mapped(映射式)组合标识符 (mapped " +"composite identifier),<composite-id>元素中列出的标识" +"属性不但在持久化类出现,还形成一个独立的标识符类。" + +#. Tag: programlisting +#: basic_mapping.xml:971 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:982 -msgid "The following attributes are used to specify a mapped composite identifier:" +#. Tag: para +#: basic_mapping.xml:973 +#, no-c-format +msgid "" +"In this example, both the composite identifier class, MedicareId, and the entity class itself have properties named " +"medicareNumber and dependent. The " +"identifier class must override equals() and " +"hashCode() and implement. Serializable. The disadvantage of this approach is quite obvious—code " +"duplication." msgstr "" +"在这个例子中,组合标识符类MedicareId和实体类都含有" +"medicareNumberdependent属性。标识符类" +"必须重载equals()hashCode()并且实现" +"Serializable接口。这种方法的缺点是出现了明显的代码重复。" -#: index.docbook:988 -msgid "mapped (optional, defaults to false): indicates that a mapped composite identifier is used, and that the contained property mappings refer to both the entity class and the composite identifier class." +#. Tag: para +#: basic_mapping.xml:982 +#, no-c-format +msgid "" +"The following attributes are used to specify a mapped composite identifier:" +msgstr "下面列出的属性是用来指定一个映射式组合标识符的:" + +#. Tag: para +#: basic_mapping.xml:988 +#, no-c-format +msgid "" +"mapped (optional, defaults to false): " +"indicates that a mapped composite identifier is used, and that the contained " +"property mappings refer to both the entity class and the composite " +"identifier class." msgstr "" +"mapped (可选, 默认为false): 指明使用一" +"个映射式组合标识符,其包含的属性映射同时在实体类和组合标识符类中出现。" -#: index.docbook:996 -msgid "class (optional, but required for a mapped composite identifier): The class used as a composite identifier." +#. Tag: para +#: basic_mapping.xml:996 +#, no-c-format +msgid "" +"class (optional, but required for a mapped composite " +"identifier): The class used as a composite identifier." msgstr "" +"class (可选,但对映射式组合标识符必须指定): 作为组合标识符" +"类使用的类名." -#: index.docbook:1003 -msgid "We will describe a third, even more convenient approach where the composite identifier is implemented as a component class in . The attributes described below apply only to this alternative approach:" +#. Tag: para +#: basic_mapping.xml:1003 +#, no-c-format +msgid "" +"We will describe a third, even more convenient approach where the composite " +"identifier is implemented as a component class in . The attributes described below apply only to this " +"alternative approach:" msgstr "" +"在一节中,我们会描述第三种方式,那就" +"是把组合标识符实现为一个组件(component)类,这是更方便的方法。下面的属性仅对第" +"三种方法有效:" -#: index.docbook:1011 -msgid "name (optional, required for this approach): A property of component type that holds the composite identifier (see chapter 9)." +#. Tag: para +#: basic_mapping.xml:1011 +#, no-c-format +msgid "" +"name (optional, required for this approach): A property " +"of component type that holds the composite identifier (see chapter 9)." msgstr "" +"name (可选,但对这种方法而言必须): 包含此组件标识符的组件类" +"型的名字 (参阅第9章)." -#: index.docbook:1023 -msgid "class (optional - defaults to the property type determined by reflection): The component class used as a composite identifier (see next section)." +#. Tag: para +#: basic_mapping.xml:1023 +#, no-c-format +msgid "" +"class (optional - defaults to the property type " +"determined by reflection): The component class used as a composite " +"identifier (see next section)." msgstr "" +"class (可选 - 默认会用反射来自动判定属性类型 ): 用来作为组" +"合标识符的组件类的类名(参阅下一节)" -#: index.docbook:1030 -msgid "This third approach, an identifier component is the one we recommend for almost all applications." +#. Tag: para +#: basic_mapping.xml:1030 +#, no-c-format +msgid "" +"This third approach, an identifier component is the one " +"we recommend for almost all applications." msgstr "" +"第三种方式,被称为identifier component(标识符组件)是我们" +"对几乎所有应用都推荐使用的方式。" -#: index.docbook:1038 +#. Tag: title +#: basic_mapping.xml:1038 +#, no-c-format msgid "discriminator" -msgstr "" +msgstr "鉴别器(discriminator)" -#: index.docbook:1040 -msgid "The <discriminator> element is required for polymorphic persistence using the table-per-class-hierarchy mapping strategy and declares a discriminator column of the table. The discriminator column contains marker values that tell the persistence layer what subclass to instantiate for a particular row. A restricted set of types may be used: string, character, integer, byte, short, boolean, yes_no, true_false." -msgstr "" - -#: index.docbook:1058 +#. Tag: para +#: basic_mapping.xml:1040 +#, no-c-format msgid "" - "]]>" +"The <discriminator> element is required for " +"polymorphic persistence using the table-per-class-hierarchy mapping strategy " +"and declares a discriminator column of the table. The discriminator column " +"contains marker values that tell the persistence layer what subclass to " +"instantiate for a particular row. A restricted set of types may be used: " +"string, character, integer, byte, short, " +"boolean, yes_no, true_false." msgstr "" +"在\"一棵对象继承树对应一个表\"的策略中,<discriminator>元素是必需的, 它定义了表的鉴别器字段。鉴别器字段包含标志值,用于告知" +"持久化层应该为某个特定的行创建哪一个子类的实例。 如下这些受到限制的类型可以使" +"用: string, character, " +"integer, byte, short, boolean, yes_no, " +"true_false." -#: index.docbook:1061 -msgid "column (optional - defaults to class) the name of the discriminator column." -msgstr "" - -#: index.docbook:1067 -msgid "type (optional - defaults to string) a name that indicates the Hibernate type" -msgstr "" - -#: index.docbook:1073 -msgid "force (optional - defaults to false) \"force\" Hibernate to specify allowed discriminator values even when retrieving all instances of the root class." -msgstr "" - -#: index.docbook:1080 -msgid "insert (optional - defaults to true) set this to false if your discriminator column is also part of a mapped composite identifier. (Tells Hibernate to not include the column in SQL INSERTs.)" -msgstr "" - -#: index.docbook:1088 -msgid "formula (optional) an arbitrary SQL expression that is executed when a type has to be evaluated. Allows content-based discrimination." -msgstr "" - -#: index.docbook:1096 -msgid "Actual values of the discriminator column are specified by the discriminator-value attribute of the <class> and <subclass> elements." -msgstr "" - -#: index.docbook:1102 -msgid "The force attribute is (only) useful if the table contains rows with \"extra\" discriminator values that are not mapped to a persistent class. This will not usually be the case." -msgstr "" - -#: index.docbook:1108 -msgid "Using the formula attribute you can declare an arbitrary SQL expression that will be used to evaluate the type of a row:" -msgstr "" - -#: index.docbook:1113 +#. Tag: programlisting +#: basic_mapping.xml:1058 +#, no-c-format msgid "" - "]]>" +"]]>" msgstr "" -#: index.docbook:1118 +#. Tag: para +#: basic_mapping.xml:1061 +#, no-c-format +msgid "" +"column (optional - defaults to class) " +"the name of the discriminator column." +msgstr "" +"column (可选 - 默认为 class) 鉴别器字段" +"的名字" + +#. Tag: para +#: basic_mapping.xml:1067 +#, no-c-format +msgid "" +"type (optional - defaults to string) a " +"name that indicates the Hibernate type" +msgstr "" +"type (可选 - 默认为 string) 一个" +"Hibernate字段类型的名字" + +#. Tag: para +#: basic_mapping.xml:1073 +#, no-c-format +msgid "" +"force (optional - defaults to false) " +"\"force\" Hibernate to specify allowed discriminator values even when " +"retrieving all instances of the root class." +msgstr "" +"force(强制) (可选 - 默认为 false) \"强" +"制\"Hibernate指定允许的鉴别器值,即使当取得的所有实例都是根类的。" + +#. Tag: para +#: basic_mapping.xml:1080 +#, no-c-format +msgid "" +"insert (optional - defaults to true) " +"set this to false if your discriminator column is also " +"part of a mapped composite identifier. (Tells Hibernate to not include the " +"column in SQL INSERTs.)" +msgstr "" +"insert (可选 - 默认为true) 如果你的鉴别" +"器字段也是映射为复合标识(composite identifier)的一部分,则需将 这个值设为" +"false。(告诉Hibernate在做SQL INSERT 时" +"不包含该列)" + +#. Tag: para +#: basic_mapping.xml:1088 +#, no-c-format +msgid "" +"formula (optional) an arbitrary SQL expression that is " +"executed when a type has to be evaluated. Allows content-based " +"discrimination." +msgstr "" +"formula (可选) 一个SQL表达式,在类型判断(判断是父类还是具" +"体子类-译注)时执行。可用于基于内容的鉴别器。" + +#. Tag: para +#: basic_mapping.xml:1096 +#, no-c-format +msgid "" +"Actual values of the discriminator column are specified by the " +"discriminator-value attribute of the <" +"class> and <subclass> elements." +msgstr "" +"鉴别器字段的实际值是根据<class><" +"subclass>元素中 的discriminator-value属性得来" +"的。" + +#. Tag: para +#: basic_mapping.xml:1102 +#, no-c-format +msgid "" +"The force attribute is (only) useful if the table " +"contains rows with \"extra\" discriminator values that are not mapped to a " +"persistent class. This will not usually be the case." +msgstr "" +"force属性仅仅在这种情况下有用的:表中包含没有被映射到持久" +"化类的附加辨别器值。 这种情况不会经常遇到。" + +#. Tag: para +#: basic_mapping.xml:1108 +#, no-c-format +msgid "" +"Using the formula attribute you can declare an arbitrary " +"SQL expression that will be used to evaluate the type of a row:" +msgstr "" +"使用formula属性你可以定义一个SQL表达式,用来判断一个行数据" +"的类型。" + +#. Tag: programlisting +#: basic_mapping.xml:1113 +#, no-c-format +msgid "" +"]]>" +msgstr "" + +#. Tag: title +#: basic_mapping.xml:1118 +#, no-c-format msgid "version (optional)" -msgstr "" +msgstr "版本(version)(可选)" -#: index.docbook:1120 -msgid "The <version> element is optional and indicates that the table contains versioned data. This is particularly useful if you plan to use long transactions (see below)." -msgstr "" - -#: index.docbook:1136 +#. Tag: para +#: basic_mapping.xml:1120 +#, no-c-format msgid "" - "]]>" +"The <version> element is optional and indicates " +"that the table contains versioned data. This is particularly useful if you " +"plan to use long transactions (see below)." +msgstr "" +"<version>元素是可选的,表明表中包含附带版本信息的数" +"据。 这在你准备使用 长事务(long transactions)的时候特" +"别有用。(见后)" + +#. Tag: programlisting +#: basic_mapping.xml:1136 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1139 -msgid "column (optional - defaults to the property name): The name of the column holding the version number." +#. Tag: para +#: basic_mapping.xml:1139 +#, no-c-format +msgid "" +"column (optional - defaults to the property name): The " +"name of the column holding the version number." msgstr "" +"column (可选 - 默认为属性名): 指定持有版本号的字段名。" -#: index.docbook:1145 -msgid "name: The name of a property of the persistent class." +#. Tag: para +#: basic_mapping.xml:1145 +#, no-c-format +msgid "" +"name: The name of a property of the persistent class." +msgstr "name: 持久化类的属性名。" + +#. Tag: para +#: basic_mapping.xml:1150 +#, no-c-format +msgid "" +"type (optional - defaults to integer): " +"The type of the version number." msgstr "" +"type (可选 - 默认是 integer): 版本号的" +"类型。" -#: index.docbook:1150 -msgid "type (optional - defaults to integer): The type of the version number." +#. Tag: para +#: basic_mapping.xml:1162 +#, no-c-format +msgid "" +"unsaved-value (optional - defaults to undefined): A version property value that indicates that an instance is newly " +"instantiated (unsaved), distinguishing it from detached instances that were " +"saved or loaded in a previous session. (undefined " +"specifies that the identifier property value should be used.)" msgstr "" +"unsaved-value (可选 - 默认是undefined): 用于标明某个实例时刚刚被实例化的(尚未保存)版本属性值,依靠这个值" +"就可以把这种情况 和已经在先前的session中保存或装载的脱管(detached)实例区分" +"开来。 (undefined指明应被使用的标识属性值。)" -#: index.docbook:1162 -msgid "unsaved-value (optional - defaults to undefined): A version property value that indicates that an instance is newly instantiated (unsaved), distinguishing it from detached instances that were saved or loaded in a previous session. (undefined specifies that the identifier property value should be used.)" +#. Tag: para +#: basic_mapping.xml:1171 +#, fuzzy, no-c-format +msgid "" +"generated (optional - defaults to never): Specifies that this version property value is actually generated " +"by the database. See the discussion of generated properties." msgstr "" +"generated (可选 - 默认是 never): 表明此" +"版本属性值是否实际上是由数据库生成的。请参阅generated properties部分的讨论。" -#: index.docbook:1171 -msgid "generated (optional - defaults to never): Specifies that this version property value is actually generated by the database. See the discussion of generated properties." +#. Tag: para +#: basic_mapping.xml:1178 +#, no-c-format +msgid "" +"insert (optional - defaults to true): " +"Specifies whether the version column should be included in SQL insert " +"statements. May be set to false if and only if the " +"database column is defined with a default value of 0." msgstr "" +"insert (可选 - 默认是 true): 表明此版本" +"列应该包含在SQL插入语句中。只有当数据库字段有默认值0的时" +"候,才可以设置为false。" -#: index.docbook:1178 -msgid "insert (optional - defaults to true): Specifies whether the version column should be included in SQL insert statements. May be set to false if and only if the database column is defined with a default value of 0." +#. Tag: para +#: basic_mapping.xml:1188 +#, no-c-format +msgid "" +"Version numbers may be of Hibernate type long, " +"integer, short, timestamp or calendar." msgstr "" +"版本号必须是以下类型:long, integer, " +"short, timestamp或者calendar。" -#: index.docbook:1188 -msgid "Version numbers may be of Hibernate type long, integer, short, timestamp or calendar." +#. Tag: para +#: basic_mapping.xml:1193 +#, no-c-format +msgid "" +"A version or timestamp property should never be null for a detached " +"instance, so Hibernate will detect any instance with a null version or " +"timestamp as transient, no matter what other unsaved-value strategies are specified. Declaring a nullable version or " +"timestamp property is an easy way to avoid any problems with transitive " +"reattachment in Hibernate, especially useful for people using assigned " +"identifiers or composite keys!" msgstr "" +"一个脱管(detached)实例的version或timestamp属性不能为空(null),因为" +"Hibernate不管 unsaved-value被指定为何种策略,它将任何属性" +"为空的version或timestamp 实例看作为瞬时(transient)实例。 避免" +"Hibernate中的传递重附(transitive reattachment)问题的一个简单方法是 定义一个" +"不能为空的version或timestamp属性,特别是在人们使用程序分配的标识符(assigned " +"identifiers) 或复合主键时非常有用!" -#: index.docbook:1193 -msgid "A version or timestamp property should never be null for a detached instance, so Hibernate will detect any instance with a null version or timestamp as transient, no matter what other unsaved-value strategies are specified. Declaring a nullable version or timestamp property is an easy way to avoid any problems with transitive reattachment in Hibernate, especially useful for people using assigned identifiers or composite keys!" -msgstr "" - -#: index.docbook:1204 +#. Tag: title +#: basic_mapping.xml:1204 +#, no-c-format msgid "timestamp (optional)" -msgstr "" +msgstr "timestamp (可选)" -#: index.docbook:1206 -msgid "The optional <timestamp> element indicates that the table contains timestamped data. This is intended as an alternative to versioning. Timestamps are by nature a less safe implementation of optimistic locking. However, sometimes the application might use the timestamps in other ways." -msgstr "" - -#: index.docbook:1222 +#. Tag: para +#: basic_mapping.xml:1206 +#, no-c-format msgid "" - "]]>" +"The optional <timestamp> element indicates that the " +"table contains timestamped data. This is intended as an alternative to " +"versioning. Timestamps are by nature a less safe implementation of " +"optimistic locking. However, sometimes the application might use the " +"timestamps in other ways." +msgstr "" +"可选的<timestamp>元素指明了表中包含时间戳数据。 这用" +"来作为版本的替代。时间戳本质上是一种对乐观锁定的一种不是特别安全的实现。当" +"然, 有时候应用程序可能在其他方面使用时间戳。" + +#. Tag: programlisting +#: basic_mapping.xml:1222 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1225 -msgid "column (optional - defaults to the property name): The name of a column holding the timestamp." -msgstr "" +#. Tag: para +#: basic_mapping.xml:1225 +#, no-c-format +msgid "" +"column (optional - defaults to the property name): The " +"name of a column holding the timestamp." +msgstr "column (可选 - 默认为属性名): 持有时间戳的字段名。" -#: index.docbook:1231 -msgid "name: The name of a JavaBeans style property of Java type Date or Timestamp of the persistent class." +#. Tag: para +#: basic_mapping.xml:1231 +#, no-c-format +msgid "" +"name: The name of a JavaBeans style property of Java type " +"Date or Timestamp of the persistent " +"class." msgstr "" +"name: 在持久化类中的JavaBeans风格的属性名, 其Java类型是 " +"Date 或者 Timestamp的。" -#: index.docbook:1244 -msgid "unsaved-value (optional - defaults to null): A version property value that indicates that an instance is newly instantiated (unsaved), distinguishing it from detached instances that were saved or loaded in a previous session. (undefined specifies that the identifier property value should be used.)" +#. Tag: para +#: basic_mapping.xml:1244 +#, no-c-format +msgid "" +"unsaved-value (optional - defaults to null): A version property value that indicates that an instance is newly " +"instantiated (unsaved), distinguishing it from detached instances that were " +"saved or loaded in a previous session. (undefined " +"specifies that the identifier property value should be used.)" msgstr "" +"unsaved-value (可选 - 默认是null): 用于" +"标明某个实例时刚刚被实例化的(尚未保存)版本属性值,依靠这个值就可以把这种情" +"况和 已经在先前的session中保存或装载的脱管(detached)实例区分开来。" +"(undefined 指明使用标识属性值进行这种判断。)" -#: index.docbook:1253 -msgid "source (optional - defaults to vm): From where should Hibernate retrieve the timestamp value? From the database, or from the current JVM? Database-based timestamps incur an overhead because Hibernate must hit the database in order to determine the \"next value\", but will be safer for use in clustered environments. Note also, that not all Dialects are known to support retrieving of the database's current timestamp, while others might be unsafe for usage in locking due to lack of precision (Oracle 8 for example)." +#. Tag: para +#: basic_mapping.xml:1253 +#, no-c-format +msgid "" +"source (optional - defaults to vm): " +"From where should Hibernate retrieve the timestamp value? From the database, " +"or from the current JVM? Database-based timestamps incur an overhead because " +"Hibernate must hit the database in order to determine the \"next value\", " +"but will be safer for use in clustered environments. Note also, that not all " +"Dialects are known to support retrieving of the " +"database's current timestamp, while others might be unsafe for usage in " +"locking due to lack of precision (Oracle 8 for example)." msgstr "" +"source (可选 - 默认是 vm): Hibernate如" +"何才能获取到时间戳的值呢?从数据库,还是当前JVM?从数据库获取会带来一些负担," +"因为Hibernate必须访问数据库来获得“下一个值”,但是在集群环境中会更安全些。还要" +"注意,并不是所有的Dialect(方言)都支持获得数据库的当前时" +"间戳的,而支持的数据库中又有一部分因为精度不足,用于锁定是不安全的(例如" +"Oracle 8)。" -#: index.docbook:1265 -msgid "generated (optional - defaults to never): Specifies that this timestamp property value is actually generated by the database. See the discussion of generated properties." +#. Tag: para +#: basic_mapping.xml:1265 +#, fuzzy, no-c-format +msgid "" +"generated (optional - defaults to never): Specifies that this timestamp property value is actually " +"generated by the database. See the discussion of generated properties." msgstr "" +"generated (可选 - 默认是 never): 指出时" +"间戳值是否实际上是由数据库生成的.请参阅generated properties的讨论。" -#: index.docbook:1274 -msgid "Note that <timestamp> is equivalent to <version type=\"timestamp\">. And <timestamp source=\"db\"> is equivalent to <version type=\"dbtimestamp\">" +#. Tag: para +#: basic_mapping.xml:1274 +#, no-c-format +msgid "" +"Note that <timestamp> is equivalent to <" +"version type=\"timestamp\">. And <timestamp source=" +"\"db\"> is equivalent to <version type=\"dbtimestamp" +"\">" msgstr "" +"注意,<timestamp><version type=" +"\"timestamp\">是等价的。并且<timestamp source=\"db" +"\"><version type=\"dbtimestamp\">是等" +"价的。" -#: index.docbook:1284 +#. Tag: title +#: basic_mapping.xml:1284 +#, no-c-format msgid "property" -msgstr "" +msgstr "property" -#: index.docbook:1286 -msgid "The <property> element declares a persistent, JavaBean style property of the class." -msgstr "" - -#: index.docbook:1308 +#. Tag: para +#: basic_mapping.xml:1286 +#, no-c-format msgid "" - "]]>" +"The <property> element declares a persistent, " +"JavaBean style property of the class." +msgstr "" +"<property>元素为类定义了一个持久化的,JavaBean风格的" +"属性。" + +#. Tag: programlisting +#: basic_mapping.xml:1308 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1311 -msgid "name: the name of the property, with an initial lowercase letter." -msgstr "" +#. Tag: para +#: basic_mapping.xml:1311 +#, no-c-format +msgid "" +"name: the name of the property, with an initial lowercase " +"letter." +msgstr "name: 属性的名字,以小写字母开头。" -#: index.docbook:1317 -msgid "column (optional - defaults to the property name): the name of the mapped database table column. This may also be specified by nested <column> element(s)." +#. Tag: para +#: basic_mapping.xml:1317 +#, no-c-format +msgid "" +"column (optional - defaults to the property name): the " +"name of the mapped database table column. This may also be specified by " +"nested <column> element(s)." msgstr "" +"column (可选 - 默认为属性名字): 对应的数据库字段名。 也可" +"以通过嵌套的<column>元素指定。" -#: index.docbook:1324 -msgid "type (optional): a name that indicates the Hibernate type." +#. Tag: para +#: basic_mapping.xml:1324 +#, no-c-format +msgid "" +"type (optional): a name that indicates the Hibernate type." +msgstr "type (可选): 一个Hibernate类型的名字。" + +#. Tag: para +#: basic_mapping.xml:1329 +#, no-c-format +msgid "" +"update, insert (optional - defaults to true) : specifies that the mapped columns should be included in SQL " +"UPDATE and/or INSERT statements. " +"Setting both to false allows a pure \"derived\" property " +"whose value is initialized from some other property that maps to the same " +"colum(s) or by a trigger or other application." msgstr "" +"update, insert (可选 - 默认为 true) : " +"表明用于UPDATE 和/或 INSERT 的SQL语句中" +"是否包含这个被映射了的字段。这二者如果都设置为false 则表明" +"这是一个“外源性(derived)”的属性,它的值来源于映射到同一个(或多个) 字段的" +"某些其他属性,或者通过一个trigger(触发器)或其他程序生成。" -#: index.docbook:1329 -msgid "update, insert (optional - defaults to true) : specifies that the mapped columns should be included in SQL UPDATE and/or INSERT statements. Setting both to false allows a pure \"derived\" property whose value is initialized from some other property that maps to the same colum(s) or by a trigger or other application." +#. Tag: para +#: basic_mapping.xml:1338 +#, no-c-format +msgid "" +"formula (optional): an SQL expression that defines the " +"value for a computed property. Computed properties do " +"not have a column mapping of their own." msgstr "" +"formula (可选): 一个SQL表达式,定义了这个计算 " +"(computed) 属性的值。计算属性没有和它对应的数据库字段。" -#: index.docbook:1338 -msgid "formula (optional): an SQL expression that defines the value for a computed property. Computed properties do not have a column mapping of their own." +#. Tag: para +#: basic_mapping.xml:1351 +#, no-c-format +msgid "" +"lazy (optional - defaults to false): " +"Specifies that this property should be fetched lazily when the instance " +"variable is first accessed (requires build-time bytecode instrumentation)." msgstr "" +"lazy (可选 - 默认为 false): 指定 指定实" +"例变量第一次被访问时,这个属性是否延迟抓取(fetched lazily)( 需要运行时字节" +"码增强)。" -#: index.docbook:1351 -msgid "lazy (optional - defaults to false): Specifies that this property should be fetched lazily when the instance variable is first accessed (requires build-time bytecode instrumentation)." +#. Tag: para +#: basic_mapping.xml:1358 +#, no-c-format +msgid "" +"unique (optional): Enable the DDL generation of a unique " +"constraint for the columns. Also, allow this to be the target of a " +"property-ref." msgstr "" +"unique (可选): 使用DDL为该字段添加唯一的约束。 同样,允许" +"它作为property-ref引用的目标。" -#: index.docbook:1358 -msgid "unique (optional): Enable the DDL generation of a unique constraint for the columns. Also, allow this to be the target of a property-ref." +#. Tag: para +#: basic_mapping.xml:1365 +#, no-c-format +msgid "" +"not-null (optional): Enable the DDL generation of a " +"nullability constraint for the columns." msgstr "" +"not-null (可选): 使用DDL为该字段添加可否为空" +"(nullability)的约束。" -#: index.docbook:1365 -msgid "not-null (optional): Enable the DDL generation of a nullability constraint for the columns." +#. Tag: para +#: basic_mapping.xml:1371 +#, no-c-format +msgid "" +"optimistic-lock (optional - defaults to true): Specifies that updates to this property do or do not require " +"acquisition of the optimistic lock. In other words, determines if a version " +"increment should occur when this property is dirty." msgstr "" +"optimistic-lock (可选 - 默认为 true): " +"指定这个属性在做更新时是否需要获得乐观锁定(optimistic lock)。 换句话说,它" +"决定这个属性发生脏数据时版本(version)的值是否增长。" -#: index.docbook:1371 -msgid "optimistic-lock (optional - defaults to true): Specifies that updates to this property do or do not require acquisition of the optimistic lock. In other words, determines if a version increment should occur when this property is dirty." +#. Tag: para +#: basic_mapping.xml:1379 +#, fuzzy, no-c-format +msgid "" +"generated (optional - defaults to never): Specifies that this property value is actually generated by the " +"database. See the discussion of generated properties." msgstr "" +"generated (可选 - 默认为 never): 表明此" +"属性值是否实际上是由数据库生成的。请参阅generated properties的讨论。" -#: index.docbook:1379 -msgid "generated (optional - defaults to never): Specifies that this property value is actually generated by the database. See the discussion of generated properties." -msgstr "" - -#: index.docbook:1388 +#. Tag: para +#: basic_mapping.xml:1388 +#, no-c-format msgid "typename could be:" -msgstr "" +msgstr "typename可以是如下几种:" -#: index.docbook:1394 -msgid "The name of a Hibernate basic type (eg. integer, string, character, date, timestamp, float, binary, serializable, object, blob)." +#. Tag: para +#: basic_mapping.xml:1394 +#, no-c-format +msgid "" +"The name of a Hibernate basic type (eg. integer, string, character, " +"date, timestamp, float, binary, serializable, object, blob)." msgstr "" +"Hibernate基本类型名(比如:integer, string, character,date, " +"timestamp, float, binary, serializable, object, blob)。" -#: index.docbook:1400 -msgid "The name of a Java class with a default basic type (eg. int, float, char, java.lang.String, java.util.Date, java.lang.Integer, java.sql.Clob)." +#. Tag: para +#: basic_mapping.xml:1400 +#, no-c-format +msgid "" +"The name of a Java class with a default basic type (eg. int, float, " +"char, java.lang.String, java.util.Date, java.lang.Integer, java.sql.Clob)." msgstr "" +"一个Java类的名字,这个类属于一种默认基础类型 (比如: int, float," +"char, java.lang.String, java.util.Date, java.lang.Integer, java.sql.Clob)。" -#: index.docbook:1406 +#. Tag: para +#: basic_mapping.xml:1406 +#, no-c-format msgid "The name of a serializable Java class." -msgstr "" +msgstr "一个可以序列化的Java类的名字。" -#: index.docbook:1411 -msgid "The class name of a custom type (eg. com.illflow.type.MyCustomType)." -msgstr "" - -#: index.docbook:1417 -msgid "If you do not specify a type, Hibernate will use reflection upon the named property to take a guess at the correct Hibernate type. Hibernate will try to interpret the name of the return class of the property getter using rules 2, 3, 4 in that order. However, this is not always enough. In certain cases you will still need the type attribute. (For example, to distinguish between Hibernate.DATE and Hibernate.TIMESTAMP, or to specify a custom type.)" -msgstr "" - -#: index.docbook:1427 -msgid "The access attribute lets you control how Hibernate will access the property at runtime. By default, Hibernate will call the property get/set pair. If you specify access=\"field\", Hibernate will bypass the get/set pair and access the field directly, using reflection. You may specify your own strategy for property access by naming a class that implements the interface org.hibernate.property.PropertyAccessor." -msgstr "" - -#: index.docbook:1436 -msgid "An especially powerful feature are derived properties. These properties are by definition read-only, the property value is computed at load time. You declare the computation as a SQL expression, this translates to a SELECT clause subquery in the SQL query that loads an instance:" -msgstr "" - -#: index.docbook:1443 +#. Tag: para +#: basic_mapping.xml:1411 +#, no-c-format msgid "" - "]]>" +"The class name of a custom type (eg. com.illflow.type.MyCustomType)." +msgstr "" +"一个自定义类型的类的名字。(比如: com.illflow.type.MyCustomType)。" + +#. Tag: para +#: basic_mapping.xml:1417 +#, no-c-format +msgid "" +"If you do not specify a type, Hibernate will use reflection upon the named " +"property to take a guess at the correct Hibernate type. Hibernate will try " +"to interpret the name of the return class of the property getter using rules " +"2, 3, 4 in that order. However, this is not always enough. In certain cases " +"you will still need the type attribute. (For example, to " +"distinguish between Hibernate.DATE and Hibernate." +"TIMESTAMP, or to specify a custom type.)" +msgstr "" +"如果你没有指定类型,Hibernarte会使用反射来得到这个名字的属性,以此来猜测正确" +"的Hibernate类型。 Hibernate会按照规则2,3,4的顺序对属性读取器(getter方法)的返" +"回类进行解释。然而,这还不够。 在某些情况下你仍然需要type" +"属性。(比如,为了区别Hibernate.DATEHibernate." +"TIMESTAMP,或者为了指定一个自定义类型。)" + +#. Tag: para +#: basic_mapping.xml:1427 +#, no-c-format +msgid "" +"The access attribute lets you control how Hibernate will " +"access the property at runtime. By default, Hibernate will call the property " +"get/set pair. If you specify access=\"field\", Hibernate " +"will bypass the get/set pair and access the field directly, using " +"reflection. You may specify your own strategy for property access by naming " +"a class that implements the interface org.hibernate.property." +"PropertyAccessor." +msgstr "" +"access属性用来让你控制Hibernate如何在运行时访问属性。在默" +"认情况下, Hibernate会使用属性的get/set方法对(pair)。如果你指明" +"access=\"field\", Hibernate会忽略get/set方法对,直接使用反" +"射来访问成员变量。你也可以指定你自己的策略, 这就需要你自己实现org." +"hibernate.property.PropertyAccessor接口, 再在access中设置你自定义" +"策略类的名字。" + +#. Tag: para +#: basic_mapping.xml:1436 +#, no-c-format +msgid "" +"An especially powerful feature are derived properties. These properties are " +"by definition read-only, the property value is computed at load time. You " +"declare the computation as a SQL expression, this translates to a " +"SELECT clause subquery in the SQL query that loads an " +"instance:" +msgstr "" +"衍生属性(derive propertie)是一个特别强大的特征。这些属性应该定义为只读,属" +"性值在装载时计算生成。 你用一个SQL表达式生成计算的结果,它会在这个实例转载时" +"翻译成一个SQL查询的SELECT 子查询语句。" + +#. Tag: programlisting +#: basic_mapping.xml:1443 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1445 -msgid "Note that you can reference the entities own table by not declaring an alias on a particular column (customerId in the given example). Also note that you can use the nested <formula> mapping element if you don't like to use the attribute." +#. Tag: para +#: basic_mapping.xml:1445 +#, no-c-format +msgid "" +"Note that you can reference the entities own table by not declaring an alias " +"on a particular column (customerId in the given example). " +"Also note that you can use the nested <formula> " +"mapping element if you don't like to use the attribute." msgstr "" +"注意,你可以使用实体自己的表,而不用为这个特别的列定义别名( 上面例子中的" +"customerId)。同时注意,如果你不喜欢使用属性, 你可以使用" +"嵌套的<formula>映射元素。" -#: index.docbook:1455 +#. Tag: title +#: basic_mapping.xml:1455 +#, no-c-format msgid "many-to-one" -msgstr "" +msgstr "多对一(many-to-one)" -#: index.docbook:1457 -msgid "An ordinary association to another persistent class is declared using a many-to-one element. The relational model is a many-to-one association: a foreign key in one table is referencing the primary key column(s) of the target table." -msgstr "" - -#: index.docbook:1485 +#. Tag: para +#: basic_mapping.xml:1457 +#, no-c-format msgid "" - "]]>" +"An ordinary association to another persistent class is declared using a " +"many-to-one element. The relational model is a many-to-" +"one association: a foreign key in one table is referencing the primary key " +"column(s) of the target table." +msgstr "" +"通过many-to-one元素,可以定义一种常见的与另一个持久化类的关" +"联。 这种关系模型是多对一关联(实际上是一个对象引用-译注):这个表的一个外键" +"引用目标表的 主键字段。" + +#. Tag: programlisting +#: basic_mapping.xml:1485 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1488, index.docbook:1669, index.docbook:1855 +#. Tag: para +#: basic_mapping.xml:1488 basic_mapping.xml:1669 basic_mapping.xml:1855 +#, fuzzy, no-c-format msgid "name: The name of the property." msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"name: 属性名。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"name: 属性的名字。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"name: 属性名" -#: index.docbook:1493, index.docbook:2284 -msgid "column (optional): The name of the foreign key column. This may also be specified by nested <column> element(s)." -msgstr "" - -#: index.docbook:1500, index.docbook:1674 -msgid "class (optional - defaults to the property type determined by reflection): The name of the associated class." -msgstr "" - -#: index.docbook:1506 -msgid "cascade (optional): Specifies which operations should be cascaded from the parent object to the associated object." -msgstr "" - -#: index.docbook:1512, index.docbook:1695 -msgid "fetch (optional - defaults to select): Chooses between outer-join fetching or sequential select fetching." -msgstr "" - -#: index.docbook:1518 -msgid "update, insert (optional - defaults to true) specifies that the mapped columns should be included in SQL UPDATE and/or INSERT statements. Setting both to false allows a pure \"derived\" association whose value is initialized from some other property that maps to the same colum(s) or by a trigger or other application." -msgstr "" - -#: index.docbook:1527 -msgid "property-ref: (optional) The name of a property of the associated class that is joined to this foreign key. If not specified, the primary key of the associated class is used." -msgstr "" - -#: index.docbook:1540 -msgid "unique (optional): Enable the DDL generation of a unique constraint for the foreign-key column. Also, allow this to be the target of a property-ref. This makes the association multiplicity effectively one to one." -msgstr "" - -#: index.docbook:1548 -msgid "not-null (optional): Enable the DDL generation of a nullability constraint for the foreign key columns." -msgstr "" - -#: index.docbook:1554 -msgid "optimistic-lock (optional - defaults to true): Specifies that updates to this property do or do not require acquisition of the optimistic lock. In other words, dertermines if a version increment should occur when this property is dirty." -msgstr "" - -#: index.docbook:1562 -msgid "lazy (optional - defaults to proxy): By default, single point associations are proxied. lazy=\"no-proxy\" specifies that the property should be fetched lazily when the instance variable is first accessed (requires build-time bytecode instrumentation). lazy=\"false\" specifies that the association will always be eagerly fetched." -msgstr "" - -#: index.docbook:1572 -msgid "not-found (optional - defaults to exception): Specifies how foreign keys that reference missing rows will be handled: ignore will treat a missing row as a null association." -msgstr "" - -#: index.docbook:1579, index.docbook:1733 -msgid "entity-name (optional): The entity name of the associated class." -msgstr "" - -#: index.docbook:1585 -msgid "formula (optional): an SQL expression that defines the value for a computed foreign key." -msgstr "" - -#: index.docbook:1592 -msgid "Setting a value of the cascade attribute to any meaningful value other than none will propagate certain operations to the associated object. The meaningful values are the names of Hibernate's basic operations, persist, merge, delete, save-update, evict, replicate, lock, refresh, as well as the special values delete-orphan and all and comma-separated combinations of operation names, for example, cascade=\"persist,merge,evict\" or cascade=\"all,delete-orphan\". See for a full explanation. Note that single valued associations (many-to-one and one-to-one associations) do not support orphan delete." -msgstr "" - -#: index.docbook:1605 -msgid "A typical many-to-one declaration looks as simple as this:" -msgstr "" - -#: index.docbook:1609 -msgid "]]>" -msgstr "" - -#: index.docbook:1611 -msgid "The property-ref attribute should only be used for mapping legacy data where a foreign key refers to a unique key of the associated table other than the primary key. This is an ugly relational model. For example, suppose the Product class had a unique serial number, that is not the primary key. (The unique attribute controls Hibernate's DDL generation with the SchemaExport tool.)" -msgstr "" - -#: index.docbook:1620 -msgid "]]>" -msgstr "" - -#: index.docbook:1622 -msgid "Then the mapping for OrderItem might use:" -msgstr "" - -#: index.docbook:1626 -msgid "]]>" -msgstr "" - -#: index.docbook:1628 -msgid "This is certainly not encouraged, however." -msgstr "" - -#: index.docbook:1632 -msgid "If the referenced unique key comprises multiple properties of the associated entity, you should map the referenced properties inside a named <properties> element." -msgstr "" - -#: index.docbook:1637 -msgid "If the referenced unique key is the property of a component, you may specify a property path:" -msgstr "" - -#: index.docbook:1641 -msgid "]]>" -msgstr "" - -#: index.docbook:1646 -msgid "one-to-one" -msgstr "" - -#: index.docbook:1648 -msgid "A one-to-one association to another persistent class is declared using a one-to-one element." -msgstr "" - -#: index.docbook:1666 +#. Tag: para +#: basic_mapping.xml:1493 basic_mapping.xml:2284 +#, fuzzy, no-c-format msgid "" - "]]>" +"column (optional): The name of the foreign key column. " +"This may also be specified by nested <column> " +"element(s)." +msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"column (可选): 外间字段名。它也可以通过嵌套的 " +"<column>元素指定。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"column (可选): 外键字段的名称。也可以通过嵌套的 " +"<column>指定。" + +#. Tag: para +#: basic_mapping.xml:1500 basic_mapping.xml:1674 +#, fuzzy, no-c-format +msgid "" +"class (optional - defaults to the property type " +"determined by reflection): The name of the associated class." +msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"class (可选 - 默认是通过反射得到属性类型): 关联的类的名" +"字。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"class (可选 - 默认是通过反射得到的属性类型):被关联的类的" +"名字。" + +#. Tag: para +#: basic_mapping.xml:1506 +#, no-c-format +msgid "" +"cascade (optional): Specifies which operations should be " +"cascaded from the parent object to the associated object." +msgstr "" +"cascade(级联) (可选): 指明哪些操作会从父对象级联到关联的" +"对象。" + +#. Tag: para +#: basic_mapping.xml:1512 basic_mapping.xml:1695 +#, fuzzy, no-c-format +msgid "" +"fetch (optional - defaults to select): " +"Chooses between outer-join fetching or sequential select fetching." +msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"fetch (可选 - 默认为 select): 在外连接" +"抓取(outer-join fetching)和序列选择抓取(sequential select fetching)两者中" +"选择其一。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"fetch (可选 - 默认设置为选择): 在外连接" +"抓取或者序列选择抓取选择其一." + +#. Tag: para +#: basic_mapping.xml:1518 +#, no-c-format +msgid "" +"update, insert (optional - defaults to true) specifies that the mapped columns should be included in SQL " +"UPDATE and/or INSERT statements. " +"Setting both to false allows a pure \"derived\" " +"association whose value is initialized from some other property that maps to " +"the same colum(s) or by a trigger or other application." +msgstr "" +"update, insert (可选 - 默认为 true) 指" +"定对应的字段是否包含在用于UPDATE 和/或 INSERT 的SQL语句中。如果二者都是false,则这是一个纯粹的 " +"“外源性(derived)”关联,它的值是通过映射到同一个(或多个)字段的某些其他属性" +"得到 或者通过trigger(触发器)、或其他程序生成。" + +#. Tag: para +#: basic_mapping.xml:1527 +#, no-c-format +msgid "" +"property-ref: (optional) The name of a property of the " +"associated class that is joined to this foreign key. If not specified, the " +"primary key of the associated class is used." +msgstr "" +"property-ref: (可选) 指定关联类的一个属性,这个属性将会和" +"本外键相对应。 如果没有指定,会使用对方关联类的主键。" + +#. Tag: para +#: basic_mapping.xml:1540 +#, no-c-format +msgid "" +"unique (optional): Enable the DDL generation of a unique " +"constraint for the foreign-key column. Also, allow this to be the target of " +"a property-ref. This makes the association multiplicity " +"effectively one to one." +msgstr "" +"unique (可选): 使用DDL为外键字段生成一个唯一约束。此外, " +"这也可以用作property-ref的目标属性。这使关联同时具有 一对" +"一的效果。" + +#. Tag: para +#: basic_mapping.xml:1548 +#, no-c-format +msgid "" +"not-null (optional): Enable the DDL generation of a " +"nullability constraint for the foreign key columns." +msgstr "" +"not-null (可选): 使用DDL为外键字段生成一个非空约束。" + +#. Tag: para +#: basic_mapping.xml:1554 +#, no-c-format +msgid "" +"optimistic-lock (optional - defaults to true): Specifies that updates to this property do or do not require " +"acquisition of the optimistic lock. In other words, dertermines if a version " +"increment should occur when this property is dirty." +msgstr "" +"optimistic-lock (可选 - 默认为 true): " +"指定这个属性在做更新时是否需要获得乐观锁定(optimistic lock)。 换句话说,它" +"决定这个属性发生脏数据时版本(version)的值是否增长。" + +#. Tag: para +#: basic_mapping.xml:1562 +#, no-c-format +msgid "" +"lazy (optional - defaults to proxy): " +"By default, single point associations are proxied. lazy=\"no-proxy" +"\" specifies that the property should be fetched lazily when the " +"instance variable is first accessed (requires build-time bytecode " +"instrumentation). lazy=\"false\" specifies that the " +"association will always be eagerly fetched." +msgstr "" +"lazy (可选 - 默认为 proxy): 默认情况" +"下,单点关联是经过代理的。lazy=\"no-proxy\"指定此属性应该" +"在实例变量第一次被访问时应该延迟抓取(fetche lazily)(需要运行时字节码的增" +"强)。 lazy=\"false\"指定此关联总是被预先抓取。" + +#. Tag: para +#: basic_mapping.xml:1572 +#, no-c-format +msgid "" +"not-found (optional - defaults to exception): Specifies how foreign keys that reference missing rows will be " +"handled: ignore will treat a missing row as a null " +"association." +msgstr "" +"not-found (可选 - 默认为 exception): 指" +"定外键引用的数据不存在时如何处理: ignore会将行数据不存在" +"视为一个空(null)关联。" + +#. Tag: para +#: basic_mapping.xml:1579 basic_mapping.xml:1733 +#, no-c-format +msgid "" +"entity-name (optional): The entity name of the associated " +"class." +msgstr "entity-name (可选): 被关联的类的实体名。" + +#. Tag: para +#: basic_mapping.xml:1585 +#, no-c-format +msgid "" +"formula (optional): an SQL expression that defines the " +"value for a computed foreign key." +msgstr "" +"formula (可选): SQL表达式,用于定义computed(计" +"算出的)外键值。" + +#. Tag: para +#: basic_mapping.xml:1592 +#, no-c-format +msgid "" +"Setting a value of the cascade attribute to any " +"meaningful value other than none will propagate certain " +"operations to the associated object. The meaningful values are the names of " +"Hibernate's basic operations, persist, merge, delete, save-update, " +"evict, replicate, lock, refresh, as well as the special values " +"delete-orphan and all and comma-" +"separated combinations of operation names, for example, cascade=" +"\"persist,merge,evict\" or cascade=\"all,delete-orphan\". See for a full " +"explanation. Note that single valued associations (many-to-one and one-to-" +"one associations) do not support orphan delete." +msgstr "" +"cascade属性设置为除了none以外任何有意义" +"的值, 它将把特定的操作传递到关联对象中。这个值就代表着Hibernate基本操作的名" +"称, persist, merge, delete, save-update, evict, replicate, lock, " +"refresh, 以及特别的值delete-orphan和" +"all,并且可以用逗号分隔符 来组合这些操作,例如," +"cascade=\"persist,merge,evict\"cascade=\"all," +"delete-orphan\"。更全面的解释请参考. 注意,单值关联 (many-to-one 和 one-to-one 关联) 不支持删除孤" +"儿(orphan delete,删除不再被引用的值)." + +#. Tag: para +#: basic_mapping.xml:1605 +#, no-c-format +msgid "" +"A typical many-to-one declaration looks as simple as this:" +msgstr "一个典型的简单many-to-one定义例子:" + +#. Tag: programlisting +#: basic_mapping.xml:1609 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1680 -msgid "cascade (optional) specifies which operations should be cascaded from the parent object to the associated object." +#. Tag: para +#: basic_mapping.xml:1611 +#, no-c-format +msgid "" +"The property-ref attribute should only be used for " +"mapping legacy data where a foreign key refers to a unique key of the " +"associated table other than the primary key. This is an ugly relational " +"model. For example, suppose the Product class had a " +"unique serial number, that is not the primary key. (The unique attribute controls Hibernate's DDL generation with the SchemaExport " +"tool.)" +msgstr "" +"property-ref属性只应该用来对付遗留下来的数据库系统, 可能" +"有外键指向对方关联表的是个非主键字段(但是应该是一个惟一关键字)的情况下。 这" +"是一种十分丑陋的关系模型。比如说,假设Product类有一个惟一" +"的序列号, 它并不是主键。(unique属性控制Hibernate通过" +"SchemaExport工具进行的DDL生成。)" + +#. Tag: programlisting +#: basic_mapping.xml:1620 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1686 -msgid "constrained (optional) specifies that a foreign key constraint on the primary key of the mapped table references the table of the associated class. This option affects the order in which save() and delete() are cascaded, and determines whether the association may be proxied (it is also used by the schema export tool)." +#. Tag: para +#: basic_mapping.xml:1622 +#, no-c-format +msgid "Then the mapping for OrderItem might use:" +msgstr "那么关于OrderItem 的映射可能是:" + +#. Tag: programlisting +#: basic_mapping.xml:1626 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1701 -msgid "property-ref: (optional) The name of a property of the associated class that is joined to the primary key of this class. If not specified, the primary key of the associated class is used." +#. Tag: para +#: basic_mapping.xml:1628 +#, no-c-format +msgid "This is certainly not encouraged, however." +msgstr "当然,我们决不鼓励这种用法。" + +#. Tag: para +#: basic_mapping.xml:1632 +#, no-c-format +msgid "" +"If the referenced unique key comprises multiple properties of the associated " +"entity, you should map the referenced properties inside a named <" +"properties> element." +msgstr "" +"如果被引用的唯一主键由关联实体的多个属性组成,你应该在名称为<" +"properties>的元素 里面映射所有关联的属性。" + +#. Tag: para +#: basic_mapping.xml:1637 +#, no-c-format +msgid "" +"If the referenced unique key is the property of a component, you may specify " +"a property path:" +msgstr "假若被引用的唯一主键是组件的属性,你可以指定属性路径:" + +#. Tag: programlisting +#: basic_mapping.xml:1641 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1714 -msgid "formula (optional): Almost all one to one associations map to the primary key of the owning entity. In the rare case that this is not the case, you may specify a some other column, columns or expression to join on using an SQL formula. (See org.hibernate.test.onetooneformula for an example.)" +#. Tag: title +#: basic_mapping.xml:1646 +#, no-c-format +msgid "one-to-one" +msgstr "一对一" + +#. Tag: para +#: basic_mapping.xml:1648 +#, no-c-format +msgid "" +"A one-to-one association to another persistent class is declared using a " +"one-to-one element." +msgstr "" +"持久化对象之间一对一的关联关系是通过one-to-one元素定义的。" + +#. Tag: programlisting +#: basic_mapping.xml:1666 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1722 -msgid "lazy (optional - defaults to proxy): By default, single point associations are proxied. lazy=\"no-proxy\" specifies that the property should be fetched lazily when the instance variable is first accessed (requires build-time bytecode instrumentation). lazy=\"false\" specifies that the association will always be eagerly fetched. Note that if constrained=\"false\", proxying is impossible and Hibernate will eager fetch the association!" +#. Tag: para +#: basic_mapping.xml:1680 +#, no-c-format +msgid "" +"cascade (optional) specifies which operations should be " +"cascaded from the parent object to the associated object." msgstr "" +"cascade(级联) (可选) 表明操作是否从父对象级联到被关联的对" +"象。" -#: index.docbook:1740 +#. Tag: para +#: basic_mapping.xml:1686 +#, no-c-format +msgid "" +"constrained (optional) specifies that a foreign key " +"constraint on the primary key of the mapped table references the table of " +"the associated class. This option affects the order in which save()" +" and delete() are cascaded, and determines " +"whether the association may be proxied (it is also used by the schema export " +"tool)." +msgstr "" +"constrained(约束) (可选) 表明该类对应的表对应的数据库表," +"和被关联的对象所对应的数据库表之间,通过一个外键引用对主键进行约束。 这个选项" +"影响save()delete()在级联执行时的先后" +"顺序以及 决定该关联能否被委托(也在schema export tool中被使用)." + +#. Tag: para +#: basic_mapping.xml:1701 +#, no-c-format +msgid "" +"property-ref: (optional) The name of a property of the " +"associated class that is joined to the primary key of this class. If not " +"specified, the primary key of the associated class is used." +msgstr "" +"property-ref: (可选) 指定关联类的属性名,这个属性将会和本" +"类的主键相对应。如果没有指定,会使用对方关联类的主键。" + +#. Tag: para +#: basic_mapping.xml:1714 +#, no-c-format +msgid "" +"formula (optional): Almost all one to one associations " +"map to the primary key of the owning entity. In the rare case that this is " +"not the case, you may specify a some other column, columns or expression to " +"join on using an SQL formula. (See org.hibernate.test." +"onetooneformula for an example.)" +msgstr "" +"formula (可选):绝大多数一对一的关联都指向其实体的主键。在" +"一些少见的情况中, 你可能会指向其他的一个或多个字段,或者是一个表达式,这些情" +"况下,你可以用一个SQL公式来表示。 (可以在org.hibernate.test.onetooneformula" +"找到例子)" + +#. Tag: para +#: basic_mapping.xml:1722 +#, no-c-format +msgid "" +"lazy (optional - defaults to proxy): " +"By default, single point associations are proxied. lazy=\"no-proxy" +"\" specifies that the property should be fetched lazily when the " +"instance variable is first accessed (requires build-time bytecode " +"instrumentation). lazy=\"false\" specifies that the " +"association will always be eagerly fetched. Note that if " +"constrained=\"false\", proxying is impossible and " +"Hibernate will eager fetch the association!" +msgstr "" +"lazy (可选 - 默认为 proxy): 默认情况" +"下,单点关联是经过代理的。lazy=\"no-proxy\"指定此属性应该" +"在实例变量第一次被访问时应该延迟抓取(fetche lazily)(需要运行时字节码的增" +"强)。 lazy=\"false\"指定此关联总是被预先抓取。" +"注意,如果constrained=\"false\", 不可能使用代理,Hibernate" +"会采取预先抓取!" + +#. Tag: para +#: basic_mapping.xml:1740 +#, no-c-format msgid "There are two varieties of one-to-one association:" -msgstr "" +msgstr "有两种不同的一对一关联:" -#: index.docbook:1744 +#. Tag: para +#: basic_mapping.xml:1744 +#, no-c-format msgid "primary key associations" -msgstr "" +msgstr "主键关联" -#: index.docbook:1747 +#. Tag: para +#: basic_mapping.xml:1747 +#, no-c-format msgid "unique foreign key associations" -msgstr "" +msgstr "惟一外键关联" -#: index.docbook:1752 -msgid "Primary key associations don't need an extra table column; if two rows are related by the association then the two table rows share the same primary key value. So if you want two objects to be related by a primary key association, you must make sure that they are assigned the same identifier value!" +#. Tag: para +#: basic_mapping.xml:1752 +#, no-c-format +msgid "" +"Primary key associations don't need an extra table column; if two rows are " +"related by the association then the two table rows share the same primary " +"key value. So if you want two objects to be related by a primary key " +"association, you must make sure that they are assigned the same identifier " +"value!" msgstr "" +"主键关联不需要额外的表字段;如果两行是通过这种一对一关系相关联的,那么这两行" +"就共享同样的主关键字值。所以如果你希望两个对象通过主键一对一关联,你必须确认" +"它们被赋予同样的标识值!" -#: index.docbook:1759 -msgid "For a primary key association, add the following mappings to Employee and Person, respectively." +#. Tag: para +#: basic_mapping.xml:1759 +#, no-c-format +msgid "" +"For a primary key association, add the following mappings to " +"Employee and Person, respectively." msgstr "" +"比如说,对下面的EmployeePerson进行主" +"键一对一关联:" -#: index.docbook:1764 +#. Tag: programlisting +#: basic_mapping.xml:1764 +#, no-c-format msgid "]]>" msgstr "" -#: index.docbook:1765 -msgid "]]>" -msgstr "" - -#: index.docbook:1767 -msgid "Now we must ensure that the primary keys of related rows in the PERSON and EMPLOYEE tables are equal. We use a special Hibernate identifier generation strategy called foreign:" -msgstr "" - -#: index.docbook:1773 +#. Tag: programlisting +#: basic_mapping.xml:1765 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " employee\n" - " \n" - " \n" - " ...\n" - " \n" - "]]>" +"]]>" msgstr "" -#: index.docbook:1775 -msgid "A newly saved instance of Person is then assigned the same primary key value as the Employee instance refered with the employee property of that Person." +#. Tag: para +#: basic_mapping.xml:1767 +#, no-c-format +msgid "" +"Now we must ensure that the primary keys of related rows in the PERSON and " +"EMPLOYEE tables are equal. We use a special Hibernate identifier generation " +"strategy called foreign:" +msgstr "" +"现在我们必须确保PERSON和EMPLOYEE中相关的字段是相等的。我们使用一个被成为" +"foreign的特殊的hibernate标识符生成策略:" + +#. Tag: programlisting +#: basic_mapping.xml:1773 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" employee\n" +" \n" +" \n" +" ...\n" +" \n" +"]]>" msgstr "" -#: index.docbook:1781 -msgid "Alternatively, a foreign key with a unique constraint, from Employee to Person, may be expressed as:" +#. Tag: para +#: basic_mapping.xml:1775 +#, no-c-format +msgid "" +"A newly saved instance of Person is then assigned the " +"same primary key value as the Employee instance refered " +"with the employee property of that Person." +msgstr "" +"一个刚刚保存的Person实例被赋予和该Personemployee属性所指向的Employee" +"实例同样的关键字值。" + +#. Tag: para +#: basic_mapping.xml:1781 +#, no-c-format +msgid "" +"Alternatively, a foreign key with a unique constraint, from " +"Employee to Person, may be expressed " +"as:" +msgstr "" +"另一种方式是一个外键和一个惟一关键字对应,上面的Employee和" +"Person的例子,如果使用这种关联方式,可以表达成:" + +#. Tag: programlisting +#: basic_mapping.xml:1786 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1786 -msgid "]]>" +#. Tag: para +#: basic_mapping.xml:1788 +#, no-c-format +msgid "" +"And this association may be made bidirectional by adding the following to " +"the Person mapping:" +msgstr "" +"如果在Person的映射加入下面几句,这种关联就是双向的:" + +#. Tag: programlisting +#: basic_mapping.xml:1793 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:1788 -msgid "And this association may be made bidirectional by adding the following to the Person mapping:" -msgstr "" - -#: index.docbook:1793 -msgid "]]>" -msgstr "" - -#: index.docbook:1798 +#. Tag: title +#: basic_mapping.xml:1798 +#, no-c-format msgid "natural-id" -msgstr "" +msgstr "自然ID(natural-id)" -#: index.docbook:1800 +#. Tag: programlisting +#: basic_mapping.xml:1800 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " ......\n" - "]]>" +"\n" +" \n" +" \n" +" ......\n" +"]]>" msgstr "" -#: index.docbook:1802 -msgid "Even though we recommend the use of surrogate keys as primary keys, you should still try to identify natural keys for all entities. A natural key is a property or combination of properties that is unique and non-null. If it is also immutable, even better. Map the properties of the natural key inside the <natural-id> element. Hibernate will generate the necessary unique key and nullability constraints, and your mapping will be more self-documenting." +#. Tag: para +#: basic_mapping.xml:1802 +#, no-c-format +msgid "" +"Even though we recommend the use of surrogate keys as primary keys, you " +"should still try to identify natural keys for all entities. A natural key is " +"a property or combination of properties that is unique and non-null. If it " +"is also immutable, even better. Map the properties of the natural key inside " +"the <natural-id> element. Hibernate will generate " +"the necessary unique key and nullability constraints, and your mapping will " +"be more self-documenting." msgstr "" +"我们建议使用代用键(键值不具备实际意义)作为主键,我们仍然应该尝试为所有的实" +"体采用自然的键值作为(附加——译者注)标示。自然键(natural key)是单个或组合属" +"性,他们必须唯一且非空。如果它还是不可变的那就更理想了。在<" +"natural-id>元素中列出自然键的属性。Hibernate会帮你生成必须的唯一" +"键值和非空约束,你的映射会更加的明显易懂(原文是self-documenting,自我注" +"解)。" -#: index.docbook:1811 -msgid "We strongly recommend that you implement equals() and hashCode() to compare the natural key properties of the entity." +#. Tag: para +#: basic_mapping.xml:1811 +#, no-c-format +msgid "" +"We strongly recommend that you implement equals() and " +"hashCode() to compare the natural key properties of the " +"entity." msgstr "" +"我们强烈建议你实现equals()hashCode()" +"方法,来比较实体的自然键属性。" -#: index.docbook:1816 -msgid "This mapping is not intended for use with entities with natural primary keys." +#. Tag: para +#: basic_mapping.xml:1816 +#, no-c-format +msgid "" +"This mapping is not intended for use with entities with natural primary keys." +msgstr "这一映射不是为了把自然键作为主键而准备的。" + +#. Tag: para +#: basic_mapping.xml:1822 +#, no-c-format +msgid "" +"mutable (optional, defaults to false): " +"By default, natural identifier properties as assumed to be immutable " +"(constant)." msgstr "" +"mutable (可选, 默认为false): 默认情况" +"下,自然标识属性被假定为不可变的(常量)。" -#: index.docbook:1822 -msgid "mutable (optional, defaults to false): By default, natural identifier properties as assumed to be immutable (constant)." -msgstr "" - -#: index.docbook:1832 +#. Tag: title +#: basic_mapping.xml:1832 +#, no-c-format msgid "component, dynamic-component" -msgstr "" +msgstr "组件(component), 动态组件(dynamic-component)" -#: index.docbook:1834 -msgid "The <component> element maps properties of a child object to columns of the table of a parent class. Components may, in turn, declare their own properties, components or collections. See \"Components\" below." -msgstr "" - -#: index.docbook:1852 +#. Tag: para +#: basic_mapping.xml:1834 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " ........\n" - "]]>" +"The <component> element maps properties of a child " +"object to columns of the table of a parent class. Components may, in turn, " +"declare their own properties, components or collections. See \"Components\" " +"below." +msgstr "" +"<component>元素把子对象的一些元素与父类对应的表的一" +"些字段映射起来。 然后组件可以定义它们自己的属性、组件或者集合。参见后面" +"的“Components”一章。" + +#. Tag: programlisting +#: basic_mapping.xml:1852 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" \n" +" ........\n" +"]]>" msgstr "" -#: index.docbook:1860 -msgid "class (optional - defaults to the property type determined by reflection): The name of the component (child) class." +#. Tag: para +#: basic_mapping.xml:1860 +#, no-c-format +msgid "" +"class (optional - defaults to the property type " +"determined by reflection): The name of the component (child) class." msgstr "" +"class (可选 - 默认为通过反射得到的属性类型):组件(子)类的名" +"字。" -#: index.docbook:1866, index.docbook:1955 -msgid "insert: Do the mapped columns appear in SQL INSERTs?" +#. Tag: para +#: basic_mapping.xml:1866 basic_mapping.xml:1955 +#, fuzzy, no-c-format +msgid "" +"insert: Do the mapped columns appear in SQL " +"INSERTs?" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"insert: 被映射的字段是否出现在SQL的INSERT语句中?\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"insert: 被映射的字段是否出现在SQL的 INSERT语句中?" -#: index.docbook:1872, index.docbook:1961 -msgid "update: Do the mapped columns appear in SQL UPDATEs?" +#. Tag: para +#: basic_mapping.xml:1872 basic_mapping.xml:1961 +#, fuzzy, no-c-format +msgid "" +"update: Do the mapped columns appear in SQL " +"UPDATEs?" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"update: 被映射的字段是否出现在SQL的UPDATE语句中?\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"update: 被映射的字段是否出现在SQL的 UPDATE语句中?" -#: index.docbook:1884 -msgid "lazy (optional - defaults to false): Specifies that this component should be fetched lazily when the instance variable is first accessed (requires build-time bytecode instrumentation)." +#. Tag: para +#: basic_mapping.xml:1884 +#, no-c-format +msgid "" +"lazy (optional - defaults to false): " +"Specifies that this component should be fetched lazily when the instance " +"variable is first accessed (requires build-time bytecode instrumentation)." msgstr "" +"lazy (可选 - 默认是 false): 表明此组件" +"应在实例变量第一次被访问的时候延迟加载(需要编译时字节码装置器)" -#: index.docbook:1891 -msgid "optimistic-lock (optional - defaults to true): Specifies that updates to this component do or do not require acquisition of the optimistic lock. In other words, determines if a version increment should occur when this property is dirty." +#. Tag: para +#: basic_mapping.xml:1891 +#, no-c-format +msgid "" +"optimistic-lock (optional - defaults to true): Specifies that updates to this component do or do not require " +"acquisition of the optimistic lock. In other words, determines if a version " +"increment should occur when this property is dirty." msgstr "" +"optimistic-lock (可选 - 默认是 true):表" +"明更新此组件是否需要获取乐观锁。换句话说,当这个属性变脏时,是否增加版本号" +"(Version)" -#: index.docbook:1899, index.docbook:1975 -msgid "unique (optional - defaults to false): Specifies that a unique constraint exists upon all mapped columns of the component." +#. Tag: para +#: basic_mapping.xml:1899 basic_mapping.xml:1975 +#, no-c-format +msgid "" +"unique (optional - defaults to false): " +"Specifies that a unique constraint exists upon all mapped columns of the " +"component." msgstr "" +"unique (可选 - 默认是 false):表明组件映" +"射的所有字段上都有唯一性约束" -#: index.docbook:1908 -msgid "The child <property> tags map properties of the child class to table columns." +#. Tag: para +#: basic_mapping.xml:1908 +#, no-c-format +msgid "" +"The child <property> tags map properties of the " +"child class to table columns." msgstr "" +"其<property>子标签为子类的一些属性与表字段之间建立映" +"射。" -#: index.docbook:1913 -msgid "The <component> element allows a <parent> subelement that maps a property of the component class as a reference back to the containing entity." +#. Tag: para +#: basic_mapping.xml:1913 +#, no-c-format +msgid "" +"The <component> element allows a <" +"parent> subelement that maps a property of the component class " +"as a reference back to the containing entity." msgstr "" +"<component>元素允许加入一个<parent>子元素,在组件类内部就可以有一个指向其容器的实体的反向引用。" -#: index.docbook:1919 -msgid "The <dynamic-component> element allows a Map to be mapped as a component, where the property names refer to keys of the map, see ." +#. Tag: para +#: basic_mapping.xml:1919 +#, no-c-format +msgid "" +"The <dynamic-component> element allows a " +"Map to be mapped as a component, where the property names " +"refer to keys of the map, see ." msgstr "" +"<dynamic-component>元素允许把一个Map映射为组件,其属性名对应map的键值。 参见." -#: index.docbook:1928 +#. Tag: title +#: basic_mapping.xml:1928 +#, no-c-format msgid "properties" -msgstr "" +msgstr "properties" -#: index.docbook:1930 -msgid "The <properties> element allows the definition of a named, logical grouping of properties of a class. The most important use of the construct is that it allows a combination of properties to be the target of a property-ref. It is also a convenient way to define a multi-column unique constraint." -msgstr "" - -#: index.docbook:1946 +#. Tag: para +#: basic_mapping.xml:1930 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " ........\n" - "]]>" +"The <properties> element allows the definition of a " +"named, logical grouping of properties of a class. The most important use of " +"the construct is that it allows a combination of properties to be the target " +"of a property-ref. It is also a convenient way to define " +"a multi-column unique constraint." msgstr "" +"<properties> 元素允许定义一个命名的逻辑分组" +"(grouping)包含一个类中的多个属性。 这个元素最重要的用处是允许多个属性的组合作" +"为property-ref的目标(target)。 这也是定义多字段唯一约束的" +"一种方便途径。" -#: index.docbook:1949 -msgid "name: The logical name of the grouping - not an actual property name." -msgstr "" - -#: index.docbook:1967 -msgid "optimistic-lock (optional - defaults to true): Specifies that updates to these properties do or do not require acquisition of the optimistic lock. In other words, determines if a version increment should occur when these properties are dirty." -msgstr "" - -#: index.docbook:1984 -msgid "For example, if we have the following <properties> mapping:" -msgstr "" - -#: index.docbook:1988 +#. Tag: programlisting +#: basic_mapping.xml:1946 +#, no-c-format msgid "" - "\n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +"\n" +" \n" +" \n" +" ........\n" +"]]>" msgstr "" -#: index.docbook:1990 -msgid "Then we might have some legacy data association which refers to this unique key of the Person table, instead of to the primary key:" -msgstr "" - -#: index.docbook:1995 +#. Tag: para +#: basic_mapping.xml:1949 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "]]>" +"name: The logical name of the grouping - not an actual property name." +msgstr "" +"name: 分组的逻辑名称 - 不是 实际属性" +"的名称." + +#. Tag: para +#: basic_mapping.xml:1967 +#, no-c-format +msgid "" +"optimistic-lock (optional - defaults to true): Specifies that updates to these properties do or do not require " +"acquisition of the optimistic lock. In other words, determines if a version " +"increment should occur when these properties are dirty." +msgstr "" +"optimistic-lock (可选 - 默认是 true):表" +"明更新此组件是否需要获取乐观锁。换句话说,当这个属性变脏时,是否增加版本号" +"(Version)" + +#. Tag: para +#: basic_mapping.xml:1984 +#, no-c-format +msgid "" +"For example, if we have the following <properties> " +"mapping:" +msgstr "例如,如果我们有如下的<properties>映射:" + +#. Tag: programlisting +#: basic_mapping.xml:1988 +#, no-c-format +msgid "" +"\n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:1997 -msgid "We don't recommend the use of this kind of thing outside the context of mapping legacy data." +#. Tag: para +#: basic_mapping.xml:1990 +#, no-c-format +msgid "" +"Then we might have some legacy data association which refers to this unique " +"key of the Person table, instead of to the primary key:" +msgstr "" +"然后,我们可能有一些遗留的数据关联,引用 Person表的这个唯" +"一键,而不是主键。" + +#. Tag: programlisting +#: basic_mapping.xml:1995 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:2005 +#. Tag: para +#: basic_mapping.xml:1997 +#, no-c-format +msgid "" +"We don't recommend the use of this kind of thing outside the context of " +"mapping legacy data." +msgstr "我们并不推荐这样使用,除非在映射遗留数据的情况下。" + +#. Tag: title +#: basic_mapping.xml:2005 +#, no-c-format msgid "subclass" -msgstr "" +msgstr "子类(subclass)" -#: index.docbook:2007 -msgid "Finally, polymorphic persistence requires the declaration of each subclass of the root persistent class. For the table-per-class-hierarchy mapping strategy, the <subclass> declaration is used." -msgstr "" - -#: index.docbook:2020 +#. Tag: para +#: basic_mapping.xml:2007 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " .....\n" - "]]>" +"Finally, polymorphic persistence requires the declaration of each subclass " +"of the root persistent class. For the table-per-class-hierarchy mapping " +"strategy, the <subclass> declaration is used." +msgstr "" +"最后,多态持久化需要为父类的每个子类都进行定义。对于“每一棵类继承树对应一个" +"表”的策略来说,就需要使用<subclass>定义。" + +#. Tag: programlisting +#: basic_mapping.xml:2020 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" .....\n" +"]]>" msgstr "" -#: index.docbook:2023, index.docbook:2081, index.docbook:2144 -msgid "name: The fully qualified class name of the subclass." -msgstr "" +#. Tag: para +#: basic_mapping.xml:2023 basic_mapping.xml:2081 basic_mapping.xml:2144 +#, no-c-format +msgid "" +"name: The fully qualified class name of the subclass." +msgstr "name: 子类的全限定名。" -#: index.docbook:2028 -msgid "discriminator-value (optional - defaults to the class name): A value that distiguishes individual subclasses." +#. Tag: para +#: basic_mapping.xml:2028 +#, no-c-format +msgid "" +"discriminator-value (optional - defaults to the class " +"name): A value that distiguishes individual subclasses." msgstr "" +"discriminator-value(辨别标志) (可选 - 默认为类名):一个用于" +"区分每个独立的子类的值。" -#: index.docbook:2034, index.docbook:2091, index.docbook:2154 -msgid "proxy (optional): Specifies a class or interface to use for lazy initializing proxies." +#. Tag: para +#: basic_mapping.xml:2034 basic_mapping.xml:2091 basic_mapping.xml:2154 +#, fuzzy, no-c-format +msgid "" +"proxy (optional): Specifies a class or interface to use " +"for lazy initializing proxies." msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"proxy(代理) (可选): 指定一个类或者接口,在延迟装载时作为代" +"理使用。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"proxy (可选): 指定一个类或者接口,在延迟装载时作为代理使" +"用。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"proxy (可选): 指定一个类或者接口,在延迟装载时作为代理使" +"用。" -#: index.docbook:2040, index.docbook:2097, index.docbook:2160 -msgid "lazy (optional, defaults to true): Setting lazy=\"false\" disables the use of lazy fetching." +#. Tag: para +#: basic_mapping.xml:2040 basic_mapping.xml:2097 basic_mapping.xml:2160 +#, fuzzy, no-c-format +msgid "" +"lazy (optional, defaults to true): " +"Setting lazy=\"false\" disables the use of lazy fetching." msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"lazy (可选, 默认是true): 设置为 " +"lazy=\"false\" 禁止使用延迟抓取\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"lazy (可选, 默认是 true): 设置为 " +"lazy=\"false\" 禁止使用延迟装载。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"lazy (可选, 默认是 true): 设置为 " +"lazy=\"false\" 禁止使用延迟装载。" -#: index.docbook:2048 -msgid "Each subclass should declare its own persistent properties and subclasses. <version> and <id> properties are assumed to be inherited from the root class. Each subclass in a heirarchy must define a unique discriminator-value. If none is specified, the fully qualified Java class name is used." +#. Tag: para +#: basic_mapping.xml:2048 +#, no-c-format +msgid "" +"Each subclass should declare its own persistent properties and subclasses. " +"<version> and <id> " +"properties are assumed to be inherited from the root class. Each subclass in " +"a heirarchy must define a unique discriminator-value. If " +"none is specified, the fully qualified Java class name is used." msgstr "" +"每个子类都应该定义它自己的持久化属性和子类。 <version><id> 属性可以从根父类继承下来。在一棵继承" +"树上的每个子类都必须定义一个唯一的discriminator-value。如" +"果没有指定,就会使用Java类的全限定名。" -#: index.docbook:2056, index.docbook:2114, index.docbook:2172 -msgid "For information about inheritance mappings, see ." +#. Tag: para +#: basic_mapping.xml:2056 basic_mapping.xml:2114 basic_mapping.xml:2172 +#, fuzzy, no-c-format +msgid "" +"For information about inheritance mappings, see ." msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"更多关于继承映射的信息, 参考 章节.\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"更多关于继承映射的信息,参考。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"更多关于继承映射的信息,参考。" -#: index.docbook:2063 +#. Tag: title +#: basic_mapping.xml:2063 +#, no-c-format msgid "joined-subclass" -msgstr "" +msgstr "连接的子类(joined-subclass)" -#: index.docbook:2065 -msgid "Alternatively, each subclass may be mapped to its own table (table-per-subclass mapping strategy). Inherited state is retrieved by joining with the table of the superclass. We use the <joined-subclass> element." -msgstr "" - -#: index.docbook:2078 +#. Tag: para +#: basic_mapping.xml:2065 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - "\n" - " \n" - " .....\n" - "]]>" +"Alternatively, each subclass may be mapped to its own table (table-per-" +"subclass mapping strategy). Inherited state is retrieved by joining with the " +"table of the superclass. We use the <joined-subclass> element." +msgstr "" +"此外,每个子类可能被映射到他自己的表中(每个子类一个表的策略)。被继承的状态通" +"过和超类的表关联得到。我们使用<joined-subclass>元" +"素。" + +#. Tag: programlisting +#: basic_mapping.xml:2078 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +"\n" +" \n" +" .....\n" +"]]>" msgstr "" -#: index.docbook:2086, index.docbook:2149 +#. Tag: para +#: basic_mapping.xml:2086 basic_mapping.xml:2149 +#, fuzzy, no-c-format msgid "table: The name of the subclass table." msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"table: 子类的表名.\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"table: 子类的表名" -#: index.docbook:2105 -msgid "No discriminator column is required for this mapping strategy. Each subclass must, however, declare a table column holding the object identifier using the <key> element. The mapping at the start of the chapter would be re-written as:" -msgstr "" - -#: index.docbook:2112 +#. Tag: para +#: basic_mapping.xml:2105 +#, no-c-format msgid "" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"No discriminator column is required for this mapping strategy. Each subclass " +"must, however, declare a table column holding the object identifier using " +"the <key> element. The mapping at the start of the " +"chapter would be re-written as:" +msgstr "" +"这种映射策略不需要指定辨别标志(discriminator)字段。但是,每一个子类都必须使用" +"<key>元素指定一个表字段来持有对象的标识符。本章开始" +"的映射可以被用如下方式重写:" + +#. Tag: programlisting +#: basic_mapping.xml:2112 +#, no-c-format +msgid "" +"\n" +"\n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:2121 +#. Tag: title +#: basic_mapping.xml:2121 +#, no-c-format msgid "union-subclass" -msgstr "" +msgstr "联合子类(union-subclass)" -#: index.docbook:2123 -msgid "A third option is to map only the concrete classes of an inheritance hierarchy to tables, (the table-per-concrete-class strategy) where each table defines all persistent state of the class, including inherited state. In Hibernate, it is not absolutely necessary to explicitly map such inheritance hierarchies. You can simply map each class with a separate <class> declaration. However, if you wish use polymorphic associations (e.g. an association to the superclass of your hierarchy), you need to use the <union-subclass> mapping." -msgstr "" - -#: index.docbook:2141 +#. Tag: para +#: basic_mapping.xml:2123 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " .....\n" - "]]>" +"A third option is to map only the concrete classes of an inheritance " +"hierarchy to tables, (the table-per-concrete-class strategy) where each " +"table defines all persistent state of the class, including inherited state. " +"In Hibernate, it is not absolutely necessary to explicitly map such " +"inheritance hierarchies. You can simply map each class with a separate " +"<class> declaration. However, if you wish use " +"polymorphic associations (e.g. an association to the superclass of your " +"hierarchy), you need to use the <union-subclass> " +"mapping." +msgstr "" +"第三种选择是仅仅映射类继承树中具体类部分到表中(每个具体类一张表的策略)。其" +"中,每张表定义了类的所有持久化状态,包括继承的状态。在 Hibernate 中,并不需要" +"完全显式地映射这样的继承树。你可以简单地使用单独的<class>定义映射每个类。然而,如果你想使用多态关联(例如,一个对类继承树中超类" +"的关联),你需要使用<union-subclass>映射。" + +#. Tag: programlisting +#: basic_mapping.xml:2141 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" .....\n" +"]]>" msgstr "" -#: index.docbook:2168 -msgid "No discriminator column or key column is required for this mapping strategy." -msgstr "" +#. Tag: para +#: basic_mapping.xml:2168 +#, no-c-format +msgid "" +"No discriminator column or key column is required for this mapping strategy." +msgstr "这种映射策略不需要指定辨别标志(discriminator)字段。" -#: index.docbook:2179 +#. Tag: title +#: basic_mapping.xml:2179 +#, no-c-format msgid "join" -msgstr "" +msgstr "连接(join)" -#: index.docbook:2181 -msgid "Using the <join> element, it is possible to map properties of one class to several tables, when there's a 1-to-1 relationship between the tables." -msgstr "" - -#: index.docbook:2195 +#. Tag: para +#: basic_mapping.xml:2181 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - "\n" - " \n" - " ...\n" - "]]>" +"Using the <join> element, it is possible to map " +"properties of one class to several tables, when there's a 1-to-1 " +"relationship between the tables." +msgstr "" +"使用 <join> 元素,假若在表之间存在一对一关联,可以将" +"一个类的属性映射到多张表中。" + +#. Tag: programlisting +#: basic_mapping.xml:2195 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +"\n" +" \n" +" ...\n" +"]]>" msgstr "" -#: index.docbook:2199 +#. Tag: para +#: basic_mapping.xml:2199 +#, no-c-format msgid "table: The name of the joined table." -msgstr "" +msgstr "table: 被连接表的名称。" -#: index.docbook:2216 -msgid "fetch (optional - defaults to join): If set to join, the default, Hibernate will use an inner join to retrieve a <join> defined by a class or its superclasses and an outer join for a <join> defined by a subclass. If set to select then Hibernate will use a sequential select for a <join> defined on a subclass, which will be issued only if a row turns out to represent an instance of the subclass. Inner joins will still be used to retrieve a <join> defined by the class and its superclasses." -msgstr "" - -#: index.docbook:2229 -msgid "inverse (optional - defaults to false): If enabled, Hibernate will not try to insert or update the properties defined by this join." -msgstr "" - -#: index.docbook:2236 -msgid "optional (optional - defaults to false): If enabled, Hibernate will insert a row only if the properties defined by this join are non-null and will always use an outer join to retrieve the properties." -msgstr "" - -#: index.docbook:2245 -msgid "For example, the address information for a person can be mapped to a separate table (while preserving value type semantics for all properties):" -msgstr "" - -#: index.docbook:2250 +#. Tag: para +#: basic_mapping.xml:2216 +#, no-c-format msgid "" - "\n" - "\n" - " ...\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...]]>" +"fetch (optional - defaults to join): " +"If set to join, the default, Hibernate will use an inner " +"join to retrieve a <join> defined by a class or its " +"superclasses and an outer join for a <join> defined " +"by a subclass. If set to select then Hibernate will use a " +"sequential select for a <join> defined on a " +"subclass, which will be issued only if a row turns out to represent an " +"instance of the subclass. Inner joins will still be used to retrieve a " +"<join> defined by the class and its superclasses." +msgstr "" +"fetch (可选 - 默认是 join): 如果设置为" +"默认值join, Hibernate 将使用一个内连接来得到这个类或其超" +"类定义的<join>,而使用一个外连接来得到其子类定义的" +"<join>。如果设置为select,则 " +"Hibernate 将为子类定义的 <join>使用顺序选择。这仅在" +"一行数据表示一个子类的对象的时候才会发生。对这个类和其超类定义的<" +"join>,依然会使用内连接得到。" + +#. Tag: para +#: basic_mapping.xml:2229 +#, no-c-format +msgid "" +"inverse (optional - defaults to false): If enabled, Hibernate will not try to insert or update the " +"properties defined by this join." +msgstr "" +"inverse (可选 - 默认是 false): 如果打" +"开,Hibernate 不会插入或者更新此连接定义的属性。" + +#. Tag: para +#: basic_mapping.xml:2236 +#, no-c-format +msgid "" +"optional (optional - defaults to false): If enabled, Hibernate will insert a row only if the properties " +"defined by this join are non-null and will always use an outer join to " +"retrieve the properties." +msgstr "" +"optional (可选 - 默认是 false): 如果打" +"开,Hibernate 只会在此连接定义的属性非空时插入一行数据,并且总是使用一个外连" +"接来得到这些属性。" + +#. Tag: para +#: basic_mapping.xml:2245 +#, no-c-format +msgid "" +"For example, the address information for a person can be mapped to a " +"separate table (while preserving value type semantics for all properties):" +msgstr "" +"例如,一个人(person)的地址(address)信息可以被映射到单独的表中(并保留所有属性" +"的值类型语义):" + +#. Tag: programlisting +#: basic_mapping.xml:2250 +#, no-c-format +msgid "" +"\n" +"\n" +" ...\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...]]>" msgstr "" -#: index.docbook:2252 -msgid "This feature is often only useful for legacy data models, we recommend fewer tables than classes and a fine-grained domain model. However, it is useful for switching between inheritance mapping strategies in a single hierarchy, as explained later." +#. Tag: para +#: basic_mapping.xml:2252 +#, no-c-format +msgid "" +"This feature is often only useful for legacy data models, we recommend fewer " +"tables than classes and a fine-grained domain model. However, it is useful " +"for switching between inheritance mapping strategies in a single hierarchy, " +"as explained later." msgstr "" +"此特性常常对遗留数据模型有用,我们推荐表个数比类个数少,以及细粒度的领域模" +"型。然而,在单独的继承树上切换继承映射策略是有用的,后面会解释这点。" -#: index.docbook:2262 +#. Tag: title +#: basic_mapping.xml:2262 +#, no-c-format msgid "key" msgstr "" -#: index.docbook:2264 -msgid "We've seen the <key> element crop up a few times now. It appears anywhere the parent mapping element defines a join to a new table, and defines the foreign key in the joined table, that references the primary key of the original table." -msgstr "" - -#: index.docbook:2280 +#. Tag: para +#: basic_mapping.xml:2264 +#, no-c-format msgid "" - "]]>" +"We've seen the <key> element crop up a few times " +"now. It appears anywhere the parent mapping element defines a join to a new " +"table, and defines the foreign key in the joined table, that references the " +"primary key of the original table." +msgstr "" +"我们目前已经见到过<key>元素多次了。 这个元素在父映射" +"元素定义了对新表的连接,并且在被连接表中定义了一个外键引用原表的主键的情况下" +"经常使用。" + +#. Tag: programlisting +#: basic_mapping.xml:2280 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:2291 -msgid "on-delete (optional, defaults to noaction): Specifies whether the foreign key constraint has database-level cascade delete enabled." +#. Tag: para +#: basic_mapping.xml:2291 +#, no-c-format +msgid "" +"on-delete (optional, defaults to noaction): Specifies whether the foreign key constraint has database-level " +"cascade delete enabled." msgstr "" +"on-delete (可选, 默认是 noaction): 表明" +"外键关联是否打开数据库级别的级联删除。" -#: index.docbook:2298 -msgid "property-ref (optional): Specifies that the foreign key refers to columns that are not the primary key of the orginal table. (Provided for legacy data.)" +#. Tag: para +#: basic_mapping.xml:2298 +#, no-c-format +msgid "" +"property-ref (optional): Specifies that the foreign key " +"refers to columns that are not the primary key of the orginal table. " +"(Provided for legacy data.)" msgstr "" +"property-ref (可选): 表明外键引用的字段不是原表的主键(提供" +"给遗留数据)。" -#: index.docbook:2305 -msgid "not-null (optional): Specifies that the foreign key columns are not nullable (this is implied whenever the foreign key is also part of the primary key)." +#. Tag: para +#: basic_mapping.xml:2305 +#, no-c-format +msgid "" +"not-null (optional): Specifies that the foreign key " +"columns are not nullable (this is implied whenever the foreign key is also " +"part of the primary key)." msgstr "" +"not-null (可选): 表明外键的字段不可为空(这意味着无论何时外" +"键都是主键的一部分)。" -#: index.docbook:2312 -msgid "update (optional): Specifies that the foreign key should never be updated (this is implied whenever the foreign key is also part of the primary key)." +#. Tag: para +#: basic_mapping.xml:2312 +#, no-c-format +msgid "" +"update (optional): Specifies that the foreign key should " +"never be updated (this is implied whenever the foreign key is also part of " +"the primary key)." msgstr "" +"update (可选): 表明外键决不应该被更新(这意味着无论何时外键" +"都是主键的一部分)。" -#: index.docbook:2319 -msgid "unique (optional): Specifies that the foreign key should have a unique constraint (this is implied whenever the foreign key is also the primary key)." +#. Tag: para +#: basic_mapping.xml:2319 +#, no-c-format +msgid "" +"unique (optional): Specifies that the foreign key should " +"have a unique constraint (this is implied whenever the foreign key is also " +"the primary key)." msgstr "" +"unique (可选): 表明外键应有唯一性约束 (这意味着无论何时外" +"键都是主键的一部分)。" -#: index.docbook:2327 -msgid "We recommend that for systems where delete performance is important, all keys should be defined on-delete=\"cascade\", and Hibernate will use a database-level ON CASCADE DELETE constraint, instead of many individual DELETE statements. Be aware that this feature bypasses Hibernate's usual optimistic locking strategy for versioned data." +#. Tag: para +#: basic_mapping.xml:2327 +#, no-c-format +msgid "" +"We recommend that for systems where delete performance is important, all " +"keys should be defined on-delete=\"cascade\", and " +"Hibernate will use a database-level ON CASCADE DELETE " +"constraint, instead of many individual DELETE statements. " +"Be aware that this feature bypasses Hibernate's usual optimistic locking " +"strategy for versioned data." msgstr "" +"对那些看重删除性能的系统,我们推荐所有的键都应该定义为on-delete=" +"\"cascade\",这样 Hibernate 将使用数据库级的ON CASCADE " +"DELETE约束,而不是多个DELETE语句。 注意,这个特" +"性会绕过 Hibernate 通常对版本数据(versioned data)采用的乐观锁策略。" -#: index.docbook:2335 -msgid "The not-null and update attributes are useful when mapping a unidirectional one to many association. If you map a unidirectional one to many to a non-nullable foreign key, you must declare the key column using <key not-null=\"true\">." +#. Tag: para +#: basic_mapping.xml:2335 +#, no-c-format +msgid "" +"The not-null and update attributes are " +"useful when mapping a unidirectional one to many association. If you map a " +"unidirectional one to many to a non-nullable foreign key, you " +"must declare the key column using <key not-" +"null=\"true\">." msgstr "" +"not-nullupdate 属性在映射单向一对多" +"关联的时候有用。如果你映射一个单向一对多关联到非空的(non-nullable)外键,你" +"必须<key not-null=\"true\">" +"定义此键字段。" -#: index.docbook:2345 +#. Tag: title +#: basic_mapping.xml:2345 +#, no-c-format msgid "column and formula elements" -msgstr "" +msgstr "字段和规则元素(column and formula elements)" -#: index.docbook:2346 -msgid "Any mapping element which accepts a column attribute will alternatively accept a <column> subelement. Likewise, <formula> is an alternative to the formula attribute." -msgstr "" - -#: index.docbook:2352 +#. Tag: para +#: basic_mapping.xml:2346 +#, no-c-format msgid "" - "]]>" +"Any mapping element which accepts a column attribute will " +"alternatively accept a <column> subelement. " +"Likewise, <formula> is an alternative to the " +"formula attribute." +msgstr "" +"任何接受column属性的映射元素都可以选择接受<" +"column> 子元素。同样的,formula子元素也可以替" +"换<formula>属性。" + +#. Tag: programlisting +#: basic_mapping.xml:2352 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:2354 +#. Tag: programlisting +#: basic_mapping.xml:2354 +#, no-c-format msgid "SQL expression]]>" msgstr "" -#: index.docbook:2356 -msgid "column and formula attributes may even be combined within the same property or association mapping to express, for example, exotic join conditions." -msgstr "" - -#: index.docbook:2362 +#. Tag: para +#: basic_mapping.xml:2356 +#, no-c-format msgid "" - "\n" - " \n" - " 'MAILING'\n" - "]]>" +"column and formula attributes may even " +"be combined within the same property or association mapping to express, for " +"example, exotic join conditions." +msgstr "" +"columnformula 属性甚至可以在同一个" +"属性或关联映射中被合并来表达,例如,一些奇异的连接条件。" + +#. Tag: programlisting +#: basic_mapping.xml:2362 +#, no-c-format +msgid "" +"\n" +" \n" +" 'MAILING'\n" +"]]>" msgstr "" -#: index.docbook:2367 +#. Tag: title +#: basic_mapping.xml:2367 +#, no-c-format msgid "import" -msgstr "" +msgstr "引用(import)" -#: index.docbook:2369 -msgid "Suppose your application has two persistent classes with the same name, and you don't want to specify the fully qualified (package) name in Hibernate queries. Classes may be \"imported\" explicitly, rather than relying upon auto-import=\"true\". You may even import classes and interfaces that are not explicitly mapped." +#. Tag: para +#: basic_mapping.xml:2369 +#, no-c-format +msgid "" +"Suppose your application has two persistent classes with the same name, and " +"you don't want to specify the fully qualified (package) name in Hibernate " +"queries. Classes may be \"imported\" explicitly, rather than relying upon " +"auto-import=\"true\". You may even import classes and " +"interfaces that are not explicitly mapped." msgstr "" +"假设你的应用程序有两个同样名字的持久化类,但是你不想在Hibernate查询中使用他们" +"的全限定名。除了依赖auto-import=\"true\"以外,类也可以被显" +"式地“import(引用)”。你甚至可以引用没有被明确映射的类和接口。" -#: index.docbook:2376 +#. Tag: programlisting +#: basic_mapping.xml:2376 +#, no-c-format msgid "]]>" msgstr "" -#: index.docbook:2383 +#. Tag: programlisting +#: basic_mapping.xml:2383 +#, no-c-format msgid "" - "]]>" +"]]>" msgstr "" -#: index.docbook:2386 -msgid "class: The fully qualified class name of of any Java class." -msgstr "" +#. Tag: para +#: basic_mapping.xml:2386 +#, no-c-format +msgid "" +"class: The fully qualified class name of of any Java " +"class." +msgstr "class: 任何Java类的全限定名。" -#: index.docbook:2391 -msgid "rename (optional - defaults to the unqualified class name): A name that may be used in the query language." +#. Tag: para +#: basic_mapping.xml:2391 +#, no-c-format +msgid "" +"rename (optional - defaults to the unqualified class " +"name): A name that may be used in the query language." msgstr "" +"rename (可选 - 默认为类的全限定名): 在查询语句中可以使用的" +"名字。" -#: index.docbook:2402 +#. Tag: title +#: basic_mapping.xml:2402 +#, no-c-format msgid "any" msgstr "" -#: index.docbook:2404 -msgid "There is one further type of property mapping. The <any> mapping element defines a polymorphic association to classes from multiple tables. This type of mapping always requires more than one column. The first column holds the type of the associated entity. The remaining columns hold the identifier. It is impossible to specify a foreign key constraint for this kind of association, so this is most certainly not meant as the usual way of mapping (polymorphic) associations. You should use this only in very special cases (eg. audit logs, user session data, etc)." -msgstr "" - -#: index.docbook:2414 -msgid "The meta-type attribute lets the application specify a custom type that maps database column values to persistent classes which have identifier properties of the type specified by id-type. You must specify the mapping from values of the meta-type to class names." -msgstr "" - -#: index.docbook:2421 +#. Tag: para +#: basic_mapping.xml:2404 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"There is one further type of property mapping. The <any> mapping element defines a polymorphic association to classes from " +"multiple tables. This type of mapping always requires more than one column. " +"The first column holds the type of the associated entity. The remaining " +"columns hold the identifier. It is impossible to specify a foreign key " +"constraint for this kind of association, so this is most certainly not meant " +"as the usual way of mapping (polymorphic) associations. You should use this " +"only in very special cases (eg. audit logs, user session data, etc)." msgstr "" +"这是属性映射的又一种类型。<any> 映射元素定义了一种从" +"多个表到类的多态关联。这种类型的映射常常需要多于一个字段。第一个字段持有被关" +"联实体的类型,其他的字段持有标识符。对这种类型的关联来说,不可能指定一个外键" +"约束,所以这当然不是映射(多态)关联的通常的方式。你只应该在非常特殊的情况下使" +"用它(比如,审计log,用户会话数据等等)。" -#: index.docbook:2432 +#. Tag: para +#: basic_mapping.xml:2414 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " .....\n" - " \n" - " \n" - " .....\n" - "]]>" +"The meta-type attribute lets the application specify a " +"custom type that maps database column values to persistent classes which " +"have identifier properties of the type specified by id-type. You must specify the mapping from values of the meta-type to class " +"names." +msgstr "" +"meta-type 属性使得应用程序能指定一个将数据库字段的值映射到" +"持久化类的自定义类型。这个持久化类包含有用id-type指定的标" +"识符属性。 你必须指定从meta-type的值到类名的映射。" + +#. Tag: programlisting +#: basic_mapping.xml:2421 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:2435 +#. Tag: programlisting +#: basic_mapping.xml:2432 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" .....\n" +" \n" +" \n" +" .....\n" +"]]>" +msgstr "" + +#. Tag: para +#: basic_mapping.xml:2435 +#, no-c-format msgid "name: the property name." -msgstr "" +msgstr "name: 属性名" -#: index.docbook:2440 +#. Tag: para +#: basic_mapping.xml:2440 +#, no-c-format msgid "id-type: the identifier type." -msgstr "" +msgstr "id-type: 标识符类型" -#: index.docbook:2445 -msgid "meta-type (optional - defaults to string): Any type that is allowed for a discriminator mapping." +#. Tag: para +#: basic_mapping.xml:2445 +#, no-c-format +msgid "" +"meta-type (optional - defaults to string): Any type that is allowed for a discriminator mapping." msgstr "" +"meta-type (可选 -默认是 string): 允许辨" +"别标志(discriminator)映射的任何类型" -#: index.docbook:2451 -msgid "cascade (optional- defaults to none): the cascade style." +#. Tag: para +#: basic_mapping.xml:2451 +#, no-c-format +msgid "" +"cascade (optional- defaults to none): " +"the cascade style." msgstr "" +"cascade (可选 -默认是none): 级联的类型" -#: index.docbook:2463 -msgid "optimistic-lock (optional - defaults to true): Specifies that updates to this property do or do not require acquisition of the optimistic lock. In other words, define if a version increment should occur if this property is dirty." +#. Tag: para +#: basic_mapping.xml:2463 +#, no-c-format +msgid "" +"optimistic-lock (optional - defaults to true): Specifies that updates to this property do or do not require " +"acquisition of the optimistic lock. In other words, define if a version " +"increment should occur if this property is dirty." msgstr "" +"optimistic-lock (可选 -默认是 true): 表" +"明更新此组件是否需要获取乐观锁。换句话说,当这个属性变脏时,是否增加版本号" +"(Version)" -#: index.docbook:2478 +#. Tag: title +#: basic_mapping.xml:2478 +#, no-c-format msgid "Hibernate Types" -msgstr "" +msgstr "Hibernate 的类型" -#: index.docbook:2481 +#. Tag: title +#: basic_mapping.xml:2481 +#, no-c-format msgid "Entities and values" -msgstr "" +msgstr "实体(Entities)和值(values)" -#: index.docbook:2483 -msgid "To understand the behaviour of various Java language-level objects with respect to the persistence service, we need to classify them into two groups:" +#. Tag: para +#: basic_mapping.xml:2483 +#, no-c-format +msgid "" +"To understand the behaviour of various Java language-level objects with " +"respect to the persistence service, we need to classify them into two groups:" msgstr "" +"为了理解很多与持久化服务相关的Java语言级对象的行为,我们需要把它们分为两类:" -#: index.docbook:2488 -msgid "An entity exists independently of any other objects holding references to the entity. Contrast this with the usual Java model where an unreferenced object is garbage collected. Entities must be explicitly saved and deleted (except that saves and deletions may be cascaded from a parent entity to its children). This is different from the ODMG model of object persistence by reachablity - and corresponds more closely to how application objects are usually used in large systems. Entities support circular and shared references. They may also be versioned." +#. Tag: para +#: basic_mapping.xml:2488 +#, no-c-format +msgid "" +"An entity exists independently of any other objects " +"holding references to the entity. Contrast this with the usual Java model " +"where an unreferenced object is garbage collected. Entities must be " +"explicitly saved and deleted (except that saves and deletions may be " +"cascaded from a parent entity to its children). This is " +"different from the ODMG model of object persistence by reachablity - and " +"corresponds more closely to how application objects are usually used in " +"large systems. Entities support circular and shared references. They may " +"also be versioned." msgstr "" +"实体entity 独立于任何持有实体引用的对象。与通常的Java模" +"型相比,不再被引用的对象会被当作垃圾收集掉。实体必须被显式的保存和删除(除非保" +"存和删除是从父实体向子实体引发的级联)。这和ODMG模型中关" +"于对象通过可触及保持持久性有一些不同——比较起来更加接近应用程序对象通常在一个" +"大系统中的使用方法。实体支持循环引用和交叉引用,它们也可以加上版本信息。" -#: index.docbook:2499 -msgid "An entity's persistent state consists of references to other entities and instances of value types. Values are primitives, collections (not what's inside a collection), components and certain immutable objects. Unlike entities, values (in particular collections and components) are persisted and deleted by reachability. Since value objects (and primitives) are persisted and deleted along with their containing entity they may not be independently versioned. Values have no independent identity, so they cannot be shared by two entities or collections." +#. Tag: para +#: basic_mapping.xml:2499 +#, no-c-format +msgid "" +"An entity's persistent state consists of references to other entities and " +"instances of value types. Values are primitives, " +"collections (not what's inside a collection), components and certain " +"immutable objects. Unlike entities, values (in particular collections and " +"components) are persisted and deleted by reachability. " +"Since value objects (and primitives) are persisted and deleted along with " +"their containing entity they may not be independently versioned. Values have " +"no independent identity, so they cannot be shared by two entities or " +"collections." msgstr "" +"一个实体的持久状态包含指向其他实体和类型实例的引用。值" +"可以是原始类型,集合(不是集合中的对象),组件或者特定的不可变对象。与实体不" +"同,值(特别是集合和组件)是通过可触及性来进行持久化和删除的。因为值对象(和原始" +"类型数据)是随着包含他们的实体而被持久化和删除的,他们不能被独立的加上版本信" +"息。值没有独立的标识,所以他们不能被两个实体或者集合共享。" -#: index.docbook:2510 -msgid "Up until now, we've been using the term \"persistent class\" to refer to entities. We will continue to do that. Strictly speaking, however, not all user-defined classes with persistent state are entities. A component is a user defined class with value semantics. A Java property of type java.lang.String also has value semantics. Given this definition, we can say that all types (classes) provided by the JDK have value type semantics in Java, while user-defined types may be mapped with entity or value type semantics. This decision is up to the application developer. A good hint for an entity class in a domain model are shared references to a single instance of that class, while composition or aggregation usually translates to a value type." +#. Tag: para +#: basic_mapping.xml:2510 +#, no-c-format +msgid "" +"Up until now, we've been using the term \"persistent class\" to refer to " +"entities. We will continue to do that. Strictly speaking, however, not all " +"user-defined classes with persistent state are entities. A " +"component is a user defined class with value semantics. " +"A Java property of type java.lang.String also has value " +"semantics. Given this definition, we can say that all types (classes) " +"provided by the JDK have value type semantics in Java, while user-defined " +"types may be mapped with entity or value type semantics. This decision is up " +"to the application developer. A good hint for an entity class in a domain " +"model are shared references to a single instance of that class, while " +"composition or aggregation usually translates to a value type." msgstr "" +"直到现在,我们都一直使用术语“持久类”(persistent class)来代表实体。我们仍然会" +"这么做。 然而严格说来,不是所有的用户自定义的,带有持久化状态的类都是实体。" +"组件就是用户自定义类,却是值语义的。java.lang." +"String类型的java属性也是值语义的。给了这个定义以后,我们可以说所有" +"JDK提供的类型(类)都是值类型的语义,而用于自定义类型可能被映射为实体类型或值类" +"型语义。采用哪种类型的语义取决于开发人员。在领域模型中,寻找实体类的一个好线" +"索是共享引用指向这个类的单一实例,而组合或聚合通常被转化为值类型。" -#: index.docbook:2524 +#. Tag: para +#: basic_mapping.xml:2524 +#, no-c-format msgid "We'll revisit both concepts throughout the documentation." -msgstr "" +msgstr "我们会在本文档中重复碰到这两个概念。" -#: index.docbook:2528 -msgid "The challenge is to map the Java type system (and the developers' definition of entities and value types) to the SQL/database type system. The bridge between both systems is provided by Hibernate: for entities we use <class>, <subclass> and so on. For value types we use <property>, <component>, etc, usually with a type attribute. The value of this attribute is the name of a Hibernate mapping type. Hibernate provides many mappings (for standard JDK value types) out of the box. You can write your own mapping types and implement your custom conversion strategies as well, as you'll see later." +#. Tag: para +#: basic_mapping.xml:2528 +#, no-c-format +msgid "" +"The challenge is to map the Java type system (and the developers' definition " +"of entities and value types) to the SQL/database type system. The bridge " +"between both systems is provided by Hibernate: for entities we use " +"<class>, <subclass> and so " +"on. For value types we use <property>, <" +"component>, etc, usually with a type " +"attribute. The value of this attribute is the name of a Hibernate " +"mapping type. Hibernate provides many mappings (for " +"standard JDK value types) out of the box. You can write your own mapping " +"types and implement your custom conversion strategies as well, as you'll see " +"later." msgstr "" +"挑战在于将java类型系统(和开发者定义的实体和值类型)映射到 SQL/数据库类型系统。" +"Hibernate提供了连接两个系统之间的桥梁:对于实体类型,我们使用<" +"class>, <subclass> 等等。对于值类型,我" +"们使用 <property>, <component> 及其他,通常跟随着type属性。这个属性的值是" +"Hibernate 的映射类型的名字。Hibernate提供了许多现成的映" +"射(标准的JDK值类型)。你也可以编写自己的映射类型并实现自定义的变换策略,随后我" +"们会看到这点。" -#: index.docbook:2541 +#. Tag: para +#: basic_mapping.xml:2541 +#, no-c-format msgid "All built-in Hibernate types except collections support null semantics." -msgstr "" +msgstr "所有的Hibernate内建类型,除了collections以外,都支持空(null)语义。" -#: index.docbook:2548 +#. Tag: title +#: basic_mapping.xml:2548 +#, no-c-format msgid "Basic value types" -msgstr "" +msgstr "基本值类型" -#: index.docbook:2550 -msgid "The built-in basic mapping types may be roughly categorized into" -msgstr "" +#. Tag: para +#: basic_mapping.xml:2550 +#, fuzzy, no-c-format +msgid "" +"The built-in basic mapping types may be roughly " +"categorized into" +msgstr "内建的 基本映射类型可以大致分为 " -#: index.docbook:2555 -msgid "integer, long, short, float, double, character, byte, boolean, yes_no, true_false" +#. Tag: literal +#: basic_mapping.xml:2555 +#, no-c-format +msgid "" +"integer, long, short, float, double, character, byte, boolean, yes_no, " +"true_false" msgstr "" +"integer, long, short, float, double, character, byte, boolean, yes_no, " +"true_false" -#: index.docbook:2558 -msgid "Type mappings from Java primitives or wrapper classes to appropriate (vendor-specific) SQL column types. boolean, yes_no and true_false are all alternative encodings for a Java boolean or java.lang.Boolean." +#. Tag: para +#: basic_mapping.xml:2558 +#, no-c-format +msgid "" +"Type mappings from Java primitives or wrapper classes to appropriate (vendor-" +"specific) SQL column types. boolean, yes_no and " +"true_false are all alternative encodings for a Java " +"boolean or java.lang.Boolean." msgstr "" +"这些类型都对应Java的原始类型或者其封装类,来符合(特定厂商的)SQL 字段类型。" +"boolean, yes_notrue_false都是Java " +"中boolean 或者java.lang.Boolean的另外说" +"法。" -#: index.docbook:2567 +#. Tag: literal +#: basic_mapping.xml:2567 +#, no-c-format msgid "string" -msgstr "" +msgstr "string" -#: index.docbook:2569 -msgid "A type mapping from java.lang.String to VARCHAR (or Oracle VARCHAR2)." +#. Tag: para +#: basic_mapping.xml:2569 +#, no-c-format +msgid "" +"A type mapping from java.lang.String to VARCHAR (or Oracle VARCHAR2)." msgstr "" +"从java.lang.StringVARCHAR (或者 " +"Oracle的 VARCHAR2)的映射。" -#: index.docbook:2576 +#. Tag: literal +#: basic_mapping.xml:2576 +#, no-c-format msgid "date, time, timestamp" -msgstr "" +msgstr "date, time, timestamp" -#: index.docbook:2578 -msgid "Type mappings from java.util.Date and its subclasses to SQL types DATE, TIME and TIMESTAMP (or equivalent)." +#. Tag: para +#: basic_mapping.xml:2578 +#, no-c-format +msgid "" +"Type mappings from java.util.Date and its subclasses to " +"SQL types DATE, TIME and " +"TIMESTAMP (or equivalent)." msgstr "" +"从java.util.Date和其子类到SQL类型DATE, " +"TIMETIMESTAMP (或等价类型)的映射。" -#: index.docbook:2586 +#. Tag: literal +#: basic_mapping.xml:2586 +#, no-c-format msgid "calendar, calendar_date" -msgstr "" +msgstr "calendar, calendar_date" -#: index.docbook:2588 -msgid "Type mappings from java.util.Calendar to SQL types TIMESTAMP and DATE (or equivalent)." +#. Tag: para +#: basic_mapping.xml:2588 +#, no-c-format +msgid "" +"Type mappings from java.util.Calendar to SQL types " +"TIMESTAMP and DATE (or equivalent)." msgstr "" +"从java.util.Calendar 到SQL 类型TIMESTAMPDATE(或等价类型)的映射。" -#: index.docbook:2596 +#. Tag: literal +#: basic_mapping.xml:2596 +#, no-c-format msgid "big_decimal, big_integer" -msgstr "" +msgstr "big_decimal, big_integer" -#: index.docbook:2598 -msgid "Type mappings from java.math.BigDecimal and java.math.BigInteger to NUMERIC (or Oracle NUMBER)." +#. Tag: para +#: basic_mapping.xml:2598 +#, no-c-format +msgid "" +"Type mappings from java.math.BigDecimal and java." +"math.BigInteger to NUMERIC (or Oracle " +"NUMBER)." msgstr "" +"从java.math.BigDecimaljava.math.BigIntegerNUMERIC (或者 Oracle 的NUMBER" +"类型)的映射。" -#: index.docbook:2606 +#. Tag: literal +#: basic_mapping.xml:2606 +#, no-c-format msgid "locale, timezone, currency" -msgstr "" +msgstr "locale, timezone, currency" -#: index.docbook:2608 -msgid "Type mappings from java.util.Locale, java.util.TimeZone and java.util.Currency to VARCHAR (or Oracle VARCHAR2). Instances of Locale and Currency are mapped to their ISO codes. Instances of TimeZone are mapped to their ID." +#. Tag: para +#: basic_mapping.xml:2608 +#, no-c-format +msgid "" +"Type mappings from java.util.Locale, java.util." +"TimeZone and java.util.Currency to " +"VARCHAR (or Oracle VARCHAR2). " +"Instances of Locale and Currency are " +"mapped to their ISO codes. Instances of TimeZone are " +"mapped to their ID." msgstr "" +"从java.util.Locale, java.util.TimeZone " +"和java.util.CurrencyVARCHAR (或者 " +"Oracle 的VARCHAR2类型)的映射. Locale和 " +"Currency 的实例被映射为它们的ISO代码。TimeZone的实例被影射为它的ID。" -#: index.docbook:2620 +#. Tag: literal +#: basic_mapping.xml:2620 +#, fuzzy, no-c-format msgid "class" -msgstr "" +msgstr "all(全部) 检查全部字段" -#: index.docbook:2622 -msgid "A type mapping from java.lang.Class to VARCHAR (or Oracle VARCHAR2). A Class is mapped to its fully qualified name." +#. Tag: para +#: basic_mapping.xml:2622 +#, no-c-format +msgid "" +"A type mapping from java.lang.Class to VARCHAR (or Oracle VARCHAR2). A Class " +"is mapped to its fully qualified name." msgstr "" +"从java.lang.ClassVARCHAR (或者 " +"Oracle 的VARCHAR2类型)的映射。Class被映" +"射为它的全限定名。" -#: index.docbook:2630 +#. Tag: literal +#: basic_mapping.xml:2630 +#, no-c-format msgid "binary" -msgstr "" +msgstr "binary" -#: index.docbook:2632 +#. Tag: para +#: basic_mapping.xml:2632 +#, no-c-format msgid "Maps byte arrays to an appropriate SQL binary type." -msgstr "" +msgstr "把字节数组(byte arrays)映射为对应的 SQL二进制类型。" -#: index.docbook:2638 +#. Tag: literal +#: basic_mapping.xml:2638 +#, no-c-format msgid "text" -msgstr "" +msgstr "text" -#: index.docbook:2640 -msgid "Maps long Java strings to a SQL CLOB or TEXT type." +#. Tag: para +#: basic_mapping.xml:2640 +#, no-c-format +msgid "" +"Maps long Java strings to a SQL CLOB or TEXT type." msgstr "" +"把长Java字符串映射为SQL的CLOB或者TEXT类" +"型。" -#: index.docbook:2647 +#. Tag: literal +#: basic_mapping.xml:2647 +#, no-c-format msgid "serializable" -msgstr "" +msgstr "serializable" -#: index.docbook:2649 -msgid "Maps serializable Java types to an appropriate SQL binary type. You may also indicate the Hibernate type serializable with the name of a serializable Java class or interface that does not default to a basic type." +#. Tag: para +#: basic_mapping.xml:2649 +#, no-c-format +msgid "" +"Maps serializable Java types to an appropriate SQL binary type. You may also " +"indicate the Hibernate type serializable with the name of " +"a serializable Java class or interface that does not default to a basic type." msgstr "" +"把可序列化的Java类型映射到对应的SQL二进制类型。你也可以为一个并非默认为基本类" +"型的可序列化Java类或者接口指定Hibernate类型serializable。" -#: index.docbook:2658 +#. Tag: literal +#: basic_mapping.xml:2658 +#, no-c-format msgid "clob, blob" -msgstr "" +msgstr "clob, blob" -#: index.docbook:2660 -msgid "Type mappings for the JDBC classes java.sql.Clob and java.sql.Blob. These types may be inconvenient for some applications, since the blob or clob object may not be reused outside of a transaction. (Furthermore, driver support is patchy and inconsistent.)" +#. Tag: para +#: basic_mapping.xml:2660 +#, no-c-format +msgid "" +"Type mappings for the JDBC classes java.sql.Clob and " +"java.sql.Blob. These types may be inconvenient for some " +"applications, since the blob or clob object may not be reused outside of a " +"transaction. (Furthermore, driver support is patchy and inconsistent.)" msgstr "" +"JDBC 类 java.sql.Clobjava.sql.Blob" +"的映射。某些程序可能不适合使用这个类型,因为blob和clob对象可能在一个事务之外" +"是无法重用的。(而且, 驱动程序对这种类型的支持充满着补丁和前后矛盾。)" -#: index.docbook:2670 -msgid "imm_date, imm_time, imm_timestamp, imm_calendar, imm_calendar_date, imm_serializable, imm_binary" +#. Tag: literal +#: basic_mapping.xml:2670 +#, no-c-format +msgid "" +"imm_date, imm_time, imm_timestamp, imm_calendar, imm_calendar_date, " +"imm_serializable, imm_binary" msgstr "" +"imm_date, imm_time, imm_timestamp, imm_calendar, imm_calendar_date, " +"imm_serializable, imm_binary" -#: index.docbook:2674 -msgid "Type mappings for what are usually considered mutable Java types, where Hibernate makes certain optimizations appropriate only for immutable Java types, and the application treats the object as immutable. For example, you should not call Date.setTime() for an instance mapped as imm_timestamp. To change the value of the property, and have that change made persistent, the application must assign a new (nonidentical) object to the property." +#. Tag: para +#: basic_mapping.xml:2674 +#, no-c-format +msgid "" +"Type mappings for what are usually considered mutable Java types, where " +"Hibernate makes certain optimizations appropriate only for immutable Java " +"types, and the application treats the object as immutable. For example, you " +"should not call Date.setTime() for an instance mapped as " +"imm_timestamp. To change the value of the property, and " +"have that change made persistent, the application must assign a new " +"(nonidentical) object to the property." msgstr "" +"一般来说,映射类型被假定为是可变的Java类型,只有对不可变Java类型,Hibernate会" +"采取特定的优化措施,应用程序会把这些对象作为不可变对象处理。比如,你不应该对" +"作为imm_timestamp映射的Date执行Date.setTime()。要改变属性的值,并且保存这一改变,应用程序必须对这一属性重新设置一" +"个新的(不一样的)对象。" -#: index.docbook:2689 -msgid "Unique identifiers of entities and collections may be of any basic type except binary, blob and clob. (Composite identifiers are also allowed, see below.)" +#. Tag: para +#: basic_mapping.xml:2689 +#, no-c-format +msgid "" +"Unique identifiers of entities and collections may be of any basic type " +"except binary, blob and clob. (Composite identifiers are also allowed, see below.)" msgstr "" +"实体及其集合的唯一标识可以是除了binaryblobclob之外的任何基础类型。(联合标识也是允许的," +"后面会说到。)" -#: index.docbook:2695 -msgid "The basic value types have corresponding Type constants defined on org.hibernate.Hibernate. For example, Hibernate.STRING represents the string type." +#. Tag: para +#: basic_mapping.xml:2695 +#, no-c-format +msgid "" +"The basic value types have corresponding Type constants " +"defined on org.hibernate.Hibernate. For example, " +"Hibernate.STRING represents the string " +"type." msgstr "" +"在org.hibernate.Hibernate中,定义了基础类型对应的" +"Type常量。比如,Hibernate.STRING代表" +"string 类型。" -#: index.docbook:2704 +#. Tag: title +#: basic_mapping.xml:2704 +#, no-c-format msgid "Custom value types" -msgstr "" +msgstr "自定义值类型" -#: index.docbook:2706 -msgid "It is relatively easy for developers to create their own value types. For example, you might want to persist properties of type java.lang.BigInteger to VARCHAR columns. Hibernate does not provide a built-in type for this. But custom types are not limited to mapping a property (or collection element) to a single table column. So, for example, you might have a Java property getName()/setName() of type java.lang.String that is persisted to the columns FIRST_NAME, INITIAL, SURNAME." -msgstr "" - -#: index.docbook:2717 -msgid "To implement a custom type, implement either org.hibernate.UserType or org.hibernate.CompositeUserType and declare properties using the fully qualified classname of the type. Check out org.hibernate.test.DoubleStringType to see the kind of things that are possible." -msgstr "" - -#: index.docbook:2725 +#. Tag: para +#: basic_mapping.xml:2706 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"It is relatively easy for developers to create their own value types. For " +"example, you might want to persist properties of type java.lang." +"BigInteger to VARCHAR columns. Hibernate does " +"not provide a built-in type for this. But custom types are not limited to " +"mapping a property (or collection element) to a single table column. So, for " +"example, you might have a Java property getName()/" +"setName() of type java.lang.String " +"that is persisted to the columns FIRST_NAME, " +"INITIAL, SURNAME." msgstr "" +"开发者创建属于他们自己的值类型也是很容易的。比如说,你可能希望持久化" +"java.lang.BigInteger类型的属性,持久化成为" +"VARCHAR字段。Hibernate没有内置这样一种类型。自定义类型能够" +"映射一个属性(或集合元素)到不止一个数据库表字段。比如说,你可能有这样的Java属" +"性:getName()/setName(),这是" +"java.lang.String类型的,对应的持久化到三个字段:" +"FIRST_NAME, INITIAL, SURNAME。" -#: index.docbook:2727 -msgid "Notice the use of <column> tags to map a property to multiple columns." -msgstr "" - -#: index.docbook:2732 -msgid "The CompositeUserType, EnhancedUserType, UserCollectionType, and UserVersionType interfaces provide support for more specialized uses." -msgstr "" - -#: index.docbook:2738 -msgid "You may even supply parameters to a UserType in the mapping file. To do this, your UserType must implement the org.hibernate.usertype.ParameterizedType interface. To supply parameters to your custom type, you can use the <type> element in your mapping files." -msgstr "" - -#: index.docbook:2746 +#. Tag: para +#: basic_mapping.xml:2717 +#, no-c-format msgid "" - "\n" - " \n" - " 0\n" - " \n" - "]]>" +"To implement a custom type, implement either org.hibernate." +"UserType or org.hibernate.CompositeUserType and " +"declare properties using the fully qualified classname of the type. Check " +"out org.hibernate.test.DoubleStringType to see the kind " +"of things that are possible." msgstr "" +"要实现一个自定义类型,可以实现org.hibernate.UserType或" +"org.hibernate.CompositeUserType中的任一个,并且使用类型的" +"Java全限定类名来定义属性。请查看org.hibernate.test." +"DoubleStringType这个例子,看看它是怎么做的。" -#: index.docbook:2748 -msgid "The UserType can now retrieve the value for the parameter named default from the Properties object passed to it." -msgstr "" - -#: index.docbook:2753 -msgid "If you use a certain UserType very often, it may be useful to define a shorter name for it. You can do this using the <typedef> element. Typedefs assign a name to a custom type, and may also contain a list of default parameter values if the type is parameterized." -msgstr "" - -#: index.docbook:2760 +#. Tag: programlisting +#: basic_mapping.xml:2725 +#, no-c-format msgid "" - "\n" - " 0\n" - "]]>" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:2762 +#. Tag: para +#: basic_mapping.xml:2727 +#, no-c-format +msgid "" +"Notice the use of <column> tags to map a property " +"to multiple columns." +msgstr "" +"注意使用<column>标签来把一个属性映射到多个字段的做" +"法。" + +#. Tag: para +#: basic_mapping.xml:2732 +#, no-c-format +msgid "" +"The CompositeUserType, EnhancedUserType, UserCollectionType, and " +"UserVersionType interfaces provide support for more " +"specialized uses." +msgstr "" +"CompositeUserType, EnhancedUserType, " +"UserCollectionType, 和 UserVersionType " +"接口为更特殊的使用方式提供支持。" + +#. Tag: para +#: basic_mapping.xml:2738 +#, no-c-format +msgid "" +"You may even supply parameters to a UserType in the " +"mapping file. To do this, your UserType must implement " +"the org.hibernate.usertype.ParameterizedType interface. " +"To supply parameters to your custom type, you can use the <" +"type> element in your mapping files." +msgstr "" +"你甚至可以在一个映射文件中提供参数给一个UserType。 为了这" +"样做,你的UserType必须实现org.hibernate.usertype." +"ParameterizedType接口。为了给自定义类型提供参数,你可以在映射文件中" +"使用<type>元素。" + +#. Tag: programlisting +#: basic_mapping.xml:2746 +#, no-c-format +msgid "" +"\n" +" \n" +" 0\n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: basic_mapping.xml:2748 +#, no-c-format +msgid "" +"The UserType can now retrieve the value for the parameter " +"named default from the Properties " +"object passed to it." +msgstr "" +"现在,UserType 可以从传入的Properties对" +"象中得到default 参数的值。" + +#. Tag: para +#: basic_mapping.xml:2753 +#, no-c-format +msgid "" +"If you use a certain UserType very often, it may be " +"useful to define a shorter name for it. You can do this using the " +"<typedef> element. Typedefs assign a name to a " +"custom type, and may also contain a list of default parameter values if the " +"type is parameterized." +msgstr "" +"如果你非常频繁地使用某一UserType,可以为他定义一个简称。这" +"可以通过使用 <typedef>元素来实现。Typedefs为一自定义" +"类型赋予一个名称,并且如果此类型是参数化的,还可以包含一系列默认的参数值。" + +#. Tag: programlisting +#: basic_mapping.xml:2760 +#, no-c-format +msgid "" +"\n" +" 0\n" +"]]>" +msgstr "" + +#. Tag: programlisting +#: basic_mapping.xml:2762 +#, no-c-format msgid "]]>" msgstr "" -#: index.docbook:2764 -msgid "It is also possible to override the parameters supplied in a typedef on a case-by-case basis by using type parameters on the property mapping." -msgstr "" +#. Tag: para +#: basic_mapping.xml:2764 +#, no-c-format +msgid "" +"It is also possible to override the parameters supplied in a typedef on a " +"case-by-case basis by using type parameters on the property mapping." +msgstr "也可以根据具体案例通过属性映射中的类型参数覆盖在typedef中提供的参数。" -#: index.docbook:2769 -msgid "Even though Hibernate's rich range of built-in types and support for components means you will very rarely need to use a custom type, it is nevertheless considered good form to use custom types for (non-entity) classes that occur frequently in your application. For example, a MonetaryAmount class is a good candidate for a CompositeUserType, even though it could easily be mapped as a component. One motivation for this is abstraction. With a custom type, your mapping documents would be future-proofed against possible changes in your way of representing monetary values." +#. Tag: para +#: basic_mapping.xml:2769 +#, no-c-format +msgid "" +"Even though Hibernate's rich range of built-in types and support for " +"components means you will very rarely need to use a " +"custom type, it is nevertheless considered good form to use custom types for " +"(non-entity) classes that occur frequently in your application. For example, " +"a MonetaryAmount class is a good candidate for a " +"CompositeUserType, even though it could easily be mapped " +"as a component. One motivation for this is abstraction. With a custom type, " +"your mapping documents would be future-proofed against possible changes in " +"your way of representing monetary values." msgstr "" +"尽管 Hibernate 内建的丰富的类型和对组件的支持意味着你可能很少 需要" +"使用自定义类型。不过,为那些在你的应用中经常出现的(非实体)类使用自" +"定义类型也是一个好方法。例如,一个MonetaryAmount类使用" +"CompositeUserType来映射是不错的选择,虽然他可以很容易地被" +"映射成组件。这样做的动机之一是抽象。使用自定义类型,以后假若你改变表示金额的" +"方法时,它可以保证映射文件不需要修改。" -#: index.docbook:2785 +#. Tag: title +#: basic_mapping.xml:2785 +#, no-c-format msgid "Mapping a class more than once" -msgstr "" +msgstr "多次映射同一个类" -#: index.docbook:2786 -msgid "It is possible to provide more than one mapping for a particular persistent class. In this case you must specify an entity name do disambiguate between instances of the two mapped entities. (By default, the entity name is the same as the class name.) Hibernate lets you specify the entity name when working with persistent objects, when writing queries, or when mapping associations to the named entity." -msgstr "" - -#: index.docbook:2794 +#. Tag: para +#: basic_mapping.xml:2786 +#, no-c-format msgid "" - "\n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " ...\n" - " \n" - "]]>" +"It is possible to provide more than one mapping for a particular persistent " +"class. In this case you must specify an entity name do " +"disambiguate between instances of the two mapped entities. (By default, the " +"entity name is the same as the class name.) Hibernate lets you specify the " +"entity name when working with persistent objects, when writing queries, or " +"when mapping associations to the named entity." +msgstr "" +"对特定的持久化类,映射多次是允许的。这种情形下,你必须指定entity " +"name来区别不同映射实体的对象实例。(默认情况下,实体名字和类名是相" +"同的。) Hibernate在操作持久化对象、编写查询条件,或者把关联映射到指定实体" +"时,允许你指定这个entity name(实体名字)。" + +#. Tag: programlisting +#: basic_mapping.xml:2794 +#, no-c-format +msgid "" +"\n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" ...\n" +" \n" +"]]>" msgstr "" -#: index.docbook:2796 -msgid "Notice how associations are now specified using entity-name instead of class." +#. Tag: para +#: basic_mapping.xml:2796 +#, no-c-format +msgid "" +"Notice how associations are now specified using entity-name instead of class." msgstr "" +"注意这里关联是如何用entity-name来代替class的。" -#: index.docbook:2804 +#. Tag: title +#: basic_mapping.xml:2804 +#, no-c-format msgid "SQL quoted identifiers" -msgstr "" +msgstr "SQL中引号包围的标识符" -#: index.docbook:2805 -msgid "You may force Hibernate to quote an identifier in the generated SQL by enclosing the table or column name in backticks in the mapping document. Hibernate will use the correct quotation style for the SQL Dialect (usually double quotes, but brackets for SQL Server and backticks for MySQL)." -msgstr "" - -#: index.docbook:2812 +#. Tag: para +#: basic_mapping.xml:2805 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " ...\n" - "]]>" +"You may force Hibernate to quote an identifier in the generated SQL by " +"enclosing the table or column name in backticks in the mapping document. " +"Hibernate will use the correct quotation style for the SQL Dialect (usually double quotes, but brackets for SQL Server and backticks " +"for MySQL)." +msgstr "" +"你可通过在映射文档中使用反向引号(`)把表名或者字段名包围起来,以强制Hibernate" +"在生成的SQL中把标识符用引号包围起来。Hibernate会使用相应的" +"SQLDialect(方言)来使用正确的引号风格(通常是双引号,但是在" +"SQL Server中是括号,MySQL中是反向引号)。" + +#. Tag: programlisting +#: basic_mapping.xml:2812 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" ...\n" +"]]>" msgstr "" -#: index.docbook:2818 +#. Tag: title +#: basic_mapping.xml:2818 +#, no-c-format msgid "Metadata alternatives" -msgstr "" +msgstr "其他元数据(Metadata)" -#: index.docbook:2820 -msgid "XML isn't for everyone, and so there are some alternative ways to define O/R mapping metadata in Hibernate." +#. Tag: para +#: basic_mapping.xml:2820 +#, no-c-format +msgid "" +"XML isn't for everyone, and so there are some alternative ways to define O/R " +"mapping metadata in Hibernate." msgstr "" +"XML 并不适用于所有人, 因此有其他定义Hibernate O/R 映射元数据(metadata)的方" +"法。" -#: index.docbook:2825 +#. Tag: title +#: basic_mapping.xml:2825 +#, no-c-format msgid "Using XDoclet markup" -msgstr "" +msgstr "使用 XDoclet 标记" -#: index.docbook:2827 -msgid "Many Hibernate users prefer to embed mapping information directly in sourcecode using XDoclet @hibernate.tags. We will not cover this approach in this document, since strictly it is considered part of XDoclet. However, we include the following example of the Cat class with XDoclet mappings." -msgstr "" - -#: index.docbook:2834 +#. Tag: para +#: basic_mapping.xml:2827 +#, no-c-format msgid "" - "" +"Many Hibernate users prefer to embed mapping information directly in " +"sourcecode using XDoclet @hibernate.tags. We will not " +"cover this approach in this document, since strictly it is considered part " +"of XDoclet. However, we include the following example of the Cat class with XDoclet mappings." +msgstr "" +"很多Hibernate使用者更喜欢使用XDoclet@hibernate.tags将映射" +"信息直接嵌入到源代码中。我们不会在本文档中涉及这个方法,因为严格说来,这属于" +"XDoclet的一部分。然而,我们包含了如下使用XDoclet映射的Cat" +"类的例子。" + +#. Tag: programlisting +#: basic_mapping.xml:2834 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:2836 +#. Tag: para +#: basic_mapping.xml:2836 +#, no-c-format msgid "See the Hibernate web site for more examples of XDoclet and Hibernate." -msgstr "" +msgstr "参考Hibernate网站更多的Xdoclet和Hibernate的例子" -#: index.docbook:2843 +#. Tag: title +#: basic_mapping.xml:2843 +#, no-c-format msgid "Using JDK 5.0 Annotations" -msgstr "" +msgstr "使用 JDK 5.0 的注解(Annotation)" -#: index.docbook:2845 -msgid "JDK 5.0 introduced XDoclet-style annotations at the language level, type-safe and checked at compile time. This mechnism is more powerful than XDoclet annotations and better supported by tools and IDEs. IntelliJ IDEA, for example, supports auto-completion and syntax highlighting of JDK 5.0 annotations. The new revision of the EJB specification (JSR-220) uses JDK 5.0 annotations as the primary metadata mechanism for entity beans. Hibernate3 implements the EntityManager of JSR-220 (the persistence API), support for mapping metadata is available via the Hibernate Annotations package, as a separate download. Both EJB3 (JSR-220) and Hibernate3 metadata is supported." +#. Tag: para +#: basic_mapping.xml:2845 +#, no-c-format +msgid "" +"JDK 5.0 introduced XDoclet-style annotations at the language level, type-" +"safe and checked at compile time. This mechnism is more powerful than " +"XDoclet annotations and better supported by tools and IDEs. IntelliJ IDEA, " +"for example, supports auto-completion and syntax highlighting of JDK 5.0 " +"annotations. The new revision of the EJB specification (JSR-220) uses JDK " +"5.0 annotations as the primary metadata mechanism for entity beans. " +"Hibernate3 implements the EntityManager of JSR-220 (the " +"persistence API), support for mapping metadata is available via the " +"Hibernate Annotations package, as a separate download. " +"Both EJB3 (JSR-220) and Hibernate3 metadata is supported." msgstr "" +"JDK 5.0 在语言级别引入了 XDoclet 风格的标注,并且是类型安全的,在编译期进行检" +"查。这一机制比XDoclet的注解更为强大,有更好的工具和IDE支持。例如, IntelliJ " +"IDEA,支持JDK 5.0注解的自动完成和语法高亮 。EJB规范的新修订版(JSR-220)使用 " +"JDK 5.0的注解作为entity beans的主要元数据(metadata)机制。Hibernate 3 实现了" +"JSR-220 (the persistence API)的EntityManager,支持通过" +"Hibernate Annotations包定义映射元数据。这个包作为单独的" +"部分下载,支持EJB3 (JSR-220)和Hibernate3的元数据。" -#: index.docbook:2856 +#. Tag: para +#: basic_mapping.xml:2856 +#, no-c-format msgid "This is an example of a POJO class annotated as an EJB entity bean:" -msgstr "" +msgstr "这是一个被注解为EJB entity bean 的POJO类的例子" -#: index.docbook:2860 +#. Tag: programlisting +#: basic_mapping.xml:2860 +#, no-c-format msgid "" - " orders;\n" - "\n" - " // Getter/setter and business methods\n" - "}]]>" +" orders;\n" +"\n" +" // Getter/setter and business methods\n" +"}]]>" msgstr "" -#: index.docbook:2862 -msgid "Note that support for JDK 5.0 Annotations (and JSR-220) is still work in progress and not completed. Please refer to the Hibernate Annotations module for more details." +#. Tag: para +#: basic_mapping.xml:2862 +#, no-c-format +msgid "" +"Note that support for JDK 5.0 Annotations (and JSR-220) is still work in " +"progress and not completed. Please refer to the Hibernate Annotations module " +"for more details." msgstr "" +"注意:对 JDK 5.0 注解 (和 JSR-220)支持的工作仍然在进行中,并未完成。更多细节请" +"参阅Hibernate Annotations 模块。" -#: index.docbook:2871 +#. Tag: title +#: basic_mapping.xml:2871 +#, no-c-format msgid "Generated Properties" -msgstr "" +msgstr "数据库生成属性(Generated Properties)" -#: index.docbook:2872 -msgid "Generated properties are properties which have their values generated by the database. Typically, Hibernate applications needed to refresh objects which contain any properties for which the database was generating values. Marking properties as generated, however, lets the application delegate this responsibility to Hibernate. Essentially, whenever Hibernate issues an SQL INSERT or UPDATE for an entity which has defined generated properties, it immediately issues a select afterwards to retrieve the generated values." +#. Tag: para +#: basic_mapping.xml:2872 +#, no-c-format +msgid "" +"Generated properties are properties which have their values generated by the " +"database. Typically, Hibernate applications needed to refresh objects which contain any properties for which the database was " +"generating values. Marking properties as generated, however, lets the " +"application delegate this responsibility to Hibernate. Essentially, whenever " +"Hibernate issues an SQL INSERT or UPDATE for an entity which has defined " +"generated properties, it immediately issues a select afterwards to retrieve " +"the generated values." msgstr "" +"Generated properties指的是其值由数据库生成的属性。一般来说,如果对象有任何属" +"性由数据库生成值,Hibernate应用程序需要进行刷新(refresh)。" +"但如果把属性标明为generated,就可以转由Hibernate来负责这个动作。实际上。对定" +"义了generated properties的实体,每当Hibernate执行一条SQL INSERT或者UPDATE语" +"句,会立刻执行一条select来获得生成的值。" -#: index.docbook:2881 -msgid "Properties marked as generated must additionally be non-insertable and non-updateable. Only versions, timestamps, and simple properties can be marked as generated." +#. Tag: para +#: basic_mapping.xml:2881 +#, fuzzy, no-c-format +msgid "" +"Properties marked as generated must additionally be non-insertable and non-" +"updateable. Only versions, " +"timestamps, and simple properties can be marked as " +"generated." msgstr "" +"被标明为generated的属性还必须是 non-insertable和 non-updateable的。只有versionstimestamps简单属性(simple properties)可以被标明为" +"generated。" -#: index.docbook:2888 -msgid "never (the default) - means that the given property value is not generated within the database." +#. Tag: para +#: basic_mapping.xml:2888 +#, no-c-format +msgid "" +"never (the default) - means that the given property value " +"is not generated within the database." +msgstr "never (默认) 标明此属性值不是从数据库中生成。" + +#. Tag: para +#: basic_mapping.xml:2892 +#, fuzzy, no-c-format +msgid "" +"insert - states that the given property value is " +"generated on insert, but is not regenerated on subsequent updates. Things " +"like created-date would fall into this category. Note that even thought " +"version and timestamp properties can be marked as " +"generated, this option is not available there..." msgstr "" +"insert - 标明此属性值在insert的时候生成,但是不会在随后的" +"update时重新生成。比如说创建日期就归属于这类。注意虽然versiontimestamp属性可以被标注为generated,但是不适用" +"这个选项..." -#: index.docbook:2892 -msgid "insert - states that the given property value is generated on insert, but is not regenerated on subsequent updates. Things like created-date would fall into this category. Note that even thought version and timestamp properties can be marked as generated, this option is not available there..." -msgstr "" +#. Tag: para +#: basic_mapping.xml:2900 +#, no-c-format +msgid "" +"always - states that the property value is generated both " +"on insert and on update." +msgstr "always - 标明此属性值在insert和update时都会被生成。" -#: index.docbook:2900 -msgid "always - states that the property value is generated both on insert and on update." -msgstr "" - -#: index.docbook:2907 +#. Tag: title +#: basic_mapping.xml:2907 +#, no-c-format msgid "Auxiliary Database Objects" -msgstr "" +msgstr "辅助数据库对象(Auxiliary Database Objects)" -#: index.docbook:2908 -msgid "Allows CREATE and DROP of arbitrary database objects, in conjunction with Hibernate's schema evolution tools, to provide the ability to fully define a user schema within the Hibernate mapping files. Although designed specifically for creating and dropping things like triggers or stored procedures, really any SQL command that can be run via a java.sql.Statement.execute() method is valid here (ALTERs, INSERTS, etc). There are essentially two modes for defining auxiliary database objects..." -msgstr "" - -#: index.docbook:2917 -msgid "The first mode is to explicitly list the CREATE and DROP commands out in the mapping file:" -msgstr "" - -#: index.docbook:2921 +#. Tag: para +#: basic_mapping.xml:2908 +#, no-c-format msgid "" - "\n" - " ...\n" - " \n" - " CREATE TRIGGER my_trigger ...\n" - " DROP TRIGGER my_trigger\n" - " \n" - "]]>" +"Allows CREATE and DROP of arbitrary database objects, in conjunction with " +"Hibernate's schema evolution tools, to provide the ability to fully define a " +"user schema within the Hibernate mapping files. Although designed " +"specifically for creating and dropping things like triggers or stored " +"procedures, really any SQL command that can be run via a java.sql." +"Statement.execute() method is valid here (ALTERs, INSERTS, etc). " +"There are essentially two modes for defining auxiliary database objects..." msgstr "" +"Allows CREATE and DROP of arbitrary database objects, in conjunction with " +"Hibernate's schema evolution tools, to provide the ability to fully define a " +"user schema within the Hibernate mapping files. Although designed " +"specifically for creating and dropping things like triggers or stored " +"procedures, really any SQL command that can be run via a java.sql." +"Statement.execute() method is valid here (ALTERs, INSERTS, etc). " +"There are essentially two modes for defining auxiliary database objects... 帮" +"助CREATE和DROP任意数据库对象,与Hibernate的schema交互工具组合起来,可以提供在" +"Hibernate映射文件中完全定义用户schema的能力。虽然这是为创建和销毁trigger(触发" +"器)或stored procedure(存储过程)等特别设计的,实际上任何可以在java." +"sql.Statement.execute()方法中执行的SQL命令都可以在此使用(比如" +"ALTER, INSERT,等等)。本质上有两种模式来定义辅助数据库对象..." -#: index.docbook:2922 -msgid "The second mode is to supply a custom class which knows how to construct the CREATE and DROP commands. This custom class must implement the org.hibernate.mapping.AuxiliaryDatabaseObject interface." -msgstr "" - -#: index.docbook:2927 +#. Tag: para +#: basic_mapping.xml:2917 +#, no-c-format msgid "" - "\n" - " ...\n" - " \n" - " \n" - " \n" - "]]>" -msgstr "" +"The first mode is to explicitly list the CREATE and DROP commands out in the " +"mapping file:" +msgstr "第一种模式是在映射文件中显式声明CREATE和DROP命令:" -#: index.docbook:2928 -msgid "Additionally, these database objects can be optionally scoped such that they only apply when certain dialects are used." -msgstr "" - -#: index.docbook:2932 +#. Tag: programlisting +#: basic_mapping.xml:2921 +#, no-c-format msgid "" - "\n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" ...\n" +" \n" +" CREATE TRIGGER my_trigger ...\n" +" DROP TRIGGER my_trigger\n" +" \n" +"]]>" msgstr "" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" +#. Tag: para +#: basic_mapping.xml:2922 +#, no-c-format +msgid "" +"The second mode is to supply a custom class which knows how to construct the " +"CREATE and DROP commands. This custom class must implement the org." +"hibernate.mapping.AuxiliaryDatabaseObject interface." +msgstr "" +"第二种模式是提供一个类,这个类知道如何组织CREATE和DROP命令。这个特别类必须实" +"现org.hibernate.mapping.AuxiliaryDatabaseObject接口。" -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" +#. Tag: programlisting +#: basic_mapping.xml:2927 +#, no-c-format +msgid "" +"\n" +" ...\n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" +#. Tag: para +#: basic_mapping.xml:2928 +#, no-c-format +msgid "" +"Additionally, these database objects can be optionally scoped such that they " +"only apply when certain dialects are used." +msgstr "还有,这些数据库对象可以特别指定为仅在特定的方言中才使用。" + +#. Tag: programlisting +#: basic_mapping.xml:2932 +#, no-c-format +msgid "" +"\n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#~ msgid "class" +#~ msgstr "class" + +#~ msgid "id" +#~ msgstr "id" + +#~ msgid "" +#~ "optimizer (optional, defaults to none): See " +#~ msgstr "" +#~ "optimizer (optional, defaults to none): See " + +#~ msgid "" +#~ "optimizer (optional, defaults to ): See " +#~ "" +#~ msgstr "" +#~ "optimizer (optional, defaults to ): See " +#~ "" + +#~ msgid "key" +#~ msgstr "键(key)" + +#~ msgid "any" +#~ msgstr "any" diff --git a/documentation/manual/translations/zh-CN/content/batch.po b/documentation/manual/translations/zh-CN/content/batch.po index f441e678e5..f3a9a54941 100644 --- a/documentation/manual/translations/zh-CN/content/batch.po +++ b/documentation/manual/translations/zh-CN/content/batch.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \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 "" - "" +"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 "" +"" msgstr "" -#: index.docbook:14 -msgid "This would fall over with an OutOfMemoryException somewhere around the 50 000th row. That's because Hibernate caches all the newly inserted Customer instances in the session-level cache." +#. Tag: para +#: batch.xml:14 +#, no-c-format +msgid "" +"This would fall over with an OutOfMemoryException " +"somewhere around the 50 000th row. That's because Hibernate caches all the " +"newly inserted Customer instances in the session-level " +"cache." msgstr "" +"这段程序大概运行到 50 000 条记录左右会失败并抛出 内存溢出异常" +"(OutOfMemoryException) 。 这是因为 Hibernate 把所有新插入的 " +"客户(Customer)实例在 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 "" msgstr "" -#: index.docbook:29 -msgid "Note that Hibernate disables insert batching at the JDBC level transparently if you use an identiy 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 identiy identifier generator." msgstr "" +"注意,假若你使用了identiy标识符生成器,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 "" msgstr "" -#: index.docbook:41 -msgid "However, this is not absolutely necessary, since we can explicitly set the CacheMode 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 " +"CacheMode to disable interaction with the second-level " +"cache." msgstr "" +"但是,这不是绝对必须的,因为我们可以显式设置CacheMode来关" +"闭与二级缓存的交互。" -#: 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 flush() and then clear() 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 "" - "" +"When making new objects persistent, you must flush() and " +"then clear() the session regularly, to control the size " +"of the first-level cache." +msgstr "" +"如果要将很多对象持久化,你必须通过经常的调用 flush() 以及" +"稍后调用 clear() 来控制第一级缓存的大小。" + +#. Tag: programlisting +#: batch.xml:55 +#, no-c-format +msgid "" +"" 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 scroll() 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 "" - "" +"For retrieving and updating data the same ideas apply. In addition, you need " +"to use scroll() to take advantage of server-side cursors " +"for queries that return many rows of data." +msgstr "" +"此方法同样适用于检索和更新数据。此外,在进行会返回很多行数据的查询时, 你需要" +"使用 scroll() 方法以便充分利用服务器端游标所带来的好处。" + +#. Tag: programlisting +#: batch.xml:68 +#, no-c-format +msgid "" +"" 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 StatelessSession 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 "" - "" +"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 StatelessSession 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的形式把数据以流" +"的方法加入到数据库,或从数据库输出。StatelessSession没有持" +"久化上下文,也不提供多少高层的生命周期语义。特别是,无状态session不实现第一级" +"cache,也不和第二级缓存,或者查询缓存交互。它不实现事务化写,也不实现脏数据检" +"查。用stateless session进行的操作甚至不级联到关联实例。stateless session忽略" +"集合类(Collections)。通过stateless session进行的操作不触发Hibernate的事件模型" +"和拦截器。无状态session对数据的混淆现象免疫,因为它没有第一级缓存。无状态" +"session是低层的抽象,和低层JDBC相当接近。" + +#. Tag: programlisting +#: batch.xml:89 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:91 -msgid "Note that in this code example, the Customer 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 Customer instances " +"returned by the query are immediately detached. They are never associated " +"with any persistence context." msgstr "" +"注意在上面的例子中,查询返回的Customer实例立即被脱管" +"(detach)。它们与任何持久化上下文都没有关系。" -#: index.docbook:97 -msgid "The insert(), update() and delete() operations defined by the StatelessSession interface are considered to be direct database row-level operations, which result in immediate execution of a SQL INSERT, UPDATE or DELETE respectively. Thus, they have very different semantics to the save(), saveOrUpdate() and delete() operations defined by the Session interface." +#. Tag: para +#: batch.xml:97 +#, no-c-format +msgid "" +"The insert(), update() and delete() " +"operations defined by the StatelessSession interface are " +"considered to be direct database row-level operations, which result in " +"immediate execution of a SQL INSERT, UPDATE or " +"DELETE respectively. Thus, they have very different " +"semantics to the save(), saveOrUpdate() and " +"delete() operations defined by the Session interface." msgstr "" +"StatelessSession 接口定义的insert(), update()delete()操作是直接的数据库行级别操作,其结果是" +"立刻执行一条INSERT, UPDATEDELETE 语" +"句。因此,它们的语义和Session 接口定义的save(), " +"saveOrUpdate()delete() 操作有很大的不同。" -#: 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 Data Manipulation Language (DML) statements: INSERT, UPDATE, DELETE) 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 (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 " +"Data Manipulation Language (DML) statements: " +"INSERT, UPDATE, DELETE) 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 (HQL)." msgstr "" +"hence manipulating (using the SQL Data Manipulation Language (DML) statements: INSERT, UPDATE, DELETE) 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 (HQL). 就像已经讨论的那样," +"自动和透明的 对象/关系 映射(object/relational mapping)关注于管理对象的状" +"态。 这就意味着对象的状态存在于内存,因此直接操作 (使用 SQL Data " +"Manipulation Language(DML,数据操作语言)语句 :INSERT ,UPDATEDELETE) 数据库中的" +"数据将不会影响内存中的对象状态和对象数据。 不过,Hibernate提供通过Hibernate查" +"询语言(HQL)来执行大批 量SQL风格的DML语句" +"的方法。" -#: index.docbook:122 -msgid "The pseudo-syntax for UPDATE and DELETE statements is: ( UPDATE | DELETE ) FROM? EntityName (WHERE where_conditions)?. Some points to note:" +#. Tag: para +#: batch.xml:122 +#, no-c-format +msgid "" +"The pseudo-syntax for UPDATE and DELETE statements is: ( UPDATE | DELETE ) FROM? EntityName (WHERE " +"where_conditions)?. Some points to note:" msgstr "" +"UPDATEDELETE语句的语法为: " +"( UPDATE | DELETE ) FROM? EntityName (WHERE where_conditions)? 有几点说明:" -#: 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-clause)中,FROM关键字是可选的" -#: 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 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 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语句中使用连接(join)(显式或者隐式的都不行)。不过在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 UPDATE, use the Query.executeUpdate() method (the method is named for those familiar with JDBC's PreparedStatement.executeUpdate()):" -msgstr "" - -#: index.docbook:162 +#. Tag: para +#: batch.xml:156 +#, no-c-format msgid "" - "" +"As an example, to execute an HQL UPDATE, use the " +"Query.executeUpdate() method (the method is named for " +"those familiar with JDBC's PreparedStatement.executeUpdate()):" msgstr "" +"举个例子,使用Query.executeUpdate()方法执行一个HQL " +"UPDATE语句(: (方法命名是来源于JDBC's " +"PreparedStatement.executeUpdate()):" -#: index.docbook:164 -msgid "HQL UPDATE statements, by default do not effect the version or the timestamp property values for the affected entities; this is in keeping with the EJB3 specification. However, you can force Hibernate to properly reset the version or timestamp property values through the use of a versioned update. This is achieved by adding the VERSIONED keyword after the UPDATE keyword." -msgstr "" - -#: index.docbook:174 +#. Tag: programlisting +#: batch.xml:162 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:176 -msgid "Note that custom version types (org.hibernate.usertype.UserVersionType) are not allowed in conjunction with a update versioned statement." -msgstr "" - -#: index.docbook:181 -msgid "To execute an HQL DELETE, use the same Query.executeUpdate() method:" -msgstr "" - -#: index.docbook:186 +#. Tag: para +#: batch.xml:164 +#, fuzzy, no-c-format msgid "" - "" +"HQL UPDATE statements, by default do not effect the version or the timestamp property values for the " +"affected entities; this is in keeping with the EJB3 specification. However, " +"you can force Hibernate to properly reset the version or " +"timestamp property values through the use of a " +"versioned update. This is achieved by adding the " +"VERSIONED keyword after the UPDATE " +"keyword." +msgstr "" +"HQL UPDATE语句,默认不会影响更新实体的version或者timestamp属性值。这和EJB3规范是一致的。但是," +"通过使用versioned update,你可以强制Hibernate正确的重置" +"version或者timestamp属性值。这通过在" +"UPDATE关键字后面增加VERSIONED关键字来实" +"现的。" + +#. Tag: programlisting +#: batch.xml:174 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:188 -msgid "The int value returned by the Query.executeUpdate() 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 (org.hibernate.usertype." +"UserVersionType) are not allowed in conjunction with a " +"update versioned statement." +msgstr "" +"注意,自定义的版本类型(org.hibernate.usertype.UserVersionType)不允许和update versioned语句联用。" + +#. Tag: para +#: batch.xml:181 +#, no-c-format +msgid "" +"To execute an HQL DELETE, use the same Query." +"executeUpdate() method:" +msgstr "" +"执行一个HQL DELETE,同样使用 Query.executeUpdate" +"() 方法:" + +#. Tag: programlisting +#: batch.xml:186 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:199 -msgid "The pseudo-syntax for INSERT statements is: INSERT INTO EntityName properties_list select_statement. Some points to note:" +#. Tag: para +#: batch.xml:188 +#, no-c-format +msgid "" +"The int value returned by the Query.executeUpdate" +"() 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 "" +"由Query.executeUpdate()方法返回的整型值" +"表明了受此操作影响的记录数量。 注意这个数值可能与数据库中被(最后一条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 INSERT statements is: " +"INSERT INTO EntityName properties_list select_statement. " +"Some points to note:" msgstr "" +"INSERT语句的伪码是: INSERT INTO EntityName " +"properties_list select_statement. 要注意的是:" -#: index.docbook:210 -msgid "The properties_list is analogous to the column speficiation in the SQL INSERT 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, INSERT 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 Types which are equivalent as opposed to equal. This might cause issues with mismatches between a property defined as a org.hibernate.type.DateType and a property defined as a org.hibernate.type.TimestampType, 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 column speficiation in the SQL INSERT 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, " +"INSERT statements are inherently non-polymorphic." msgstr "" +"properties_list和SQL INSERT语句中的字段定义" +"(column speficiation)类似。对参与继承树映射的实体而言,只有直接定义" +"在给定的类级别的属性才能直接在properties_list中使用。超类的属性不被支持;子类" +"的属性无意义。换句话说,INSERT天生不支持多态。" -#: 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 org.hibernate.id.SequenceGenerator (and its subclasses) and any implementors of org.hibernate.id.PostInsertIdentifierGenerator. The most notable exception here is org.hibernate.id.TableHiLoGenerator, 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 Types which are equivalent " +"as opposed to equal. This might cause issues with " +"mismatches between a property defined as a org.hibernate.type." +"DateType and a property defined as a org.hibernate.type." +"TimestampType, even though the database might not make a " +"distinction or might be able to handle the conversion." msgstr "" +"select_statement可以是任何合法的HQL选择查询,不过要保证返回类型必须和要插入的" +"类型完全匹配。目前,这一检查是在查询编译的时候进行的,而不是把它交给数据库。" +"注意,在HibernateType间如果只是等价" +"(equivalent)而非相等(equal),会导致问题。定" +"义为org.hibernate.type.DateTypeorg.hibernate." +"type.TimestampType的两个属性可能会产生类型不匹配错误,虽然数据库级" +"可能不加区分或者可以处理这种转换。" -#: index.docbook:247 -msgid "For properties mapped as either version or timestamp, 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 seed value defined by the org.hibernate.type.VersionType 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 " +"org.hibernate.id.SequenceGenerator (and its subclasses) " +"and any implementors of org.hibernate.id." +"PostInsertIdentifierGenerator. The most notable exception here is " +"org.hibernate.id.TableHiLoGenerator, 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产生器时才能使" +"用;如果是“内存”中计算的类型生成器,在解析时会抛出一个异常。注意,为了说明这" +"一问题,数据库产生值的生成器是org.hibernate.id.SequenceGenerator(和它的子类),以及任何org.hibernate.id." +"PostInsertIdentifierGenerator接口的实现。这儿最值得注意的意外是" +"org.hibernate.id.TableHiLoGenerator,它不能在此使用,因为" +"它没有得到其值的途径。" -#: index.docbook:257 +#. Tag: para +#: batch.xml:247 +#, no-c-format +msgid "" +"For properties mapped as either version or " +"timestamp, 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 seed value " +"defined by the org.hibernate.type.VersionType is used)." +msgstr "" +"对映射为versiontimestamp的属性来" +"说,insert语句也给你两个选择,你可以在properties_list表中指定(此时其值从对应" +"的select表达式中获得),或者在properties_list中省略它(此时,使用在" +"org.hibernate.type.VersionType 中定义的seed value" +"(种子值))。" + +#. Tag: para +#: batch.xml:257 +#, no-c-format msgid "An example HQL INSERT statement execution:" -msgstr "" +msgstr "执行HQL INSERT语句的例子如下:" -#: index.docbook:261 +#. Tag: programlisting +#: batch.xml:261 +#, no-c-format msgid "" - "" +"" msgstr "" - -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - diff --git a/documentation/manual/translations/zh-CN/content/best_practices.po b/documentation/manual/translations/zh-CN/content/best_practices.po index 587a9e4331..eee7566f16 100644 --- a/documentation/manual/translations/zh-CN/content/best_practices.po +++ b/documentation/manual/translations/zh-CN/content/best_practices.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \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 <component>." +#. Tag: term +#: best_practices.xml:9 +#, no-c-format +msgid "" +"Write fine-grained classes and map them using <component>." msgstr "" +"设计细颗粒度的持久类并且使用<component>来实现映射。" -#: index.docbook:11 -msgid "Use an Address class to encapsulate street, suburb, state, postcode. This encourages code reuse and simplifies refactoring." +#. Tag: para +#: best_practices.xml:11 +#, no-c-format +msgid "" +"Use an Address class to encapsulate street, suburb, state, " +"postcode. This encourages code reuse and simplifies " +"refactoring." msgstr "" +"使用一个Address持久类来封装 street, " +"suburb, state, postcode. 这将有利于代码重用和简化代码重构(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 <natural-id>. Implement equals() and hashCode() 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 <" +"natural-id>. Implement equals() and " +"hashCode() to compare the properties that make up the " +"natural key." msgstr "" +"对所有的实体都标识出自然键,用<natural-id>进行映射。" +"实现equals()hashCode(),在其中用组成" +"自然键的属性进行比较。" -#: 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 com.eg.Foo in the file com/eg/Foo.hbm.xml. 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 com.eg.Foo in the file com/eg/Foo.hbm.xml. This makes " +"particularly good sense in a team environment." msgstr "" +"不要把所有的持久类映射都写到一个大文件中。把 com.eg.Foo 映" +"射到com/eg/Foo.hbm.xml中, 在团队开发环境中,这一点显得特" +"别有意义。" -#: 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 org.hibernate.connection.ConnectionProvider." +#. 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 org." +"hibernate.connection.ConnectionProvider." msgstr "" +"Hibernate允许应用程序自己来管理JDBC connections,但是应该作为最后没有办法的办" +"法。如果你不能使用Hibernate内建的connections providers,那么考虑实现自己来实" +"现org.hibernate.connection.ConnectionProvider" -#: 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 org.hibernate.UserType. 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 org.hibernate.UserType. " +"This approach frees the application code from implementing transformations " +"to / from a Hibernate type." msgstr "" +"假设你有一个Java类型,来自某些类库,需要被持久化,但是该类没有提供映射操作需" +"要的存取方法。那么你应该考虑实现org.hibernate.UserType接" +"口。这种办法使程序代码写起来更加自如,不再需要考虑类与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 know 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 Session 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 know 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 Session 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 know 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 Session and using that JDBC " +"connection. That way you can still use the same transaction strategy and " +"underlying connection provider. 在系统中对性能要求很严格的一些部分,某些操作" +"也许直接使用JDBC会更好。但是请先确认这的确是一个瓶颈,并" +"且不要想当然认为JDBC一定会更快。如果确实需要直接使用JDBC,那么最好打开一个 " +"Hibernate Session 然后从 Session获得" +"connection,按照这种办法你仍然可以使用同样的transaction策略和底层的" +"connection provider。" -#: index.docbook:110 +#. Tag: term +#: best_practices.xml:110 +#, no-c-format msgid "Understand Session flushing." -msgstr "" +msgstr "理解Session清洗( 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 Session.merge() or Session.saveOrUpdate() 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 Session.merge() or Session.saveOrUpdate() to synchronize objects " +"with the database." msgstr "" +"当使用一个servlet / session bean 类型的架构的时候, 你可以把已加载的持久对象在" +"session bean层和servlet / JSP 层之间来回传递。使用新的session来为每个请求服" +"务,使用 Session.merge() 或者Session.saveOrUpdate" +"()来与数据库同步。" -#: 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 application transactions, 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 " +"application transactions, 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)应该尽可能的短。但" +"是,程序常常需要实现长时间运行的“应用程序事务(Application " +"Transaction)”,包含一个从用户的观点来看的原子操作。这个应用程序事" +"务可能跨越多次从用户请求到得到反馈的循环。用脱管对象(与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 Transaction and close the Session. 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 Session.load() to determine if an instance with the given identifier exists on the database; use Session.get() 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 Transaction and close the " +"Session. 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 Session.load() to determine if an " +"instance with the given identifier exists on the database; use " +"Session.get() or a query instead." msgstr "" +"这一点甚至比“最佳实践”还要重要,这是“必备常识”。当异常发生的时候,必须要回滚 " +"Transaction ,关闭Session。如果你不这样" +"做的话,Hibernate无法保证内存状态精确的反应持久状态。尤其不要使用" +"Session.load()来判断一个给定标识符的对象实例在数据库中是否" +"存在,应该使用Session.get()或者进行一次查询." -#: 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 lazy=\"false\". When an join fetching is appropriate to a particular use case, use a query with a left join fetch." +#. 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 lazy=\"false\". When an join fetching is " +"appropriate to a particular use case, use a query with a left join " +"fetch." msgstr "" +"谨慎的使用主动抓取(eager fetching)。对于关联来说,若其目标是无法在第二级缓存" +"中完全缓存所有实例的类,应该使用代理(proxies)与/或具有延迟加载属性的集合" +"(lazy collections)。若目标是可以被缓存的,尤其是缓存的命中率非常高的情况下," +"应该使用lazy=\"false\",明确的禁止掉eager fetching。如果那" +"些特殊的确实适合使用join fetch 的场合,请在查询中使用left join " +"fetch。" -#: index.docbook:172 -msgid "Use the open session in view pattern, or a disciplined assembly phase to avoid problems with unfetched data." +#. Tag: term +#: best_practices.xml:172 +#, no-c-format +msgid "" +"Use the open session in view pattern, or a disciplined " +"assembly phase to avoid problems with unfetched data." msgstr "" +"使用open session in view模式,或者执行严格的装" +"配期(assembly phase)策略来避免再次抓取数据带来的问题" -#: index.docbook:177 -msgid "Hibernate frees the developer from writing tedious Data Transfer Objects (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 Data Transfer " +"Objects (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让开发者们摆脱了繁琐的Data Transfer Objects " +"(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 DAO and Thread Local Session patterns. You can even have some classes persisted by handcoded JDBC, associated to Hibernate via a UserType. (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 " +"DAO and Thread Local Session " +"patterns. You can even have some classes persisted by handcoded JDBC, " +"associated to Hibernate via a UserType. (This advice is " +"intended for \"sufficiently large\" applications; it is not appropriate for " +"an application with five tables!)" msgstr "" +"把Hibernate的数据存取代码隐藏到接口(interface)的后面,组合使用DAOThread Local Session模式。通过Hibernate的" +"UserType,你甚至可以用硬编码的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 "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +"单向关联更加难于查询。在大型应用中,几乎所有的关联必须在查询中可以双向导航。" diff --git a/documentation/manual/translations/zh-CN/content/collection_mapping.po b/documentation/manual/translations/zh-CN/content/collection_mapping.po index 12287f6fb4..3fdc4e7f60 100644 --- a/documentation/manual/translations/zh-CN/content/collection_mapping.po +++ b/documentation/manual/translations/zh-CN/content/collection_mapping.po @@ -1,919 +1,1832 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: collection_mapping.xml:5 +#, no-c-format msgid "Collection Mapping" -msgstr "" +msgstr "集合类(Collections)映射" -#: index.docbook:8 +#. Tag: title +#: collection_mapping.xml:8 +#, no-c-format msgid "Persistent collections" -msgstr "" +msgstr "持久化集合类(Persistent collections)" -#: index.docbook:10 -msgid "Hibernate requires that persistent collection-valued fields be declared as an interface type, for example:" -msgstr "" - -#: index.docbook:15 +#. Tag: para +#: collection_mapping.xml:10 +#, no-c-format msgid "" - "" +"Hibernate requires that persistent collection-valued fields be declared as " +"an interface type, for example:" msgstr "" +"Hibernate要求持久化集合值字段必须声明为接口,比如:(译者注:在阅读本章的时" +"候,以后整个手册的阅读过程中,我们都会面临一个名词方面的问题,那就是“集合”。" +"\"Collections\"和\"Set\"在中文里对应都被翻译为“集合”,但是他们的含义很不一" +"样。Collections是一个超集,Set是其中的一种。大部分情况下,本译稿中泛指的未加" +"英文注明的“集合”,都应当理解为“Collections”。在有些二者同时出现,可能造成混淆" +"的地方,我们用“集合类”来特指“Collecions”,“集合(Set)”来指\"Set\",一般都会在后" +"面的括号中给出英文。希望大家在阅读时联系上下文理解,不要造成误解。 与此同" +"时,“元素”一词对应的英文“element”,也有两个不同的含义。其一为集合的元素,是内" +"存中的一个变量;另一含义则是XML文档中的一个标签所代表的元素。也请注意区别。 " +"本章中,特别是后半部分是需要反复阅读才能理解清楚的。如果遇到任何疑问,请记住,英" +"文版本的reference是惟一标准的参考资料。)" -#: index.docbook:17 -msgid "The actual interface might be java.util.Set, java.util.Collection, java.util.List, java.util.Map, java.util.SortedSet, java.util.SortedMap or ... anything you like! (Where \"anything you like\" means you will have to write an implementation of org.hibernate.usertype.UserCollectionType.)" -msgstr "" - -#: index.docbook:26 -msgid "Notice how we initialized the instance variable with an instance of HashSet. This is the best way to initialize collection valued properties of newly instantiated (non-persistent) instances. When you make the instance persistent - by calling persist(), for example - Hibernate will actually replace the HashSet with an instance of Hibernate's own implementation of Set. Watch out for errors like this:" -msgstr "" - -#: index.docbook:36 +#. Tag: programlisting +#: collection_mapping.xml:15 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:38 -msgid "The persistent collections injected by Hibernate behave like HashMap, HashSet, TreeMap, TreeSet or ArrayList, depending upon the interface type." +#. Tag: para +#: collection_mapping.xml:17 +#, no-c-format +msgid "" +"The actual interface might be java.util.Set, " +"java.util.Collection, java.util.List, " +"java.util.Map, java.util.SortedSet, " +"java.util.SortedMap or ... anything you like! (Where " +"\"anything you like\" means you will have to write an implementation of " +"org.hibernate.usertype.UserCollectionType.)" +msgstr "" +"实际的接口可能是java.util.Set, java.util." +"Collection, java.util.List, java.util." +"Map, java.util.SortedSet, java.util." +"SortedMap 或者...任何你喜欢的类型!(\"任何你喜欢的类型\" 代表你需要" +"编写 org.hibernate.usertype.UserCollectionType的实现.)" + +#. Tag: para +#: collection_mapping.xml:26 +#, no-c-format +msgid "" +"Notice how we initialized the instance variable with an instance of " +"HashSet. This is the best way to initialize collection " +"valued properties of newly instantiated (non-persistent) instances. When you " +"make the instance persistent - by calling persist(), for " +"example - Hibernate will actually replace the HashSet " +"with an instance of Hibernate's own implementation of Set. Watch out for errors like this:" +msgstr "" +"注意我们是如何用一个HashSet实例来初始化实例变量的.这是用于" +"初始化新创建(尚未持久化)的类实例中集合值属性的最佳方法。当你持久化这个实例时" +"——比如通过调用persist()——Hibernate 会自动把" +"HashSet替换为Hibernate自己的Set实现。观" +"察下面的错误:" + +#. Tag: programlisting +#: collection_mapping.xml:36 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:45 -msgid "Collections instances have the usual behavior of value types. They are automatically persisted when referenced by a persistent object and automatically deleted when unreferenced. If a collection is passed from one persistent object to another, its elements might be moved from one table to another. Two entities may not share a reference to the same collection instance. Due to the underlying relational model, collection-valued properties do not support null value semantics; Hibernate does not distinguish between a null collection reference and an empty collection." +#. Tag: para +#: collection_mapping.xml:38 +#, no-c-format +msgid "" +"The persistent collections injected by Hibernate behave like " +"HashMap, HashSet, TreeMap, TreeSet or ArrayList, " +"depending upon the interface type." msgstr "" +"根据不同的接口类型,被Hibernate注射的持久化集合类的表现类似HashMap, HashSet, TreeMap, " +"TreeSet or ArrayList。" -#: index.docbook:56 -msgid "You shouldn't have to worry much about any of this. Use persistent collections the same way you use ordinary Java collections. Just make sure you understand the semantics of bidirectional associations (discussed later)." +#. Tag: para +#: collection_mapping.xml:45 +#, no-c-format +msgid "" +"Collections instances have the usual behavior of value types. They are " +"automatically persisted when referenced by a persistent object and " +"automatically deleted when unreferenced. If a collection is passed from one " +"persistent object to another, its elements might be moved from one table to " +"another. Two entities may not share a reference to the same collection " +"instance. Due to the underlying relational model, collection-valued " +"properties do not support null value semantics; Hibernate does not " +"distinguish between a null collection reference and an empty collection." msgstr "" +"集合类实例具有值类型的通常行为。当被持久化对象引用后,他们会自动被持久化,当" +"不再被引用后,自动被删除。假若实例被从一个持久化对象传递到另一个,它的元素可" +"能从一个表转移到另一个表。两个实体不能共享同一个集合类实例的引用。因为底层关" +"系数据库模型的原因,集合值属性无法支持空值语义;Hibernate对空的集合引用和空集" +"合不加区别。" -#: index.docbook:65 +#. Tag: para +#: collection_mapping.xml:56 +#, no-c-format +msgid "" +"You shouldn't have to worry much about any of this. Use persistent " +"collections the same way you use ordinary Java collections. Just make sure " +"you understand the semantics of bidirectional associations (discussed later)." +msgstr "" +"你不需要过多的为此担心。就如同你平时使用普通的Java集合类一样来使用持久化集合" +"类。只是要确认你理解了双向关联的语义(后文讨论)。" + +#. Tag: title +#: collection_mapping.xml:65 +#, no-c-format msgid "Collection mappings" -msgstr "" +msgstr "集合映射( Collection mappings )" -#: index.docbook:67 -msgid "The Hibernate mapping element used for mapping a collection depends upon the type of the interface. For example, a <set> element is used for mapping properties of type Set." -msgstr "" - -#: index.docbook:73 +#. Tag: para +#: collection_mapping.xml:67 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"The Hibernate mapping element used for mapping a collection depends upon the " +"type of the interface. For example, a <set> element " +"is used for mapping properties of type Set." msgstr "" +"用于映射集合类的Hibernate映射元素取决于接口的类型。比如, <" +"set> 元素用来映射Set类型的属性。" -#: index.docbook:75 -msgid "Apart from <set>, there is also <list>, <map>, <bag>, <array> and <primitive-array> mapping elements. The <map> element is representative:" -msgstr "" - -#: index.docbook:100 +#. Tag: programlisting +#: collection_mapping.xml:73 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:103 +#. Tag: para +#: collection_mapping.xml:75 +#, no-c-format +msgid "" +"Apart from <set>, there is also <" +"list>, <map>, <bag>, <array> and <primitive-" +"array> mapping elements. The <map> " +"element is representative:" +msgstr "" +"除了<set>,还有<list>, " +"<map>, <bag>, <" +"array><primitive-array> 映射元素。" +"<map>具有代表性:" + +#. Tag: programlisting +#: collection_mapping.xml:100 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: collection_mapping.xml:103 +#, no-c-format msgid "name the collection property name" -msgstr "" +msgstr "name 集合属性的名称" -#: index.docbook:108 -msgid "table (optional - defaults to property name) the name of the collection table (not used for one-to-many associations)" +#. Tag: para +#: collection_mapping.xml:108 +#, no-c-format +msgid "" +"table (optional - defaults to property name) the name of " +"the collection table (not used for one-to-many associations)" msgstr "" +"table (可选——默认为属性的名称)这个集合表的名称(不能在一" +"对多的关联关系中使用)" -#: index.docbook:114 -msgid "schema (optional) the name of a table schema to override the schema declared on the root element" +#. Tag: para +#: collection_mapping.xml:114 +#, no-c-format +msgid "" +"schema (optional) the name of a table schema to override " +"the schema declared on the root element" msgstr "" +"schema (可选) 表的schema的名称, 他将覆盖在根元素中定义的" +"schema" -#: index.docbook:120 -msgid "lazy (optional - defaults to true) may be used to disable lazy fetching and specify that the association is always eagerly fetched, or to enable \"extra-lazy\" fetching where most operations do not initialize the collection (suitable for very large collections)" +#. Tag: para +#: collection_mapping.xml:120 +#, no-c-format +msgid "" +"lazy (optional - defaults to true) may " +"be used to disable lazy fetching and specify that the association is always " +"eagerly fetched, or to enable \"extra-lazy\" fetching where most operations " +"do not initialize the collection (suitable for very large collections)" msgstr "" +"lazy (可选--默认为true) 可以用来关闭延迟加载(false),指定" +"一直使用预先抓取,或者打开\"extra-lazy\" 抓取,此时大多数操作不会初始化集合类" +"(适用于非常大的集合)" -#: index.docbook:129 -msgid "inverse (optional - defaults to false) mark this collection as the \"inverse\" end of a bidirectional association" +#. Tag: para +#: collection_mapping.xml:129 +#, no-c-format +msgid "" +"inverse (optional - defaults to false) " +"mark this collection as the \"inverse\" end of a bidirectional association" msgstr "" +"inverse (可选——默认为false) 标记这个集" +"合作为双向关联关系中的方向一端。" -#: index.docbook:135 -msgid "cascade (optional - defaults to none) enable operations to cascade to child entities" +#. Tag: para +#: collection_mapping.xml:135 +#, no-c-format +msgid "" +"cascade (optional - defaults to none) " +"enable operations to cascade to child entities" msgstr "" +"cascade (可选——默认为none) 让操作级联到" +"子实体" -#: index.docbook:141 -msgid "sort (optional) specify a sorted collection with natural sort order, or a given comparator class" +#. Tag: para +#: collection_mapping.xml:141 +#, no-c-format +msgid "" +"sort (optional) specify a sorted collection with " +"natural sort order, or a given comparator class" msgstr "" +"sort(可选)指定集合的排序顺序, 其可以为自然的" +"(natural)或者给定一个用来比较的类。" -#: index.docbook:147 -msgid "order-by (optional, JDK1.4 only) specify a table column (or columns) that define the iteration order of the Map, Set or bag, together with an optional asc or desc" +#. Tag: para +#: collection_mapping.xml:147 +#, no-c-format +msgid "" +"order-by (optional, JDK1.4 only) specify a table column " +"(or columns) that define the iteration order of the Map, " +"Set or bag, together with an optional asc or desc" msgstr "" +"order-by (可选, 仅用于jdk1.4) 指定表的字段(一个或几个)再加" +"上asc或者desc(可选), 定义Map,Set和Bag的迭代顺序" -#: index.docbook:154 -msgid "where (optional) specify an arbitrary SQL WHERE condition to be used when retrieving or removing the collection (useful if the collection should contain only a subset of the available data)" +#. Tag: para +#: collection_mapping.xml:154 +#, no-c-format +msgid "" +"where (optional) specify an arbitrary SQL WHERE condition to be used when retrieving or removing the collection " +"(useful if the collection should contain only a subset of the available data)" msgstr "" +"where (可选) 指定任意的SQL where条件, 该条件将在重新载入或" +"者删除这个集合时使用(当集合中的数据仅仅是所有可用数据的一个子集时这个条件非常" +"有用)" -#: index.docbook:161 -msgid "fetch (optional, defaults to select) Choose between outer-join fetching, fetching by sequential select, and fetching by sequential subselect." +#. Tag: para +#: collection_mapping.xml:161 +#, no-c-format +msgid "" +"fetch (optional, defaults to select) " +"Choose between outer-join fetching, fetching by sequential select, and " +"fetching by sequential subselect." msgstr "" +"fetch (可选, 默认为select) 用于在外连接" +"抓取、通过后续select抓取和通过后续subselect抓取之间选择。" -#: index.docbook:168 -msgid "batch-size (optional, defaults to 1) specify a \"batch size\" for lazily fetching instances of this collection." +#. Tag: para +#: collection_mapping.xml:168 +#, no-c-format +msgid "" +"batch-size (optional, defaults to 1) " +"specify a \"batch size\" for lazily fetching instances of this collection." msgstr "" +"batch-size (可选, 默认为1) 指定通过延迟" +"加载取得集合实例的批处理块大小(\"batch size\")。" -#: index.docbook:174 -msgid "access (optional - defaults to property): The strategy Hibernate should use for accessing the collection property value." +#. Tag: para +#: collection_mapping.xml:174 +#, no-c-format +msgid "" +"access (optional - defaults to property): The strategy Hibernate should use for accessing the collection " +"property value." msgstr "" +"access(可选-默认为属性property):Hibernate取得集合属性值时" +"使用的策略" -#: index.docbook:180 -msgid "optimistic-lock (optional - defaults to true): Species that changes to the state of the collection results in increment of the owning entity's version. (For one to many associations, it is often reasonable to disable this setting.)" +#. Tag: para +#: collection_mapping.xml:180 +#, no-c-format +msgid "" +"optimistic-lock (optional - defaults to true): Species that changes to the state of the collection results in " +"increment of the owning entity's version. (For one to many associations, it " +"is often reasonable to disable this setting.)" msgstr "" +"乐观锁 (可选 - 默认为 true): 对集合的状" +"态的改变会是否导致其所属的实体的版本增长。 (对一对多关联来说,关闭这个属性常" +"常是有理的)" -#: index.docbook:188 -msgid "mutable (optional - defaults to true): A value of false specifies that the elements of the collection never change (a minor performance optimization in some cases)." +#. Tag: para +#: collection_mapping.xml:188 +#, no-c-format +msgid "" +"mutable (optional - defaults to true): " +"A value of false specifies that the elements of the " +"collection never change (a minor performance optimization in some cases)." msgstr "" +"mutable(可变) (可选 - 默认为true): 若" +"值为false,表明集合中的元素不会改变(在某些情况下可以进行一" +"些小的性能优化)。" -#: index.docbook:198 +#. Tag: title +#: collection_mapping.xml:198 +#, no-c-format msgid "Collection foreign keys" -msgstr "" +msgstr "集合外键(Collection foreign keys)" -#: index.docbook:200 -msgid "Collection instances are distinguished in the database by the foreign key of the entity that owns the collection. This foreign key is referred to as the collection key column (or columns) of the collection table. The collection key column is mapped by the <key> element." +#. Tag: para +#: collection_mapping.xml:200 +#, no-c-format +msgid "" +"Collection instances are distinguished in the database by the foreign key of " +"the entity that owns the collection. This foreign key is referred to as the " +"collection key column (or columns) of the collection " +"table. The collection key column is mapped by the <key> element." msgstr "" +"集合实例在数据库中依靠持有集合的实体的外键加以辨别。此外键作为集合" +"关键字段(collection key column)(或多个字段)加以引用。集合关键" +"字段通过<key> 元素映射。" -#: index.docbook:208 -msgid "There may be a nullability constraint on the foreign key column. For most collections, this is implied. For unidirectional one to many associations, the foreign key column is nullable by default, so you might need to specify not-null=\"true\"." +#. Tag: para +#: collection_mapping.xml:208 +#, no-c-format +msgid "" +"There may be a nullability constraint on the foreign key column. For most " +"collections, this is implied. For unidirectional one to many associations, " +"the foreign key column is nullable by default, so you might need to specify " +"not-null=\"true\"." msgstr "" +"在外键字段上可能具有非空约束。对于大多数集合来说,这是隐含的。对单向一对多关" +"联来说,外键字段默认是可以为空的,因此你可能需要指明 not-null=\"true" +"\"。" -#: index.docbook:215 +#. Tag: programlisting +#: collection_mapping.xml:215 +#, no-c-format msgid "]]>" msgstr "" -#: index.docbook:217 -msgid "The foreign key constraint may use ON DELETE CASCADE." -msgstr "" +#. Tag: para +#: collection_mapping.xml:217 +#, no-c-format +msgid "" +"The foreign key constraint may use ON DELETE CASCADE." +msgstr "外键约束可以使用ON DELETE CASCADE。" -#: index.docbook:221 +#. Tag: programlisting +#: collection_mapping.xml:221 +#, no-c-format msgid "]]>" msgstr "" -#: index.docbook:223 -msgid "See the previous chapter for a full definition of the <key> element." -msgstr "" +#. Tag: para +#: collection_mapping.xml:223 +#, no-c-format +msgid "" +"See the previous chapter for a full definition of the <key> element." +msgstr "对<key> 元素的完整定义,请参阅前面的章节。" -#: index.docbook:231 +#. Tag: title +#: collection_mapping.xml:231 +#, no-c-format msgid "Collection elements" -msgstr "" +msgstr "集合元素(Collection elements)" -#: index.docbook:233 -msgid "Collections may contain almost any other Hibernate type, including all basic types, custom types, components, and of course, references to other entities. This is an important distinction: an object in a collection might be handled with \"value\" semantics (its life cycle fully depends on the collection owner) or it might be a reference to another entity, with its own life cycle. In the latter case, only the \"link\" between the two objects is considered to be state held by the collection." +#. Tag: para +#: collection_mapping.xml:233 +#, no-c-format +msgid "" +"Collections may contain almost any other Hibernate type, including all basic " +"types, custom types, components, and of course, references to other " +"entities. This is an important distinction: an object in a collection might " +"be handled with \"value\" semantics (its life cycle fully depends on the " +"collection owner) or it might be a reference to another entity, with its own " +"life cycle. In the latter case, only the \"link\" between the two objects is " +"considered to be state held by the collection." msgstr "" +"集合几乎可以包含任何其他的Hibernate类型,包括所有的基本类型、自定义类型、组" +"件,当然还有对其他实体的引用。存在一个重要的区别:位于集合中的对象可能是根" +"据“值”语义来操作(其声明周期完全依赖于集合持有者),或者它可能是指向另一个实" +"体的引用,具有其自己的生命周期。在后者的情况下,被作为集合持有的状态考虑的," +"只有两个对象之间的“连接”。" -#: index.docbook:242 -msgid "The contained type is referred to as the collection element type. Collection elements are mapped by <element> or <composite-element>, or in the case of entity references, with <one-to-many> or <many-to-many>. The first two map elements with value semantics, the next two are used to map entity associations." +#. Tag: para +#: collection_mapping.xml:242 +#, no-c-format +msgid "" +"The contained type is referred to as the collection element type. Collection elements are mapped by <element> or <composite-element>, or in the case of " +"entity references, with <one-to-many> or " +"<many-to-many>. The first two map elements with " +"value semantics, the next two are used to map entity associations." msgstr "" +"被包容的类型被称为集合元素类型(collection element type)。集合元素通过<element><" +"composite-element>映射,或在其是实体引用的时候,通过" +"<one-to-many><many-to-many>映射。前两种用于使用值语义映射元素,后两种用于映射实体关联。" -#: index.docbook:254 +#. Tag: title +#: collection_mapping.xml:254 +#, no-c-format msgid "Indexed collections" -msgstr "" +msgstr "索引集合类(Indexed collections)" -#: index.docbook:256 -msgid "All collection mappings, except those with set and bag semantics, need an index column in the collection table - a column that maps to an array index, or List index, or Map key. The index of a Map may be of any basic type, mapped with <map-key>, it may be an entity reference mapped with <map-key-many-to-many>, or it may be a composite type, mapped with <composite-map-key>. The index of an array or list is always of type integer and is mapped using the <list-index> element. The mapped column contains sequential integers (numbered from zero, by default)." -msgstr "" - -#: index.docbook:267 +#. Tag: para +#: collection_mapping.xml:256 +#, no-c-format msgid "" - " ]]> column_name (required): The name of the column holding the collection index values. base (optional, defaults to 0): The value of the index column that corresponds to the first element of the list or array. ]]> column (optional): The name of the column holding the collection index values. formula (optional): A SQL formula used to evaluate the key of the map. type (reguired): The type of the map keys. ]]> column (optional): The name of the foreign key column for the collection index values. formula (optional): A SQL formula used to evaluate the foreign key of the map key. class (required): The entity class used as the map key. " +"All collection mappings, except those with set and bag semantics, need an " +"index column in the collection table - a column that " +"maps to an array index, or List index, or Map key. The index of a Map may be of any basic " +"type, mapped with <map-key>, it may be an entity " +"reference mapped with <map-key-many-to-many>, or it " +"may be a composite type, mapped with <composite-map-key>. The index of an array or list is always of type integer and is mapped using the <list-index> " +"element. The mapped column contains sequential integers (numbered from zero, " +"by default)." +msgstr "" +"所有的集合映射,除了set和bag语义的以外,都需要指定一个集合表的索引" +"字段(index column)——用于对应到数组索引,或者List的索引,或者Map的关键字。通过<map-" +"key>,Map 的索引可以是任何基础类型;若通过" +"<map-key-many-to-many>,它也可以是一个实体引用;若通" +"过<composite-map-key>,它还可以是一个组合类型。数组" +"或列表的索引必须是integer类型,并且使用 <list-" +"index>元素定义映射。被映射的字段包含有顺序排列的整数(默认从0开" +"始)。" + +#. Tag: sect2 +#: collection_mapping.xml:267 +#, no-c-format +msgid "" +" ]]> column_name (required): The " +"name of the column holding the collection index values. " +" base (optional, " +"defaults to 0): The value of the index column that " +"corresponds to the first element of the list or array. ]]> column (optional): The name of the " +"column holding the collection index values. formula (optional): A SQL " +"formula used to evaluate the key of the map. type (reguired): The type of " +"the map keys. " +" ]]> " +" column (optional): The name of the foreign key " +"column for the collection index values. formula (optional): A SQL " +"formula used to evaluate the foreign key of the map key. " +" class " +"(required): The entity class used as the map key. " msgstr "" -#: index.docbook:348 -msgid "If your table doesn't have an index column, and you still wish to use List as the property type, you should map the property as a Hibernate <bag>. A bag does not retain its order when it is retrieved from the database, but it may be optionally sorted or ordered." +#. Tag: para +#: collection_mapping.xml:348 +#, no-c-format +msgid "" +"If your table doesn't have an index column, and you still wish to use " +"List as the property type, you should map the property as " +"a Hibernate <bag>. A bag does not retain its " +"order when it is retrieved from the database, but it may be optionally " +"sorted or ordered." msgstr "" +"值集合于多对多关联(Collections of values and many-to-many associations)" -#: index.docbook:357 -msgid "There are quite a range of mappings that can be generated for collections, covering many common relational models. We suggest you experiment with the schema generation tool to get a feeling for how various mapping declarations translate to database tables." +#. Tag: para +#: collection_mapping.xml:357 +#, no-c-format +msgid "" +"There are quite a range of mappings that can be generated for collections, " +"covering many common relational models. We suggest you experiment with the " +"schema generation tool to get a feeling for how various mapping declarations " +"translate to database tables." msgstr "" +"任何值集合或者多对多关联需要专用的具有一个或多个外键字段的" +"collection table、一个或多个collection " +"element column,以及还可能有一个或多个索引字段。" -#: index.docbook:364 +#. Tag: title +#: collection_mapping.xml:364 +#, no-c-format msgid "Collections of values and many-to-many associations" -msgstr "" +msgstr "对于一个值集合, 我们使用<element>标签。" -#: index.docbook:366 -msgid "Any collection of values or many-to-many association requires a dedicated collection table with a foreign key column or columns, collection element column or columns and possibly an index column or columns." -msgstr "" - -#: index.docbook:373 -msgid "For a collection of values, we use the <element> tag." -msgstr "" - -#: index.docbook:375 +#. Tag: para +#: collection_mapping.xml:366 +#, no-c-format msgid "" - " ]]> column (optional): The name of the column holding the collection element values. formula (optional): An SQL formula used to evaluate the element. type (required): The type of the collection element. A many-to-many association is specified using the <many-to-many> element. ]]> column (optional): The name of the element foreign key column. formula (optional): An SQL formula used to evaluate the element foreign key value. class (required): The name of the associated class. fetch (optional - defaults to join): enables outer-join or sequential select fetching for this association. This is a special case; for full eager fetching (in a single SELECT) of an entity and its many-to-many relationships to other entities, you would enable join fetching not only of the collection itself, but also with this attribute on the <many-to-many> nested element. unique (optional): Enable the DDL generation of a unique constraint for the foreign-key column. This makes the association multiplicity effectively one to many. not-found (optional - defaults to exception): Specifies how foreign keys that reference missing rows will be handled: ignore will treat a missing row as a null association. entity-name (optional): The entity name of the associated class, as an alternative to class. property-ref: (optional) The name of a property of the associated class that is joined to this foreign key. If not specified, the primary key of the associated class is used. " +"Any collection of values or many-to-many association requires a dedicated " +"collection table with a foreign key column or columns, " +"collection element column or columns and possibly an " +"index column or columns." +msgstr "column(可选):保存集合元素值的字段名。" + +#. Tag: para +#: collection_mapping.xml:373 +#, no-c-format +msgid "" +"For a collection of values, we use the <element> " +"tag." +msgstr "formula (可选): 用于计算元素的SQL公式" + +#. Tag: sect2 +#: collection_mapping.xml:375 +#, no-c-format +msgid "" +" " +" ]]> " +"column (optional): The name of the column holding the " +"collection element values. formula (optional): An SQL formula used to " +"evaluate the element. " +" type (required): The type of the collection " +"element. A " +"many-to-many association is specified using the " +"<many-to-many> element. " +" " +" " +"]]> " +" column (optional): The name of the element foreign " +"key column. " +"formula (optional): An SQL formula used to evaluate the " +"element foreign key value. class (required): The name of the associated " +"class. " +"fetch (optional - defaults to join): " +"enables outer-join or sequential select fetching for this association. This " +"is a special case; for full eager fetching (in a single SELECT) of an entity and its many-to-many relationships to other entities, " +"you would enable join fetching not only of the collection " +"itself, but also with this attribute on the <many-to-many> nested element. unique (optional): Enable the DDL generation " +"of a unique constraint for the foreign-key column. This makes the " +"association multiplicity effectively one to many. " +" not-found " +"(optional - defaults to exception): Specifies how foreign " +"keys that reference missing rows will be handled: ignore " +"will treat a missing row as a null association. entity-name (optional): " +"The entity name of the associated class, as an alternative to " +"class. property-ref: (optional) The name of a " +"property of the associated class that is joined to this foreign key. If not " +"specified, the primary key of the associated class is used. " msgstr "" -#: index.docbook:480 +#. Tag: para +#: collection_mapping.xml:480 +#, no-c-format msgid "Some examples, first, a set of strings:" msgstr "" +"包含一组整数的bag(还设置了order-by参数指定了迭代的顺序):" -#: index.docbook:484 +#. Tag: programlisting +#: collection_mapping.xml:484 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:486 -msgid "A bag containing integers (with an iteration order determined by the order-by attribute):" -msgstr "" - -#: index.docbook:491 +#. Tag: para +#: collection_mapping.xml:486 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"A bag containing integers (with an iteration order determined by the " +"order-by attribute):" +msgstr "" +"一个实体数组,在这个案例中是一个多对多的关联(注意这里的实体是自动管理生命周期" +"的对象(life cycle objects),cascade=\"all\"):" + +#. Tag: programlisting +#: collection_mapping.xml:491 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:493 +#. Tag: para +#: collection_mapping.xml:493 +#, no-c-format msgid "An array of entities - in this case, a many to many association:" -msgstr "" +msgstr "一个map,通过字符串的索引来指明日期:" -#: index.docbook:497 +#. Tag: programlisting +#: collection_mapping.xml:497 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:499 +#. Tag: para +#: collection_mapping.xml:499 +#, no-c-format msgid "A map from string indices to dates:" -msgstr "" +msgstr "一个组件的列表:(下一章讨论)" -#: index.docbook:503 +#. Tag: programlisting +#: collection_mapping.xml:503 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:505 +#. Tag: para +#: collection_mapping.xml:505 +#, no-c-format msgid "A list of components (discussed in the next chapter):" -msgstr "" +msgstr "一对多关联(One-to-many Associations)" -#: index.docbook:509 +#. Tag: programlisting +#: collection_mapping.xml:509 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:514 +#. Tag: title +#: collection_mapping.xml:514 +#, no-c-format msgid "One-to-many associations" msgstr "" +"一对多关联通过外键连接两个类对应的" +"表,而没有中间集合表。 这个关系模型失去了一些Java集合的语义:" -#: index.docbook:516 -msgid "A one to many association links the tables of two classes via a foreign key, with no intervening collection table. This mapping loses certain semantics of normal Java collections:" -msgstr "" - -#: index.docbook:524 -msgid "An instance of the contained entity class may not belong to more than one instance of the collection" -msgstr "" - -#: index.docbook:530 -msgid "An instance of the contained entity class may not appear at more than one value of the collection index" -msgstr "" - -#: index.docbook:537 -msgid "An association from Product to Part requires existence of a foreign key column and possibly an index column to the Part table. A <one-to-many> tag indicates that this is a one to many association." -msgstr "" - -#: index.docbook:550 +#. Tag: para +#: collection_mapping.xml:516 +#, no-c-format msgid "" - "]]>" +"A one to many association links the tables of two " +"classes via a foreign key, with no intervening collection table. This " +"mapping loses certain semantics of normal Java collections:" +msgstr "一个被包含的实体的实例只能被包含在一个集合的实例中" + +#. Tag: para +#: collection_mapping.xml:524 +#, no-c-format +msgid "" +"An instance of the contained entity class may not belong to more than one " +"instance of the collection" +msgstr "一个被包含的实体的实例只能对应于集合索引的一个值中" + +#. Tag: para +#: collection_mapping.xml:530 +#, no-c-format +msgid "" +"An instance of the contained entity class may not appear at more than one " +"value of the collection index" +msgstr "" +"一个从ProductPart的关联需要关键字字" +"段,可能还有一个索引字段指向Part所对应的表。 <" +"one-to-many>标记指明了一个一对多的关联。" + +#. Tag: para +#: collection_mapping.xml:537 +#, no-c-format +msgid "" +"An association from Product to Part " +"requires existence of a foreign key column and possibly an index column to " +"the Part table. A <one-to-many> " +"tag indicates that this is a one to many association." +msgstr "class(必须):被关联类的名称。" + +#. Tag: programlisting +#: collection_mapping.xml:550 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:553 +#. Tag: para +#: collection_mapping.xml:553 +#, fuzzy, no-c-format msgid "class (required): The name of the associated class." msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"为此关联打开外连接抓取或者后续select抓取。这是特殊情况;对于一个实体及其指向" +"其他实体的多对多关联进全预先抓取(使用一条单独的SELECT)," +"你不仅需要对集合自身打开join,也需要对<many-" +"to-many>这个内嵌元素打开此属性。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"not-found (可选 - 默认为exception): 指" +"明若缓存的标示值关联的行缺失,该如何处理: ignore 会把缺失的" +"行作为一个空关联处理。" -#: index.docbook:558 -msgid "not-found (optional - defaults to exception): Specifies how cached identifiers that reference missing rows will be handled: ignore will treat a missing row as a null association." -msgstr "" - -#: index.docbook:565 -msgid "entity-name (optional): The entity name of the associated class, as an alternative to class." -msgstr "" - -#: index.docbook:573 -msgid "Notice that the <one-to-many> element does not need to declare any columns. Nor is it necessary to specify the table name anywhere." -msgstr "" - -#: index.docbook:579 -msgid "Very important note: If the foreign key column of a <one-to-many> association is declared NOT NULL, you must declare the <key> mapping not-null=\"true\" or use a bidirectional association with the collection mapping marked inverse=\"true\". See the discussion of bidirectional associations later in this chapter." -msgstr "" - -#: index.docbook:588 -msgid "This example shows a map of Part entities by name (where partName is a persistent property of Part). Notice the use of a formula-based index." -msgstr "" - -#: index.docbook:594 +#. Tag: para +#: collection_mapping.xml:558 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "]]>" +"not-found (optional - defaults to exception): Specifies how cached identifiers that reference missing rows will " +"be handled: ignore will treat a missing row as a null " +"association." +msgstr "" +"entity-name (可选): 被关联的类的实体名,作为" +"class的替代。" + +#. Tag: para +#: collection_mapping.xml:565 +#, fuzzy, no-c-format +msgid "" +"entity-name (optional): The entity name of the associated " +"class, as an alternative to class." +msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"property-ref: (可选) 被关联到此外键(foreign key)的类中的对" +"应属性的名字。若未指定,使用被关联类的主键。\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"例子" + +#. Tag: para +#: collection_mapping.xml:573 +#, no-c-format +msgid "" +"Notice that the <one-to-many> element does not need " +"to declare any columns. Nor is it necessary to specify the table name anywhere." +msgstr "" +"注意:<one-to-many>元素不需要定义任何字段。 也不需要" +"指定表名。" + +#. Tag: para +#: collection_mapping.xml:579 +#, no-c-format +msgid "" +"Very important note: If the foreign key column of a " +"<one-to-many> association is declared NOT " +"NULL, you must declare the <key> mapping " +"not-null=\"true\" or use a bidirectional " +"association with the collection mapping marked inverse=" +"\"true\". See the discussion of bidirectional associations later " +"in this chapter." +msgstr "" +"重要提示:如果一对多关联中的外键字段定" +"义成NOT NULL,你必须把<key>映射声" +"明为not-null=\"true\",或者使用双向关联,并且标明inverse=\"true\"。参阅本章后面关于双向" +"关联的讨论。" + +#. Tag: para +#: collection_mapping.xml:588 +#, no-c-format +msgid "" +"This example shows a map of Part entities by name (where " +"partName is a persistent property of Part). Notice the use of a formula-based index." +msgstr "" +"下面的例子展示一个Part实体的map,把name作为关键字。" +"( partNamePart的持久化属性)。注意其" +"中的基于公式的索引的用法。" + +#. Tag: programlisting +#: collection_mapping.xml:594 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:600 +#. Tag: title +#: collection_mapping.xml:600 +#, no-c-format msgid "Advanced collection mappings" -msgstr "" +msgstr "高级集合映射(Advanced collection mappings)" -#: index.docbook:603 +#. Tag: title +#: collection_mapping.xml:603 +#, no-c-format msgid "Sorted collections" -msgstr "" +msgstr "有序集合(Sorted collections)" -#: index.docbook:605 -msgid "Hibernate supports collections implementing java.util.SortedMap and java.util.SortedSet. You must specify a comparator in the mapping file:" -msgstr "" - -#: index.docbook:610 +#. Tag: para +#: collection_mapping.xml:605 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" +"Hibernate supports collections implementing java.util.SortedMap and java.util.SortedSet. You must specify a " +"comparator in the mapping file:" msgstr "" +"Hibernate支持实现java.util.SortedMapjava.util." +"SortedSet的集合。 你必须在映射文件中指定一个比较器:" -#: index.docbook:612 -msgid "Allowed values of the sort attribute are unsorted, natural and the name of a class implementing java.util.Comparator." -msgstr "" - -#: index.docbook:618 -msgid "Sorted collections actually behave like java.util.TreeSet or java.util.TreeMap." -msgstr "" - -#: index.docbook:623 -msgid "If you want the database itself to order the collection elements use the order-by attribute of set, bag or map mappings. This solution is only available under JDK 1.4 or higher (it is implemented using LinkedHashSet or LinkedHashMap). This performs the ordering in the SQL query, not in memory." -msgstr "" - -#: index.docbook:632 +#. Tag: programlisting +#: collection_mapping.xml:610 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:634 -msgid "Note that the value of the order-by attribute is an SQL ordering, not a HQL ordering!" +#. Tag: para +#: collection_mapping.xml:612 +#, no-c-format +msgid "" +"Allowed values of the sort attribute are " +"unsorted, natural and the name of a " +"class implementing java.util.Comparator." +msgstr "" +"sort属性中允许的值包括unsorted," +"natural和某个实现了java.util.Comparator" +"的类的名称。" + +#. Tag: para +#: collection_mapping.xml:618 +#, no-c-format +msgid "" +"Sorted collections actually behave like java.util.TreeSet " +"or java.util.TreeMap." +msgstr "" +"分类集合的行为事实上象java.util.TreeSet或者java." +"util.TreeMap。" + +#. Tag: para +#: collection_mapping.xml:623 +#, no-c-format +msgid "" +"If you want the database itself to order the collection elements use the " +"order-by attribute of set, " +"bag or map mappings. This solution is " +"only available under JDK 1.4 or higher (it is implemented using " +"LinkedHashSet or LinkedHashMap). This " +"performs the ordering in the SQL query, not in memory." +msgstr "" +"如果你希望数据库自己对集合元素排序,可以利用set," +"bag或者map映射中的order-by属性。这个解决方案只能在jdk1.4或者更高的jdk版本中才可以实现(通过" +"LinkedHashSet或者 LinkedHashMap实现)。 它是在SQL查询中完成排序,而不是在内存" +"中。" + +#. Tag: programlisting +#: collection_mapping.xml:632 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:639 -msgid "Associations may even be sorted by some arbitrary criteria at runtime using a collection filter()." +#. Tag: para +#: collection_mapping.xml:634 +#, no-c-format +msgid "" +"Note that the value of the order-by attribute is an SQL " +"ordering, not a HQL ordering!" +msgstr "" +"注意: 这个order-by属性的值是一个SQL排序子句而不是HQL的!" + +#. Tag: para +#: collection_mapping.xml:639 +#, no-c-format +msgid "" +"Associations may even be sorted by some arbitrary criteria at runtime using " +"a collection filter()." +msgstr "" +"关联还可以在运行时使用集合filter()根据任意的条件来排序。" + +#. Tag: programlisting +#: collection_mapping.xml:644 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:644 -msgid "" -msgstr "" - -#: index.docbook:649 +#. Tag: title +#: collection_mapping.xml:649 +#, no-c-format msgid "Bidirectional associations" -msgstr "" +msgstr "双向关联(Bidirectional associations)" -#: index.docbook:651 -msgid "A bidirectional association allows navigation from both \"ends\" of the association. Two kinds of bidirectional association are supported:" +#. Tag: para +#: collection_mapping.xml:651 +#, fuzzy, no-c-format +msgid "" +"A bidirectional association allows navigation from both " +"\"ends\" of the association. Two kinds of bidirectional association are " +"supported:" msgstr "" +"双向关联允许通过关联的任一端访问另外一端。在Hibernate" +"中, 支持两种类型的双向关联: " -#: index.docbook:658 +#. Tag: term +#: collection_mapping.xml:658 +#, no-c-format msgid "one-to-many" -msgstr "" +msgstr "一对多(one-to-many)" -#: index.docbook:660 +#. Tag: para +#: collection_mapping.xml:660 +#, no-c-format msgid "set or bag valued at one end, single-valued at the other" -msgstr "" +msgstr "Set或者bag值在一端, 单独值(非集合)在另外一端" -#: index.docbook:666 +#. Tag: term +#: collection_mapping.xml:666 +#, no-c-format msgid "many-to-many" -msgstr "" +msgstr "多对多(many-to-many)" -#: index.docbook:668 +#. Tag: para +#: collection_mapping.xml:668 +#, no-c-format msgid "set or bag valued at both ends" -msgstr "" +msgstr "两端都是set或bag值" -#: index.docbook:677 -msgid "You may specify a bidirectional many-to-many association simply by mapping two many-to-many associations to the same database table and declaring one end as inverse (which one is your choice, but it can not be an indexed collection)." -msgstr "" - -#: index.docbook:684 -msgid "Here's an example of a bidirectional many-to-many association; each category can have many items and each item can be in many categories:" -msgstr "" - -#: index.docbook:689 +#. Tag: para +#: collection_mapping.xml:677 +#, no-c-format msgid "" - "\n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " ...\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"You may specify a bidirectional many-to-many association simply by mapping " +"two many-to-many associations to the same database table and declaring one " +"end as inverse (which one is your choice, but it can " +"not be an indexed collection)." msgstr "" +"要建立一个双向的多对多关联,只需要映射两个many-to-many关联到同一个数据库表" +"中,并再定义其中的一端为inverse(使用哪一端要根据你的选" +"择,但它不能是一个索引集合)。" -#: index.docbook:691 -msgid "Changes made only to the inverse end of the association are not persisted. This means that Hibernate has two representations in memory for every bidirectional association, one link from A to B and another link from B to A. This is easier to understand if you think about the Java object model and how we create a many-to-many relationship in Java:" -msgstr "" - -#: index.docbook:699 +#. Tag: para +#: collection_mapping.xml:684 +#, no-c-format msgid "" - "" +"Here's an example of a bidirectional many-to-many association; each category " +"can have many items and each item can be in many categories:" msgstr "" +"这里有一个many-to-many的双向关联的例子;每一个category都可以有很多items,每一个" +"items可以属于很多categories:" -#: index.docbook:701 -msgid "The non-inverse side is used to save the in-memory representation to the database." -msgstr "" - -#: index.docbook:705 -msgid "You may define a bidirectional one-to-many association by mapping a one-to-many association to the same table column(s) as a many-to-one association and declaring the many-valued end inverse=\"true\"." -msgstr "" - -#: index.docbook:711 +#. Tag: programlisting +#: collection_mapping.xml:689 +#, no-c-format msgid "" - "\n" - " \n" - " ....\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " ....\n" - " \n" - "]]>" +"\n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" ...\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:713 -msgid "Mapping one end of an association with inverse=\"true\" doesn't affect the operation of cascades, these are orthogonal concepts!" +#. Tag: para +#: collection_mapping.xml:691 +#, no-c-format +msgid "" +"Changes made only to the inverse end of the association are not persisted. This means that Hibernate has two representations in " +"memory for every bidirectional association, one link from A to B and another " +"link from B to A. This is easier to understand if you think about the Java " +"object model and how we create a many-to-many relationship in Java:" +msgstr "" +"如果只对关联的反向端进行了改变,这个改变不会被持久化。 " +"这表示Hibernate为每个双向关联在内存中存在两次表现,一个从A连接到B,另一个从B连" +"接到A。如果你回想一下Java对象模型,我们是如何在Java中创建多对多关系的,这可以" +"让你更容易理解:" + +#. Tag: programlisting +#: collection_mapping.xml:699 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:721 +#. Tag: para +#: collection_mapping.xml:701 +#, no-c-format +msgid "" +"The non-inverse side is used to save the in-memory representation to the " +"database." +msgstr "非反向端用于把内存中的表示保存到数据库中。" + +#. Tag: para +#: collection_mapping.xml:705 +#, no-c-format +msgid "" +"You may define a bidirectional one-to-many association by mapping a one-to-" +"many association to the same table column(s) as a many-to-one association " +"and declaring the many-valued end inverse=\"true\"." +msgstr "" +"要建立一个一对多的双向关联,你可以通过把一个一对多关联,作为一个多对一关联映" +"射到到同一张表的字段上,并且在\"多\"的那一端定义inverse=\"true\"。" + +#. Tag: programlisting +#: collection_mapping.xml:711 +#, no-c-format +msgid "" +"\n" +" \n" +" ....\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" ....\n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: collection_mapping.xml:713 +#, no-c-format +msgid "" +"Mapping one end of an association with inverse=\"true\" " +"doesn't affect the operation of cascades, these are orthogonal concepts!" +msgstr "" +"在“一”这一端定义inverse=\"true\"不会影响级联操作,二者是正" +"交的概念!" + +#. Tag: title +#: collection_mapping.xml:721 +#, no-c-format msgid "Bidirectional associations with indexed collections" -msgstr "" +msgstr "双向关联,涉及有序集合类" -#: index.docbook:722 -msgid "A bidirectional association where one end is represented as a <list> or <map> requires special consideration. If there is a property of the child class which maps to the index column, no problem, we can continue using inverse=\"true\" on the collection mapping:" -msgstr "" - -#: index.docbook:729 +#. Tag: para +#: collection_mapping.xml:722 +#, no-c-format msgid "" - "\n" - " \n" - " ....\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " ....\n" - " \n" - " \n" - "]]>" +"A bidirectional association where one end is represented as a <" +"list> or <map> requires special " +"consideration. If there is a property of the child class which maps to the " +"index column, no problem, we can continue using inverse=\"true\" on the collection mapping:" msgstr "" +"对于有一端是<list>或者<map>" +"的双向关联,需要加以特别考虑。假若子类中的一个属性映射到索引字段,没问题,我" +"们仍然可以在集合类映射上使用inverse=\"true\":" -#: index.docbook:731 -msgid "But, if there is no such property on the child class, we can't think of the association as truly bidirectional (there is information available at one end of the association that is not available at the other end). In this case, we can't map the collection inverse=\"true\". Instead, we could use the following mapping:" -msgstr "" - -#: index.docbook:738 +#. Tag: programlisting +#: collection_mapping.xml:729 +#, no-c-format msgid "" - "\n" - " \n" - " ....\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " ....\n" - " \n" - "]]>" +"\n" +" \n" +" ....\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" ....\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:740 -msgid "Note that in this mapping, the collection-valued end of the association is responsible for updates to the foreign key. TODO: Does this really result in some unnecessary update statements?" +#. Tag: para +#: collection_mapping.xml:731 +#, no-c-format +msgid "" +"But, if there is no such property on the child class, we can't think of the " +"association as truly bidirectional (there is information available at one " +"end of the association that is not available at the other end). In this " +"case, we can't map the collection inverse=\"true\". " +"Instead, we could use the following mapping:" +msgstr "" +"但是,假若子类中没有这样的属性存在,我们不能认为这个关联是真正的双向关联(信" +"息不对称,在关联的一端有一些另外一端没有的信息)。在这种情况下,我们不能使用" +"inverse=\"true\"。我们需要这样用:" + +#. Tag: programlisting +#: collection_mapping.xml:738 +#, no-c-format +msgid "" +"\n" +" \n" +" ....\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" ....\n" +" \n" +"]]>" msgstr "" -#: index.docbook:748 +#. Tag: para +#: collection_mapping.xml:740 +#, no-c-format +msgid "" +"Note that in this mapping, the collection-valued end of the association is " +"responsible for updates to the foreign key. TODO: Does this really result in " +"some unnecessary update statements?" +msgstr "" +"注意在这个映射中,关联中集合类\"值\"一端负责来更新外键.TODO: Does this " +"really result in some unnecessary update statements?" + +#. Tag: title +#: collection_mapping.xml:748 +#, no-c-format msgid "Ternary associations" -msgstr "" +msgstr "三重关联(Ternary associations)" -#: index.docbook:750 -msgid "There are three possible approaches to mapping a ternary association. One is to use a Map with an association as its index:" -msgstr "" - -#: index.docbook:755 +#. Tag: para +#: collection_mapping.xml:750 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "]]>" +"There are three possible approaches to mapping a ternary association. One is " +"to use a Map with an association as its index:" msgstr "" +"有三种可能的途径来映射一个三重关联。第一种是使用一个Map," +"把一个关联作为其索引:" -#: index.docbook:757 +#. Tag: programlisting +#: collection_mapping.xml:755 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:759 -msgid "A second approach is to simply remodel the association as an entity class. This is the approach we use most commonly." +#. Tag: programlisting +#: collection_mapping.xml:757 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:764 -msgid "A final alternative is to use composite elements, which we will discuss later." +#. Tag: para +#: collection_mapping.xml:759 +#, no-c-format +msgid "" +"A second approach is to simply remodel the association as an entity class. " +"This is the approach we use most commonly." msgstr "" +"第二种方法是简单的把关联重新建模为一个实体类。这使我们最经常使用的方法。" -#: index.docbook:771 +#. Tag: para +#: collection_mapping.xml:764 +#, no-c-format +msgid "" +"A final alternative is to use composite elements, which we will discuss " +"later." +msgstr "最后一种选择是使用复合元素,我们会在后面讨论" + +#. Tag: literal +#: collection_mapping.xml:771 +#, no-c-format msgid "Using an <idbag>" -msgstr "" +msgstr "使用<idbag>" -#: index.docbook:773 -msgid "If you've fully embraced our view that composite keys are a bad thing and that entities should have synthetic identifiers (surrogate keys), then you might find it a bit odd that the many to many associations and collections of values that we've shown so far all map to tables with composite keys! Now, this point is quite arguable; a pure association table doesn't seem to benefit much from a surrogate key (though a collection of composite values might). Nevertheless, Hibernate provides a feature that allows you to map many to many associations and collections of values to a table with a surrogate key." -msgstr "" - -#: index.docbook:784 -msgid "The <idbag> element lets you map a List (or Collection) with bag semantics." -msgstr "" - -#: index.docbook:789 +#. Tag: para +#: collection_mapping.xml:773 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"If you've fully embraced our view that composite keys are a bad thing and " +"that entities should have synthetic identifiers (surrogate keys), then you " +"might find it a bit odd that the many to many associations and collections " +"of values that we've shown so far all map to tables with composite keys! " +"Now, this point is quite arguable; a pure association table doesn't seem to " +"benefit much from a surrogate key (though a collection of composite values " +"might). Nevertheless, Hibernate provides a feature that " +"allows you to map many to many associations and collections of values to a " +"table with a surrogate key." +msgstr "" +"如果你完全信奉我们对于“联合主键(composite keys)是个坏东西”,和“实体应该使用" +"(无机的)自己生成的代用标识符(surrogate keys)”的观点,也许你会感到有一些奇" +"怪,我们目前为止展示的多对多关联和值集合都是映射成为带有联合主键的表的!现" +"在,这一点非常值得争辩;看上去一个单纯的关联表并不能从代用标识符中获得什么好" +"处(虽然使用组合值的集合可能会获得一点好处)。不过," +"Hibernate提供了一个(一点点试验性质的)功能,让你把多对多关联和值集合应得到一" +"个使用代用标识符的表去。" + +#. Tag: para +#: collection_mapping.xml:784 +#, no-c-format +msgid "" +"The <idbag> element lets you map a List (or Collection) with bag semantics." +msgstr "" +"<idbag> 属性让你使用bag语义来映射一个List (或Collection)。" + +#. Tag: programlisting +#: collection_mapping.xml:789 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:791 -msgid "As you can see, an <idbag> has a synthetic id generator, just like an entity class! A different surrogate key is assigned to each collection row. Hibernate does not provide any mechanism to discover the surrogate key value of a particular row, however." +#. Tag: para +#: collection_mapping.xml:791 +#, no-c-format +msgid "" +"As you can see, an <idbag> has a synthetic id " +"generator, just like an entity class! A different surrogate key is assigned " +"to each collection row. Hibernate does not provide any mechanism to discover " +"the surrogate key value of a particular row, however." msgstr "" +"你可以理解,<idbag>人工的id生成器,就好像是实体类一" +"样!集合的每一行都有一个不同的人造关键字。但是,Hibernate没有提供任何机制来让" +"你取得某个特定行的人造关键字。" -#: index.docbook:798 -msgid "Note that the update performance of an <idbag> is much better than a regular <bag>! Hibernate can locate individual rows efficiently and update or delete them individually, just like a list, map or set." +#. Tag: para +#: collection_mapping.xml:798 +#, no-c-format +msgid "" +"Note that the update performance of an <idbag> is " +"much better than a regular <bag>! Hibernate can locate individual rows efficiently and update or " +"delete them individually, just like a list, map or set." msgstr "" +"注意<idbag>的更新性能要比普通的<bag>" +"高得多!Hibernate可以有效的定位到不同的行,分别进行更新或删除工作," +"就如同处理一个list, map或者set一样。" -#: index.docbook:805 -msgid "In the current implementation, the native identifier generation strategy is not supported for <idbag> collection identifiers." +#. Tag: para +#: collection_mapping.xml:805 +#, no-c-format +msgid "" +"In the current implementation, the native identifier " +"generation strategy is not supported for <idbag> " +"collection identifiers." msgstr "" +"在目前的实现中,还不支持使用identity标识符生成器策略来生成" +"<idbag>集合的标识符。" -#: index.docbook:829 +#. Tag: title +#: collection_mapping.xml:829 +#, no-c-format msgid "Collection examples" -msgstr "" +msgstr "集合例子(Collection example)" -#: index.docbook:831 -msgid "The previous sections are pretty confusing. So lets look at an example. This class:" -msgstr "" - -#: index.docbook:836 +#. Tag: para +#: collection_mapping.xml:831 +#, no-c-format msgid "" - "" -msgstr "" +"The previous sections are pretty confusing. So lets look at an example. This " +"class:" +msgstr "在前面的几个章节的确非常令人迷惑。 因此让我们来看一个例子。这个类:" -#: index.docbook:838 -msgid "has a collection of Child instances. If each child has at most one parent, the most natural mapping is a one-to-many association:" -msgstr "" - -#: index.docbook:844 +#. Tag: programlisting +#: collection_mapping.xml:836 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"" msgstr "" -#: index.docbook:846 +#. Tag: para +#: collection_mapping.xml:838 +#, no-c-format +msgid "" +"has a collection of Child instances. If each child has at " +"most one parent, the most natural mapping is a one-to-many association:" +msgstr "" +"这个类有一个Child的实例集合。如果每一个子实例至多有一个父" +"实例, 那么最自然的映射是一个one-to-many的关联关系:" + +#. Tag: programlisting +#: collection_mapping.xml:844 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" +msgstr "" + +#. Tag: para +#: collection_mapping.xml:846 +#, no-c-format msgid "This maps to the following table definitions:" -msgstr "" +msgstr "在以下的表定义中反应了这个映射关系:" -#: index.docbook:850 +#. Tag: programlisting +#: collection_mapping.xml:850 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:852 -msgid "If the parent is required, use a bidirectional one-to-many association:" -msgstr "" - -#: index.docbook:857 +#. Tag: para +#: collection_mapping.xml:852 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"If the parent is required, use a bidirectional one-to-" +"many association:" +msgstr "" +"如果父亲是必须的, 那么就可以使用双向one-to-many的关联" +"了:" + +#. Tag: programlisting +#: collection_mapping.xml:857 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:859 +#. Tag: para +#: collection_mapping.xml:859 +#, no-c-format msgid "Notice the NOT NULL constraint:" -msgstr "" +msgstr "请注意NOT NULL的约束:" -#: index.docbook:863 +#. Tag: programlisting +#: collection_mapping.xml:863 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:865 -msgid "Alternatively, if you absolutely insist that this association should be unidirectional, you can declare the NOT NULL constraint on the <key> mapping:" -msgstr "" - -#: index.docbook:871 +#. Tag: para +#: collection_mapping.xml:865 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"Alternatively, if you absolutely insist that this association should be " +"unidirectional, you can declare the NOT NULL constraint " +"on the <key> mapping:" msgstr "" +"另外,如果你绝对坚持这个关联应该是单向的,你可以对<key>映射声明NOT NULL约束:" -#: index.docbook:873 -msgid "On the other hand, if a child might have multiple parents, a many-to-many association is appropriate:" -msgstr "" - -#: index.docbook:878 +#. Tag: programlisting +#: collection_mapping.xml:871 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:880 +#. Tag: para +#: collection_mapping.xml:873 +#, no-c-format +msgid "" +"On the other hand, if a child might have multiple parents, a many-to-many " +"association is appropriate:" +msgstr "" +"另外一方面,如果一个子实例可能有多个父实例, 那么就应该使用many-to-many关联:" + +#. Tag: programlisting +#: collection_mapping.xml:878 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" +msgstr "" + +#. Tag: para +#: collection_mapping.xml:880 +#, no-c-format msgid "Table definitions:" -msgstr "" +msgstr "表定义:" -#: index.docbook:884 +#. Tag: programlisting +#: collection_mapping.xml:884 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:886 -msgid "For more examples and a complete walk-through a parent/child relationship mapping, see ." +#. Tag: para +#: collection_mapping.xml:886 +#, no-c-format +msgid "" +"For more examples and a complete walk-through a parent/child relationship " +"mapping, see ." msgstr "" +"更多的例子,以及一个完整的父/子关系映射的排练,请参阅." -#: index.docbook:891 -msgid "Even more exotic association mappings are possible, we will catalog all possibilities in the next chapter." -msgstr "" +#. Tag: para +#: collection_mapping.xml:891 +#, no-c-format +msgid "" +"Even more exotic association mappings are possible, we will catalog all " +"possibilities in the next chapter." +msgstr "甚至可能出现更加复杂的关联映射,我们会在下一章中列出所有可能性。" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" +#~ msgid "" +#~ "column_name (required): The name of the column holding " +#~ "the collection index values." +#~ msgstr "column(可选):保存集合索引值的字段名。" -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" +#~ msgid "" +#~ "base (optional, defaults to 0): The " +#~ "value of the index column that corresponds to the first element of the " +#~ "list or array." +#~ msgstr "formula (可选): 用于计算map关键字的SQL公式" +#~ msgid "" +#~ "column (optional): The name of the column holding the " +#~ "collection index values." +#~ msgstr "type (必须):映射键(map key)的类型。" + +#~ msgid "" +#~ "formula (optional): A SQL formula used to evaluate the " +#~ "key of the map." +#~ msgstr "column(可选):集合索引值中外键字段的名称" + +#~ msgid "type (reguired): The type of the map keys." +#~ msgstr "formula (可选): 用于计算map关键字的外键的SQL公式" + +#~ msgid "" +#~ "column (optional): The name of the foreign key column " +#~ "for the collection index values." +#~ msgstr "class (必需):映射的键(map key)使用的实体类。" + +#~ msgid "" +#~ "formula (optional): A SQL formula used to evaluate the " +#~ "foreign key of the map key." +#~ msgstr "" +#~ "假若你的表没有一个索引字段,当你仍然希望使用List作为属性" +#~ "类型,你应该把此属性映射为Hibernate <bag>。从数" +#~ "据库中获取的时候,bag不维护其顺序,但也可选择性的进行排序。" + +#~ msgid "" +#~ "class (required): The entity class used as the map key." +#~ msgstr "" +#~ "从集合类可以产生很大一部分映射,覆盖了很多常见的关系模型。我们建议你试验" +#~ "schema生成工具,来体会一下不同的映射声明是如何被翻译为数据库表的。" + +#~ msgid "" +#~ "column (optional): The name of the column holding the " +#~ "collection element values." +#~ msgstr "type (必需):集合元素的类型" + +#~ msgid "" +#~ "formula (optional): An SQL formula used to evaluate " +#~ "the element." +#~ msgstr "" +#~ "多对多关联(many-to-many association) 使用 " +#~ "<many-to-many>元素定义." + +#~ msgid "" +#~ "type (required): The type of the collection element." +#~ msgstr "column(可选): 这个元素的外键关键字段名" + +#~ msgid "" +#~ "A many-to-many association is specified using the " +#~ "<many-to-many> element." +#~ msgstr "formula (可选): 用于计算元素外键值的SQL公式." + +#~ msgid "" +#~ "column (optional): The name of the element foreign key " +#~ "column." +#~ msgstr "class (必需): 关联类的名称" + +#~ msgid "" +#~ "formula (optional): An SQL formula used to evaluate " +#~ "the element foreign key value." +#~ msgstr "" +#~ "outer-join (可选 - 默认为auto): 在" +#~ "Hibernate系统参数中hibernate.use_outer_join被打开的情况" +#~ "下,该参数用来允许使用outer join来载入此集合的数据。" + +#~ msgid "" +#~ "fetch (optional - defaults to join): enables outer-join or sequential select fetching for this " +#~ "association. This is a special case; for full eager fetching (in a single " +#~ "SELECT) of an entity and its many-to-many " +#~ "relationships to other entities, you would enable join " +#~ "fetching not only of the collection itself, but also with this attribute " +#~ "on the <many-to-many> nested element." +#~ msgstr "" +#~ "对外键字段允许DDL生成的时候生成一个惟一约束。这使关联变成了一个高效的一对" +#~ "多关联。(此句存疑:原文为This makes the association multiplicity " +#~ "effectively one to many.)" + +#~ msgid "" +#~ "unique (optional): Enable the DDL generation of a " +#~ "unique constraint for the foreign-key column. This makes the association " +#~ "multiplicity effectively one to many." +#~ msgstr "" +#~ "not-found (可选 - 默认为 exception): 指明引用的外键中缺少某些行该如何处理: ignore 会把缺失的行作为一个空引用处理。" + +#~ msgid "" +#~ "not-found (optional - defaults to exception): Specifies how foreign keys that reference missing rows will be " +#~ "handled: ignore will treat a missing row as a null " +#~ "association." +#~ msgstr "" +#~ "entity-name (可选): 被关联的类的实体名,作为" +#~ "class的替代。" + +#~ msgid "" +#~ "property-ref: (optional) The name of a property of the " +#~ "associated class that is joined to this foreign key. If not specified, " +#~ "the primary key of the associated class is used." +#~ msgstr "例子:首先, 一组字符串:" diff --git a/documentation/manual/translations/zh-CN/content/component_mapping.po b/documentation/manual/translations/zh-CN/content/component_mapping.po index 1cfbd2e182..8ea7025844 100644 --- a/documentation/manual/translations/zh-CN/content/component_mapping.po +++ b/documentation/manual/translations/zh-CN/content/component_mapping.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \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 component 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 component is re-used in several " +"different contexts, for different purposes, throughout Hibernate." msgstr "" +"组件(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 "" - "" +"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 "" - "" +"" msgstr "" -#: index.docbook:25 -msgid "Now Name may be persisted as a component of Person. Notice that Name 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 "" +"" msgstr "" -#: index.docbook:32 +#. Tag: para +#: component_mapping.xml:25 +#, no-c-format +msgid "" +"Now Name may be persisted as a component of " +"Person. Notice that Name defines " +"getter and setter methods for its persistent properties, but doesn't need to " +"declare any interfaces or identifier properties." +msgstr "" +"在持久化的过程中,姓名(Name)可以作为人(Person)的一个组件。需要注意的是:你应该为姓名的持久化属性" +"定义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 "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:38 -msgid "The person table would have the columns pid, birthday, initial, first and last." -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 ad hoc. 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 not be considered an exotic usage. Hibernate is intended to support a very fine-grained object model." -msgstr "" - -#: index.docbook:62 -msgid "The <component> element allows a <parent> 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 "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"The person table would have the columns pid, " +"birthday, initial, first and last." +msgstr "" +"人员(Person)表中将包括pid, birthday, " +"initial, firstlast等字段。" + +#. 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 ad hoc. 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 " +"not 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 <component> element allows a <" +"parent> subelement that maps a property of the component class " +"as a reference back to the containing entity." +msgstr "" +"<component> 元素还允许有 <parent>子元素,用来表明component类中的一个属性是指向包含它的实体的引用。" + +#. Tag: programlisting +#: component_mapping.xml:68 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"Collections of components are supported (eg. an array of type Name). Declare your component collection by replacing the <" +"element> tag with a <composite-element> tag." msgstr "" +"Hibernate支持组件的集合(例如: 一个元素是姓名(Name)这种类型的数组)。 你可以使" +"用<composite-element>标签替代<" +"element>标签来定义你的组件集合。" -#: index.docbook:84 -msgid "Note: if you define a Set of composite elements, it is very important to implement equals() and hashCode() correctly." -msgstr "" - -#: index.docbook:90 -msgid "Composite elements may contain components but not collections. If your composite element itself contains components, use the <nested-composite-element> 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 <set>. 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 <list>, <map>, <bag> or <idbag>." -msgstr "" - -#: index.docbook:113 -msgid "A special case of a composite element is a composite element with a nested <many-to-one> 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 Order to Item where purchaseDate, price and quantity are properties of the association:" -msgstr "" - -#: index.docbook:123 +#. Tag: programlisting +#: component_mapping.xml:82 +#, no-c-format msgid "" - "\n" - " ....\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" 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 Purchase can be in the set of an Order, but it can't be referenced by the Item at the same time." +#. Tag: para +#: component_mapping.xml:84 +#, no-c-format +msgid "" +"Note: if you define a Set of composite elements, it is " +"very important to implement equals() and hashCode" +"() correctly." +msgstr "" +"注意,如果你定义的Set包含组合元素(composite-element),正确地实现" +"equals()hashCode()是非常重要的。" + +#. 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 <nested-" +"composite-element> 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 "" +"组合元素可以包含组件,但是不能包含集合。如果你的组合元素自身包含组件, 你必须" +"使用<nested-composite-element>标签。这是一个相当特殊" +"的案例 - 在一个组件的集合里,那些组件本身又可以包含其他的组件。这个时候你就应" +"该考虑一下使用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 <set>. 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 <list>, <map>, <bag> or " +"<idbag>." +msgstr "" +"请注意如果你使用<set>标签,一个组合元素的映射不支持可" +"能为空的属性. 当删除对象时, Hibernate必须使用每一个字段的值来确定一条记录(在" +"组合元素表中,没有单独的关键字段), 如果有为null的字段,这样做就不可能了。你" +"必须作出一个选择,要么在组合元素中使用不能为空的属性,要么选择使用" +"<list>,<map>,<" +"bag> 或者 <idbag>而不是 <" +"set>。" + +#. Tag: para +#: component_mapping.xml:113 +#, no-c-format +msgid "" +"A special case of a composite element is a composite element with a nested " +"<many-to-one> 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 " +"Order to Item where " +"purchaseDate, price and " +"quantity are properties of the association:" +msgstr "" +"组合元素有个特别的用法是它可以包含一个<many-to-one>" +"元素。类似这样的映射允许你将一个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.) 接下来的的例子是从" +"OrderItem的一个多对多的关联关系, 关联" +"属性是 purchaseDate, price 和 " +"quantity 。" + +#. Tag: programlisting +#: component_mapping.xml:123 +#, no-c-format +msgid "" +"\n" +" ....\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" 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 Purchase can be in the set of an Order, but it can't be " +"referenced by the Item at the same time." +msgstr "" +"当然,当你定义Item时,你无法引用这些purchase,因此你无法实现双向关联查询。记" +"住组件是值类型,并且不允许共享引用。某一个特定的Purchase " +"可以放在Order的集合中,但它不能同时被Item所引用。" + +#. 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 "" - "\n" - " ....\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" ....\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" 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 <composite-map-key> element lets you map a component class as the key of a Map. Make sure you override hashCode() and equals() correctly on the component class." +#. Tag: para +#: component_mapping.xml:147 +#, no-c-format +msgid "" +"The <composite-map-key> element lets you map a " +"component class as the key of a Map. Make sure you " +"override hashCode() and equals() " +"correctly on the component class." msgstr "" +"<composite-map-key>元素允许你映射一个组件类作为一个" +"Map的key,前提是你必须正确的在这个类中重写了" +"hashCode()equals()方法。" -#: 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 java.io.Serializable." -msgstr "" +msgstr "它必须实现java.io.Serializable接口" -#: index.docbook:170 -msgid "It must re-implement equals() and hashCode(), 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 IdentifierGenerator to generate composite keys. Instead the application must assign its own identifiers." -msgstr "" - -#: index.docbook:188 -msgid "Use the <composite-id> tag (with nested <key-property> elements) in place of the usual <id> declaration. For example, the OrderLine class has a primary key that depends upon the (composite) primary key of Order." -msgstr "" - -#: index.docbook:196 +#. Tag: para +#: component_mapping.xml:170 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ....\n" - " \n" - "]]>" +"It must re-implement equals() and hashCode(), consistently with the database's notion of composite key equality." msgstr "" +"它必须重新实现equals()hashCode()方" +"法, 始终和组合关键字在数据库中的概念保持一致" -#: index.docbook:198 -msgid "Now, any foreign keys referencing the OrderLine table are also composite. You must declare this in your mappings for other classes. An association to OrderLine would be mapped like this:" -msgstr "" - -#: index.docbook:204 +#. Tag: emphasis +#: component_mapping.xml:179 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - "]]>" +"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 <column> tag is an alternative to the column attribute everywhere.)" -msgstr "" - -#: index.docbook:211 -msgid "A many-to-many association to OrderLine also uses the composite foreign key:" -msgstr "" - -#: index.docbook:216 +#. Tag: para +#: component_mapping.xml:183 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"You can't use an IdentifierGenerator to generate " +"composite keys. Instead the application must assign its own identifiers." msgstr "" +"你不能使用一个IdentifierGenerator产生组合关键字。一个应用" +"程序必须分配它自己的标识符。" -#: index.docbook:218 -msgid "The collection of OrderLines in Order would use:" -msgstr "" - -#: index.docbook:223 +#. Tag: para +#: component_mapping.xml:188 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"Use the <composite-id> tag (with nested " +"<key-property> elements) in place of the usual " +"<id> declaration. For example, the " +"OrderLine class has a primary key that depends upon the " +"(composite) primary key of Order." msgstr "" +"使用<composite-id> 标签(并且内嵌<key-" +"property>元素)代替通常的<id>标签。比如," +"OrderLine类具有一个主键,这个主键依赖于Order的(联合)主键。" -#: index.docbook:225 -msgid "(The <one-to-many> element, as usual, declares no columns.)" -msgstr "" - -#: index.docbook:229 -msgid "If OrderLine 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 "" - "\n" - " ....\n" - " ....\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ....\n" +" \n" +"]]>" msgstr "" -#: index.docbook:239 +#. Tag: para +#: component_mapping.xml:198 +#, no-c-format +msgid "" +"Now, any foreign keys referencing the OrderLine table are " +"also composite. You must declare this in your mappings for other classes. An " +"association to OrderLine would be mapped like this:" +msgstr "" +"现在,任何指向OrderLine的外键都是复合的。在你的映射文件" +"中,必须为其他类也这样声明。例如,一个指向OrderLine的关联" +"可能被这样映射:" + +#. Tag: programlisting +#: component_mapping.xml:204 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: component_mapping.xml:206 +#, no-c-format +msgid "" +"(Note that the <column> tag is an alternative to " +"the column attribute everywhere.)" +msgstr "" +"(注意在各个地方<column>标签都是column属性的替代写法。)" + +#. Tag: para +#: component_mapping.xml:211 +#, no-c-format +msgid "" +"A many-to-many association to OrderLine also uses the composite foreign key:" +msgstr "" +"指向OrderLine多对多关联也使用联合外" +"键:" + +#. Tag: programlisting +#: component_mapping.xml:216 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: component_mapping.xml:218 +#, no-c-format +msgid "" +"The collection of OrderLines in Order " +"would use:" +msgstr "" +"在Order中,OrderLine的集合则是这样:" + +#. Tag: programlisting +#: component_mapping.xml:223 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: component_mapping.xml:225 +#, no-c-format +msgid "" +"(The <one-to-many> element, as usual, declares no " +"columns.)" +msgstr "(与通常一样,<one-to-many>元素不声明任何列.)" + +#. Tag: para +#: component_mapping.xml:229 +#, no-c-format +msgid "" +"If OrderLine itself owns a collection, it also has a " +"composite foreign key." +msgstr "假若OrderLine本身拥有一个集合,它也具有组合外键。" + +#. Tag: programlisting +#: component_mapping.xml:234 +#, no-c-format +msgid "" +"\n" +" ....\n" +" ....\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +"]]>" +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 Map:" -msgstr "" +msgstr "你甚至可以映射Map类型的属性:" -#: index.docbook:245 +#. Tag: programlisting +#: component_mapping.xml:245 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:247 -msgid "The semantics of a <dynamic-component> mapping are identical to <component>. 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 Configuration object." +#. Tag: para +#: component_mapping.xml:247 +#, no-c-format +msgid "" +"The semantics of a <dynamic-component> mapping are " +"identical to <component>. 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 Configuration object." msgstr "" - -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +"从<dynamic-component>映射的语义上来讲,它和" +"<component>是相同的。 这种映射类型的优点在于通过修改" +"映射文件,就可以具有在部署时检测真实属性的能力。利用一个DOM解析器,也可以在程" +"序运行时操作映射文件。 更好的是,你可以通过Configuration对" +"象来访问(或者修改)Hibernate的运行时元模型。" diff --git a/documentation/manual/translations/zh-CN/content/configuration.po b/documentation/manual/translations/zh-CN/content/configuration.po index d34494fb4f..158793266a 100644 --- a/documentation/manual/translations/zh-CN/content/configuration.po +++ b/documentation/manual/translations/zh-CN/content/configuration.po @@ -1,1489 +1,3731 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: configuration.xml:5 +#, no-c-format msgid "Configuration" -msgstr "" +msgstr "配置" -#: index.docbook:7 -msgid "Because Hibernate is designed to operate in many different environments, there are a large number of configuration parameters. Fortunately, most have sensible default values and Hibernate is distributed with an example hibernate.properties file in etc/ that shows the various options. Just put the example file in your classpath and customize it." +#. Tag: para +#: configuration.xml:7 +#, no-c-format +msgid "" +"Because Hibernate is designed to operate in many different environments, " +"there are a large number of configuration parameters. Fortunately, most have " +"sensible default values and Hibernate is distributed with an example " +"hibernate.properties file in etc/ that " +"shows the various options. Just put the example file in your classpath and " +"customize it." msgstr "" +"由于Hibernate是为了能在各种不同环境下工作而设计的, 因此存在着大量的配置参数. " +"幸运的是多数配置参数都 有比较直观的默认值, 并有随Hibernate一同分发的配置样例" +"hibernate.properties (位于etc/)来展示各" +"种配置选项. 所需做的仅仅是将这个样例文件复制到类路径 (classpath)下并做一些自" +"定义的修改." -#: index.docbook:16 +#. Tag: title +#: configuration.xml:16 +#, no-c-format msgid "Programmatic configuration" -msgstr "" +msgstr "可编程的配置方式" -#: index.docbook:18 -msgid "An instance of org.hibernate.cfg.Configuration represents an entire set of mappings of an application's Java types to an SQL database. The Configuration is used to build an (immutable) SessionFactory. The mappings are compiled from various XML mapping files." -msgstr "" - -#: index.docbook:26 -msgid "You may obtain a Configuration instance by instantiating it directly and specifying XML mapping documents. If the mapping files are in the classpath, use addResource():" -msgstr "" - -#: index.docbook:32 +#. Tag: para +#: configuration.xml:18 +#, no-c-format msgid "" - "" +"An instance of org.hibernate.cfg.Configuration represents " +"an entire set of mappings of an application's Java types to an SQL database. " +"The Configuration is used to build an (immutable) " +"SessionFactory. The mappings are compiled from various " +"XML mapping files." msgstr "" +"一个org.hibernate.cfg.Configuration实例代表了一个应用程序" +"中Java类型 到SQL数据库映射的完整集合. Configuration被用来" +"构建一个(不可变的 (immutable))SessionFactory. 映射定义则由" +"不同的XML映射定义文件编译而来." -#: index.docbook:34 -msgid "An alternative (sometimes better) way is to specify the mapped class, and let Hibernate find the mapping document for you:" -msgstr "" - -#: index.docbook:39 +#. Tag: para +#: configuration.xml:26 +#, no-c-format msgid "" - "" +"You may obtain a Configuration instance by instantiating " +"it directly and specifying XML mapping documents. If the mapping files are " +"in the classpath, use addResource():" msgstr "" +"你可以直接实例化Configuration来获取一个实例,并为它指定XML" +"映射定义 文件. 如果映射定 义文件在类路径(classpath)中, 请使用" +"addResource():" -#: index.docbook:41 -msgid "Then Hibernate will look for mapping files named /org/hibernate/auction/Item.hbm.xml and /org/hibernate/auction/Bid.hbm.xml in the classpath. This approach eliminates any hardcoded filenames." -msgstr "" - -#: index.docbook:48 -msgid "A Configuration also allows you to specify configuration properties:" -msgstr "" - -#: index.docbook:53 +#. Tag: programlisting +#: configuration.xml:32 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:55 -msgid "This is not the only way to pass configuration properties to Hibernate. The various options include:" +#. Tag: para +#: configuration.xml:34 +#, no-c-format +msgid "" +"An alternative (sometimes better) way is to specify the mapped class, and " +"let Hibernate find the mapping document for you:" +msgstr "" +"一个替代方法(有时是更好的选择)是,指定被映射的类,让Hibernate帮你寻找映射定" +"义文件:" + +#. Tag: programlisting +#: configuration.xml:39 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:62 -msgid "Pass an instance of java.util.Properties to Configuration.setProperties()." +#. Tag: para +#: configuration.xml:41 +#, no-c-format +msgid "" +"Then Hibernate will look for mapping files named /org/hibernate/" +"auction/Item.hbm.xml and /org/hibernate/auction/Bid.hbm." +"xml in the classpath. This approach eliminates any hardcoded " +"filenames." +msgstr "" +"Hibernate将会在类路径(classpath)中寻找名字为 /org/hibernate/auction/" +"Item.hbm.xml/org/hibernate/auction/Bid.hbm.xml映射定义文件. 这种方式消除了任何对文件名的硬编码(hardcoded)." + +#. Tag: para +#: configuration.xml:48 +#, no-c-format +msgid "" +"A Configuration also allows you to specify configuration " +"properties:" +msgstr "Configuration也允许你指定配置属性:" + +#. Tag: programlisting +#: configuration.xml:53 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:68 -msgid "Place hibernate.properties in a root directory of the classpath." -msgstr "" +#. Tag: para +#: configuration.xml:55 +#, no-c-format +msgid "" +"This is not the only way to pass configuration properties to Hibernate. The " +"various options include:" +msgstr "当然这不是唯一的传递Hibernate配置属性的方式, 其他可选方式还包括:" -#: index.docbook:74 -msgid "Set System properties using java -Dproperty=value." +#. Tag: para +#: configuration.xml:62 +#, no-c-format +msgid "" +"Pass an instance of java.util.Properties to " +"Configuration.setProperties()." msgstr "" +"传一个java.util.Properties实例给 Configuration." +"setProperties()." -#: index.docbook:80 -msgid "Include <property> elements in hibernate.cfg.xml (discussed later)." +#. Tag: para +#: configuration.xml:68 +#, no-c-format +msgid "" +"Place hibernate.properties in a root directory of the " +"classpath." msgstr "" +"将hibernate.properties放置在类路径(classpath)的根目录下 " +"(root directory)." -#: index.docbook:87 -msgid "hibernate.properties is the easiest approach if you want to get started quickly." +#. Tag: para +#: configuration.xml:74 +#, no-c-format +msgid "" +"Set System properties using java -" +"Dproperty=value." msgstr "" +"通过java -Dproperty=value来设置系统 (System)属性." -#: index.docbook:92 -msgid "The Configuration is intended as a startup-time object, to be discarded once a SessionFactory is created." +#. Tag: para +#: configuration.xml:80 +#, no-c-format +msgid "" +"Include <property> elements in hibernate." +"cfg.xml (discussed later)." msgstr "" +"在hibernate.cfg.xml中加入元素 <property> (稍后讨论)." -#: index.docbook:100 +#. Tag: para +#: configuration.xml:87 +#, no-c-format +msgid "" +"hibernate.properties is the easiest approach if you want " +"to get started quickly." +msgstr "" +"如果想尽快体验Hibernate, hibernate.properties是最简单的方" +"式." + +#. Tag: para +#: configuration.xml:92 +#, no-c-format +msgid "" +"The Configuration is intended as a startup-time object, " +"to be discarded once a SessionFactory is created." +msgstr "" +"Configuration实例被设计成启动期间(startup-time)对象, 一" +"旦SessionFactory创建完成它就被丢弃了." + +#. Tag: title +#: configuration.xml:100 +#, no-c-format msgid "Obtaining a SessionFactory" -msgstr "" +msgstr "获得SessionFactory" -#: index.docbook:102 -msgid "When all mappings have been parsed by the Configuration, the application must obtain a factory for Session instances. This factory is intended to be shared by all application threads:" +#. Tag: para +#: configuration.xml:102 +#, no-c-format +msgid "" +"When all mappings have been parsed by the Configuration, " +"the application must obtain a factory for Session " +"instances. This factory is intended to be shared by all application threads:" msgstr "" +"当所有映射定义被Configuration解析后, 应用程序必须获得一个" +"用于构造Session实例的工厂. 这个工厂将被应用程序的所有线程" +"共享:" -#: index.docbook:108 +#. Tag: programlisting +#: configuration.xml:108 +#, no-c-format msgid "" msgstr "" -#: index.docbook:110 -msgid "Hibernate does allow your application to instantiate more than one SessionFactory. This is useful if you are using more than one database." -msgstr "" - -#: index.docbook:119 -msgid "JDBC connections" -msgstr "" - -#: index.docbook:121 -msgid "Usually, you want to have the SessionFactory create and pool JDBC connections for you. If you take this approach, opening a Session is as simple as:" -msgstr "" - -#: index.docbook:127 -msgid "" -msgstr "" - -#: index.docbook:129 -msgid "As soon as you do something that requires access to the database, a JDBC connection will be obtained from the pool." -msgstr "" - -#: index.docbook:134 -msgid "For this to work, we need to pass some JDBC connection properties to Hibernate. All Hibernate property names and semantics are defined on the class org.hibernate.cfg.Environment. We will now describe the most important settings for JDBC connection configuration." -msgstr "" - -#: index.docbook:141 -msgid "Hibernate will obtain (and pool) connections using java.sql.DriverManager if you set the following properties:" -msgstr "" - -#: index.docbook:147 -msgid "Hibernate JDBC Properties" -msgstr "" - -#: index.docbook:153, index.docbook:241, index.docbook:338, index.docbook:529, index.docbook:725, index.docbook:832, index.docbook:920 -msgid "Property name" -msgstr "" - -#: index.docbook:154, index.docbook:242, index.docbook:339, index.docbook:530, index.docbook:726, index.docbook:833, index.docbook:921 -msgid "Purpose" -msgstr "" - -#: index.docbook:160 -msgid "hibernate.connection.driver_class" -msgstr "" - -#: index.docbook:163 -msgid "JDBC driver class" -msgstr "" - -#: index.docbook:168 -msgid "hibernate.connection.url" -msgstr "" - -#: index.docbook:171 -msgid "JDBC URL" -msgstr "" - -#: index.docbook:176, index.docbook:272 -msgid "hibernate.connection.username" -msgstr "" - -#: index.docbook:179 -msgid "database user" -msgstr "" - -#: index.docbook:184, index.docbook:280 -msgid "hibernate.connection.password" -msgstr "" - -#: index.docbook:187 -msgid "database user password" -msgstr "" - -#: index.docbook:192 -msgid "hibernate.connection.pool_size" -msgstr "" - -#: index.docbook:195 -msgid "maximum number of pooled connections" -msgstr "" - -#: index.docbook:202 -msgid "Hibernate's own connection pooling algorithm is however quite rudimentary. It is intended to help you get started and is not intended for use in a production system or even for performance testing. You should use a third party pool for best performance and stability. Just replace the hibernate.connection.pool_size property with connection pool specific settings. This will turn off Hibernate's internal pool. For example, you might like to use C3P0." -msgstr "" - -#: index.docbook:212 -msgid "C3P0 is an open source JDBC connection pool distributed along with Hibernate in the lib directory. Hibernate will use its C3P0ConnectionProvider for connection pooling if you set hibernate.c3p0.* properties. If you'd like to use Proxool refer to the packaged hibernate.properties and the Hibernate web site for more information." -msgstr "" - -#: index.docbook:221 -msgid "Here is an example hibernate.properties file for C3P0:" -msgstr "" - -#: index.docbook:225 +#. Tag: para +#: configuration.xml:110 +#, no-c-format msgid "" - "" +"Hibernate does allow your application to instantiate more than one " +"SessionFactory. This is useful if you are using more than " +"one database." +msgstr "" +"Hibernate允许你的应用程序创建多个SessionFactory实例. 这对 " +"使用多个数据库的应用来说很有用." + +#. Tag: title +#: configuration.xml:119 +#, no-c-format +msgid "JDBC connections" +msgstr "JDBC连接" + +#. Tag: para +#: configuration.xml:121 +#, no-c-format +msgid "" +"Usually, you want to have the SessionFactory create and " +"pool JDBC connections for you. If you take this approach, opening a " +"Session is as simple as:" +msgstr "" +"通常你希望SessionFactory来为你创建和缓存(pool)JDBC连接. 如" +"果你采用这种方式, 只需要如下例所示那样,打开一个Session:" + +#. Tag: programlisting +#: configuration.xml:127 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:227 -msgid "For use inside an application server, you should almost always configure Hibernate to obtain connections from an application server Datasource registered in JNDI. You'll need to set at least one of the following properties:" +#. Tag: para +#: configuration.xml:129 +#, no-c-format +msgid "" +"As soon as you do something that requires access to the database, a JDBC " +"connection will be obtained from the pool." +msgstr "" +"一旦你需要进行数据访问时, 就会从连接池(connection pool)获得一个JDBC连接." + +#. Tag: para +#: configuration.xml:134 +#, no-c-format +msgid "" +"For this to work, we need to pass some JDBC connection properties to " +"Hibernate. All Hibernate property names and semantics are defined on the " +"class org.hibernate.cfg.Environment. We will now describe " +"the most important settings for JDBC connection configuration." +msgstr "" +"为了使这种方式工作起来, 我们需要向Hibernate传递一些JDBC连接的属性. 所有" +"Hibernate属性的名字和语义都在org.hibernate.cfg.Environment" +"中定义. 我们现在将描述JDBC连接配置中最重要的设置." + +#. Tag: para +#: configuration.xml:141 +#, no-c-format +msgid "" +"Hibernate will obtain (and pool) connections using java.sql." +"DriverManager if you set the following properties:" +msgstr "" +"如果你设置如下属性,Hibernate将使用java.sql.DriverManager" +"来获得(和缓存)JDBC连接 :" + +#. Tag: title +#: configuration.xml:147 +#, no-c-format +msgid "Hibernate JDBC Properties" +msgstr "Hibernate JDBC属性" + +#. Tag: entry +#: configuration.xml:153 configuration.xml:241 configuration.xml:338 +#: configuration.xml:529 configuration.xml:725 configuration.xml:832 +#: configuration.xml:920 +#, no-c-format +msgid "Property name" +msgstr "属性名" + +#. Tag: entry +#: configuration.xml:154 configuration.xml:242 configuration.xml:339 +#: configuration.xml:530 configuration.xml:726 configuration.xml:833 +#: configuration.xml:921 +#, no-c-format +msgid "Purpose" +msgstr "用途" + +#. Tag: literal +#: configuration.xml:160 +#, no-c-format +msgid "hibernate.connection.driver_class" +msgstr "hibernate.connection.driver_class" + +#. Tag: emphasis +#: configuration.xml:163 +#, no-c-format +msgid "JDBC driver class" +msgstr "jdbc驱动类" + +#. Tag: literal +#: configuration.xml:168 +#, no-c-format +msgid "hibernate.connection.url" +msgstr "hibernate.connection.url" + +#. Tag: emphasis +#: configuration.xml:171 +#, no-c-format +msgid "JDBC URL" +msgstr "jdbc URL" + +#. Tag: literal +#: configuration.xml:176 configuration.xml:272 +#, no-c-format +msgid "hibernate.connection.username" +msgstr "hibernate.connection.username" + +#. Tag: emphasis +#: configuration.xml:179 +#, no-c-format +msgid "database user" +msgstr "数据库用户" + +#. Tag: literal +#: configuration.xml:184 configuration.xml:280 +#, no-c-format +msgid "hibernate.connection.password" +msgstr "hibernate.connection.password" + +#. Tag: emphasis +#: configuration.xml:187 +#, no-c-format +msgid "database user password" +msgstr "数据库用户密码" + +#. Tag: literal +#: configuration.xml:192 +#, no-c-format +msgid "hibernate.connection.pool_size" +msgstr "hibernate.connection.pool_size" + +#. Tag: emphasis +#: configuration.xml:195 +#, no-c-format +msgid "maximum number of pooled connections" +msgstr "连接池容量上限数目" + +#. Tag: para +#: configuration.xml:202 +#, no-c-format +msgid "" +"Hibernate's own connection pooling algorithm is however quite rudimentary. " +"It is intended to help you get started and is not intended for use " +"in a production system or even for performance testing. You " +"should use a third party pool for best performance and stability. Just " +"replace the hibernate.connection.pool_size property with " +"connection pool specific settings. This will turn off Hibernate's internal " +"pool. For example, you might like to use C3P0." +msgstr "" +"但Hibernate自带的连接池算法相当不成熟. 它只是为了让你快些上手,并不" +"适合用于产品系统或性能测试中。 出于最佳性能和稳定性考虑你应该使用" +"第三方的连接池。只需要用特定连接池的设置替换 hibernate.connection." +"pool_size即可。这将关闭Hibernate自带的连接池. 例如, 你可能会想用" +"C3P0." + +#. Tag: para +#: configuration.xml:212 +#, no-c-format +msgid "" +"C3P0 is an open source JDBC connection pool distributed along with Hibernate " +"in the lib directory. Hibernate will use its " +"C3P0ConnectionProvider for connection pooling if you set " +"hibernate.c3p0.* properties. If you'd like to use Proxool " +"refer to the packaged hibernate.properties and the " +"Hibernate web site for more information." +msgstr "" +"C3P0是一个随Hibernate一同分发的开源的JDBC连接池, 它位于lib" +"目录下。 如果你设置了hibernate.c3p0.*相关的属性, Hibernate" +"将使用 C3P0ConnectionProvider来缓存JDBC连接. 如果你更原意" +"使用Proxool, 请参考发 行包中的hibernate.properties并到" +"Hibernate网站获取更多的信息." + +#. Tag: para +#: configuration.xml:221 +#, no-c-format +msgid "" +"Here is an example hibernate.properties file for C3P0:" +msgstr "这是一个使用C3P0的hibernate.properties样例文件:" + +#. Tag: programlisting +#: configuration.xml:225 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:235 +#. Tag: para +#: configuration.xml:227 +#, no-c-format +msgid "" +"For use inside an application server, you should almost always configure " +"Hibernate to obtain connections from an application server " +"Datasource registered in JNDI. You'll need to set at " +"least one of the following properties:" +msgstr "" +"为了能在应用程序服务器(application server)中使用Hibernate, 应当总是将" +"Hibernate 配置成从注册在JNDI中的Datasource处获得连接,你至" +"少需要设置下列属性中的一个:" + +#. Tag: title +#: configuration.xml:235 +#, no-c-format msgid "Hibernate Datasource Properties" -msgstr "" +msgstr "Hibernate数据源属性" -#: index.docbook:248 +#. Tag: literal +#: configuration.xml:248 +#, no-c-format msgid "hibernate.connection.datasource" -msgstr "" +msgstr "hibernate.connection.datasource" -#: index.docbook:251 +#. Tag: emphasis +#: configuration.xml:251 +#, no-c-format msgid "datasource JNDI name" -msgstr "" +msgstr "数据源JNDI名字" -#: index.docbook:256 +#. Tag: literal +#: configuration.xml:256 +#, no-c-format msgid "hibernate.jndi.url" -msgstr "" +msgstr "hibernate.jndi.url" -#: index.docbook:258 +#. Tag: entry +#: configuration.xml:258 +#, fuzzy, no-c-format msgid "URL of the JNDI provider (optional)" -msgstr "" +msgstr "JNDI提供者的URL" -#: index.docbook:264 +#. Tag: literal +#: configuration.xml:264 +#, no-c-format msgid "hibernate.jndi.class" +msgstr "hibernate.jndi.class" + +#. Tag: entry +#: configuration.xml:266 +#, no-c-format +msgid "" +"class of the JNDI InitialContextFactory (optional)" msgstr "" -#: index.docbook:266 -msgid "class of the JNDI InitialContextFactory (optional)" -msgstr "" - -#: index.docbook:274 +#. Tag: entry +#: configuration.xml:274 +#, no-c-format msgid "database user (optional)" msgstr "" -#: index.docbook:282 +#. Tag: entry +#: configuration.xml:282 +#, no-c-format msgid "database user password (optional)" msgstr "" -#: index.docbook:290 -msgid "Here's an example hibernate.properties file for an application server provided JNDI datasource:" -msgstr "" - -#: index.docbook:295 +#. Tag: para +#: configuration.xml:290 +#, no-c-format msgid "" - "" +"Here's an example hibernate.properties file for an " +"application server provided JNDI datasource:" +msgstr "" +"这是一个使用应用程序服务器提供的JNDI数据源的hibernate.properties样例文件:" + +#. Tag: programlisting +#: configuration.xml:295 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:297 -msgid "JDBC connections obtained from a JNDI datasource will automatically participate in the container-managed transactions of the application server." +#. Tag: para +#: configuration.xml:297 +#, no-c-format +msgid "" +"JDBC connections obtained from a JNDI datasource will automatically " +"participate in the container-managed transactions of the application server." msgstr "" +"从JNDI数据源获得的JDBC连接将自动参与到应用程序服务器中容器管理的事务" +"(container-managed transactions)中去." -#: index.docbook:302 -msgid "Arbitrary connection properties may be given by prepending \"hibernate.connection\" to the property name. For example, you may specify a charSet using hibernate.connection.charSet." +#. Tag: para +#: configuration.xml:302 +#, no-c-format +msgid "" +"Arbitrary connection properties may be given by prepending " +"\"hibernate.connection\" to the property name. For " +"example, you may specify a charSet using " +"hibernate.connection.charSet." msgstr "" +"任何连接(connection)属性的属性名都要以\"hibernate.connnection\"开头. 例如, 你可能会使用hibernate.connection.charSet来指定字符集charSet." -#: index.docbook:308 -msgid "You may define your own plugin strategy for obtaining JDBC connections by implementing the interface org.hibernate.connection.ConnectionProvider. You may select a custom implementation by setting hibernate.connection.provider_class." +#. Tag: para +#: configuration.xml:308 +#, no-c-format +msgid "" +"You may define your own plugin strategy for obtaining JDBC connections by " +"implementing the interface org.hibernate.connection." +"ConnectionProvider. You may select a custom implementation by " +"setting hibernate.connection.provider_class." msgstr "" +"通过实现org.hibernate.connection.ConnectionProvider接口," +"你可以定义属于 你自己的获得JDBC连接的插件策略。通过设置hibernate." +"connection.provider_class, 你可以选择一个自定义的实现." -#: index.docbook:317 +#. Tag: title +#: configuration.xml:317 +#, no-c-format msgid "Optional configuration properties" -msgstr "" +msgstr "可选的配置属性" -#: index.docbook:319 -msgid "There are a number of other properties that control the behaviour of Hibernate at runtime. All are optional and have reasonable default values." +#. Tag: para +#: configuration.xml:319 +#, no-c-format +msgid "" +"There are a number of other properties that control the behaviour of " +"Hibernate at runtime. All are optional and have reasonable default values." msgstr "" +"有大量属性能用来控制Hibernate在运行期的行为. 它们都是可选的, 并拥有适当的默认" +"值." -#: index.docbook:324 -msgid "Warning: some of these properties are \"system-level\" only. System-level properties can be set only via java -Dproperty=value or hibernate.properties. They may not be set by the other techniques described above." +#. Tag: para +#: configuration.xml:324 +#, no-c-format +msgid "" +"Warning: some of these properties are \"system-level\" only. System-level properties can be set only via java -" +"Dproperty=value or hibernate.properties. They " +"may not be set by the other techniques described above." msgstr "" +"警告: 其中一些属性是\"系统级(system-level)的\". 系统级属" +"性只能通过java -Dproperty=valuehibernate." +"properties来设置, 而不能用上面描述的其他方法来" +"设置." -#: index.docbook:332 +#. Tag: title +#: configuration.xml:332 +#, no-c-format msgid "Hibernate Configuration Properties" -msgstr "" +msgstr "Hibernate配置属性" -#: index.docbook:345 +#. Tag: literal +#: configuration.xml:345 +#, no-c-format msgid "hibernate.dialect" -msgstr "" +msgstr "hibernate.dialect" -#: index.docbook:347 -msgid "The classname of a Hibernate Dialect which allows Hibernate to generate SQL optimized for a particular relational database." +#. Tag: entry +#: configuration.xml:347 +#, fuzzy, no-c-format +msgid "" +"The classname of a Hibernate Dialect which allows " +"Hibernate to generate SQL optimized for a particular relational database." msgstr "" +"一个Hibernate 类名允许Hibernate针对特定的关系数据库生成优化的" +"SQL. " -#: index.docbook:351 -msgid "eg. full.classname.of.Dialect" +#. Tag: para +#: configuration.xml:351 +#, fuzzy, no-c-format +msgid "" +"eg. full.classname.of.Dialect" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:359 +#. Tag: literal +#: configuration.xml:359 +#, no-c-format msgid "hibernate.show_sql" -msgstr "" +msgstr "hibernate.show_sql" -#: index.docbook:361 -msgid "Write all SQL statements to console. This is an alternative to setting the log category org.hibernate.SQL to debug." +#. Tag: entry +#: configuration.xml:361 +#, fuzzy, no-c-format +msgid "" +"Write all SQL statements to console. This is an alternative to setting the " +"log category org.hibernate.SQL to debug." msgstr "" +"输出所有SQL语句到控制台. 有一个另外的选择是把这个log category" +"设为" -#: index.docbook:365, index.docbook:377, index.docbook:471, index.docbook:484, index.docbook:497, index.docbook:510, index.docbook:564, index.docbook:591, index.docbook:605, index.docbook:660, index.docbook:888, index.docbook:903, index.docbook:993 -msgid "eg. true | false" +#. Tag: para +#: configuration.xml:365 configuration.xml:377 configuration.xml:471 +#: configuration.xml:484 configuration.xml:497 configuration.xml:510 +#: configuration.xml:564 configuration.xml:591 configuration.xml:605 +#: configuration.xml:660 configuration.xml:888 configuration.xml:903 +#: configuration.xml:993 +#, fuzzy, no-c-format +msgid "" +"eg. true | " +"false" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:373 +#. Tag: literal +#: configuration.xml:373 +#, no-c-format msgid "hibernate.format_sql" -msgstr "" +msgstr "hibernate.format_sql" -#: index.docbook:375 +#. Tag: entry +#: configuration.xml:375 +#, fuzzy, no-c-format msgid "Pretty print the SQL in the log and console." -msgstr "" +msgstr "在log和console中打印出更漂亮的SQL。 " -#: index.docbook:385 +#. Tag: literal +#: configuration.xml:385 +#, no-c-format msgid "hibernate.default_schema" -msgstr "" +msgstr "hibernate.default_schema" -#: index.docbook:387 -msgid "Qualify unqualified table names with the given schema/tablespace in generated SQL." +#. Tag: entry +#: configuration.xml:387 +#, fuzzy, no-c-format +msgid "" +"Qualify unqualified table names with the given schema/tablespace in " +"generated SQL." msgstr "" +"在生成的SQL中, 将给定的schema/tablespace附加于非全限定名的表名上. " +"" -#: index.docbook:390 +#. Tag: para +#: configuration.xml:390 +#, fuzzy, no-c-format msgid "eg. SCHEMA_NAME" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:398 +#. Tag: literal +#: configuration.xml:398 +#, no-c-format msgid "hibernate.default_catalog" -msgstr "" +msgstr "hibernate.default_catalog" -#: index.docbook:400 -msgid "Qualify unqualified table names with the given catalog in generated SQL." +#. Tag: entry +#: configuration.xml:400 +#, fuzzy, no-c-format +msgid "" +"Qualify unqualified table names with the given catalog in generated SQL." msgstr "" +"在生成的SQL中, 将给定的catalog附加于非全限定名的表名上. " -#: index.docbook:403 -msgid "eg. CATALOG_NAME" +#. Tag: para +#: configuration.xml:403 +#, fuzzy, no-c-format +msgid "" +"eg. CATALOG_NAME" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:411 +#. Tag: literal +#: configuration.xml:411 +#, no-c-format msgid "hibernate.session_factory_name" -msgstr "" +msgstr "hibernate.session_factory_name" -#: index.docbook:413 -msgid "The SessionFactory will be automatically bound to this name in JNDI after it has been created." +#. Tag: entry +#: configuration.xml:413 +#, fuzzy, no-c-format +msgid "" +"The SessionFactory will be automatically bound to this " +"name in JNDI after it has been created." msgstr "" +"创建后,将自动使用这个名字绑定到JNDI中. " -#: index.docbook:416, index.docbook:859 -msgid "eg. jndi/composite/name" +#. Tag: para +#: configuration.xml:416 configuration.xml:859 +#, fuzzy, no-c-format +msgid "" +"eg. jndi/composite/name" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:424 +#. Tag: literal +#: configuration.xml:424 +#, no-c-format msgid "hibernate.max_fetch_depth" -msgstr "" +msgstr "hibernate.max_fetch_depth" -#: index.docbook:426 -msgid "Set a maximum \"depth\" for the outer join fetch tree for single-ended associations (one-to-one, many-to-one). A 0 disables default outer join fetching." +#. Tag: entry +#: configuration.xml:426 +#, fuzzy, no-c-format +msgid "" +"Set a maximum \"depth\" for the outer join fetch tree for single-ended " +"associations (one-to-one, many-to-one). A 0 disables " +"default outer join fetching." msgstr "" +"为单向关联(一对一, 多对一)的外连接抓取(outer join fetch)树设置最大深度. 值" +"为意味着将关闭默认的外连接抓取. " -#: index.docbook:430 -msgid "eg. recommended values between 0 and 3" +#. Tag: para +#: configuration.xml:430 +#, no-c-format +msgid "" +"eg. recommended values between " +"0 and 3" msgstr "" +"取值 建议在0到" +"3之间取值" -#: index.docbook:439 +#. Tag: literal +#: configuration.xml:439 +#, no-c-format msgid "hibernate.default_batch_fetch_size" -msgstr "" +msgstr "hibernate.default_batch_fetch_size" -#: index.docbook:441 +#. Tag: entry +#: configuration.xml:441 +#, fuzzy, no-c-format msgid "Set a default size for Hibernate batch fetching of associations." -msgstr "" +msgstr "为Hibernate关联的批量抓取设置默认数量. " -#: index.docbook:443 -msgid "eg. recommended values 4, 8, 16" +#. Tag: para +#: configuration.xml:443 +#, no-c-format +msgid "" +"eg. recommended values 4, 8, 16" msgstr "" +"取值 建议的取值为4, " +"8, 和16" -#: index.docbook:452 +#. Tag: literal +#: configuration.xml:452 +#, no-c-format msgid "hibernate.default_entity_mode" -msgstr "" +msgstr "hibernate.default_entity_mode" -#: index.docbook:454 -msgid "Set a default mode for entity representation for all sessions opened from this SessionFactory" +#. Tag: entry +#: configuration.xml:454 +#, fuzzy, no-c-format +msgid "" +"Set a default mode for entity representation for all sessions opened from " +"this SessionFactory" msgstr "" +"为由这个打开的所有Session指定默认的实体表现模式. " +"" -#: index.docbook:457 -msgid "dynamic-map, dom4j, pojo" +#. Tag: para +#: configuration.xml:457 +#, no-c-format +msgid "" +"dynamic-map, dom4j, pojo" msgstr "" +"取值dynamic-map, " +"dom4j, pojo" -#: index.docbook:465 +#. Tag: literal +#: configuration.xml:465 +#, no-c-format msgid "hibernate.order_updates" -msgstr "" +msgstr "hibernate.order_updates" -#: index.docbook:467 -msgid "Force Hibernate to order SQL updates by the primary key value of the items being updated. This will result in fewer transaction deadlocks in highly concurrent systems." +#. Tag: entry +#: configuration.xml:467 +#, fuzzy, no-c-format +msgid "" +"Force Hibernate to order SQL updates by the primary key value of the items " +"being updated. This will result in fewer transaction deadlocks in highly " +"concurrent systems." msgstr "" +"强制Hibernate按照被更新数据的主键,为SQL更新排序。这么做将减少在高并发系统中" +"事务的死锁。 " -#: index.docbook:479 +#. Tag: literal +#: configuration.xml:479 +#, no-c-format msgid "hibernate.generate_statistics" -msgstr "" +msgstr "hibernate.generate_statistics" -#: index.docbook:481 -msgid "If enabled, Hibernate will collect statistics useful for performance tuning." -msgstr "" +#. Tag: entry +#: configuration.xml:481 +#, fuzzy, no-c-format +msgid "" +"If enabled, Hibernate will collect statistics useful for performance tuning." +msgstr "如果开启, Hibernate将收集有助于性能调节的统计数据. " -#: index.docbook:492 +#. Tag: literal +#: configuration.xml:492 +#, no-c-format msgid "hibernate.use_identifier_rollback" -msgstr "" +msgstr "hibernate.use_identifer_rollback" -#: index.docbook:494 -msgid "If enabled, generated identifier properties will be reset to default values when objects are deleted." +#. Tag: entry +#: configuration.xml:494 +#, fuzzy, no-c-format +msgid "" +"If enabled, generated identifier properties will be reset to default values " +"when objects are deleted." msgstr "" +"如果开启, 在对象被删除时生成的标识属性将被重设为默认值. " -#: index.docbook:505 +#. Tag: literal +#: configuration.xml:505 +#, no-c-format msgid "hibernate.use_sql_comments" -msgstr "" +msgstr "hibernate.use_sql_comments" -#: index.docbook:507 -msgid "If turned on, Hibernate will generate comments inside the SQL, for easier debugging, defaults to false." +#. Tag: entry +#: configuration.xml:507 +#, fuzzy, no-c-format +msgid "" +"If turned on, Hibernate will generate comments inside the SQL, for easier " +"debugging, defaults to false." msgstr "" +"如果开启, Hibernate将在SQL中生成有助于调试的注释信息, 默认值为. " -#: index.docbook:521 +#. Tag: title +#: configuration.xml:521 +#, no-c-format msgid "Hibernate JDBC and Connection Properties" -msgstr "" +msgstr "Hibernate JDBC和连接(connection)属性" -#: index.docbook:536 +#. Tag: literal +#: configuration.xml:536 +#, no-c-format msgid "hibernate.jdbc.fetch_size" -msgstr "" +msgstr "hibernate.jdbc.fetch_size" -#: index.docbook:538 -msgid "A non-zero value determines the JDBC fetch size (calls Statement.setFetchSize())." -msgstr "" +#. Tag: entry +#: configuration.xml:538 +#, fuzzy, no-c-format +msgid "" +"A non-zero value determines the JDBC fetch size (calls Statement." +"setFetchSize())." +msgstr "非零值,指定JDBC抓取数量的大小 (调用)." -#: index.docbook:545 +#. Tag: literal +#: configuration.xml:545 +#, no-c-format msgid "hibernate.jdbc.batch_size" -msgstr "" +msgstr "hibernate.jdbc.batch_size" -#: index.docbook:547 +#. Tag: entry +#: configuration.xml:547 +#, fuzzy, no-c-format msgid "A non-zero value enables use of JDBC2 batch updates by Hibernate." -msgstr "" +msgstr "非零值,允许Hibernate使用JDBC2的批量更新. " -#: index.docbook:549 -msgid "eg. recommended values between 5 and 30" +#. Tag: para +#: configuration.xml:549 +#, no-c-format +msgid "" +"eg. recommended values between " +"5 and 30" msgstr "" +"取值 建议取5到" +"30之间的值" -#: index.docbook:557 +#. Tag: literal +#: configuration.xml:557 +#, no-c-format msgid "hibernate.jdbc.batch_versioned_data" -msgstr "" +msgstr "hibernate.jdbc.batch_versioned_data" -#: index.docbook:559 -msgid "Set this property to true if your JDBC driver returns correct row counts from executeBatch() (it is usually safe to turn this option on). Hibernate will then use batched DML for automatically versioned data. Defaults to false." +#. Tag: entry +#: configuration.xml:559 +#, fuzzy, no-c-format +msgid "" +"Set this property to true if your JDBC driver returns " +"correct row counts from executeBatch() (it is usually " +"safe to turn this option on). Hibernate will then use batched DML for " +"automatically versioned data. Defaults to false." msgstr "" +"如果你想让你的JDBC驱动从返回正确的行计数 , 那么将此属性设为" +"(开启这个选项通常是安全的). 同时,Hibernate将为自动版本化的数" +"据使用批量DML. 默认值为. " -#: index.docbook:572 +#. Tag: literal +#: configuration.xml:572 +#, no-c-format msgid "hibernate.jdbc.factory_class" -msgstr "" +msgstr "hibernate.jdbc.factory_class" -#: index.docbook:574 -msgid "Select a custom Batcher. Most applications will not need this configuration property." +#. Tag: entry +#: configuration.xml:574 +#, fuzzy, no-c-format +msgid "" +"Select a custom Batcher. Most applications will not need " +"this configuration property." msgstr "" +"选择一个自定义的. 多数应用程序不需要这个配置属性. " +"" -#: index.docbook:577 -msgid "eg. classname.of.BatcherFactory" +#. Tag: para +#: configuration.xml:577 +#, fuzzy, no-c-format +msgid "" +"eg. classname.of." +"BatcherFactory" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:585 +#. Tag: literal +#: configuration.xml:585 +#, no-c-format msgid "hibernate.jdbc.use_scrollable_resultset" -msgstr "" +msgstr "hibernate.jdbc.use_scrollable_resultset" -#: index.docbook:587 -msgid "Enables use of JDBC2 scrollable resultsets by Hibernate. This property is only necessary when using user supplied JDBC connections, Hibernate uses connection metadata otherwise." +#. Tag: entry +#: configuration.xml:587 +#, fuzzy, no-c-format +msgid "" +"Enables use of JDBC2 scrollable resultsets by Hibernate. This property is " +"only necessary when using user supplied JDBC connections, Hibernate uses " +"connection metadata otherwise." msgstr "" +"允许Hibernate使用JDBC2的可滚动结果集. 只有在使用用户提供的JDBC连接时,这个选" +"项才是必要的, 否则Hibernate会使用连接的元数据. " -#: index.docbook:599 +#. Tag: literal +#: configuration.xml:599 +#, no-c-format msgid "hibernate.jdbc.use_streams_for_binary" -msgstr "" +msgstr "hibernate.jdbc.use_streams_for_binary" -#: index.docbook:601 -msgid "Use streams when writing/reading binary or serializable types to/from JDBC (system-level property)." +#. Tag: entry +#: configuration.xml:601 +#, fuzzy, no-c-format +msgid "" +"Use streams when writing/reading binary or " +"serializable types to/from JDBC (system-level property)." msgstr "" +"在JDBC读写 的类型时使用流(stream)(系统级属" +"性). " -#: index.docbook:613 +#. Tag: literal +#: configuration.xml:613 +#, no-c-format msgid "hibernate.jdbc.use_get_generated_keys" -msgstr "" +msgstr "hibernate.jdbc.use_get_generated_keys" -#: index.docbook:615 -msgid "Enable use of JDBC3 PreparedStatement.getGeneratedKeys() to retrieve natively generated keys after insert. Requires JDBC3+ driver and JRE1.4+, set to false if your driver has problems with the Hibernate identifier generators. By default, tries to determine the driver capabilities using connection metadata." +#. Tag: entry +#: configuration.xml:615 +#, fuzzy, no-c-format +msgid "" +"Enable use of JDBC3 PreparedStatement.getGeneratedKeys() " +"to retrieve natively generated keys after insert. Requires JDBC3+ driver and " +"JRE1.4+, set to false if your driver has problems with the Hibernate " +"identifier generators. By default, tries to determine the driver " +"capabilities using connection metadata." msgstr "" +"在数据插入数据库之后,允许使用JDBC3 来获取数据库生成的key" +"(键)。需要JDBC3+驱动和JRE1.4+, 如果你的数据库驱动在使用Hibernate的标 识生成器" +"时遇到问题,请将此值设为false. 默认情况下将使用连接的元数据来判定驱动的能力. " +"" -#: index.docbook:621, index.docbook:751, index.docbook:763, index.docbook:777, index.docbook:815 +#. Tag: para +#: configuration.xml:621 configuration.xml:751 configuration.xml:763 +#: configuration.xml:777 configuration.xml:815 +#, fuzzy, no-c-format msgid "eg. true|false" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:629 +#. Tag: literal +#: configuration.xml:629 +#, no-c-format msgid "hibernate.connection.provider_class" -msgstr "" +msgstr "hibernate.connection.provider_class" -#: index.docbook:631 -msgid "The classname of a custom ConnectionProvider which provides JDBC connections to Hibernate." +#. Tag: entry +#: configuration.xml:631 +#, fuzzy, no-c-format +msgid "" +"The classname of a custom ConnectionProvider which " +"provides JDBC connections to Hibernate." msgstr "" +"自定义的类名, 此类用来向Hibernate提供JDBC连接. " -#: index.docbook:634 -msgid "eg. classname.of.ConnectionProvider" +#. Tag: para +#: configuration.xml:634 +#, fuzzy, no-c-format +msgid "" +"eg. classname.of." +"ConnectionProvider" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:642 +#. Tag: literal +#: configuration.xml:642 +#, no-c-format msgid "hibernate.connection.isolation" -msgstr "" +msgstr "hibernate.connection.isolation" -#: index.docbook:644 -msgid "Set the JDBC transaction isolation level. Check java.sql.Connection for meaningful values but note that most databases do not support all isolation levels." +#. Tag: entry +#: configuration.xml:644 +#, fuzzy, no-c-format +msgid "" +"Set the JDBC transaction isolation level. Check java.sql." +"Connection for meaningful values but note that most databases do " +"not support all isolation levels." msgstr "" +"设置JDBC事务隔离级别. 查看来了解各个值的具体意义, 但请注意多" +"数数据库都不支持所有的隔离级别. " -#: index.docbook:648 +#. Tag: para +#: configuration.xml:648 +#, fuzzy, no-c-format msgid "eg. 1, 2, 4, 8" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:656 +#. Tag: literal +#: configuration.xml:656 +#, no-c-format msgid "hibernate.connection.autocommit" -msgstr "" +msgstr "hibernate.connection.autocommit" -#: index.docbook:658 +#. Tag: entry +#: configuration.xml:658 +#, fuzzy, no-c-format msgid "Enables autocommit for JDBC pooled connections (not recommended)." msgstr "" +"允许被缓存的JDBC连接开启自动提交(autocommit) (不建议). " -#: index.docbook:668 +#. Tag: literal +#: configuration.xml:668 +#, no-c-format msgid "hibernate.connection.release_mode" -msgstr "" +msgstr "hibernate.connection.release_mode" -#: index.docbook:670 -msgid "Specify when Hibernate should release JDBC connections. By default, a JDBC connection is held until the session is explicitly closed or disconnected. For an application server JTA datasource, you should use after_statement to aggressively release connections after every JDBC call. For a non-JTA connection, it often makes sense to release the connection at the end of each transaction, by using after_transaction. auto will choose after_statement for the JTA and CMT transaction strategies and after_transaction for the JDBC transaction strategy." +#. Tag: entry +#: configuration.xml:670 +#, fuzzy, no-c-format +msgid "" +"Specify when Hibernate should release JDBC connections. By default, a JDBC " +"connection is held until the session is explicitly closed or disconnected. " +"For an application server JTA datasource, you should use " +"after_statement to aggressively release connections after " +"every JDBC call. For a non-JTA connection, it often makes sense to release " +"the connection at the end of each transaction, by using " +"after_transaction. auto will choose " +"after_statement for the JTA and CMT transaction " +"strategies and after_transaction for the JDBC transaction " +"strategy." msgstr "" +"指定Hibernate在何时释放JDBC连接. 默认情况下,直到Session被显式关闭或被断开连接" +"时,才会释放JDBC连接. 对于应用程序服务器的JTA数据源, 你应当使用, 这样在每次JDBC调用后,都会主动的释放连接. 对于非JTA的连接, 使用" +"在每个事务结束时释放连接是合理的. 将为JTA和" +"CMT事务策略选择, 为JDBC事务策略选择. " +"" -#: index.docbook:681 -msgid "eg. auto (default) | on_close | after_transaction | after_statement" +#. Tag: para +#: configuration.xml:681 +#, fuzzy, no-c-format +msgid "" +"eg. auto (default) | " +"on_close | after_transaction | " +"after_statement" msgstr "" +"取值auto (默认) | " +"on_close | after_transaction | " +"after_statement" -#: index.docbook:686 -msgid "Note that this setting only affects Sessions returned from SessionFactory.openSession. For Sessions obtained through SessionFactory.getCurrentSession, the CurrentSessionContext implementation configured for use controls the connection release mode for those Sessions. See" +#. Tag: para +#: configuration.xml:686 +#, fuzzy, no-c-format +msgid "" +"Note that this setting only affects Sessions returned " +"from SessionFactory.openSession. For Sessions obtained through SessionFactory.getCurrentSession, the CurrentSessionContext implementation " +"configured for use controls the connection release mode for those " +"Sessions. See" msgstr "" +"注意,这些设置仅对通过SessionFactory.openSession得到的" +"Session起作用。对于通过SessionFactory." +"getCurrentSession得到的Session,所配置的" +"CurrentSessionContext实现控制这些Session的连接释放模式。请参阅。" -#: index.docbook:698 +#. Tag: literal +#: configuration.xml:698 +#, no-c-format msgid "hibernate.connection.<propertyName>" msgstr "" -#: index.docbook:700 -msgid "Pass the JDBC property propertyName to DriverManager.getConnection()." +#. Tag: entry +#: configuration.xml:700 +#, fuzzy, no-c-format +msgid "" +"Pass the JDBC property propertyName to " +"DriverManager.getConnection()." msgstr "" +"传一个java.util.Properties实例给 Configuration." +"setProperties()." -#: index.docbook:707 +#. Tag: literal +#: configuration.xml:707 +#, no-c-format msgid "hibernate.jndi.<propertyName>" msgstr "" -#: index.docbook:709 -msgid "Pass the property propertyName to the JNDI InitialContextFactory." +#. Tag: entry +#: configuration.xml:709 +#, fuzzy, no-c-format +msgid "" +"Pass the property propertyName to the JNDI " +"InitialContextFactory." msgstr "" +"传一个java.util.Properties实例给 Configuration." +"setProperties()." -#: index.docbook:719 +#. Tag: title +#: configuration.xml:719 +#, no-c-format msgid "Hibernate Cache Properties" -msgstr "" +msgstr "Hibernate缓存属性" -#: index.docbook:732 +#. Tag: literal +#: configuration.xml:732 +#, no-c-format msgid "hibernate.cache.provider_class" -msgstr "" +msgstr "hibernate.cache.provider_class" -#: index.docbook:734 +#. Tag: entry +#: configuration.xml:734 +#, fuzzy, no-c-format msgid "The classname of a custom CacheProvider." -msgstr "" +msgstr "自定义的的类名. " -#: index.docbook:736 -msgid "eg. classname.of.CacheProvider" +#. Tag: para +#: configuration.xml:736 +#, fuzzy, no-c-format +msgid "" +"eg. classname.of." +"CacheProvider" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:744 +#. Tag: literal +#: configuration.xml:744 +#, no-c-format msgid "hibernate.cache.use_minimal_puts" -msgstr "" +msgstr "hibernate.cache.use_minimal_puts" -#: index.docbook:746 -msgid "Optimize second-level cache operation to minimize writes, at the cost of more frequent reads. This setting is most useful for clustered caches and, in Hibernate3, is enabled by default for clustered cache implementations." +#. Tag: entry +#: configuration.xml:746 +#, fuzzy, no-c-format +msgid "" +"Optimize second-level cache operation to minimize writes, at the cost of " +"more frequent reads. This setting is most useful for clustered caches and, " +"in Hibernate3, is enabled by default for clustered cache implementations." msgstr "" +"以频繁的读操作为代价, 优化二级缓存来最小化写操作. 在Hibernate3中,这个设置对" +"的集群缓存非常有用, 对集群缓存的实现而言,默认是开启的. " -#: index.docbook:759 +#. Tag: literal +#: configuration.xml:759 +#, no-c-format msgid "hibernate.cache.use_query_cache" -msgstr "" +msgstr "hibernate.cache.use_query_cache" -#: index.docbook:761 -msgid "Enable the query cache, individual queries still have to be set cachable." -msgstr "" +#. Tag: entry +#: configuration.xml:761 +#, fuzzy, no-c-format +msgid "" +"Enable the query cache, individual queries still have to be set cachable." +msgstr "允许查询缓存, 个别查询仍然需要被设置为可缓存的. " -#: index.docbook:771 +#. Tag: literal +#: configuration.xml:771 +#, no-c-format msgid "hibernate.cache.use_second_level_cache" -msgstr "" +msgstr "hibernate.cache.use_second_level_cache" -#: index.docbook:773 -msgid "May be used to completely disable the second level cache, which is enabled by default for classes which specify a <cache> mapping." +#. Tag: entry +#: configuration.xml:773 +#, fuzzy, no-c-format +msgid "" +"May be used to completely disable the second level cache, which is enabled " +"by default for classes which specify a <cache> " +"mapping." msgstr "" +"能用来完全禁止使用二级缓存. 对那些在类的映射定义中指定的类," +"会默认开启二级缓存. " -#: index.docbook:785 +#. Tag: literal +#: configuration.xml:785 +#, no-c-format msgid "hibernate.cache.query_cache_factory" -msgstr "" +msgstr "hibernate.cache.query_cache_factory" -#: index.docbook:787 -msgid "The classname of a custom QueryCache interface, defaults to the built-in StandardQueryCache." +#. Tag: entry +#: configuration.xml:787 +#, fuzzy, no-c-format +msgid "" +"The classname of a custom QueryCache interface, defaults " +"to the built-in StandardQueryCache." msgstr "" +"自定义实现接口的类名, 默认为内建的. " +"" -#: index.docbook:790 -msgid "eg. classname.of.QueryCache" +#. Tag: para +#: configuration.xml:790 +#, fuzzy, no-c-format +msgid "" +"eg. classname.of.QueryCache" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:798 +#. Tag: literal +#: configuration.xml:798 +#, no-c-format msgid "hibernate.cache.region_prefix" -msgstr "" +msgstr "hibernate.cache.region_prefix" -#: index.docbook:800 +#. Tag: entry +#: configuration.xml:800 +#, fuzzy, no-c-format msgid "A prefix to use for second-level cache region names." -msgstr "" +msgstr "二级缓存区域名的前缀. " -#: index.docbook:802 +#. Tag: para +#: configuration.xml:802 +#, fuzzy, no-c-format msgid "eg. prefix" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:810 +#. Tag: literal +#: configuration.xml:810 +#, no-c-format msgid "hibernate.cache.use_structured_entries" -msgstr "" +msgstr "hibernate.cache.use_structured_entries" -#: index.docbook:812 -msgid "Forces Hibernate to store data in the second-level cache in a more human-friendly format." -msgstr "" +#. Tag: entry +#: configuration.xml:812 +#, fuzzy, no-c-format +msgid "" +"Forces Hibernate to store data in the second-level cache in a more human-" +"friendly format." +msgstr "强制Hibernate以更人性化的格式将数据存入二级缓存. " -#: index.docbook:826 +#. Tag: title +#: configuration.xml:826 +#, no-c-format msgid "Hibernate Transaction Properties" -msgstr "" +msgstr "Hibernate事务属性" -#: index.docbook:839 +#. Tag: literal +#: configuration.xml:839 +#, no-c-format msgid "hibernate.transaction.factory_class" -msgstr "" +msgstr "hibernate.transaction.factory_class" -#: index.docbook:841 -msgid "The classname of a TransactionFactory to use with Hibernate Transaction API (defaults to JDBCTransactionFactory)." +#. Tag: entry +#: configuration.xml:841 +#, fuzzy, no-c-format +msgid "" +"The classname of a TransactionFactory to use with " +"Hibernate Transaction API (defaults to " +"JDBCTransactionFactory)." msgstr "" +"一个的类名, 用于Hibernate API (默认为" +"). " -#: index.docbook:845 -msgid "eg. classname.of.TransactionFactory" +#. Tag: para +#: configuration.xml:845 +#, fuzzy, no-c-format +msgid "" +"eg. classname.of." +"TransactionFactory" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:853 +#. Tag: literal +#: configuration.xml:853 +#, no-c-format msgid "jta.UserTransaction" -msgstr "" +msgstr "jta.UserTransaction" -#: index.docbook:855 -msgid "A JNDI name used by JTATransactionFactory to obtain the JTA UserTransaction from the application server." +#. Tag: entry +#: configuration.xml:855 +#, fuzzy, no-c-format +msgid "" +"A JNDI name used by JTATransactionFactory to obtain the " +"JTA UserTransaction from the application server." msgstr "" +"一个JNDI名字,被用来从应用服务器获取JTA . " +"" -#: index.docbook:867 +#. Tag: literal +#: configuration.xml:867 +#, no-c-format msgid "hibernate.transaction.manager_lookup_class" -msgstr "" +msgstr "hibernate.transaction.manager_lookup_class" -#: index.docbook:869 -msgid "The classname of a TransactionManagerLookup - required when JVM-level caching is enabled or when using hilo generator in a JTA environment." +#. Tag: entry +#: configuration.xml:869 +#, fuzzy, no-c-format +msgid "" +"The classname of a TransactionManagerLookup - required " +"when JVM-level caching is enabled or when using hilo generator in a JTA " +"environment." msgstr "" +"一个的类名 - 当使用JVM级缓存,或在JTA环境中使用hilo生成器的时" +"候需要该类. " -#: index.docbook:873 -msgid "eg. classname.of.TransactionManagerLookup" +#. Tag: para +#: configuration.xml:873 +#, fuzzy, no-c-format +msgid "" +"eg. classname.of." +"TransactionManagerLookup" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:881 +#. Tag: literal +#: configuration.xml:881 +#, no-c-format msgid "hibernate.transaction.flush_before_completion" -msgstr "" +msgstr "hibernate.transaction.flush_before_completion" -#: index.docbook:883 -msgid "If enabled, the session will be automatically flushed during the before completion phase of the transaction. Built-in and automatic session context management is preferred, see ." +#. Tag: entry +#: configuration.xml:883 +#, fuzzy, no-c-format +msgid "" +"If enabled, the session will be automatically flushed during the before " +"completion phase of the transaction. Built-in and automatic session context " +"management is preferred, see ." msgstr "" +"如果开启, session在事务完成后将被自动清洗(flush)。 现在更好的方法是使用自动" +"session上下文管理。请参见。 " +"" -#: index.docbook:896 +#. Tag: literal +#: configuration.xml:896 +#, no-c-format msgid "hibernate.transaction.auto_close_session" -msgstr "" +msgstr "hibernate.transaction.auto_close_session" -#: index.docbook:898 -msgid "If enabled, the session will be automatically closed during the after completion phase of the transaction. Built-in and utomatic session context management is preferred, see ." +#. Tag: entry +#: configuration.xml:898 +#, fuzzy, no-c-format +msgid "" +"If enabled, the session will be automatically closed during the after " +"completion phase of the transaction. Built-in and utomatic session context " +"management is preferred, see ." msgstr "" +"如果开启, session在事务完成后将被自动关闭。 现在更好的方法是使用自动session上" +"下文管理。请参见。 " +"" -#: index.docbook:914 +#. Tag: title +#: configuration.xml:914 +#, no-c-format msgid "Miscellaneous Properties" -msgstr "" +msgstr "其他属性" -#: index.docbook:927 +#. Tag: literal +#: configuration.xml:927 +#, no-c-format msgid "hibernate.current_session_context_class" -msgstr "" +msgstr "hibernate.current_session_context_class" -#: index.docbook:929 -msgid "Supply a (custom) strategy for the scoping of the \"current\" Session. See for more information about the built-in strategies." +#. Tag: entry +#: configuration.xml:929 +#, fuzzy, no-c-format +msgid "" +"Supply a (custom) strategy for the scoping of the \"current\" " +"Session. See for more information about the built-in strategies." msgstr "" +"为\"当前\" 指定一个(自定义的)策略。关于内置策略的详情,请参见" +"" -#: index.docbook:934 -msgid "eg. jta | thread | managed | custom.Class" +#. Tag: para +#: configuration.xml:934 +#, fuzzy, no-c-format +msgid "" +"eg. jta | " +"thread | managed | custom." +"Class" msgstr "" +"eg.jta | " +"thread | managed | custom." +"Class" -#: index.docbook:943 +#. Tag: literal +#: configuration.xml:943 +#, no-c-format msgid "hibernate.query.factory_class" -msgstr "" +msgstr "hibernate.query.factory_class" -#: index.docbook:945 +#. Tag: entry +#: configuration.xml:945 +#, fuzzy, no-c-format msgid "Chooses the HQL parser implementation." -msgstr "" +msgstr "选择HQL解析器的实现. " -#: index.docbook:947 -msgid "eg. org.hibernate.hql.ast.ASTQueryTranslatorFactory or org.hibernate.hql.classic.ClassicQueryTranslatorFactory" +#. Tag: para +#: configuration.xml:947 +#, fuzzy, no-c-format +msgid "" +"eg. org.hibernate.hql.ast." +"ASTQueryTranslatorFactory or org.hibernate.hql.classic." +"ClassicQueryTranslatorFactory" msgstr "" +"取值org.hibernate.hql.ast." +"ASTQueryTranslatorFactory or org.hibernate.hql.classic." +"ClassicQueryTranslatorFactory" -#: index.docbook:956 +#. Tag: literal +#: configuration.xml:956 +#, no-c-format msgid "hibernate.query.substitutions" -msgstr "" +msgstr "hibernate.query.substitutions" -#: index.docbook:958 -msgid "Mapping from tokens in Hibernate queries to SQL tokens (tokens might be function or literal names, for example)." +#. Tag: entry +#: configuration.xml:958 +#, fuzzy, no-c-format +msgid "" +"Mapping from tokens in Hibernate queries to SQL tokens (tokens might be " +"function or literal names, for example)." msgstr "" +"将Hibernate查询中的符号映射到SQL查询中的符号 (符号可能是函数名或常量名字). " +"" -#: index.docbook:961 -msgid "eg. hqlLiteral=SQL_LITERAL, hqlFunction=SQLFUNC" +#. Tag: para +#: configuration.xml:961 +#, fuzzy, no-c-format +msgid "" +"eg. hqlLiteral=SQL_LITERAL, " +"hqlFunction=SQLFUNC" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"eg.true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"取值true | " +"false" -#: index.docbook:969 +#. Tag: literal +#: configuration.xml:969 +#, no-c-format msgid "hibernate.hbm2ddl.auto" -msgstr "" +msgstr "hibernate.hbm2ddl.auto" -#: index.docbook:971 -msgid "Automatically validate or export schema DDL to the database when the SessionFactory is created. With create-drop, the database schema will be dropped when the SessionFactory is closed explicitly." +#. Tag: entry +#: configuration.xml:971 +#, fuzzy, no-c-format +msgid "" +"Automatically validate or export schema DDL to the database when the " +"SessionFactory is created. With create-drop, the database schema will be dropped when the " +"SessionFactory is closed explicitly." msgstr "" +"在创建时,自动检查数据库结构,或者将数据库schema的DDL导出到数" +"据库. 使用 时,在显式关闭时,将drop掉数据库" +"schema. " -#: index.docbook:977 -msgid "eg. validate | update | create | create-drop" +#. Tag: para +#: configuration.xml:977 +#, fuzzy, no-c-format +msgid "" +"eg. validate | " +"update | create | create-" +"drop" msgstr "" +"取值validate | " +"update | create | create-" +"drop" -#: index.docbook:986 +#. Tag: literal +#: configuration.xml:986 +#, no-c-format msgid "hibernate.cglib.use_reflection_optimizer" -msgstr "" +msgstr "hibernate.cglib.use_reflection_optimizer" -#: index.docbook:988 -msgid "Enables use of CGLIB instead of runtime reflection (System-level property). Reflection can sometimes be useful when troubleshooting, note that Hibernate always requires CGLIB even if you turn off the optimizer. You can not set this property in hibernate.cfg.xml." +#. Tag: entry +#: configuration.xml:988 +#, fuzzy, no-c-format +msgid "" +"Enables use of CGLIB instead of runtime reflection (System-level property). " +"Reflection can sometimes be useful when troubleshooting, note that Hibernate " +"always requires CGLIB even if you turn off the optimizer. You can not set " +"this property in hibernate.cfg.xml." msgstr "" +"开启CGLIB来替代运行时反射机制(系统级属性). 反射机制有时在除错时比较有用. 注意" +"即使关闭这个优化, Hibernate还是需要CGLIB. 你不能在中设置此属" +"性. " -#: index.docbook:1004 +#. Tag: title +#: configuration.xml:1004 +#, no-c-format msgid "SQL Dialects" -msgstr "" +msgstr "SQL方言" -#: index.docbook:1006 -msgid "You should always set the hibernate.dialect property to the correct org.hibernate.dialect.Dialect subclass for your database. If you specify a dialect, Hibernate will use sensible defaults for some of the other properties listed above, saving you the effort of specifying them manually." +#. Tag: para +#: configuration.xml:1006 +#, no-c-format +msgid "" +"You should always set the hibernate.dialect property to " +"the correct org.hibernate.dialect.Dialect subclass for " +"your database. If you specify a dialect, Hibernate will use sensible " +"defaults for some of the other properties listed above, saving you the " +"effort of specifying them manually." msgstr "" +"你应当总是为你的数据库将hibernate.dialect属性设置成正确的 " +"org.hibernate.dialect.Dialect子类. 如果你指定一种方言, " +"Hibernate将为上面列出的一些属性使用合理的默认值, 为你省去了手工指定它们的功" +"夫." -#: index.docbook:1014 +#. Tag: title +#: configuration.xml:1014 +#, no-c-format msgid "Hibernate SQL Dialects (hibernate.dialect)" -msgstr "" +msgstr "Hibernate SQL方言 (hibernate.dialect)" -#: index.docbook:1022 +#. Tag: entry +#: configuration.xml:1022 +#, no-c-format msgid "RDBMS" -msgstr "" +msgstr "RDBMS" -#: index.docbook:1023 +#. Tag: entry +#: configuration.xml:1023 +#, fuzzy, no-c-format msgid "Dialect" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"Dialect\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"方言" -#: index.docbook:1028 +#. Tag: entry +#: configuration.xml:1028 +#, no-c-format msgid "DB2" msgstr "" -#: index.docbook:1028 +#. Tag: literal +#: configuration.xml:1028 +#, no-c-format msgid "org.hibernate.dialect.DB2Dialect" -msgstr "" +msgstr "org.hibernate.dialect.DB2Dialect" -#: index.docbook:1031 +#. Tag: entry +#: configuration.xml:1031 +#, no-c-format msgid "DB2 AS/400" -msgstr "" +msgstr "DB2 AS/400" -#: index.docbook:1031 +#. Tag: literal +#: configuration.xml:1031 +#, no-c-format msgid "org.hibernate.dialect.DB2400Dialect" -msgstr "" +msgstr "org.hibernate.dialect.DB2400Dialect" -#: index.docbook:1034 +#. Tag: entry +#: configuration.xml:1034 +#, no-c-format msgid "DB2 OS390" -msgstr "" +msgstr "DB2 OS390" -#: index.docbook:1034 +#. Tag: literal +#: configuration.xml:1034 +#, no-c-format msgid "org.hibernate.dialect.DB2390Dialect" -msgstr "" +msgstr "org.hibernate.dialect.DB2390Dialect" -#: index.docbook:1037 +#. Tag: entry +#: configuration.xml:1037 +#, no-c-format msgid "PostgreSQL" -msgstr "" +msgstr "PostgreSQL" -#: index.docbook:1037 +#. Tag: literal +#: configuration.xml:1037 +#, no-c-format msgid "org.hibernate.dialect.PostgreSQLDialect" -msgstr "" +msgstr "org.hibernate.dialect.PostgreSQLDialect" -#: index.docbook:1040 +#. Tag: entry +#: configuration.xml:1040 +#, no-c-format msgid "MySQL" -msgstr "" +msgstr "MySQL" -#: index.docbook:1040 +#. Tag: literal +#: configuration.xml:1040 +#, no-c-format msgid "org.hibernate.dialect.MySQLDialect" -msgstr "" +msgstr "org.hibernate.dialect.MySQLDialect" -#: index.docbook:1043 +#. Tag: entry +#: configuration.xml:1043 +#, no-c-format msgid "MySQL with InnoDB" -msgstr "" +msgstr "MySQL with InnoDB" -#: index.docbook:1043 +#. Tag: literal +#: configuration.xml:1043 +#, no-c-format msgid "org.hibernate.dialect.MySQLInnoDBDialect" -msgstr "" +msgstr "org.hibernate.dialect.MySQLInnoDBDialect" -#: index.docbook:1046 +#. Tag: entry +#: configuration.xml:1046 +#, no-c-format msgid "MySQL with MyISAM" -msgstr "" +msgstr "MySQL with MyISAM" -#: index.docbook:1046 +#. Tag: literal +#: configuration.xml:1046 +#, no-c-format msgid "org.hibernate.dialect.MySQLMyISAMDialect" -msgstr "" +msgstr "org.hibernate.dialect.MySQLMyISAMDialect" -#: index.docbook:1049 +#. Tag: entry +#: configuration.xml:1049 +#, no-c-format msgid "Oracle (any version)" -msgstr "" +msgstr "Oracle (any version)" -#: index.docbook:1049 +#. Tag: literal +#: configuration.xml:1049 +#, no-c-format msgid "org.hibernate.dialect.OracleDialect" -msgstr "" +msgstr "org.hibernate.dialect.OracleDialect" -#: index.docbook:1052 +#. Tag: entry +#: configuration.xml:1052 +#, no-c-format msgid "Oracle 9i/10g" -msgstr "" +msgstr "Oracle 9i/10g" -#: index.docbook:1052 +#. Tag: literal +#: configuration.xml:1052 +#, no-c-format msgid "org.hibernate.dialect.Oracle9Dialect" -msgstr "" +msgstr "org.hibernate.dialect.Oracle9Dialect" -#: index.docbook:1055 +#. Tag: entry +#: configuration.xml:1055 +#, no-c-format msgid "Sybase" -msgstr "" +msgstr "Sybase" -#: index.docbook:1055 +#. Tag: literal +#: configuration.xml:1055 +#, no-c-format msgid "org.hibernate.dialect.SybaseDialect" -msgstr "" +msgstr "org.hibernate.dialect.SybaseDialect" -#: index.docbook:1058 +#. Tag: entry +#: configuration.xml:1058 +#, no-c-format msgid "Sybase Anywhere" -msgstr "" +msgstr "Sybase Anywhere" -#: index.docbook:1058 +#. Tag: literal +#: configuration.xml:1058 +#, no-c-format msgid "org.hibernate.dialect.SybaseAnywhereDialect" -msgstr "" +msgstr "org.hibernate.dialect.SybaseAnywhereDialect" -#: index.docbook:1061 +#. Tag: entry +#: configuration.xml:1061 +#, no-c-format msgid "Microsoft SQL Server" -msgstr "" +msgstr "Microsoft SQL Server" -#: index.docbook:1061 +#. Tag: literal +#: configuration.xml:1061 +#, no-c-format msgid "org.hibernate.dialect.SQLServerDialect" -msgstr "" +msgstr "org.hibernate.dialect.SQLServerDialect" -#: index.docbook:1064 +#. Tag: entry +#: configuration.xml:1064 +#, no-c-format msgid "SAP DB" -msgstr "" +msgstr "SAP DB" -#: index.docbook:1064 +#. Tag: literal +#: configuration.xml:1064 +#, no-c-format msgid "org.hibernate.dialect.SAPDBDialect" -msgstr "" +msgstr "org.hibernate.dialect.SAPDBDialect" -#: index.docbook:1067 +#. Tag: entry +#: configuration.xml:1067 +#, no-c-format msgid "Informix" -msgstr "" +msgstr "Informix" -#: index.docbook:1067 +#. Tag: literal +#: configuration.xml:1067 +#, no-c-format msgid "org.hibernate.dialect.InformixDialect" -msgstr "" +msgstr "org.hibernate.dialect.InformixDialect" -#: index.docbook:1070 +#. Tag: entry +#: configuration.xml:1070 +#, no-c-format msgid "HypersonicSQL" -msgstr "" +msgstr "HypersonicSQL" -#: index.docbook:1070 +#. Tag: literal +#: configuration.xml:1070 +#, no-c-format msgid "org.hibernate.dialect.HSQLDialect" -msgstr "" +msgstr "org.hibernate.dialect.HSQLDialect" -#: index.docbook:1073 +#. Tag: entry +#: configuration.xml:1073 +#, no-c-format msgid "Ingres" -msgstr "" +msgstr "Ingres" -#: index.docbook:1073 +#. Tag: literal +#: configuration.xml:1073 +#, no-c-format msgid "org.hibernate.dialect.IngresDialect" -msgstr "" +msgstr "org.hibernate.dialect.IngresDialect" -#: index.docbook:1076 +#. Tag: entry +#: configuration.xml:1076 +#, no-c-format msgid "Progress" -msgstr "" +msgstr "Progress" -#: index.docbook:1076 +#. Tag: literal +#: configuration.xml:1076 +#, no-c-format msgid "org.hibernate.dialect.ProgressDialect" -msgstr "" +msgstr "org.hibernate.dialect.ProgressDialect" -#: index.docbook:1079 +#. Tag: entry +#: configuration.xml:1079 +#, no-c-format msgid "Mckoi SQL" -msgstr "" +msgstr "Mckoi SQL" -#: index.docbook:1079 +#. Tag: literal +#: configuration.xml:1079 +#, no-c-format msgid "org.hibernate.dialect.MckoiDialect" -msgstr "" +msgstr "org.hibernate.dialect.MckoiDialect" -#: index.docbook:1082 +#. Tag: entry +#: configuration.xml:1082 +#, no-c-format msgid "Interbase" -msgstr "" +msgstr "Interbase" -#: index.docbook:1082 +#. Tag: literal +#: configuration.xml:1082 +#, no-c-format msgid "org.hibernate.dialect.InterbaseDialect" -msgstr "" +msgstr "org.hibernate.dialect.InterbaseDialect" -#: index.docbook:1085 +#. Tag: entry +#: configuration.xml:1085 +#, no-c-format msgid "Pointbase" -msgstr "" +msgstr "Pointbase" -#: index.docbook:1085 +#. Tag: literal +#: configuration.xml:1085 +#, no-c-format msgid "org.hibernate.dialect.PointbaseDialect" -msgstr "" +msgstr "org.hibernate.dialect.PointbaseDialect" -#: index.docbook:1088 +#. Tag: entry +#: configuration.xml:1088 +#, no-c-format msgid "FrontBase" -msgstr "" +msgstr "FrontBase" -#: index.docbook:1088 +#. Tag: literal +#: configuration.xml:1088 +#, no-c-format msgid "org.hibernate.dialect.FrontbaseDialect" -msgstr "" +msgstr "org.hibernate.dialect.FrontbaseDialect" -#: index.docbook:1091 +#. Tag: entry +#: configuration.xml:1091 +#, no-c-format msgid "Firebird" -msgstr "" +msgstr "Firebird" -#: index.docbook:1091 +#. Tag: literal +#: configuration.xml:1091 +#, no-c-format msgid "org.hibernate.dialect.FirebirdDialect" -msgstr "" +msgstr "org.hibernate.dialect.FirebirdDialect" -#: index.docbook:1100 +#. Tag: title +#: configuration.xml:1100 +#, no-c-format msgid "Outer Join Fetching" -msgstr "" +msgstr "外连接抓取(Outer Join Fetching)" -#: index.docbook:1102 -msgid "If your database supports ANSI, Oracle or Sybase style outer joins, outer join fetching will often increase performance by limiting the number of round trips to and from the database (at the cost of possibly more work performed by the database itself). Outer join fetching allows a whole graph of objects connected by many-to-one, one-to-many, many-to-many and one-to-one associations to be retrieved in a single SQL SELECT." +#. Tag: para +#: configuration.xml:1102 +#, no-c-format +msgid "" +"If your database supports ANSI, Oracle or Sybase style outer joins, " +"outer join fetching will often increase performance by " +"limiting the number of round trips to and from the database (at the cost of " +"possibly more work performed by the database itself). Outer join fetching " +"allows a whole graph of objects connected by many-to-one, one-to-many, many-" +"to-many and one-to-one associations to be retrieved in a single SQL " +"SELECT." msgstr "" +"如果你的数据库支持ANSI, Oracle或Sybase风格的外连接, 外连接抓取通常能通过限制往返数据库次数 (更多的工作交由数据库自己来完成)来提高" +"效率. 外连接抓取允许在单个SELECTSQL语句中, 通过many-to-" +"one, one-to-many, many-to-many和one-to-one关联获取连接对象的整个对象图." -#: index.docbook:1111 -msgid "Outer join fetching may be disabled globally by setting the property hibernate.max_fetch_depth to 0. A setting of 1 or higher enables outer join fetching for one-to-one and many-to-one associations which have been mapped with fetch=\"join\"." +#. Tag: para +#: configuration.xml:1111 +#, no-c-format +msgid "" +"Outer join fetching may be disabled globally by setting " +"the property hibernate.max_fetch_depth to 0. A setting of 1 or higher enables outer join " +"fetching for one-to-one and many-to-one associations which have been mapped " +"with fetch=\"join\"." msgstr "" +"将hibernate.max_fetch_depth设为0能在" +"全局 范围内禁止外连接抓取. 设为1或更" +"高值能启用one-to-one和many-to-oneouter关联的外连接抓取, 它们通过 " +"fetch=\"join\"来映射." -#: index.docbook:1119 +#. Tag: para +#: configuration.xml:1119 +#, no-c-format msgid "See for more information." -msgstr "" +msgstr "参见获得更多信息." -#: index.docbook:1126 +#. Tag: title +#: configuration.xml:1126 +#, no-c-format msgid "Binary Streams" -msgstr "" +msgstr "二进制流 (Binary Streams)" -#: index.docbook:1128 -msgid "Oracle limits the size of byte arrays that may be passed to/from its JDBC driver. If you wish to use large instances of binary or serializable type, you should enable hibernate.jdbc.use_streams_for_binary. This is a system-level setting only." +#. Tag: para +#: configuration.xml:1128 +#, no-c-format +msgid "" +"Oracle limits the size of byte arrays that may be passed " +"to/from its JDBC driver. If you wish to use large instances of " +"binary or serializable type, you " +"should enable hibernate.jdbc.use_streams_for_binary. " +"This is a system-level setting only." msgstr "" +"Oracle限制那些通过JDBC驱动传输的字节数组的数目. 如果你希望" +"使用二进值 (binary)可序列化的 (serializable)类型的大对象, 你应该开启 hibernate.jdbc." +"use_streams_for_binary属性. 这是系统级属性." -#: index.docbook:1139 +#. Tag: title +#: configuration.xml:1139 +#, no-c-format msgid "Second-level and query cache" -msgstr "" +msgstr "二级缓存与查询缓存" -#: index.docbook:1141 -msgid "The properties prefixed by hibernate.cache allow you to use a process or cluster scoped second-level cache system with Hibernate. See the for more details." +#. Tag: para +#: configuration.xml:1141 +#, no-c-format +msgid "" +"The properties prefixed by hibernate.cache allow you to " +"use a process or cluster scoped second-level cache system with Hibernate. " +"See the for more details." msgstr "" +"以hibernate.cache为前缀的属性允许你在Hibernate中,使用进程" +"或群集范围内的二级缓存系统. 参见获取更多" +"的详情." -#: index.docbook:1151 +#. Tag: title +#: configuration.xml:1151 +#, no-c-format msgid "Query Language Substitution" -msgstr "" +msgstr "查询语言中的替换" -#: index.docbook:1153 -msgid "You may define new Hibernate query tokens using hibernate.query.substitutions. For example:" +#. Tag: para +#: configuration.xml:1153 +#, no-c-format +msgid "" +"You may define new Hibernate query tokens using hibernate.query." +"substitutions. For example:" msgstr "" +"你可以使用hibernate.query.substitutions在Hibernate中定义新" +"的查询符号. 例如:" -#: index.docbook:1158 +#. Tag: programlisting +#: configuration.xml:1158 +#, no-c-format msgid "hibernate.query.substitutions true=1, false=0" -msgstr "" +msgstr "hibernate.query.substitutions true=1, false=0" -#: index.docbook:1160 -msgid "would cause the tokens true and false to be translated to integer literals in the generated SQL." +#. Tag: para +#: configuration.xml:1160 +#, no-c-format +msgid "" +"would cause the tokens true and false " +"to be translated to integer literals in the generated SQL." msgstr "" +"将导致符号truefalse在生成的SQL中被翻" +"译成整数常量." -#: index.docbook:1165 +#. Tag: programlisting +#: configuration.xml:1165 +#, no-c-format msgid "hibernate.query.substitutions toLowercase=LOWER" -msgstr "" +msgstr "hibernate.query.substitutions toLowercase=LOWER" -#: index.docbook:1167 +#. Tag: para +#: configuration.xml:1167 +#, no-c-format msgid "would allow you to rename the SQL LOWER function." -msgstr "" +msgstr "将允许你重命名SQL中的LOWER函数." -#: index.docbook:1174 +#. Tag: title +#: configuration.xml:1174 +#, no-c-format msgid "Hibernate statistics" -msgstr "" +msgstr "Hibernate的统计(statistics)机制" -#: index.docbook:1176 -msgid "If you enable hibernate.generate_statistics, Hibernate will expose a number of metrics that are useful when tuning a running system via SessionFactory.getStatistics(). Hibernate can even be configured to expose these statistics via JMX. Read the Javadoc of the interfaces in org.hibernate.stats for more information." +#. Tag: para +#: configuration.xml:1176 +#, no-c-format +msgid "" +"If you enable hibernate.generate_statistics, Hibernate " +"will expose a number of metrics that are useful when tuning a running system " +"via SessionFactory.getStatistics(). Hibernate can even be " +"configured to expose these statistics via JMX. Read the Javadoc of the " +"interfaces in org.hibernate.stats for more information." msgstr "" +"如果你开启hibernate.generate_statistics, 那么当你通过 " +"SessionFactory.getStatistics()调整正在运行的系统时," +"Hibernate将导出大量有用的数据. Hibernate甚至能被配置成通过JMX导出这些统计信" +"息. 参考org.hibernate.stats中接口的Javadoc,以获得更多信" +"息." -#: index.docbook:1188 +#. Tag: title +#: configuration.xml:1188 +#, no-c-format msgid "Logging" -msgstr "" +msgstr "日志" -#: index.docbook:1190 +#. Tag: para +#: configuration.xml:1190 +#, no-c-format msgid "Hibernate logs various events using Apache commons-logging." -msgstr "" +msgstr "Hibernate使用Apache commons-logging来为各种事件记录日志." -#: index.docbook:1194 -msgid "The commons-logging service will direct output to either Apache Log4j (if you include log4j.jar in your classpath) or JDK1.4 logging (if running under JDK1.4 or above). You may download Log4j from http://jakarta.apache.org. To use Log4j you will need to place a log4j.properties file in your classpath, an example properties file is distributed with Hibernate in the src/ directory." +#. Tag: para +#: configuration.xml:1194 +#, no-c-format +msgid "" +"The commons-logging service will direct output to either Apache Log4j (if " +"you include log4j.jar in your classpath) or JDK1.4 " +"logging (if running under JDK1.4 or above). You may download Log4j from " +"http://jakarta.apache.org. To use Log4j you will need to " +"place a log4j.properties file in your classpath, an " +"example properties file is distributed with Hibernate in the src/ directory." msgstr "" +"commons-logging将直接输出到Apache Log4j(如果在类路径中包括log4j." +"jar)或 JDK1.4 logging (如果运行在JDK1.4或以上的环境下). 你可以从" +"http://jakarta.apache.org 下载Log4j. 要使用Log4j,你需要将" +"log4j.properties文件放置在类路径下, 随Hibernate 一同分发的" +"样例属性文件在src/目录下." -#: index.docbook:1204 -msgid "We strongly recommend that you familiarize yourself with Hibernate's log messages. A lot of work has been put into making the Hibernate log as detailed as possible, without making it unreadable. It is an essential troubleshooting device. The most interesting log categories are the following:" +#. Tag: para +#: configuration.xml:1204 +#, no-c-format +msgid "" +"We strongly recommend that you familiarize yourself with Hibernate's log " +"messages. A lot of work has been put into making the Hibernate log as " +"detailed as possible, without making it unreadable. It is an essential " +"troubleshooting device. The most interesting log categories are the " +"following:" msgstr "" +"我们强烈建议你熟悉一下Hibernate的日志消息. 在不失可读性的前提下, 我们做了很" +"多工作,使Hibernate的日志可能地详细. 这是必要的查错利器. 最令人感兴趣的日志分" +"类有如下这些:" -#: index.docbook:1213 +#. Tag: title +#: configuration.xml:1213 +#, no-c-format msgid "Hibernate Log Categories" -msgstr "" +msgstr "Hibernate日志类别" -#: index.docbook:1219 +#. Tag: entry +#: configuration.xml:1219 +#, no-c-format msgid "Category" -msgstr "" +msgstr "类别" -#: index.docbook:1220 +#. Tag: entry +#: configuration.xml:1220 +#, no-c-format msgid "Function" -msgstr "" +msgstr "功能" -#: index.docbook:1225 +#. Tag: literal +#: configuration.xml:1225 +#, no-c-format msgid "org.hibernate.SQL" -msgstr "" +msgstr "org.hibernate.SQL" -#: index.docbook:1226 +#. Tag: entry +#: configuration.xml:1226 +#, no-c-format msgid "Log all SQL DML statements as they are executed" -msgstr "" +msgstr "在所有SQL DML语句被执行时为它们记录日志" -#: index.docbook:1229 +#. Tag: literal +#: configuration.xml:1229 +#, no-c-format msgid "org.hibernate.type" -msgstr "" +msgstr "org.hibernate.type" -#: index.docbook:1230 +#. Tag: entry +#: configuration.xml:1230 +#, no-c-format msgid "Log all JDBC parameters" -msgstr "" +msgstr "为所有JDBC参数记录日志" -#: index.docbook:1233 +#. Tag: literal +#: configuration.xml:1233 +#, no-c-format msgid "org.hibernate.tool.hbm2ddl" -msgstr "" +msgstr "org.hibernate.tool.hbm2ddl" -#: index.docbook:1234 +#. Tag: entry +#: configuration.xml:1234 +#, no-c-format msgid "Log all SQL DDL statements as they are executed" -msgstr "" +msgstr "在所有SQL DDL语句执行时为它们记录日志" -#: index.docbook:1237 +#. Tag: literal +#: configuration.xml:1237 +#, no-c-format msgid "org.hibernate.pretty" -msgstr "" +msgstr "org.hibernate.pretty" -#: index.docbook:1238 -msgid "Log the state of all entities (max 20 entities) associated with the session at flush time" -msgstr "" +#. Tag: entry +#: configuration.xml:1238 +#, no-c-format +msgid "" +"Log the state of all entities (max 20 entities) associated with the session " +"at flush time" +msgstr "在session清洗(flush)时,为所有与其关联的实体(最多20个)的状态记录日志" -#: index.docbook:1244 +#. Tag: literal +#: configuration.xml:1244 +#, no-c-format msgid "org.hibernate.cache" -msgstr "" +msgstr "org.hibernate.cache" -#: index.docbook:1245 +#. Tag: entry +#: configuration.xml:1245 +#, no-c-format msgid "Log all second-level cache activity" -msgstr "" +msgstr "为所有二级缓存的活动记录日志" -#: index.docbook:1248 +#. Tag: literal +#: configuration.xml:1248 +#, no-c-format msgid "org.hibernate.transaction" -msgstr "" +msgstr "org.hibernate.transaction" -#: index.docbook:1249 +#. Tag: entry +#: configuration.xml:1249 +#, no-c-format msgid "Log transaction related activity" -msgstr "" +msgstr "为事务相关的活动记录日志" -#: index.docbook:1252 +#. Tag: literal +#: configuration.xml:1252 +#, no-c-format msgid "org.hibernate.jdbc" -msgstr "" +msgstr "org.hibernate.jdbc" -#: index.docbook:1253 +#. Tag: entry +#: configuration.xml:1253 +#, no-c-format msgid "Log all JDBC resource acquisition" -msgstr "" +msgstr "为所有JDBC资源的获取记录日志" -#: index.docbook:1256 +#. Tag: literal +#: configuration.xml:1256 +#, no-c-format msgid "org.hibernate.hql.ast.AST" -msgstr "" +msgstr "org.hibernate.hql.AST" -#: index.docbook:1257 +#. Tag: entry +#: configuration.xml:1257 +#, no-c-format msgid "Log HQL and SQL ASTs during query parsing" -msgstr "" +msgstr "在解析查询的时候,记录HQL和SQL的AST分析日志" -#: index.docbook:1262 +#. Tag: literal +#: configuration.xml:1262 +#, no-c-format msgid "org.hibernate.secure" -msgstr "" +msgstr "org.hibernate.secure" -#: index.docbook:1263 +#. Tag: entry +#: configuration.xml:1263 +#, no-c-format msgid "Log all JAAS authorization requests" -msgstr "" +msgstr "为JAAS认证请求做日志" -#: index.docbook:1266 +#. Tag: literal +#: configuration.xml:1266 +#, no-c-format msgid "org.hibernate" -msgstr "" +msgstr "org.hibernate" -#: index.docbook:1267 -msgid "Log everything (a lot of information, but very useful for troubleshooting)" -msgstr "" +#. Tag: entry +#: configuration.xml:1267 +#, no-c-format +msgid "" +"Log everything (a lot of information, but very useful for troubleshooting)" +msgstr "为任何Hibernate相关信息做日志 (信息量较大, 但对查错非常有帮助)" -#: index.docbook:1276 -msgid "When developing applications with Hibernate, you should almost always work with debug enabled for the category org.hibernate.SQL, or, alternatively, the property hibernate.show_sql enabled." +#. Tag: para +#: configuration.xml:1276 +#, no-c-format +msgid "" +"When developing applications with Hibernate, you should almost always work " +"with debug enabled for the category org." +"hibernate.SQL, or, alternatively, the property hibernate." +"show_sql enabled." msgstr "" +"在使用Hibernate开发应用程序时, 你应当总是为org.hibernate.SQL 开启debug级别的日志记录,或者开启" +"hibernate.show_sql属性。" -#: index.docbook:1286 +#. Tag: title +#: configuration.xml:1286 +#, no-c-format msgid "Implementing a NamingStrategy" -msgstr "" +msgstr "实现NamingStrategy" -#: index.docbook:1288 -msgid "The interface org.hibernate.cfg.NamingStrategy allows you to specify a \"naming standard\" for database objects and schema elements." -msgstr "" - -#: index.docbook:1293 -msgid "You may provide rules for automatically generating database identifiers from Java identifiers or for processing \"logical\" column and table names given in the mapping file into \"physical\" table and column names. This feature helps reduce the verbosity of the mapping document, eliminating repetitive noise (TBL_ prefixes, for example). The default strategy used by Hibernate is quite minimal." -msgstr "" - -#: index.docbook:1302 -msgid "You may specify a different strategy by calling Configuration.setNamingStrategy() before adding mappings:" -msgstr "" - -#: index.docbook:1307 +#. Tag: para +#: configuration.xml:1288 +#, no-c-format msgid "" - "" +"The interface org.hibernate.cfg.NamingStrategy allows you " +"to specify a \"naming standard\" for database objects and schema elements." +msgstr "" +"org.hibernate.cfg.NamingStrategy接口允许你为数据库中的对象" +"和schema 元素指定一个“命名标准”." + +#. Tag: para +#: configuration.xml:1293 +#, no-c-format +msgid "" +"You may provide rules for automatically generating database identifiers from " +"Java identifiers or for processing \"logical\" column and table names given " +"in the mapping file into \"physical\" table and column names. This feature " +"helps reduce the verbosity of the mapping document, eliminating repetitive " +"noise (TBL_ prefixes, for example). The default strategy " +"used by Hibernate is quite minimal." +msgstr "" +"你可能会提供一些通过Java标识生成数据库标识或将映射定义文件中\"逻辑\"表/列名处" +"理成\"物理\"表/列名的规则. 这个特性有助于减少冗长的映射定义文件." + +#. Tag: para +#: configuration.xml:1302 +#, no-c-format +msgid "" +"You may specify a different strategy by calling Configuration." +"setNamingStrategy() before adding mappings:" +msgstr "" +"在加入映射定义前,你可以调用 Configuration.setNamingStrategy()指定一个不同的命名策略:" + +#. Tag: programlisting +#: configuration.xml:1307 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:1309 -msgid "org.hibernate.cfg.ImprovedNamingStrategy is a built-in strategy that might be a useful starting point for some applications." +#. Tag: para +#: configuration.xml:1309 +#, no-c-format +msgid "" +"org.hibernate.cfg.ImprovedNamingStrategy is a built-in " +"strategy that might be a useful starting point for some applications." msgstr "" +"org.hibernate.cfg.ImprovedNamingStrategy是一个内建的命名策" +"略, 对 一些应用程序而言,可能是非常有用的起点." -#: index.docbook:1317 +#. Tag: title +#: configuration.xml:1317 +#, no-c-format msgid "XML configuration file" -msgstr "" +msgstr "XML配置文件" -#: index.docbook:1319 -msgid "An alternative approach to configuration is to specify a full configuration in a file named hibernate.cfg.xml. This file can be used as a replacement for the hibernate.properties file or, if both are present, to override properties." -msgstr "" - -#: index.docbook:1326 -msgid "The XML configuration file is by default expected to be in the root o your CLASSPATH. Here is an example:" -msgstr "" - -#: index.docbook:1331 +#. Tag: para +#: configuration.xml:1319 +#, no-c-format msgid "" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - " \n" - "\n" - " \n" - " java:/comp/env/jdbc/MyDB\n" - " org.hibernate.dialect.MySQLDialect\n" - " false\n" - " \n" - " org.hibernate.transaction.JTATransactionFactory\n" - " \n" - " java:comp/UserTransaction\n" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - "\n" - "]]>" +"An alternative approach to configuration is to specify a full configuration " +"in a file named hibernate.cfg.xml. This file can be used " +"as a replacement for the hibernate.properties file or, if " +"both are present, to override properties." +msgstr "" +"另一个配置方法是在hibernate.cfg.xml文件中指定一套完整的配" +"置. 这个文件可以当成hibernate.properties的替代。 若两个文" +"件同时存在,它将覆盖前者的属性." + +#. Tag: para +#: configuration.xml:1326 +#, no-c-format +msgid "" +"The XML configuration file is by default expected to be in the root o your " +"CLASSPATH. Here is an example:" +msgstr "" +"XML配置文件被默认是放在CLASSPATH的根目录下. 这是一个例子:" + +#. Tag: programlisting +#: configuration.xml:1331 +#, no-c-format +msgid "" +"\n" +"\n" +"\n" +"\n" +"\n" +" \n" +" \n" +"\n" +" \n" +" java:/comp/env/jdbc/MyDB\n" +" org.hibernate.dialect.MySQLDialect\n" +" false\n" +" \n" +" org.hibernate.transaction.JTATransactionFactory\n" +" \n" +" java:comp/UserTransaction\n" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:1333 -msgid "As you can see, the advantage of this approach is the externalization of the mapping file names to configuration. The hibernate.cfg.xml is also more convenient once you have to tune the Hibernate cache. Note that is your choice to use either hibernate.properties or hibernate.cfg.xml, both are equivalent, except for the above mentioned benefits of using the XML syntax." +#. Tag: para +#: configuration.xml:1333 +#, no-c-format +msgid "" +"As you can see, the advantage of this approach is the externalization of the " +"mapping file names to configuration. The hibernate.cfg.xml is also more convenient once you have to tune the Hibernate cache. " +"Note that is your choice to use either hibernate.properties or hibernate.cfg.xml, both are equivalent, " +"except for the above mentioned benefits of using the XML syntax." msgstr "" +"如你所见, 这个方法优势在于,在配置文件中指出了映射定义文件的名字. 一旦你需要" +"调整Hibernate的缓存, hibernate.cfg.xml也是更方便. 注意," +"使用hibernate.properties还是 hibernate.cfg.xml完全是由你来决定, 除了上面提到的XML语法的优势之外, 两者是等价的." -#: index.docbook:1342 +#. Tag: para +#: configuration.xml:1342 +#, no-c-format msgid "With the XML configuration, starting Hibernate is then as simple as" msgstr "" +"使用XML配置,使得启动Hibernate变的异常简单, 如下所示,一行代码就可以搞定:" -#: index.docbook:1346 -msgid "" +#. Tag: programlisting +#: configuration.xml:1346 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:1348 +#. Tag: para +#: configuration.xml:1348 +#, no-c-format msgid "You can pick a different XML configuration file using" -msgstr "" +msgstr "你可以使用如下代码来添加一个不同的XML配置文件" -#: index.docbook:1352 +#. Tag: programlisting +#: configuration.xml:1352 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:1357 +#. Tag: title +#: configuration.xml:1357 +#, no-c-format msgid "J2EE Application Server integration" -msgstr "" +msgstr "J2EE应用程序服务器的集成" -#: index.docbook:1359 +#. Tag: para +#: configuration.xml:1359 +#, no-c-format msgid "Hibernate has the following integration points for J2EE infrastructure:" -msgstr "" +msgstr "针对J2EE体系,Hibernate有如下几个集成的方面:" -#: index.docbook:1365 -msgid "Container-managed datasources: Hibernate can use JDBC connections managed by the container and provided through JNDI. Usually, a JTA compatible TransactionManager and a ResourceManager take care of transaction management (CMT), esp. distributed transaction handling across several datasources. You may of course also demarcate transaction boundaries programmatically (BMT) or you might want to use the optional Hibernate Transaction API for this to keep your code portable." -msgstr "" - -#: index.docbook:1380 -msgid "Automatic JNDI binding: Hibernate can bind its SessionFactory to JNDI after startup." -msgstr "" - -#: index.docbook:1389 -msgid "JTA Session binding: The Hibernate Session may be automatically bound to the scope of JTA transactions. Simply lookup the SessionFactory from JNDI and get the current Session. Let Hibernate take care of flushing and closing the Session when your JTA transaction completes. Transaction demarcation is either declarative (CMT) or programmatic (BMT/UserTransaction)." -msgstr "" - -#: index.docbook:1402 -msgid "JMX deployment: If you have a JMX capable application server (e.g. JBoss AS), you can chose to deploy Hibernate as a managed MBean. This saves you the one line startup code to build your SessionFactory from a Configuration. The container will startup your HibernateService, and ideally also take care of service dependencies (Datasource has to be available before Hibernate starts, etc)." -msgstr "" - -#: index.docbook:1413 -msgid "Depending on your environment, you might have to set the configuration option hibernate.connection.aggressive_release to true if your application server shows \"connection containment\" exceptions." -msgstr "" - -#: index.docbook:1420 -msgid "Transaction strategy configuration" -msgstr "" - -#: index.docbook:1422 -msgid "The Hibernate Session API is independent of any transaction demarcation system in your architecture. If you let Hibernate use JDBC directly, through a connection pool, you may begin and end your transactions by calling the JDBC API. If you run in a J2EE application server, you might want to use bean-managed transactions and call the JTA API and UserTransaction when needed." -msgstr "" - -#: index.docbook:1430 -msgid "To keep your code portable between these two (and other) environments we recommend the optional Hibernate Transaction API, which wraps and hides the underlying system. You have to specify a factory class for Transaction instances by setting the Hibernate configuration property hibernate.transaction.factory_class." -msgstr "" - -#: index.docbook:1437 -msgid "There are three standard (built-in) choices:" -msgstr "" - -#: index.docbook:1443 -msgid "org.hibernate.transaction.JDBCTransactionFactory" -msgstr "" - -#: index.docbook:1445 -msgid "delegates to database (JDBC) transactions (default)" -msgstr "" - -#: index.docbook:1449 -msgid "org.hibernate.transaction.JTATransactionFactory" -msgstr "" - -#: index.docbook:1451 -msgid "delegates to container-managed transaction if an existing transaction is underway in this context (e.g. EJB session bean method), otherwise a new transaction is started and bean-managed transaction are used." -msgstr "" - -#: index.docbook:1459 -msgid "org.hibernate.transaction.CMTTransactionFactory" -msgstr "" - -#: index.docbook:1461 -msgid "delegates to container-managed JTA transactions" -msgstr "" - -#: index.docbook:1466 -msgid "You may also define your own transaction strategies (for a CORBA transaction service, for example)." -msgstr "" - -#: index.docbook:1471 -msgid "Some features in Hibernate (i.e. the second level cache, Contextual Sessions with JTA, etc.) require access to the JTA TransactionManager in a managed environment. In an application server you have to specify how Hibernate should obtain a reference to the TransactionManager, since J2EE does not standardize a single mechanism:" -msgstr "" - -#: index.docbook:1479 -msgid "JTA TransactionManagers" -msgstr "" - -#: index.docbook:1485 -msgid "Transaction Factory" -msgstr "" - -#: index.docbook:1486 -msgid "Application Server" -msgstr "" - -#: index.docbook:1491 -msgid "org.hibernate.transaction.JBossTransactionManagerLookup" -msgstr "" - -#: index.docbook:1492 -msgid "JBoss" -msgstr "" - -#: index.docbook:1495 -msgid "org.hibernate.transaction.WeblogicTransactionManagerLookup" -msgstr "" - -#: index.docbook:1496 -msgid "Weblogic" -msgstr "" - -#: index.docbook:1499 -msgid "org.hibernate.transaction.WebSphereTransactionManagerLookup" -msgstr "" - -#: index.docbook:1500 -msgid "WebSphere" -msgstr "" - -#: index.docbook:1503 -msgid "org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" -msgstr "" - -#: index.docbook:1504 -msgid "WebSphere 6" -msgstr "" - -#: index.docbook:1507 -msgid "org.hibernate.transaction.OrionTransactionManagerLookup" -msgstr "" - -#: index.docbook:1508 -msgid "Orion" -msgstr "" - -#: index.docbook:1511 -msgid "org.hibernate.transaction.ResinTransactionManagerLookup" -msgstr "" - -#: index.docbook:1512 -msgid "Resin" -msgstr "" - -#: index.docbook:1515 -msgid "org.hibernate.transaction.JOTMTransactionManagerLookup" -msgstr "" - -#: index.docbook:1516 -msgid "JOTM" -msgstr "" - -#: index.docbook:1519 -msgid "org.hibernate.transaction.JOnASTransactionManagerLookup" -msgstr "" - -#: index.docbook:1520 -msgid "JOnAS" -msgstr "" - -#: index.docbook:1523 -msgid "org.hibernate.transaction.JRun4TransactionManagerLookup" -msgstr "" - -#: index.docbook:1524 -msgid "JRun4" -msgstr "" - -#: index.docbook:1527 -msgid "org.hibernate.transaction.BESTransactionManagerLookup" -msgstr "" - -#: index.docbook:1528 -msgid "Borland ES" -msgstr "" - -#: index.docbook:1537 -msgid "JNDI-bound SessionFactory" -msgstr "" - -#: index.docbook:1539 -msgid "A JNDI bound Hibernate SessionFactory can simplify the lookup of the factory and the creation of new Sessions. Note that this is not related to a JNDI bound Datasource, both simply use the same registry!" -msgstr "" - -#: index.docbook:1546 -msgid "If you wish to have the SessionFactory bound to a JNDI namespace, specify a name (eg. java:hibernate/SessionFactory) using the property hibernate.session_factory_name. If this property is omitted, the SessionFactory will not be bound to JNDI. (This is especially useful in environments with a read-only JNDI default implementation, e.g. Tomcat.)" -msgstr "" - -#: index.docbook:1554 -msgid "When binding the SessionFactory to JNDI, Hibernate will use the values of hibernate.jndi.url, hibernate.jndi.class to instantiate an initial context. If they are not specified, the default InitialContext will be used." -msgstr "" - -#: index.docbook:1561 -msgid "Hibernate will automatically place the SessionFactory in JNDI after you call cfg.buildSessionFactory(). This means you will at least have this call in some startup code (or utility class) in your application, unless you use JMX deployment with the HibernateService (discussed later)." -msgstr "" - -#: index.docbook:1568 -msgid "If you use a JNDI SessionFactory, an EJB or any other class may obtain the SessionFactory using a JNDI lookup." -msgstr "" - -#: index.docbook:1573 -msgid "We recommend that you bind the SessionFactory to JNDI in a managed environment and use a static singleton otherwise. To shield your application code from these details, we also recommend to hide the actual lookup code for a SessionFactory in a helper class, such as HibernateUtil.getSessionFactory(). Note that such a class is also a convenient way to startup Hibernate—see chapter 1." -msgstr "" - -#: index.docbook:1585 -msgid "Current Session context management with JTA" -msgstr "" - -#: index.docbook:1587 -msgid "The easiest way to handle Sessions and transactions is Hibernates automatic \"current\" Session management. See the discussion of current sessions. Using the \"jta\" session context, if there is no Hibernate Session associated with the current JTA transaction, one will be started and associated with that JTA transaction the first time you call sessionFactory.getCurrentSession(). The Sessions retrieved via getCurrentSession() in \"jta\" context will be set to automatically flush before the transaction completes, close after the transaction completes, and aggressively release JDBC connections after each statement. This allows the Sessions to be managed by the life cycle of the JTA transaction to which it is associated, keeping user code clean of such management concerns. Your code can either use JTA programmatically through UserTransaction, or (recommended for portable code) use the Hibernate Transaction API to set transaction boundaries. If you run in an EJB container, declarative transaction demarcation with CMT is preferred." -msgstr "" - -#: index.docbook:1610 -msgid "JMX deployment" -msgstr "" - -#: index.docbook:1612 -msgid "The line cfg.buildSessionFactory() still has to be executed somewhere to get a SessionFactory into JNDI. You can do this either in a static initializer block (like the one in HibernateUtil) or you deploy Hibernate as a managed service." -msgstr "" - -#: index.docbook:1620 -msgid "Hibernate is distributed with org.hibernate.jmx.HibernateService for deployment on an application server with JMX capabilities, such as JBoss AS. The actual deployment and configuration is vendor specific. Here is an example jboss-service.xml for JBoss 4.0.x:" -msgstr "" - -#: index.docbook:1627 +#. Tag: para +#: configuration.xml:1365 +#, no-c-format msgid "" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - " jboss.jca:service=RARDeployer\n" - " jboss.jca:service=LocalTxCM,name=HsqlDS\n" - "\n" - " \n" - " java:/hibernate/SessionFactory\n" - "\n" - " \n" - " java:HsqlDS\n" - " org.hibernate.dialect.HSQLDialect\n" - "\n" - " \n" - " \n" - " org.hibernate.transaction.JTATransactionFactory\n" - " \n" - " org.hibernate.transaction.JBossTransactionManagerLookup\n" - " true\n" - " true\n" - "\n" - " \n" - " 5\n" - "\n" - " \n" - " true\n" - " org.hibernate.cache.EhCacheProvider\n" - " true\n" - "\n" - " \n" - " true\n" - "\n" - " \n" - " auction/Item.hbm.xml,auction/Category.hbm.xml\n" - "\n" - "\n" - "\n" - "]]>" +"Container-managed datasources: Hibernate can use JDBC " +"connections managed by the container and provided through JNDI. Usually, a " +"JTA compatible TransactionManager and a " +"ResourceManager take care of transaction management " +"(CMT), esp. distributed transaction handling across several datasources. You " +"may of course also demarcate transaction boundaries programmatically (BMT) " +"or you might want to use the optional Hibernate Transaction API for this to keep your code portable." +msgstr "" +"容器管理的数据源(Container-managed datasources): " +"Hibernate能使用通过容器管理,并由JNDI提供的JDBC连接. 通常, 特别是当处理多个数" +"据源的分布式事务的时候, 由一个JTA兼容的TransactionManager" +"和一个 ResourceManager来处理事务管理(CMT, 容器管理的事" +"务). 当然你可以通过 编程方式来划分事务边界(BMT, Bean管理的事务). 或者为了代码" +"的可移植性,你也也许会想使用可选的 Hibernate Transaction " +"API." + +#. Tag: para +#: configuration.xml:1380 +#, no-c-format +msgid "" +"Automatic JNDI binding: Hibernate can bind its " +"SessionFactory to JNDI after startup." +msgstr "" +"自动JNDI绑定: Hibernate可以在启动后将 " +"SessionFactory绑定到JNDI." + +#. Tag: para +#: configuration.xml:1389 +#, no-c-format +msgid "" +"JTA Session binding: The Hibernate Session may be automatically bound to the scope of JTA transactions. Simply " +"lookup the SessionFactory from JNDI and get the current " +"Session. Let Hibernate take care of flushing and closing " +"the Session when your JTA transaction completes. " +"Transaction demarcation is either declarative (CMT) or programmatic (BMT/" +"UserTransaction)." +msgstr "" +"JTA Session绑定: Hibernate Session 可" +"以自动绑定到JTA事务作用的范围. 只需简单地从JNDI查找SessionFactory并获得当前的 Session. 当JTA事务完成时, 让Hibernate" +"来处理 Session的清洗(flush)与关闭. 事务的划分可以是声明式" +"的(CMT),也可以是编程式的(BMT/UserTransaction)." + +#. Tag: para +#: configuration.xml:1402 +#, no-c-format +msgid "" +"JMX deployment: If you have a JMX capable application " +"server (e.g. JBoss AS), you can chose to deploy Hibernate as a managed " +"MBean. This saves you the one line startup code to build your " +"SessionFactory from a Configuration. " +"The container will startup your HibernateService, and " +"ideally also take care of service dependencies (Datasource has to be " +"available before Hibernate starts, etc)." +msgstr "" +"JMX部署: 如果你使用支持JMX应用程序服务器(如, JBoss AS), " +"那么你可以选择将Hibernate部署成托管MBean. 这将为你省去一行从" +"Configuration构建SessionFactory的启动代" +"码. 容器将启动你的HibernateService, 并完美地处理好服务间的" +"依赖关系 (在Hibernate启动前,数据源必须是可用的,等等)." + +#. Tag: para +#: configuration.xml:1413 +#, no-c-format +msgid "" +"Depending on your environment, you might have to set the configuration " +"option hibernate.connection.aggressive_release to true if " +"your application server shows \"connection containment\" exceptions." +msgstr "" +"如果应用程序服务器抛出\"connection containment\"异常, 根据你的环境,也许该将" +"配置属性 hibernate.connection.release_mode设为" +"after_statement." + +#. Tag: title +#: configuration.xml:1420 +#, no-c-format +msgid "Transaction strategy configuration" +msgstr "事务策略配置" + +#. Tag: para +#: configuration.xml:1422 +#, no-c-format +msgid "" +"The Hibernate Session API is independent of any " +"transaction demarcation system in your architecture. If you let Hibernate " +"use JDBC directly, through a connection pool, you may begin and end your " +"transactions by calling the JDBC API. If you run in a J2EE application " +"server, you might want to use bean-managed transactions and call the JTA API " +"and UserTransaction when needed." +msgstr "" +"在你的架构中,Hibernate的Session API是独立于任何事务分界系" +"统的. 如果你让Hibernate通过连接池直接使用JDBC, 你需要调用JDBC API来打开和关闭" +"你的事务. 如果你运行在J2EE应用程序服务器中, 你也许想用Bean管理的事务并在需要" +"的时候调用JTA API和UserTransaction." + +#. Tag: para +#: configuration.xml:1430 +#, no-c-format +msgid "" +"To keep your code portable between these two (and other) environments we " +"recommend the optional Hibernate Transaction API, which " +"wraps and hides the underlying system. You have to specify a factory class " +"for Transaction instances by setting the Hibernate " +"configuration property hibernate.transaction.factory_class." +msgstr "" +"为了让你的代码在两种(或其他)环境中可以移植,我们建议使用可选的Hibernate " +"Transaction API, 它包装并隐藏了底层系统. 你必须通过设置" +"Hibernate配置属性hibernate.transaction.factory_class来指" +"定 一个Transaction实例的工厂类." + +#. Tag: para +#: configuration.xml:1437 +#, no-c-format +msgid "There are three standard (built-in) choices:" +msgstr "有三个标准(内建)的选择:" + +#. Tag: literal +#: configuration.xml:1443 +#, no-c-format +msgid "org.hibernate.transaction.JDBCTransactionFactory" +msgstr "org.hibernate.transaction.JDBCTransactionFactory" + +#. Tag: para +#: configuration.xml:1445 +#, no-c-format +msgid "delegates to database (JDBC) transactions (default)" +msgstr "委托给数据库(JDBC)事务(默认)" + +#. Tag: literal +#: configuration.xml:1449 +#, no-c-format +msgid "org.hibernate.transaction.JTATransactionFactory" +msgstr "org.hibernate.transaction.JTATransactionFactory" + +#. Tag: para +#: configuration.xml:1451 +#, no-c-format +msgid "" +"delegates to container-managed transaction if an existing transaction is " +"underway in this context (e.g. EJB session bean method), otherwise a new " +"transaction is started and bean-managed transaction are used." +msgstr "" +"如果在上下文环境中存在运行着的事务(如, EJB会话Bean的方法), 则委托给容器管 理" +"的事务, 否则,将启动一个新的事务,并使用Bean管理的事务." + +#. Tag: literal +#: configuration.xml:1459 +#, no-c-format +msgid "org.hibernate.transaction.CMTTransactionFactory" +msgstr "org.hibernate.transaction.CMTTransactionFactory" + +#. Tag: para +#: configuration.xml:1461 +#, no-c-format +msgid "delegates to container-managed JTA transactions" +msgstr "委托给容器管理的JTA事务" + +#. Tag: para +#: configuration.xml:1466 +#, no-c-format +msgid "" +"You may also define your own transaction strategies (for a CORBA transaction " +"service, for example)." +msgstr "你也可以定义属于你自己的事务策略 (如, 针对CORBA的事务服务)" + +#. Tag: para +#: configuration.xml:1471 +#, no-c-format +msgid "" +"Some features in Hibernate (i.e. the second level cache, Contextual Sessions " +"with JTA, etc.) require access to the JTA TransactionManager in a managed environment. In an application server you have to " +"specify how Hibernate should obtain a reference to the " +"TransactionManager, since J2EE does not standardize a " +"single mechanism:" +msgstr "" +"Hibernate的一些特性 (比如二级缓存, Contextual Sessions with JTA等等)需要访问" +"在托管环境中的JTA TransactionManager. 由于J2EE没有标准化一" +"个单一的机制,Hibernate在应用程序服务器中,你必须指定Hibernate如何获得" +"TransactionManager的引用:" + +#. Tag: title +#: configuration.xml:1479 +#, no-c-format +msgid "JTA TransactionManagers" +msgstr "JTA TransactionManagers" + +#. Tag: entry +#: configuration.xml:1485 +#, no-c-format +msgid "Transaction Factory" +msgstr "Transaction工厂类" + +#. Tag: entry +#: configuration.xml:1486 +#, no-c-format +msgid "Application Server" +msgstr "应用程序服务器" + +#. Tag: literal +#: configuration.xml:1491 +#, no-c-format +msgid "org.hibernate.transaction.JBossTransactionManagerLookup" +msgstr "org.hibernate.transaction.JBossTransactionManagerLookup" + +#. Tag: entry +#: configuration.xml:1492 +#, no-c-format +msgid "JBoss" +msgstr "JBoss" + +#. Tag: literal +#: configuration.xml:1495 +#, no-c-format +msgid "org.hibernate.transaction.WeblogicTransactionManagerLookup" +msgstr "org.hibernate.transaction.WeblogicTransactionManagerLookup" + +#. Tag: entry +#: configuration.xml:1496 +#, no-c-format +msgid "Weblogic" +msgstr "Weblogic" + +#. Tag: literal +#: configuration.xml:1499 +#, no-c-format +msgid "org.hibernate.transaction.WebSphereTransactionManagerLookup" +msgstr "org.hibernate.transaction.WebSphereTransactionManagerLookup" + +#. Tag: entry +#: configuration.xml:1500 +#, no-c-format +msgid "WebSphere" +msgstr "WebSphere" + +#. Tag: literal +#: configuration.xml:1503 +#, no-c-format +msgid "org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" +msgstr "org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" + +#. Tag: entry +#: configuration.xml:1504 +#, no-c-format +msgid "WebSphere 6" +msgstr "WebSphere 6" + +#. Tag: literal +#: configuration.xml:1507 +#, no-c-format +msgid "org.hibernate.transaction.OrionTransactionManagerLookup" +msgstr "org.hibernate.transaction.OrionTransactionManagerLookup" + +#. Tag: entry +#: configuration.xml:1508 +#, no-c-format +msgid "Orion" +msgstr "Orion" + +#. Tag: literal +#: configuration.xml:1511 +#, no-c-format +msgid "org.hibernate.transaction.ResinTransactionManagerLookup" +msgstr "org.hibernate.transaction.ResinTransactionManagerLookup" + +#. Tag: entry +#: configuration.xml:1512 +#, no-c-format +msgid "Resin" +msgstr "Resin" + +#. Tag: literal +#: configuration.xml:1515 +#, no-c-format +msgid "org.hibernate.transaction.JOTMTransactionManagerLookup" +msgstr "org.hibernate.transaction.JOTMTransactionManagerLookup" + +#. Tag: entry +#: configuration.xml:1516 +#, no-c-format +msgid "JOTM" +msgstr "JOTM" + +#. Tag: literal +#: configuration.xml:1519 +#, no-c-format +msgid "org.hibernate.transaction.JOnASTransactionManagerLookup" +msgstr "org.hibernate.transaction.JOnASTransactionManagerLookup" + +#. Tag: entry +#: configuration.xml:1520 +#, no-c-format +msgid "JOnAS" +msgstr "JOnAS" + +#. Tag: literal +#: configuration.xml:1523 +#, no-c-format +msgid "org.hibernate.transaction.JRun4TransactionManagerLookup" +msgstr "org.hibernate.transaction.JRun4TransactionManagerLookup" + +#. Tag: entry +#: configuration.xml:1524 +#, no-c-format +msgid "JRun4" +msgstr "JRun4" + +#. Tag: literal +#: configuration.xml:1527 +#, no-c-format +msgid "org.hibernate.transaction.BESTransactionManagerLookup" +msgstr "org.hibernate.transaction.BESTransactionManagerLookup" + +#. Tag: entry +#: configuration.xml:1528 +#, no-c-format +msgid "Borland ES" +msgstr "Borland ES" + +#. Tag: title +#: configuration.xml:1537 +#, no-c-format +msgid "JNDI-bound SessionFactory" +msgstr "JNDI绑定的SessionFactory" + +#. Tag: para +#: configuration.xml:1539 +#, no-c-format +msgid "" +"A JNDI bound Hibernate SessionFactory can simplify the " +"lookup of the factory and the creation of new Sessions. " +"Note that this is not related to a JNDI bound Datasource, " +"both simply use the same registry!" +msgstr "" +"与JNDI绑定的Hibernate的SessionFactory能简化工厂的查询,简" +"化创建新的Session. 需要注意的是这与JNDI绑定" +"Datasource没有关系, 它们只是恰巧用了相同的注册表!" + +#. Tag: para +#: configuration.xml:1546 +#, no-c-format +msgid "" +"If you wish to have the SessionFactory bound to a JNDI " +"namespace, specify a name (eg. java:hibernate/SessionFactory) using the property hibernate.session_factory_name. If this property is omitted, the SessionFactory " +"will not be bound to JNDI. (This is especially useful in environments with a " +"read-only JNDI default implementation, e.g. Tomcat.)" +msgstr "" +"如果你希望将SessionFactory绑定到一个JNDI的名字空间, 用属性" +"hibernate.session_factory_name指定一个名字(如, " +"java:hibernate/SessionFactory). 如果不设置这个属性, " +"SessionFactory将不会被绑定到JNDI中. (在以只读JNDI为默认实" +"现的环境中,这个设置尤其有用, 如Tomcat.)" + +#. Tag: para +#: configuration.xml:1554 +#, no-c-format +msgid "" +"When binding the SessionFactory to JNDI, Hibernate will " +"use the values of hibernate.jndi.url, hibernate." +"jndi.class to instantiate an initial context. If they are not " +"specified, the default InitialContext will be used." +msgstr "" +"在将SessionFactory绑定至JNDI时, Hibernate将使用" +"hibernate.jndi.url, 和hibernate.jndi.class的值来实例化初始环境(initial context). 如果它们没有被指定, 将使用默认" +"的InitialContext." + +#. Tag: para +#: configuration.xml:1561 +#, no-c-format +msgid "" +"Hibernate will automatically place the SessionFactory in " +"JNDI after you call cfg.buildSessionFactory(). This means " +"you will at least have this call in some startup code (or utility class) in " +"your application, unless you use JMX deployment with the " +"HibernateService (discussed later)." +msgstr "" +"在你调用cfg.buildSessionFactory()后, Hibernate会自动将" +"SessionFactory注册到JNDI. 这意味这你至少需要在你应用程序的" +"启动代码(或工具类)中完成这个调用, 除非你使用HibernateService来做JMX部署 (见后面讨论)." + +#. Tag: para +#: configuration.xml:1568 +#, no-c-format +msgid "" +"If you use a JNDI SessionFactory, an EJB or any other " +"class may obtain the SessionFactory using a JNDI lookup." +msgstr "" +"假若你使用JNDI SessionFactory,EJB或者任何其它类都可以从" +"JNDI中找到此SessionFactory。" + +#. Tag: para +#: configuration.xml:1573 +#, no-c-format +msgid "" +"We recommend that you bind the SessionFactory to JNDI in " +"a managed environment and use a static singleton " +"otherwise. To shield your application code from these details, we also " +"recommend to hide the actual lookup code for a SessionFactory in a helper class, such as HibernateUtil.getSessionFactory" +"(). Note that such a class is also a convenient way to startup " +"Hibernate—see chapter 1." +msgstr "" +"我们建议,在受管理的环境中,把SessionFactory绑定到JNDI,在" +"其它情况下,使用一个static(静态的)singleton。为了在你的应" +"用程序代码中隐藏这些细节,我们还建议你用一个helper类把实际查找" +"SessionFactory的代码隐藏起来,比如HibernateUtil." +"getSessionFactory()。注意,这个类也就可以方便地启动Hibernate,参见" +"第一章。" + +#. Tag: title +#: configuration.xml:1585 +#, no-c-format +msgid "Current Session context management with JTA" +msgstr "在JTA环境下使用Current Session context (当前session上下文)管理" + +#. Tag: para +#: configuration.xml:1587 +#, fuzzy, no-c-format +msgid "" +"The easiest way to handle Sessions and transactions is " +"Hibernates automatic \"current\" Session management. See " +"the discussion of current " +"sessions. Using the \"jta\" session context, if there is " +"no Hibernate Session associated with the current JTA " +"transaction, one will be started and associated with that JTA transaction " +"the first time you call sessionFactory.getCurrentSession(). The Sessions retrieved via " +"getCurrentSession() in \"jta\" context " +"will be set to automatically flush before the transaction completes, close " +"after the transaction completes, and aggressively release JDBC connections " +"after each statement. This allows the Sessions to be " +"managed by the life cycle of the JTA transaction to which it is associated, " +"keeping user code clean of such management concerns. Your code can either " +"use JTA programmatically through UserTransaction, or " +"(recommended for portable code) use the Hibernate Transaction API to set transaction boundaries. If you run in an EJB container, " +"declarative transaction demarcation with CMT is preferred." +msgstr "" +"在Hibernate中,管理Session和transaction最好的方法是自动的" +"\"当前\"Session管理。请参见contextual sessions一节的讨论。使用\"jta" +"\"session上下文,假若在当前JTA事务中还没有" +"HibernateSession关联,第一次sessionFactory." +"getCurrentSession()调用会启动一个Session,并关联到当前的JTA事务。在" +"\"jta\"上下文中调用getCurrentSession()" +"获得的Session,会被设置为在transaction关闭的时候自动flush" +"(清洗)、在transaction关闭之后自动关闭,每句语句之后主动释放JDBC连接。这就可" +"以根据JTA事务的生命周期来管理与之关联的Session,用户代码中" +"就可以不再考虑这些管理。你的代码也可以通过UserTransaction" +"用编程方式使用JTA,或者(我们建议,为了便于移植代码)使用Hibernate的" +"Transaction API来设置transaction边界。如果你的代码运行在" +"EJB容器中,建议对CMT使用声明式事务声明。" + +#. Tag: title +#: configuration.xml:1610 +#, no-c-format +msgid "JMX deployment" +msgstr "JMX部署" + +#. Tag: para +#: configuration.xml:1612 +#, no-c-format +msgid "" +"The line cfg.buildSessionFactory() still has to be " +"executed somewhere to get a SessionFactory into JNDI. You " +"can do this either in a static initializer block (like " +"the one in HibernateUtil) or you deploy Hibernate as a " +"managed service." +msgstr "" +"为了将SessionFactory注册到JNDI中,cfg." +"buildSessionFactory()这行代码仍需在某处被执行. 你可在一个" +"static初始化块(像HibernateUtil中的那样)" +"中执行它或将Hibernate部署为一个托管的服务." + +#. Tag: para +#: configuration.xml:1620 +#, no-c-format +msgid "" +"Hibernate is distributed with org.hibernate.jmx.HibernateService for deployment on an application server with JMX capabilities, such " +"as JBoss AS. The actual deployment and configuration is vendor specific. " +"Here is an example jboss-service.xml for JBoss 4.0.x:" +msgstr "" +"为了部署在一个支持JMX的应用程序服务器上,Hibernate和 org.hibernate." +"jmx.HibernateService一同分发,如Jboss AS。 实际的部署和配置是由应用" +"程序服务器提供者指定的. 这里是JBoss 4.0.x的jboss-service.xml样例:" + +#. Tag: programlisting +#: configuration.xml:1627 +#, no-c-format +msgid "" +"\n" +"\n" +"\n" +"\n" +"\n" +" \n" +" jboss.jca:service=RARDeployer\n" +" jboss.jca:service=LocalTxCM,name=HsqlDS\n" +"\n" +" \n" +" java:/hibernate/SessionFactory\n" +"\n" +" \n" +" java:HsqlDS\n" +" org.hibernate.dialect.HSQLDialect\n" +"\n" +" \n" +" \n" +" org.hibernate.transaction.JTATransactionFactory\n" +" \n" +" org.hibernate.transaction.JBossTransactionManagerLookup\n" +" true\n" +" true\n" +"\n" +" \n" +" 5\n" +"\n" +" \n" +" true\n" +" org.hibernate.cache." +"EhCacheProvider\n" +" true\n" +"\n" +" \n" +" true\n" +"\n" +" \n" +" auction/Item.hbm.xml,auction/Category." +"hbm.xml\n" +"\n" +"\n" +"\n" +"]]>" msgstr "" -#: index.docbook:1629 -msgid "This file is deployed in a directory called META-INF and packaged in a JAR file with the extension .sar (service archive). You also need to package Hibernate, its required third-party libraries, your compiled persistent classes, as well as your mapping files in the same archive. Your enterprise beans (usually session beans) may be kept in their own JAR file, but you may include this EJB JAR file in the main service archive to get a single (hot-)deployable unit. Consult the JBoss AS documentation for more information about JMX service and EJB deployment." +#. Tag: para +#: configuration.xml:1629 +#, no-c-format +msgid "" +"This file is deployed in a directory called META-INF and " +"packaged in a JAR file with the extension .sar (service " +"archive). You also need to package Hibernate, its required third-party " +"libraries, your compiled persistent classes, as well as your mapping files " +"in the same archive. Your enterprise beans (usually session beans) may be " +"kept in their own JAR file, but you may include this EJB JAR file in the " +"main service archive to get a single (hot-)deployable unit. Consult the " +"JBoss AS documentation for more information about JMX service and EJB " +"deployment." msgstr "" +"这个文件是部署在META-INF目录下的, 并会被打包到以." +"sar (service archive)为扩展名的JAR文件中. 同时,你需要将Hibernate、" +"它所需要的第三方库、你编译好的持久化类以及你的映射定义文件打包进同一个文档. " +"你的企业Bean(一般为会话Bean)可能会被打包成它们自己的JAR文件, 但你也许会将EJB " +"JAR文件一同包含进能独立(热)部署的主服务文档. 参考JBoss AS文档以了解更多的JMX" +"服务与EJB部署的信息." -msgid "ROLES_OF_TRANSLATORS" -msgstr "" +#~ msgid " (optional)" +#~ msgstr " (可选)" -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" +#~ msgid "InitialContextFactory" +#~ msgstr "InitialContextFactory" +#~ msgid "class of the JNDI " +#~ msgstr "JNDI 类" + +#, fuzzy +#~ msgid "eg." +#~ msgstr "" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "eg.\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "取值" + +#~ msgid "full.classname.of.Dialect" +#~ msgstr "full.classname.of.Dialect" + +#~ msgid "debug" +#~ msgstr "debug" + +#~ msgid "SCHEMA_NAME" +#~ msgstr "SCHEMA_NAME" + +#~ msgid "CATALOG_NAME" +#~ msgstr "CATALOG_NAME" + +#~ msgid "SessionFactory" +#~ msgstr "SessionFactory" + +#~ msgid "jndi/composite/name" +#~ msgstr "jndi/composite/name" + +#~ msgid "0" +#~ msgstr "0" + +#~ msgid "false" +#~ msgstr "false" + +#~ msgid "Statement.setFetchSize()" +#~ msgstr "Statement.setFetchSize()" + +#~ msgid "true" +#~ msgstr "executeBatch()" + +#~ msgid "executeBatch()" +#~ msgstr "true" + +#~ msgid "Batcher" +#~ msgstr "Batcher" + +#~ msgid "classname.of.BatcherFactory" +#~ msgstr "classname.of.BatcherFactory" + +#~ msgid "binary" +#~ msgstr "binary (二进制)" + +#~ msgid "serializable" +#~ msgstr "serializable (可序列化)" + +#~ msgid "PreparedStatement.getGeneratedKeys()" +#~ msgstr "PreparedStatement.getGeneratedKeys()" + +#~ msgid "true|false" +#~ msgstr "true|false" + +#~ msgid "ConnectionProvider" +#~ msgstr "ConnectionProvider" + +#~ msgid "classname.of.ConnectionProvider" +#~ msgstr "classname.of.ConnectionProvider" + +#~ msgid "java.sql.Connection" +#~ msgstr "java.sql.Connection" + +#~ msgid "1, 2, 4, 8" +#~ msgstr "1, 2, 4, 8" + +#~ msgid "after_statement" +#~ msgstr "after_statement" + +#~ msgid "after_transaction" +#~ msgstr "after_transaction" + +#~ msgid "auto" +#~ msgstr "auto" + +#~ msgid "<propertyName>" +#~ msgstr "<propertyName>" + +#~ msgid "hibernate.connection." +#~ msgstr "hibernate.connection." + +#~ msgid "propertyName" +#~ msgstr "propertyName" + +#~ msgid "DriverManager.getConnection()" +#~ msgstr "DriverManager.getConnection()" + +#~ msgid "Pass the JDBC property to ." +#~ msgstr "将JDBC属性传递到中去." + +#~ msgid "hibernate.jndi." +#~ msgstr "hibernate.jndi." + +#~ msgid "Pass the property to the JNDI ." +#~ msgstr "将属性传递到JNDI 中去." + +#~ msgid "CacheProvider" +#~ msgstr "CacheProvider" + +#~ msgid "classname.of.CacheProvider" +#~ msgstr "classname.of.CacheProvider" + +#~ msgid "<cache>" +#~ msgstr "<cache>" + +#~ msgid "QueryCache" +#~ msgstr "QueryCache" + +#~ msgid "StandardQueryCache" +#~ msgstr "StandardQueryCache" + +#~ msgid "classname.of.QueryCache" +#~ msgstr "classname.of.QueryCache" + +#~ msgid "prefix" +#~ msgstr "prefix" + +#~ msgid "TransactionFactory" +#~ msgstr "TransactionFactory" + +#~ msgid "Transaction" +#~ msgstr "Transaction" + +#~ msgid "JDBCTransactionFactory" +#~ msgstr "JDBCTransactionFactory" + +#~ msgid "classname.of.TransactionFactory" +#~ msgstr "classname.of.TransactionFactory" + +#~ msgid "JTATransactionFactory" +#~ msgstr "JTATransactionFactory" + +#~ msgid "UserTransaction" +#~ msgstr "UserTransaction" + +#~ msgid "TransactionManagerLookup" +#~ msgstr "TransactionManagerLookup" + +#~ msgid "classname.of.TransactionManagerLookup" +#~ msgstr "classname.of.TransactionManagerLookup" + +#~ msgid "Session" +#~ msgstr "Session" + +#~ msgid "hqlLiteral=SQL_LITERAL, hqlFunction=SQLFUNC" +#~ msgstr "hqlLiteral=SQL_LITERAL, hqlFunction=SQLFUNC" + +#~ msgid "create-drop" +#~ msgstr "create-drop" + +#~ msgid "hibernate.cfg.xml" +#~ msgstr "hibernate.cfg.xml" + +#~ msgid "DB2" +#~ msgstr "DB2" diff --git a/documentation/manual/translations/zh-CN/content/events.po b/documentation/manual/translations/zh-CN/content/events.po index 4423496136..044e78e708 100644 --- a/documentation/manual/translations/zh-CN/content/events.po +++ b/documentation/manual/translations/zh-CN/content/events.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \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 Interceptor 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 Interceptor automatically sets the createTimestamp when an Auditable is created and updates the lastUpdateTimestamp property when an Auditable is updated." -msgstr "" - -#: index.docbook:27 -msgid "You may either implement Interceptor directly or (better) extend EmptyInterceptor." -msgstr "" - -#: index.docbook:32 +#. Tag: para +#: events.xml:7 +#, no-c-format msgid "" - "" +"It is often useful for the application to react to certain events that occur " +"inside Hibernate. This allows implementation of certain kinds of generic " +"functionality, and extension of Hibernate functionality." +msgstr "" +"应用程序能够响应Hibernate内部产生的特定事件是非常有用的。这样就允许实现某些通" +"用的功能 以及允许对Hibernate功能进行扩展。" + +#. Tag: title +#: events.xml:14 +#, no-c-format +msgid "Interceptors" +msgstr "拦截器(Interceptors)" + +#. Tag: para +#: events.xml:16 +#, no-c-format +msgid "" +"The Interceptor 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 Interceptor " +"automatically sets the createTimestamp when an " +"Auditable is created and updates the " +"lastUpdateTimestamp property when an Auditable is updated." +msgstr "" +"Interceptor接口提供了从会话(session)回调(callback)应用程序" +"(application)的机制, 这种回调机制可以允许应用程序在持久化对象被保存、更新、" +"删除或是加载之前,检查并(或)修改其 属性。一个可能的用途,就是用来跟踪审核" +"(auditing)信息。例如:下面的这个拦截器,会在一个实现了 " +"Auditable接口的对象被创建时自动地设置" +"createTimestamp属性,并在实现了 Auditable接口的对象被更新时,同步更新lastUpdateTimestamp属" +"性。" + +#. Tag: para +#: events.xml:27 +#, no-c-format +msgid "" +"You may either implement Interceptor directly or (better) " +"extend EmptyInterceptor." +msgstr "" +"你可以直接实现Interceptor接口,也可以(最好)继承自" +"EmptyInterceptor。" + +#. Tag: programlisting +#: events.xml:32 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:34 -msgid "Interceptors come in two flavors: Session-scoped and SessionFactory-scoped." +#. Tag: para +#: events.xml:34 +#, no-c-format +msgid "" +"Interceptors come in two flavors: Session-scoped and " +"SessionFactory-scoped." msgstr "" +"拦截器可以有两种:Session范围内的,和" +"SessionFactory范围内的。" -#: index.docbook:39 -msgid "A Session-scoped interceptor is specified when a session is opened using one of the overloaded SessionFactory.openSession() methods accepting an Interceptor." +#. Tag: para +#: events.xml:39 +#, no-c-format +msgid "" +"A Session-scoped interceptor is specified when a session " +"is opened using one of the overloaded SessionFactory.openSession() methods " +"accepting an Interceptor." msgstr "" +"当使用某个重载的SessionFactory.openSession()使用Interceptor作为参数调用打开一个session的时候,就指定了Session" +"范围内的拦截器。" -#: index.docbook:45 +#. Tag: programlisting +#: events.xml:45 +#, no-c-format msgid "" msgstr "" -#: index.docbook:47 -msgid "A SessionFactory-scoped interceptor is registered with the Configuration object prior to building the SessionFactory. In this case, the supplied interceptor will be applied to all sessions opened from that SessionFactory; this is true unless a session is opened explicitly specifying the interceptor to use. SessionFactory-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 SessionFactory-scoped interceptor is registered with " +"the Configuration object prior to building the " +"SessionFactory. In this case, the supplied interceptor " +"will be applied to all sessions opened from that SessionFactory; this is true unless a session is opened explicitly specifying the " +"interceptor to use. SessionFactory-scoped interceptors " +"must be thread safe, taking care to not store session-specific state since " +"multiple sessions will use this interceptor (potentially) concurrently." +msgstr "" +"SessionFactory范围内的拦截器要通过Configuration中注册,而这必须在创建SessionFactory之前。在这种情" +"况下,给出的拦截器会被这个SessionFactory所打开的所有" +"session使用了;除非session打开时明确指明了使用的拦截器。" +"SessionFactory范围内的拦截器,必须是线程安全的,因为多个" +"session可能并发使用这个拦截器,要因此小心不要保存与session相关的状态。" + +#. Tag: programlisting +#: events.xml:56 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:56 -msgid "" -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 event 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 Session interface correlate to an event. You have a LoadEvent, a FlushEvent, etc (consult the XML configuration-file DTD or the org.hibernate.event package for the full list of defined event types). When a request is made of one of these methods, the Hibernate Session 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 LoadEvent is processed by the registered implemenation of the LoadEventListener interface), in which case their implementation would be responsible for processing any load() requests made of the Session." -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 Configuration 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 "" - "" +"If you have to react to particular events in your persistence layer, you may " +"also use the Hibernate3 event 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 "" - "\n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"Essentially all of the methods of the Session interface " +"correlate to an event. You have a LoadEvent, a " +"FlushEvent, etc (consult the XML configuration-file DTD " +"or the org.hibernate.event package for the full list of " +"defined event types). When a request is made of one of these methods, the " +"Hibernate Session 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 LoadEvent is processed by " +"the registered implemenation of the LoadEventListener " +"interface), in which case their implementation would be responsible for " +"processing any load() requests made of the " +"Session." +msgstr "" +"基本上,Session接口的每个方法都有相对应的事件。比如 " +"LoadEventFlushEvent,等等(查阅XML配" +"置文件 的DTD,以及org.hibernate.event包来获得所有已定义的" +"事件的列表)。当某个方 法被调用时,Hibernate Session会生成" +"一个相对应的事件并激活所 有配置好的事件监听器。系统预设的监听器实现的处理过程" +"就是被监听的方法要做的(被监听的方法所做的其实仅仅是激活监听器, “实际”的工作" +"是由监听器完成的)。不过,你可以自由地选择实现 一个自己定制的监听器(比如,实" +"现并注册用来处理处理LoadEvent的" +"LoadEventListener接口), 来负责处理所有的调用" +"Sessionload()方法的请求。" + +#. 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 Configuration " +"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的了)。用户定制的监听器可以通过编程使用" +"Configuration对象 来注册,也可以在Hibernate的XML格式的配置" +"文件中进行声明(不支持在Properties格式的配置文件声明监听器)。 下面是一个用户" +"定制的加载事件(load event)的监听器:" + +#. Tag: programlisting +#: events.xml:99 +#, no-c-format +msgid "" +"" 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 "" +"\n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" +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 "" - "" +"" msgstr "" -#: index.docbook:114 -msgid "Listeners registered declaratively cannot share instances. If the same class name is used in multiple <listener/> 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 <listener/> 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配置文件声明而注册的监听器不能共享实例。如果在多个<" +"listener/>节点中使用 了相同的类的名字,则每一个引用都将会产生一" +"个独立的实例。如果你需要在多个监听器类型之间共享 监听器的实例,则你必须使用编" +"程的方式来进行注册。" -#: 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 "" - "\n" - "\n" - "\n" - "]]>" +"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 <listener type=\"...\" class=\"...\"/> is just a shorthand for <event type=\"...\"><listener class=\"...\"/></event> when there is exactly one listener for a particular event type." -msgstr "" - -#: index.docbook:152 -msgid "Next, still in hibernate.cfg.xml, bind the permissions to roles:" -msgstr "" - -#: index.docbook:156 +#. Tag: para +#: events.xml:139 +#, no-c-format msgid "" - "\n" - "]]>" +"First, you must configure the appropriate event listeners, to enable the use " +"of JAAS authorization." +msgstr "" +"首先,你必须要配置适当的事件监听器(event listener),来激活使用JAAS管理授权" +"的功能。" + +#. Tag: programlisting +#: events.xml:144 +#, no-c-format +msgid "" +"\n" +"\n" +"\n" +"]]>" msgstr "" -#: index.docbook:158 +#. Tag: para +#: events.xml:146 +#, no-c-format +msgid "" +"Note that <listener type=\"...\" class=\"...\"/> is " +"just a shorthand for <event type=\"...\"><listener class=" +"\"...\"/></event> when there is exactly one listener for " +"a particular event type." +msgstr "" +"注意,<listener type=\"...\" class=\"...\"/>只是" +"<event type=\"...\"><listener class=\"...\"/></" +"event>的简写,对每一个事件类型都必须严格的有一个监听器与之对应。" + +#. Tag: para +#: events.xml:152 +#, no-c-format +msgid "" +"Next, still in hibernate.cfg.xml, bind the permissions to " +"roles:" +msgstr "" +"接下来,仍然在hibernate.cfg.xml文件中,绑定角色的权限:" + +#. Tag: programlisting +#: events.xml:156 +#, no-c-format +msgid "" +"\n" +"]]>" +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 "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +msgstr "这些角色的名字就是你的JACC provider所定义的角色的名字。" diff --git a/documentation/manual/translations/zh-CN/content/example_mappings.po b/documentation/manual/translations/zh-CN/content/example_mappings.po index e611cb90f6..b0efe10a48 100644 --- a/documentation/manual/translations/zh-CN/content/example_mappings.po +++ b/documentation/manual/translations/zh-CN/content/example_mappings.po @@ -1,653 +1,785 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:20 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: example_mappings.xml:20 +#, no-c-format msgid "Example: Various Mappings" -msgstr "" +msgstr "示例:复杂映射实例" -#: index.docbook:22 +#. Tag: para +#: example_mappings.xml:22 +#, no-c-format msgid "This chapters shows off some more complex association mappings." -msgstr "" +msgstr "本章展示了一些较为复杂的关系映射。" -#: index.docbook:27 +#. Tag: title +#: example_mappings.xml:27 +#, no-c-format msgid "Employer/Employee" -msgstr "" +msgstr "Employer(雇主)/Employee(雇员)" -#: index.docbook:29 -msgid "The following model of the relationship between Employer and Employee uses an actual entity class (Employment) to represent the association. This is done because there might be more than one period of employment for the same two parties. Components are used to model monetary values and employee names." +#. Tag: para +#: example_mappings.xml:29 +#, no-c-format +msgid "" +"The following model of the relationship between Employer " +"and Employee uses an actual entity class " +"(Employment) to represent the association. This is done " +"because there might be more than one period of employment for the same two " +"parties. Components are used to model monetary values and employee names." msgstr "" +"下面关于EmployerEmployee的关系模型" +"使用了一个真实的实体类 (Employment)来表述,这是因为对于相" +"同的雇员和雇主可能会有多个雇佣时间段。 对于金额和雇员姓名,用Components建模。" -#: index.docbook:46 +#. Tag: para +#: example_mappings.xml:46 +#, no-c-format msgid "Heres a possible mapping document:" -msgstr "" +msgstr "映射文件可能是这样:" -#: index.docbook:50 +#. Tag: programlisting +#: example_mappings.xml:50 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " employer_id_seq\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - " employment_id_seq\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - " employee_id_seq\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" employer_id_seq\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +" employment_id_seq\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +" employee_id_seq\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:52 -msgid "And heres the table schema generated by SchemaExport." -msgstr "" - -#: index.docbook:56 +#. Tag: para +#: example_mappings.xml:52 +#, no-c-format msgid "" - "" +"And heres the table schema generated by SchemaExport." +msgstr "用SchemaExport生成表结构。" + +#. Tag: programlisting +#: example_mappings.xml:56 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:61 +#. Tag: title +#: example_mappings.xml:61 +#, no-c-format msgid "Author/Work" -msgstr "" +msgstr "Author(作家)/Work(作品)" -#: index.docbook:63 -msgid "Consider the following model of the relationships between Work, Author and Person. We represent the relationship between Work and Author as a many-to-many association. We choose to represent the relationship between Author and Person as one-to-one association. Another possibility would be to have Author extend Person." -msgstr "" - -#: index.docbook:81 -msgid "The following mapping document correctly represents these relationships:" -msgstr "" - -#: index.docbook:85 +#. Tag: para +#: example_mappings.xml:63 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"Consider the following model of the relationships between Work, Author and Person. We " +"represent the relationship between Work and " +"Author as a many-to-many association. We choose to " +"represent the relationship between Author and " +"Person as one-to-one association. Another possibility " +"would be to have Author extend Person." msgstr "" +"考虑下面的Work,Author 和 " +"Person模型的关系。 我们用多对多关系来描述WorkAuthor, 用一对一关系来描述AuthorPerson, 另一种可能性是Author继承Person。" -#: index.docbook:87 -msgid "There are four tables in this mapping. works, authors and persons hold work, author and person data respectively. author_work is an association table linking authors to works. Heres the table schema, as generated by SchemaExport." -msgstr "" - -#: index.docbook:95 +#. Tag: para +#: example_mappings.xml:81 +#, no-c-format msgid "" - "" +"The following mapping document correctly represents these relationships:" +msgstr "下面的映射文件正确的描述了这些关系:" + +#. Tag: programlisting +#: example_mappings.xml:85 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:100 +#. Tag: para +#: example_mappings.xml:87 +#, no-c-format +msgid "" +"There are four tables in this mapping. works, " +"authors and persons hold work, author " +"and person data respectively. author_work is an " +"association table linking authors to works. Heres the table schema, as " +"generated by SchemaExport." +msgstr "" +"映射中有4个表。works, authors 和 " +"persons 分别保存着work,author和person的数据。" +"author_work是authors和works的关联表。 表结构是由" +"SchemaExport生成的。" + +#. Tag: programlisting +#: example_mappings.xml:95 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: example_mappings.xml:100 +#, no-c-format msgid "Customer/Order/Product" -msgstr "" +msgstr "Customer(客户)/Order(订单)/Product(产品)" -#: index.docbook:102 -msgid "Now consider a model of the relationships between Customer, Order and LineItem and Product. There is a one-to-many association between Customer and Order, but how should we represent Order / LineItem / Product? I've chosen to map LineItem as an association class representing the many-to-many association between Order and Product. In Hibernate, this is called a composite element." +#. Tag: para +#: example_mappings.xml:102 +#, no-c-format +msgid "" +"Now consider a model of the relationships between Customer, Order and LineItem and " +"Product. There is a one-to-many association between " +"Customer and Order, but how should we " +"represent Order / LineItem / " +"Product? I've chosen to map LineItem " +"as an association class representing the many-to-many association between " +"Order and Product. In Hibernate, this " +"is called a composite element." msgstr "" +"现在来考虑Customer,Order , " +"LineItemProduct关系的模型。" +"CustomerOrder之间 是一对多的关系," +"但是我们怎么来描述Order / LineItem / " +"Product呢? 我可以把LineItem作为描述" +"OrderProduct 多对多关系的关联类,在" +"Hibernate,这叫做组合元素。" -#: index.docbook:122 +#. Tag: para +#: example_mappings.xml:122 +#, no-c-format msgid "The mapping document:" -msgstr "" +msgstr "映射文件如下:" -#: index.docbook:126 +#. Tag: programlisting +#: example_mappings.xml:126 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:128 -msgid "customers, orders, line_items and products hold customer, order, order line item and product data respectively. line_items also acts as an association table linking orders with products." -msgstr "" - -#: index.docbook:135 +#. Tag: para +#: example_mappings.xml:128 +#, no-c-format msgid "" - "" +"customers, orders, " +"line_items and products hold customer, " +"order, order line item and product data respectively. line_items also acts as an association table linking orders with products." +msgstr "" +"customers, orders, " +"line_itemsproducts 分别保存着" +"customer, order, order line item 和 product的数据。 line_items也作为连接orders 和 products的关联表。" + +#. Tag: programlisting +#: example_mappings.xml:135 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:140 +#. Tag: title +#: example_mappings.xml:140 +#, no-c-format msgid "Miscellaneous example mappings" -msgstr "" +msgstr "杂例" -#: index.docbook:142 -msgid "These examples are all taken from the Hibernate test suite. You will find many other useful example mappings there. Look in the test folder of the Hibernate distribution." +#. Tag: para +#: example_mappings.xml:142 +#, no-c-format +msgid "" +"These examples are all taken from the Hibernate test suite. You will find " +"many other useful example mappings there. Look in the test folder of the Hibernate distribution." msgstr "" +"这些例子全部来自于Hibernate的test suite,同时你也可以找到其他有用的例子。 可" +"以参考Hibernate的test目录。" -#: index.docbook:148 +#. Tag: para +#: example_mappings.xml:148 +#, no-c-format msgid "TODO: put words around this stuff" -msgstr "" +msgstr "TODO: put words around this stuff" -#: index.docbook:151 +#. Tag: title +#: example_mappings.xml:151 +#, no-c-format msgid "\"Typed\" one-to-one association" -msgstr "" +msgstr "\"Typed\" one-to-one association" -#: index.docbook:152 +#. Tag: programlisting +#: example_mappings.xml:152 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " name\n" - " 'HOME'\n" - " \n" - " \n" - " name\n" - " 'MAILING'\n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" name\n" +" 'HOME'\n" +" \n" +" \n" +" name\n" +" 'MAILING'\n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:156 +#. Tag: title +#: example_mappings.xml:156 +#, no-c-format msgid "Composite key example" -msgstr "" +msgstr "Composite key example" -#: index.docbook:157 +#. Tag: programlisting +#: example_mappings.xml:157 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ( select sum(li.quantity*p.price) \n" - " from LineItem li, Product p \n" - " where li.productId = p.productId \n" - " and li.customerId = customerId \n" - " and li.orderNumber = orderNumber )\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ( select sum(li.quantity) \n" - " from LineItem li \n" - " where li.productId = productId )\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ( select sum(li.quantity*p.price) \n" +" from LineItem li, Product p \n" +" where li.productId = p.productId \n" +" and li.customerId = customerId \n" +" and li.orderNumber = orderNumber )\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ( select sum(li.quantity) \n" +" from LineItem li \n" +" where li.productId = productId )\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:161 +#. Tag: title +#: example_mappings.xml:161 +#, no-c-format msgid "Many-to-many with shared composite key attribute" msgstr "" +"共有组合键属性的多对多(Many-to-many with shared composite key attribute)" -#: index.docbook:162 +#. Tag: programlisting +#: example_mappings.xml:162 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " org\n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " org\n" - " \n" - " \n" - "\n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" org\n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" org\n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:166 +#. Tag: title +#: example_mappings.xml:166 +#, no-c-format msgid "Content based discrimination" -msgstr "" +msgstr "Content based discrimination" -#: index.docbook:167 +#. Tag: programlisting +#: example_mappings.xml:167 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " case \n" - " when title is not null then 'E' \n" - " when salesperson is not null then 'C' \n" - " else 'P' \n" - " end\n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" case \n" +" when title is not null then 'E' \n" +" when salesperson is not null then 'C' \n" +" else 'P' \n" +" end\n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:171 +#. Tag: title +#: example_mappings.xml:171 +#, no-c-format msgid "Associations on alternate keys" -msgstr "" +msgstr "Associations on alternate keys" -#: index.docbook:172 +#. Tag: programlisting +#: example_mappings.xml:172 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" - -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - diff --git a/documentation/manual/translations/zh-CN/content/example_parentchild.po b/documentation/manual/translations/zh-CN/content/example_parentchild.po index d86f3becb4..7f46f43e62 100644 --- a/documentation/manual/translations/zh-CN/content/example_parentchild.po +++ b/documentation/manual/translations/zh-CN/content/example_parentchild.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \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 Parent and Child as entity classes with a <one-to-many> association from Parent to Child. (The alternative approach is to declare the Child as a <composite-element>.) 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 bidirectional one to many association with cascades 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 Parent and Child as entity classes with a <one-to-many> " +"association from Parent to Child. (The " +"alternative approach is to declare the Child as a " +"<composite-element>.) 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 " +"bidirectional one to many association with cascades to " +"model a parent / child relationship efficiently and elegantly. It's not at " +"all difficult!" msgstr "" +"刚刚接触Hibernate的人大多是从父子关系(parent / child type relationship)的建" +"模入手的。父子关系的建模有两种方法。由于种种原因,最方便的方法是把" +"ParentChild都建模成实体类,并创建一个" +"从Parent指向Child的<one-to-many>" +"关联,对新手来说尤其如此。还有一种方法,就是将Child声明为" +"一个<composite-element>(组合元素)。 事实上在" +"Hibernate中one to many关联的默认语义远没有composite element贴近parent / child" +"关系的通常语义。下面我们会阐述如何使用带有级联的双向一对多关联" +"(bidirectional one to many association with cascades)去建立有效、" +"优美的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 <one-to-many> association from Parent to Child." -msgstr "" - -#: index.docbook:71 +#. Tag: para +#: example_parentchild.xml:66 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"Suppose we start with a simple <one-to-many> " +"association from Parent to Child." +msgstr "假设我们要实现一个简单的从Parent到Child的<one-to-many>关联。" + +#. Tag: programlisting +#: example_parentchild.xml:71 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"]]>" 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 "" - "" +"" 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 INSERT to create the record for c" -msgstr "" - -#: index.docbook:88 -msgid "an UPDATE to create the link from p to c" -msgstr "" - -#: index.docbook:95 -msgid "This is not only inefficient, but also violates any NOT NULL constraint on the parent_id column. We can fix the nullability constraint violation by specifying not-null=\"true\" in the collection mapping:" -msgstr "" - -#: index.docbook:101 +#. Tag: para +#: example_parentchild.xml:85 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"an INSERT to create the record for c" +msgstr "一条INSERT语句,为c创建一条记录" + +#. Tag: para +#: example_parentchild.xml:88 +#, no-c-format +msgid "" +"an UPDATE to create the link from p to " +"c" +msgstr "" +"一条UPDATE语句,创建从pc的连接" + +#. Tag: para +#: example_parentchild.xml:95 +#, no-c-format +msgid "" +"This is not only inefficient, but also violates any NOT NULL constraint on the parent_id column. We can fix " +"the nullability constraint violation by specifying not-null=\"true" +"\" in the collection mapping:" +msgstr "" +"这样做不仅效率低,而且违反了列parent_id非空的限制。我们可" +"以通过在集合类映射上指定not-null=\"true\"来解决违反非空约" +"束的问题:" + +#. Tag: programlisting +#: example_parentchild.xml:101 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"]]>" 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 parent_id) from p to c is not considered part of the state of the Child object and is therefore not created in the INSERT. So the solution is to make the link part of the Child mapping." -msgstr "" - -#: index.docbook:113 -msgid "]]>" -msgstr "" - -#: index.docbook:115 -msgid "(We also need to add the parent property to the Child class.)" -msgstr "" - -#: index.docbook:119 -msgid "Now that the Child entity is managing the state of the link, we tell the collection not to update the link. We use the inverse attribute." -msgstr "" - -#: index.docbook:124 +#. Tag: para +#: example_parentchild.xml:106 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"The underlying cause of this behaviour is that the link (the foreign key " +"parent_id) from p to c is not considered part of the state of the Child " +"object and is therefore not created in the INSERT. So the " +"solution is to make the link part of the Child mapping." +msgstr "" +"这种现象的根本原因是从pc的连接(外键" +"parent_id)没有被当作Child对象状态的一部分,因而没有在" +"INSERT语句中被创建。因此解决的办法就是把这个连接添加到Child的映射中。" + +#. Tag: programlisting +#: example_parentchild.xml:113 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:126 +#. Tag: para +#: example_parentchild.xml:115 +#, no-c-format +msgid "" +"(We also need to add the parent property to the " +"Child class.)" +msgstr "" +"(我们还需要为类Child添加parent属性)" + +#. Tag: para +#: example_parentchild.xml:119 +#, no-c-format +msgid "" +"Now that the Child entity is managing the state of the " +"link, we tell the collection not to update the link. We use the " +"inverse attribute." +msgstr "" +"现在实体Child在管理连接的状态,为了使collection不更新连" +"接,我们使用inverse属性。" + +#. Tag: programlisting +#: example_parentchild.xml:124 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: example_parentchild.xml:126 +#, no-c-format msgid "The following code would be used to add a new Child" -msgstr "" +msgstr "下面的代码是用来添加一个新的Child" -#: index.docbook:130 +#. Tag: programlisting +#: example_parentchild.xml:130 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:132 +#. Tag: para +#: example_parentchild.xml:132 +#, no-c-format msgid "And now, only one SQL INSERT would be issued!" -msgstr "" +msgstr "现在,只会有一条INSERT语句被执行!" -#: index.docbook:136 -msgid "To tighten things up a bit, we could create an addChild() method of Parent." -msgstr "" - -#: index.docbook:141 +#. Tag: para +#: example_parentchild.xml:136 +#, no-c-format msgid "" - "" +"To tighten things up a bit, we could create an addChild() " +"method of Parent." +msgstr "" +"为了让事情变得井井有条,可以为Parent加一个" +"addChild()方法。" + +#. Tag: programlisting +#: example_parentchild.xml:141 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:143 +#. Tag: para +#: example_parentchild.xml:143 +#, no-c-format msgid "Now, the code to add a Child looks like" -msgstr "" +msgstr "现在,添加Child的代码就是这样" -#: index.docbook:147 +#. Tag: programlisting +#: example_parentchild.xml:147 +#, no-c-format msgid "" - "" +"" 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 save() is still annoying. We will address this by using cascades." -msgstr "" - -#: index.docbook:159 +#. Tag: para +#: example_parentchild.xml:154 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"The explicit call to save() is still annoying. We will " +"address this by using cascades." +msgstr "" +"需要显式调用save()仍然很麻烦,我们可以用级联来解决这个问" +"题。" + +#. Tag: programlisting +#: example_parentchild.xml:159 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"]]>" 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 "" - "" +"" msgstr "" -#: index.docbook:167 -msgid "Similarly, we don't need to iterate over the children when saving or deleting a Parent. The following removes p and all its children from the database." -msgstr "" - -#: index.docbook:172 +#. Tag: para +#: example_parentchild.xml:167 +#, no-c-format msgid "" - "" +"Similarly, we don't need to iterate over the children when saving or " +"deleting a Parent. The following removes p and all its children from the database." +msgstr "" +"同样的,保存或删除Parent对象的时候并不需要遍历其子对象。 " +"下面的代码会删除对象p及其所有子对象对应的数据库记录。" + +#. Tag: programlisting +#: example_parentchild.xml:172 +#, no-c-format +msgid "" +"" 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 "" - "" +"" msgstr "" -#: index.docbook:180 -msgid "will not remove c from the database; it will ony remove the link to p (and cause a NOT NULL constraint violation, in this case). You need to explicitly delete() the Child." -msgstr "" - -#: index.docbook:186 +#. Tag: para +#: example_parentchild.xml:180 +#, no-c-format msgid "" - "" +"will not remove c from the database; it will ony remove " +"the link to p (and cause a NOT NULL " +"constraint violation, in this case). You need to explicitly delete()" +" the Child." msgstr "" +"不会从数据库删除c;它只会删除与p之间的" +"连接(并且会导致违反NOT NULL约束,在这个例子中)。你需要显" +"式调用delete()来删除Child。" -#: index.docbook:188 -msgid "Now, in our case, a Child can't really exist without its parent. So if we remove a Child from the collection, we really do want it to be deleted. For this, we must use cascade=\"all-delete-orphan\"." -msgstr "" - -#: index.docbook:194 +#. Tag: programlisting +#: example_parentchild.xml:186 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"" msgstr "" -#: index.docbook:196 -msgid "Note: even though the collection mapping specifies inverse=\"true\", 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 setParent()." +#. Tag: para +#: example_parentchild.xml:188 +#, no-c-format +msgid "" +"Now, in our case, a Child can't really exist without its " +"parent. So if we remove a Child from the collection, we " +"really do want it to be deleted. For this, we must use cascade=" +"\"all-delete-orphan\"." +msgstr "" +"在我们的例子中,如果没有父对象,子对象就不应该存在,如果将子对象从collection" +"中移除,实际上我们是想删除它。要实现这种要求,就必须使用cascade=" +"\"all-delete-orphan\"。" + +#. Tag: programlisting +#: example_parentchild.xml:194 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:206 +#. Tag: para +#: example_parentchild.xml:196 +#, no-c-format +msgid "" +"Note: even though the collection mapping specifies inverse=\"true" +"\", 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 " +"setParent()." +msgstr "" +"注意:即使在collection一方的映射中指定inverse=\"true\",级" +"联仍然是通过遍历collection中的元素来处理的。如果你想要通过级联进行子对象的插" +"入、删除、更新操作,就必须把它加到collection中,只调用setParent()是不够的。" + +#. Tag: title +#: example_parentchild.xml:206 +#, no-c-format msgid "Cascades and unsaved-value" msgstr "" +"级联与未保存值(Cascades and unsaved-value)" -#: index.docbook:208 -msgid "Suppose we loaded up a Parent in one Session, made some changes in a UI action and wish to persist these changes in a new session by calling update(). The Parent 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 Parent and Child have genenerated identifier properties of type Long. Hibernate will use the identifier and version/timestamp property value to determine which of the children are new. (See .) In Hibernate3, it is no longer necessary to specify an unsaved-value explicitly." -msgstr "" - -#: index.docbook:220 -msgid "The following code will update parent and child and insert newChild." -msgstr "" - -#: index.docbook:225 +#. Tag: para +#: example_parentchild.xml:208 +#, no-c-format msgid "" - "" +"Suppose we loaded up a Parent in one Session, made some changes in a UI action and wish to persist these changes " +"in a new session by calling update(). The " +"Parent 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 Parent and Child have " +"genenerated identifier properties of type Long. Hibernate " +"will use the identifier and version/timestamp property value to determine " +"which of the children are new. (See .) In Hibernate3, it is no longer necessary to specify an " +"unsaved-value explicitly." +msgstr "" +"假设我们从Session中装入了一个Parent对" +"象,用户界面对其进行了修改,然后希望在一个新的Session里面调用update" +"()来保存这些修改。对象Parent包含了子对象的集合," +"由于打开了级联更新,Hibernate需要知道哪些Child对象是新实例化的,哪些代表数据" +"库中已经存在的记录。我们假设ParentChild对象的标识属性都是自动生成的,类型为java.lang.Long。Hibernate会使用标识属性的值,和version 或 timestamp 属性,来判断哪" +"些子对象是新的。(参见.) " +"在 Hibernate3 中,显式指定unsaved-value不再是必须" +"的了。" + +#. Tag: para +#: example_parentchild.xml:220 +#, no-c-format +msgid "" +"The following code will update parent and child and insert newChild." +msgstr "" +"下面的代码会更新parentchild对象,并且" +"插入newChild对象。" + +#. Tag: programlisting +#: example_parentchild.xml:225 +#, no-c-format +msgid "" +"" 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 <composite-element> 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 <composite-element> 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 "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +"在第一段中我们曾经提到另一个方案。上面的这些问题都不会出现在<" +"composite-element>映射中,它准确地表达了父子关系的语义。很不幸复" +"合元素还有两个重大限制:复合元素不能拥有collections,并且,除了用于惟一的父对" +"象外,它们不能再作为其它任何实体的子对象。" diff --git a/documentation/manual/translations/zh-CN/content/example_weblog.po b/documentation/manual/translations/zh-CN/content/example_weblog.po index 901b9feb91..3860f02749 100644 --- a/documentation/manual/translations/zh-CN/content/example_weblog.po +++ b/documentation/manual/translations/zh-CN/content/example_weblog.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \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 "" - "" +"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 "" - "" +"" msgstr "" -#: index.docbook:23 +#. Tag: programlisting +#: example_weblog.xml:18 +#, no-c-format +msgid "" +"" +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 "" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - "]]>" +"\n" +"\n" +"\n" +"\n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:31 +#. Tag: programlisting +#: example_weblog.xml:31 +#, no-c-format msgid "" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - "]]>" +"\n" +"\n" +"\n" +"\n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +"]]>" 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 "" - " :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 "" +" :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 "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - diff --git a/documentation/manual/translations/zh-CN/content/filters.po b/documentation/manual/translations/zh-CN/content/filters.po index fc464c0bd8..34b3cc9969 100644 --- a/documentation/manual/translations/zh-CN/content/filters.po +++ b/documentation/manual/translations/zh-CN/content/filters.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \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 Hibernate filter 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 Hibernate filter is a global, " +"named, parameterized filter that may be enabled or disabled for a particular " +"Hibernate session." msgstr "" +"Hibernate3 提供了一种创新的方式来处理具有“显性(visibility)”规则的数据,那就是" +"使用Hibernate filterHibernate filter是全局有效的、具有名字、可以带参数的过滤器, 对于某个特定的" +"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 <filter-def/> element within a <hibernate-mapping/> element:" -msgstr "" - -#: index.docbook:32 +#. Tag: para +#: filters.xml:16 +#, no-c-format msgid "" - "\n" - " \n" - "]]>" +"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 <" +"filter-def/> element within a <hibernate-mapping/" +"> element:" +msgstr "" +"要使用过滤器,必须首先在相应的映射节点中定义。而定义一个过滤器,要用到位于" +"<hibernate-mapping/> 节点之内的<filter-" +"def/>节点:" + +#. Tag: programlisting +#: filters.xml:32 +#, no-c-format +msgid "" +"\n" +" \n" +"]]>" 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 "" - "\n" - " ...\n" - " \n" - "]]>" +"\n" +" ...\n" +" \n" +"]]>" 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 "" - "\n" - " \n" - "]]>" +"\n" +" \n" +"]]>" 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 Session are: enableFilter(String filterName), getEnabledFilter(String filterName), and disableFilter(String filterName). By default, filters are not enabled for a given session; they must be explcitly enabled through use of the Session.enabledFilter() method, which returns an instance of the Filter interface. Using the simple filter defined above, this would look like:" -msgstr "" - -#: index.docbook:59 -msgid "" -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 "" - "\n" - " \n" - "\n" - "\n" - "\n" - "...\n" - " \n" - " \n" - " \n" - "...\n" - " \n" - " \n" - "\n" - "\n" - "\n" - "...\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"The methods on Session are: enableFilter(String " +"filterName), getEnabledFilter(String filterName), and disableFilter(String filterName). By " +"default, filters are not enabled for a given session; " +"they must be explcitly enabled through use of the Session." +"enabledFilter() method, which returns an instance of the " +"Filter interface. Using the simple filter defined above, " +"this would look like:" msgstr "" +"Session对象中会用到的方法有:enableFilter(String " +"filterName), getEnabledFilter(String filterName), 和 disableFilter(String filterName). Session中默" +"认是启用过滤器的,必须通过Session." +"enabledFilter()方法显式的启用。 该方法返回被启用的Filter的实例。以上文定义的过滤器为例:" -#: 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 "" - " :targetSalary\")\n" - " .setLong(\"targetSalary\", new Long(1000000))\n" - " .list();\n" - "]]>" +"" 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 <filter-def/> allows defining a default condition, either as an attribute or CDATA:" -msgstr "" - -#: index.docbook:98 +#. Tag: para +#: filters.xml:61 +#, no-c-format msgid "" - " xyz\">...\n" - "abc=xyz]]>" +"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 "" +"\n" +" \n" +"\n" +"\n" +"\n" +"...\n" +" \n" +" \n" +" \n" +"...\n" +" \n" +" \n" +"\n" +"\n" +"\n" +"...\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" 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 "" +" :" +"targetSalary\")\n" +" .setLong(\"targetSalary\", new Long(1000000))\n" +" .list();\n" +"]]>" msgstr "" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" +#. 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 "" +#. 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 <filter-def/> allows defining a default condition, either as an attribute or " +"CDATA:" +msgstr "" +"在Filter定义之后,它可能被附加到多个实体和/或集合类,每个都有自己的条件。假若这" +"些条件都是一样的,每次都要定义就显得很繁琐。因此,<filter-def/" +">被用来定义一个默认条件,它可能作为属性或者CDATA出现:" + +#. Tag: programlisting +#: filters.xml:98 +#, no-c-format +msgid "" +" xyz\">...\n" +"abc=xyz]]>" +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附加特别的条件来重载默认条件。" diff --git a/documentation/manual/translations/zh-CN/content/inheritance_mapping.po b/documentation/manual/translations/zh-CN/content/inheritance_mapping.po index 7416abbdeb..29521dbb33 100644 --- a/documentation/manual/translations/zh-CN/content/inheritance_mapping.po +++ b/documentation/manual/translations/zh-CN/content/inheritance_mapping.po @@ -1,477 +1,820 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: inheritance_mapping.xml:5 +#, no-c-format msgid "Inheritance Mapping" -msgstr "" +msgstr "继承映射(Inheritance Mappings)" -#: index.docbook:8 +#. Tag: title +#: inheritance_mapping.xml:8 +#, no-c-format msgid "The Three Strategies" -msgstr "" +msgstr "三种策略" -#: index.docbook:10 +#. Tag: para +#: inheritance_mapping.xml:10 +#, no-c-format msgid "Hibernate supports the three basic inheritance mapping strategies:" -msgstr "" +msgstr "Hibernate支持三种基本的继承映射策略:" -#: index.docbook:16 +#. Tag: para +#: inheritance_mapping.xml:16 +#, no-c-format msgid "table per class hierarchy" -msgstr "" +msgstr "每个类分层结构一张表(table per class hierarchy)" -#: index.docbook:21 +#. Tag: para +#: inheritance_mapping.xml:21 +#, fuzzy, no-c-format msgid "table per subclass" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"每个子类一张表(table per subclass)\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"每个子类一张表" -#: index.docbook:26 +#. Tag: para +#: inheritance_mapping.xml:26 +#, no-c-format msgid "table per concrete class" -msgstr "" +msgstr "每个具体类一张表(table per concrete class)" -#: index.docbook:32 -msgid "In addition, Hibernate supports a fourth, slightly different kind of polymorphism:" -msgstr "" +#. Tag: para +#: inheritance_mapping.xml:32 +#, no-c-format +msgid "" +"In addition, Hibernate supports a fourth, slightly different kind of " +"polymorphism:" +msgstr "此外,Hibernate还支持第四种稍有不同的多态映射策略:" -#: index.docbook:39 +#. Tag: para +#: inheritance_mapping.xml:39 +#, no-c-format msgid "implicit polymorphism" -msgstr "" +msgstr "隐式多态(implicit polymorphism)" -#: index.docbook:45 -msgid "It is possible to use different mapping strategies for different branches of the same inheritance hierarchy, and then make use of implicit polymorphism to achieve polymorphism across the whole hierarchy. However, Hibernate does not support mixing <subclass>, and <joined-subclass> and <union-subclass> mappings under the same root <class> element. It is possible to mix together the table per hierarchy and table per subclass strategies, under the the same <class> element, by combining the <subclass> and <join> elements (see below)." -msgstr "" - -#: index.docbook:59 -msgid "It is possible to define subclass, union-subclass, and joined-subclass mappings in separate mapping documents, directly beneath hibernate-mapping. This allows you to extend a class hierachy just by adding a new mapping file. You must specify an extends attribute in the subclass mapping, naming a previously mapped superclass. Note: Previously this feature made the ordering of the mapping documents important. Since Hibernate3, the ordering of mapping files does not matter when using the extends keyword. The ordering inside a single mapping file still needs to be defined as superclasses before subclasses." -msgstr "" - -#: index.docbook:70 +#. Tag: para +#: inheritance_mapping.xml:45 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " ]]>" +"It is possible to use different mapping strategies for different branches of " +"the same inheritance hierarchy, and then make use of implicit polymorphism " +"to achieve polymorphism across the whole hierarchy. However, Hibernate does " +"not support mixing <subclass>, and <" +"joined-subclass> and <union-subclass> " +"mappings under the same root <class> element. It is " +"possible to mix together the table per hierarchy and table per subclass " +"strategies, under the the same <class> element, by " +"combining the <subclass> and <join> elements (see below)." +msgstr "" +"对于同一个继承层次内的不同分支,可以采用不同的映射策略,然后用隐式多 态来完成" +"跨越整个层次的多态。但是在同一个<class>根元素 下," +"Hibernate不支持混合了元素<subclass><" +"joined-subclass><union-subclass> 的映" +"射。在同一个<class>元素下,可以混合使用 “每个类分层" +"结构一张表”(table per hierarchy) 和“每个子类一张表”(table per subclass) " +"这两种映射策略,这是通过结合元素<subclass>和 " +"<join>来实现的(见后)。" + +#. Tag: para +#: inheritance_mapping.xml:59 +#, no-c-format +msgid "" +"It is possible to define subclass, union-" +"subclass, and joined-subclass mappings in " +"separate mapping documents, directly beneath hibernate-mapping. This allows you to extend a class hierachy just by adding a new " +"mapping file. You must specify an extends attribute in " +"the subclass mapping, naming a previously mapped superclass. Note: " +"Previously this feature made the ordering of the mapping documents " +"important. Since Hibernate3, the ordering of mapping files does not matter " +"when using the extends keyword. The ordering inside a single mapping file " +"still needs to be defined as superclasses before subclasses." +msgstr "" +"在多个映射文件中,可以直接在hibernate-mapping根下定义" +"subclassunion-subclass和" +"joined-subclass。也就是说,你可以仅加入一个新的映射文件来" +"扩展类层次。你必须在subclass的映射中指明extends属性,给出" +"一个之前定义的超类的名字。注意,在以前,这一功能对映射文件的顺序有严格的要" +"求,从Hibernate 3开始,使用extends关键字的时侯,对映射文件的顺序不再有要求;" +"但在每个映射文件里,超类必须在子类之前定义。" + +#. Tag: programlisting +#: inheritance_mapping.xml:70 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" ]]>" msgstr "" -#: index.docbook:74 +#. Tag: title +#: inheritance_mapping.xml:74 +#, no-c-format msgid "Table per class hierarchy" -msgstr "" +msgstr "每个类分层结构一张表(Table per class hierarchy)" -#: index.docbook:76 -msgid "Suppose we have an interface Payment, with implementors CreditCardPayment, CashPayment, ChequePayment. The table per hierarchy mapping would look like:" -msgstr "" - -#: index.docbook:83 +#. Tag: para +#: inheritance_mapping.xml:76 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " ...\n" - " \n" - "]]>" +"Suppose we have an interface Payment, with implementors " +"CreditCardPayment, CashPayment, " +"ChequePayment. The table per hierarchy mapping would look " +"like:" +msgstr "" +"假设我们有接口Payment和它的几个实现类: " +"CreditCardPayment, CashPayment, 和" +"ChequePayment。则“每个类分层结构一张表”(Table per class " +"hierarchy)的映射代码如下所示:" + +#. Tag: programlisting +#: inheritance_mapping.xml:83 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" ...\n" +" \n" +"]]>" msgstr "" -#: index.docbook:85 -msgid "Exactly one table is required. There is one big limitation of this mapping strategy: columns declared by the subclasses, such as CCTYPE, may not have NOT NULL constraints." +#. Tag: para +#: inheritance_mapping.xml:85 +#, no-c-format +msgid "" +"Exactly one table is required. There is one big limitation of this mapping " +"strategy: columns declared by the subclasses, such as CCTYPE, may not have NOT NULL constraints." msgstr "" +"采用这种策略只需要一张表即可。它有一个很大的限制:要求那些由子类定义的字段, " +"如CCTYPE,不能有非空(NOT NULL)约束。" -#: index.docbook:94 +#. Tag: title +#: inheritance_mapping.xml:94 +#, no-c-format msgid "Table per subclass" -msgstr "" +msgstr "每个子类一张表(Table per subclass)" -#: index.docbook:96 +#. Tag: para +#: inheritance_mapping.xml:96 +#, no-c-format msgid "A table per subclass mapping would look like:" -msgstr "" +msgstr "对于上例中的几个类而言,采用“每个子类一张表”的映射策略,代码如下所示:" -#: index.docbook:100 +#. Tag: programlisting +#: inheritance_mapping.xml:100 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +"]]>" msgstr "" -#: index.docbook:102 -msgid "Four tables are required. The three subclass tables have primary key associations to the superclass table (so the relational model is actually a one-to-one association)." +#. Tag: para +#: inheritance_mapping.xml:102 +#, no-c-format +msgid "" +"Four tables are required. The three subclass tables have primary key " +"associations to the superclass table (so the relational model is actually a " +"one-to-one association)." msgstr "" +"需要四张表。三个子类表通过主键关联到超类表(因而关系模型实际上是一对一关联)。" -#: index.docbook:111 +#. Tag: title +#: inheritance_mapping.xml:111 +#, no-c-format msgid "Table per subclass, using a discriminator" -msgstr "" +msgstr "每个子类一张表(Table per subclass),使用辨别标志(Discriminator)" -#: index.docbook:113 -msgid "Note that Hibernate's implementation of table per subclass requires no discriminator column. Other object/relational mappers use a different implementation of table per subclass which requires a type discriminator column in the superclass table. The approach taken by Hibernate is much more difficult to implement but arguably more correct from a relational point of view. If you would like to use a discriminator column with the table per subclass strategy, you may combine the use of <subclass> and <join>, as follow:" -msgstr "" - -#: index.docbook:125 +#. Tag: para +#: inheritance_mapping.xml:113 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - "]]>" +"Note that Hibernate's implementation of table per subclass requires no " +"discriminator column. Other object/relational mappers use a different " +"implementation of table per subclass which requires a type discriminator " +"column in the superclass table. The approach taken by Hibernate is much more " +"difficult to implement but arguably more correct from a relational point of " +"view. If you would like to use a discriminator column with the table per " +"subclass strategy, you may combine the use of <subclass> and <join>, as follow:" +msgstr "" +"注意,对“每个子类一张表”的映射策略,Hibernate的实现不需要辨别字段,而其他 的" +"对象/关系映射工具使用了一种不同于Hibernate的实现方法,该方法要求在超类 表中有" +"一个类型辨别字段(type discriminator column)。Hibernate采用的方法更 难实现,但" +"从关系(数据库)的角度来看,按理说它更正确。若你愿意使用带有辨别字 段的“每个" +"子类一张表”的策略,你可以结合使用<subclass> 与" +"<join>,如下所示:" + +#. Tag: programlisting +#: inheritance_mapping.xml:125 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:127 -msgid "The optional fetch=\"select\" declaration tells Hibernate not to fetch the ChequePayment subclass data using an outer join when querying the superclass." +#. Tag: para +#: inheritance_mapping.xml:127 +#, no-c-format +msgid "" +"The optional fetch=\"select\" declaration tells Hibernate " +"not to fetch the ChequePayment subclass data using an " +"outer join when querying the superclass." msgstr "" +"可选的声明fetch=\"select\",是用来告诉Hibernate,在查询超" +"类时, 不要使用外部连接(outer join)来抓取子类ChequePayment" +"的数据。" -#: index.docbook:136 +#. Tag: title +#: inheritance_mapping.xml:136 +#, no-c-format msgid "Mixing table per class hierarchy with table per subclass" -msgstr "" +msgstr "混合使用“每个类分层结构一张表”和“每个子类一张表”" -#: index.docbook:138 -msgid "You may even mix the table per hierarchy and table per subclass strategies using this approach:" -msgstr "" - -#: index.docbook:143 +#. Tag: para +#: inheritance_mapping.xml:138 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " ...\n" - " \n" - "]]>" +"You may even mix the table per hierarchy and table per subclass strategies " +"using this approach:" +msgstr "" +"你甚至可以采取如下方法混和使用“每个类分层结构一张表”和“每个子类一张表”这两种" +"策略:" + +#. Tag: programlisting +#: inheritance_mapping.xml:143 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" ...\n" +" \n" +"]]>" msgstr "" -#: index.docbook:145 -msgid "For any of these mapping strategies, a polymorphic association to the root Payment class is mapped using <many-to-one>." +#. Tag: para +#: inheritance_mapping.xml:145 +#, no-c-format +msgid "" +"For any of these mapping strategies, a polymorphic association to the root " +"Payment class is mapped using <many-to-one>" +"." +msgstr "" +"对上述任何一种映射策略而言,指向根类Payment的 关联是使用" +"<many-to-one>进行映射的。" + +#. Tag: programlisting +#: inheritance_mapping.xml:151 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:151 -msgid "]]>" -msgstr "" - -#: index.docbook:156 +#. Tag: title +#: inheritance_mapping.xml:156 +#, no-c-format msgid "Table per concrete class" -msgstr "" +msgstr "每个具体类一张表(Table per concrete class)" -#: index.docbook:158 -msgid "There are two ways we could go about mapping the table per concrete class strategy. The first is to use <union-subclass>." -msgstr "" - -#: index.docbook:163 +#. Tag: para +#: inheritance_mapping.xml:158 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " ...\n" - " \n" - "]]>" +"There are two ways we could go about mapping the table per concrete class " +"strategy. The first is to use <union-subclass>." +msgstr "" +"对于“每个具体类一张表”的映射策略,可以采用两种方法。第一种方法是使用 " +"<union-subclass>。" + +#. Tag: programlisting +#: inheritance_mapping.xml:163 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" ...\n" +" \n" +"]]>" msgstr "" -#: index.docbook:165 -msgid "Three tables are involved for the subclasses. Each table defines columns for all properties of the class, including inherited properties." +#. Tag: para +#: inheritance_mapping.xml:165 +#, no-c-format +msgid "" +"Three tables are involved for the subclasses. Each table defines columns for " +"all properties of the class, including inherited properties." msgstr "" +"这里涉及三张与子类相关的表。每张表为对应类的所有属性(包括从超类继承的属性)" +"定义相应字段。" -#: index.docbook:170 -msgid "The limitation of this approach is that if a property is mapped on the superclass, the column name must be the same on all subclass tables. (We might relax this in a future release of Hibernate.) The identity generator strategy is not allowed in union subclass inheritance, indeed the primary key seed has to be shared accross all unioned subclasses of a hierarchy." +#. Tag: para +#: inheritance_mapping.xml:170 +#, no-c-format +msgid "" +"The limitation of this approach is that if a property is mapped on the " +"superclass, the column name must be the same on all subclass tables. (We " +"might relax this in a future release of Hibernate.) The identity generator " +"strategy is not allowed in union subclass inheritance, indeed the primary " +"key seed has to be shared accross all unioned subclasses of a hierarchy." msgstr "" +"这种方式的局限在于,如果一个属性在超类中做了映射,其字段名必须与所有子类 表中" +"定义的相同。(我们可能会在Hibernate的后续发布版本中放宽此限制。) 不允许在联合" +"子类(union subclass)的继承层次中使用标识生成器策略(identity generator " +"strategy), 实际上, 主键的种子(primary key seed)不得不为同一继承层次中的全部被" +"联合子类所共用." -#: index.docbook:179 -msgid "If your superclass is abstract, map it with abstract=\"true\". Of course, if it is not abstract, an additional table (defaults to PAYMENT in the example above) is needed to hold instances of the superclass." +#. Tag: para +#: inheritance_mapping.xml:179 +#, no-c-format +msgid "" +"If your superclass is abstract, map it with abstract=\"true\". Of course, if it is not abstract, an additional table (defaults to " +"PAYMENT in the example above) is needed to hold instances " +"of the superclass." msgstr "" +"假若超类是抽象类,请使用abstract=\"true\"。当然,假若它不" +"是抽象的,需要一个额外的表(上面的例子中,默认是PAYMENT),来保存超类的实例。" -#: index.docbook:189 +#. Tag: title +#: inheritance_mapping.xml:189 +#, no-c-format msgid "Table per concrete class, using implicit polymorphism" -msgstr "" +msgstr "每个具体类一张表,使用隐式多态" -#: index.docbook:191 +#. Tag: para +#: inheritance_mapping.xml:191 +#, no-c-format msgid "An alternative approach is to make use of implicit polymorphism:" -msgstr "" +msgstr "另一种可供选择的方法是采用隐式多态:" -#: index.docbook:195 +#. Tag: programlisting +#: inheritance_mapping.xml:195 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +"]]>" msgstr "" -#: index.docbook:197 -msgid "Notice that nowhere do we mention the Payment interface explicitly. Also notice that properties of Payment are mapped in each of the subclasses. If you want to avoid duplication, consider using XML entities (e.g. [ <!ENTITY allproperties SYSTEM \"allproperties.xml\"> ] in the DOCTYPE declartion and &allproperties; in the mapping)." -msgstr "" - -#: index.docbook:207 -msgid "The disadvantage of this approach is that Hibernate does not generate SQL UNIONs when performing polymorphic queries." -msgstr "" - -#: index.docbook:212 -msgid "For this mapping strategy, a polymorphic association to Payment is usually mapped using <any>." -msgstr "" - -#: index.docbook:217 +#. Tag: para +#: inheritance_mapping.xml:197 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"Notice that nowhere do we mention the Payment interface " +"explicitly. Also notice that properties of Payment are " +"mapped in each of the subclasses. If you want to avoid duplication, consider " +"using XML entities (e.g. [ <!ENTITY allproperties SYSTEM " +"\"allproperties.xml\"> ] in the DOCTYPE " +"declartion and &allproperties; in the mapping)." +msgstr "" +"注意,我们没有在任何地方明确的提及接口Payment。同时注意 " +"Payment的属性在每个子类中都进行了映射。如果你想避免重复, " +"可以考虑使用XML实体(例如:位于DOCTYPE声明内的 " +"[ <!ENTITY allproperties SYSTEM \"allproperties.xml\"> ] 和映" +"射中的&allproperties;)。" + +#. Tag: para +#: inheritance_mapping.xml:207 +#, no-c-format +msgid "" +"The disadvantage of this approach is that Hibernate does not generate SQL " +"UNIONs when performing polymorphic queries." +msgstr "" +"这种方法的缺陷在于,在Hibernate执行多态查询时(polymorphic queries)无法生成带 " +"UNION的SQL语句。" + +#. Tag: para +#: inheritance_mapping.xml:212 +#, no-c-format +msgid "" +"For this mapping strategy, a polymorphic association to Payment is usually mapped using <any>." +msgstr "" +"对于这种映射策略而言,通常用<any>来实现到 " +"Payment的多态关联映射。" + +#. Tag: programlisting +#: inheritance_mapping.xml:217 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:222 +#. Tag: title +#: inheritance_mapping.xml:222 +#, no-c-format msgid "Mixing implicit polymorphism with other inheritance mappings" -msgstr "" +msgstr "隐式多态和其他继承映射混合使用" -#: index.docbook:224 -msgid "There is one further thing to notice about this mapping. Since the subclasses are each mapped in their own <class> element (and since Payment is just an interface), each of the subclasses could easily be part of another inheritance hierarchy! (And you can still use polymorphic queries against the Payment interface.)" -msgstr "" - -#: index.docbook:232 +#. Tag: para +#: inheritance_mapping.xml:224 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - "\n" - "\n" - "\n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - "]]>" +"There is one further thing to notice about this mapping. Since the " +"subclasses are each mapped in their own <class> " +"element (and since Payment is just an interface), each of " +"the subclasses could easily be part of another inheritance hierarchy! (And " +"you can still use polymorphic queries against the Payment " +"interface.)" +msgstr "" +"对这一映射还有一点需要注意。因为每个子类都在各自独立的元素<" +"class> 中映射(并且Payment只是一个接口),每个" +"子类可以很容易的成为另一 个继承体系中的一部分!(你仍然可以对接口" +"Payment使用多态查询。)" + +#. Tag: programlisting +#: inheritance_mapping.xml:232 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +"\n" +"\n" +"\n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +"]]>" msgstr "" -#: index.docbook:234 -msgid "Once again, we don't mention Payment explicitly. If we execute a query against the Payment interface - for example, from Payment - Hibernate automatically returns instances of CreditCardPayment (and its subclasses, since they also implement Payment), CashPayment and ChequePayment but not instances of NonelectronicTransaction." +#. Tag: para +#: inheritance_mapping.xml:234 +#, no-c-format +msgid "" +"Once again, we don't mention Payment explicitly. If we " +"execute a query against the Payment interface - for " +"example, from Payment - Hibernate automatically returns " +"instances of CreditCardPayment (and its subclasses, since " +"they also implement Payment), CashPayment and ChequePayment but not instances of " +"NonelectronicTransaction." msgstr "" +"我们还是没有明确的提到Payment。 如果我们针对接口" +"Payment执行查询 ——如from Payment—— " +"Hibernate 自动返回CreditCardPayment(和它的子类,因为 它们" +"也实现了接口Payment)、 CashPayment和" +"Chequepayment的实例, 但不返回" +"NonelectronicTransaction的实例。" -#: index.docbook:249 +#. Tag: title +#: inheritance_mapping.xml:249 +#, no-c-format msgid "Limitations" -msgstr "" +msgstr "限制" -#: index.docbook:251 -msgid "There are certain limitations to the \"implicit polymorphism\" approach to the table per concrete-class mapping strategy. There are somewhat less restrictive limitations to <union-subclass> mappings." +#. Tag: para +#: inheritance_mapping.xml:251 +#, no-c-format +msgid "" +"There are certain limitations to the \"implicit polymorphism\" approach to " +"the table per concrete-class mapping strategy. There are somewhat less " +"restrictive limitations to <union-subclass> " +"mappings." msgstr "" +"对“每个具体类映射一张表”(table per concrete-class)的映射策略而言,隐式多态" +"的 方式有一定的限制。而<union-subclass>映射的限制则" +"没有那 么严格。" -#: index.docbook:258 -msgid "The following table shows the limitations of table per concrete-class mappings, and of implicit polymorphism, in Hibernate." -msgstr "" +#. Tag: para +#: inheritance_mapping.xml:258 +#, no-c-format +msgid "" +"The following table shows the limitations of table per concrete-class " +"mappings, and of implicit polymorphism, in Hibernate." +msgstr "下面表格中列出了在Hibernte中“每个具体类一张表”的策略和隐式多态的限制。" -#: index.docbook:264 +#. Tag: title +#: inheritance_mapping.xml:264 +#, no-c-format msgid "Features of inheritance mappings" -msgstr "" +msgstr "继承映射特性(Features of inheritance mappings)" -#: index.docbook:276 +#. Tag: entry +#: inheritance_mapping.xml:276 +#, no-c-format msgid "Inheritance strategy" -msgstr "" +msgstr "继承策略(Inheritance strategy)" -#: index.docbook:277 +#. Tag: entry +#: inheritance_mapping.xml:277 +#, no-c-format msgid "Polymorphic many-to-one" -msgstr "" +msgstr "多态多对一" -#: index.docbook:278 +#. Tag: entry +#: inheritance_mapping.xml:278 +#, no-c-format msgid "Polymorphic one-to-one" -msgstr "" +msgstr "多态一对一" -#: index.docbook:279 +#. Tag: entry +#: inheritance_mapping.xml:279 +#, no-c-format msgid "Polymorphic one-to-many" -msgstr "" +msgstr "多态一对多" -#: index.docbook:280 +#. Tag: entry +#: inheritance_mapping.xml:280 +#, no-c-format msgid "Polymorphic many-to-many" -msgstr "" +msgstr "多态多对多" -#: index.docbook:281 +#. Tag: entry +#: inheritance_mapping.xml:281 +#, no-c-format msgid "Polymorphic load()/get()" msgstr "" -#: index.docbook:282 +#. Tag: entry +#: inheritance_mapping.xml:282 +#, no-c-format msgid "Polymorphic queries" -msgstr "" +msgstr "多态查询" -#: index.docbook:283 +#. Tag: entry +#: inheritance_mapping.xml:283 +#, no-c-format msgid "Polymorphic joins" -msgstr "" +msgstr "多态连接(join)" -#: index.docbook:284 +#. Tag: entry +#: inheritance_mapping.xml:284 +#, no-c-format msgid "Outer join fetching" -msgstr "" +msgstr "外连接(Outer join)读取" -#: index.docbook:289 +#. Tag: entry +#: inheritance_mapping.xml:289 +#, no-c-format msgid "table per class-hierarchy" -msgstr "" +msgstr "每个类分层结构一张表" -#: index.docbook:290, index.docbook:301, index.docbook:312 +#. Tag: literal +#: inheritance_mapping.xml:290 inheritance_mapping.xml:301 +#: inheritance_mapping.xml:312 +#, no-c-format msgid "<many-to-one>" -msgstr "" +msgstr "<many-to-one>" -#: index.docbook:291, index.docbook:302, index.docbook:313 +#. Tag: literal +#: inheritance_mapping.xml:291 inheritance_mapping.xml:302 +#: inheritance_mapping.xml:313 +#, no-c-format msgid "<one-to-one>" -msgstr "" +msgstr "<one-to-one>" -#: index.docbook:292, index.docbook:303 +#. Tag: literal +#: inheritance_mapping.xml:292 inheritance_mapping.xml:303 +#, no-c-format msgid "<one-to-many>" -msgstr "" +msgstr "<one-to-many>" -#: index.docbook:293, index.docbook:304, index.docbook:315 +#. Tag: literal +#: inheritance_mapping.xml:293 inheritance_mapping.xml:304 +#: inheritance_mapping.xml:315 +#, no-c-format msgid "<many-to-many>" -msgstr "" +msgstr "<many-to-many>" -#: index.docbook:294, index.docbook:305, index.docbook:316 +#. Tag: literal +#: inheritance_mapping.xml:294 inheritance_mapping.xml:305 +#: inheritance_mapping.xml:316 +#, no-c-format msgid "s.get(Payment.class, id)" -msgstr "" +msgstr "s.get(Payment.class, id)" -#: index.docbook:295, index.docbook:306, index.docbook:317, index.docbook:328 +#. Tag: literal +#: inheritance_mapping.xml:295 inheritance_mapping.xml:306 +#: inheritance_mapping.xml:317 inheritance_mapping.xml:328 +#, no-c-format msgid "from Payment p" -msgstr "" +msgstr "from Payment p" -#: index.docbook:296, index.docbook:307, index.docbook:318 +#. Tag: literal +#: inheritance_mapping.xml:296 inheritance_mapping.xml:307 +#: inheritance_mapping.xml:318 +#, no-c-format msgid "from Order o join o.payment p" -msgstr "" +msgstr "from Order o join o.payment p" -#: index.docbook:297, index.docbook:308, index.docbook:319 +#. Tag: emphasis +#: inheritance_mapping.xml:297 inheritance_mapping.xml:308 +#: inheritance_mapping.xml:319 +#, no-c-format msgid "supported" -msgstr "" +msgstr "支持" -#: index.docbook:300 +#. Tag: entry +#: inheritance_mapping.xml:300 +#, fuzzy, no-c-format msgid "table per subclass" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"每个子类一张表(table per subclass)\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"每个子类一张表" -#: index.docbook:311 +#. Tag: entry +#: inheritance_mapping.xml:311 +#, no-c-format msgid "table per concrete-class (union-subclass)" +msgstr "每个具体类一张表(union-subclass)" + +#. Tag: entry +#: inheritance_mapping.xml:314 +#, no-c-format +msgid "" +"<one-to-many> (for inverse=\"true\" only)" msgstr "" -#: index.docbook:314 -msgid "<one-to-many> (for inverse=\"true\" only)" -msgstr "" - -#: index.docbook:322 +#. Tag: entry +#: inheritance_mapping.xml:322 +#, no-c-format msgid "table per concrete class (implicit polymorphism)" -msgstr "" +msgstr "每个具体类一张表(隐式多态)" -#: index.docbook:323 +#. Tag: literal +#: inheritance_mapping.xml:323 +#, no-c-format msgid "<any>" -msgstr "" +msgstr "<any>" -#: index.docbook:324, index.docbook:325, index.docbook:329, index.docbook:330 +#. Tag: emphasis +#: inheritance_mapping.xml:324 inheritance_mapping.xml:325 +#: inheritance_mapping.xml:329 inheritance_mapping.xml:330 +#, no-c-format msgid "not supported" -msgstr "" +msgstr "不支持" -#: index.docbook:326 +#. Tag: literal +#: inheritance_mapping.xml:326 +#, no-c-format msgid "<many-to-any>" +msgstr "<many-to-any>" + +#. Tag: literal +#: inheritance_mapping.xml:327 +#, no-c-format +msgid "" +"s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()" msgstr "" +"s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()" -#: index.docbook:327 -msgid "s.createCriteria(Payment.class).add( Restrictions.idEq(id) ).uniqueResult()" -msgstr "" +#~ msgid "load()/get()" +#~ msgstr "load()/get()" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" +#~ msgid "Polymorphic " +#~ msgstr "多态 " -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" +#~ msgid "inverse=\"true\"" +#~ msgstr "inverse=\"true\"" +#~ msgid " (for only)" +#~ msgstr " (仅对于的情况)" diff --git a/documentation/manual/translations/zh-CN/content/performance.po b/documentation/manual/translations/zh-CN/content/performance.po index e74ccb6170..4d95516d16 100644 --- a/documentation/manual/translations/zh-CN/content/performance.po +++ b/documentation/manual/translations/zh-CN/content/performance.po @@ -1,1068 +1,2430 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: performance.xml:5 +#, no-c-format msgid "Improving performance" -msgstr "" +msgstr "提升性能" -#: index.docbook:8 +#. Tag: title +#: performance.xml:8 +#, no-c-format msgid "Fetching strategies" -msgstr "" +msgstr "抓取策略(Fetching strategies)" -#: index.docbook:10 -msgid "A fetching strategy is the strategy Hibernate will use for retrieving associated objects if the application needs to navigate the association. Fetch strategies may be declared in the O/R mapping metadata, or over-ridden by a particular HQL or Criteria query." +#. Tag: para +#: performance.xml:10 +#, no-c-format +msgid "" +"A fetching strategy is the strategy Hibernate will use " +"for retrieving associated objects if the application needs to navigate the " +"association. Fetch strategies may be declared in the O/R mapping metadata, " +"or over-ridden by a particular HQL or Criteria query." msgstr "" +"抓取策略(fetching strategy) 是指:当应用程序需要在" +"(Hibernate实体对象图的)关联关系间进行导航的时候, Hibernate如何获取关联对象" +"的策略。抓取策略可以在O/R映射的元数据中声明,也可以在特定的HQL 或条" +"件查询(Criteria Query)中重载声明。" -#: index.docbook:17 +#. Tag: para +#: performance.xml:17 +#, no-c-format msgid "Hibernate3 defines the following fetching strategies:" -msgstr "" +msgstr "Hibernate3 定义了如下几种抓取策略:" -#: index.docbook:23 -msgid "Join fetching - Hibernate retrieves the associated instance or collection in the same SELECT, using an OUTER JOIN." +#. Tag: para +#: performance.xml:23 +#, no-c-format +msgid "" +"Join fetching - Hibernate retrieves the associated " +"instance or collection in the same SELECT, using an " +"OUTER JOIN." msgstr "" +"连接抓取(Join fetching) - Hibernate通过 在" +"SELECT语句使用OUTER JOIN(外连接)来 获" +"得对象的关联实例或者关联集合。" -#: index.docbook:30 -msgid "Select fetching - a second SELECT is used to retrieve the associated entity or collection. Unless you explicitly disable lazy fetching by specifying lazy=\"false\", this second select will only be executed when you actually access the association." +#. Tag: para +#: performance.xml:30 +#, no-c-format +msgid "" +"Select fetching - a second SELECT is " +"used to retrieve the associated entity or collection. Unless you explicitly " +"disable lazy fetching by specifying lazy=\"false\", this " +"second select will only be executed when you actually access the association." msgstr "" +"查询抓取(Select fetching) - 另外发送一条 " +"SELECT 语句抓取当前对象的关联实体或集合。除非你显式的指定" +"lazy=\"false\"禁止 延迟抓取(lazy fetching),否则只有当你" +"真正访问关联关系的时候,才会执行第二条select语句。" -#: index.docbook:39 -msgid "Subselect fetching - a second SELECT is used to retrieve the associated collections for all entities retrieved in a previous query or fetch. Unless you explicitly disable lazy fetching by specifying lazy=\"false\", this second select will only be executed when you actually access the association." +#. Tag: para +#: performance.xml:39 +#, no-c-format +msgid "" +"Subselect fetching - a second SELECT " +"is used to retrieve the associated collections for all entities retrieved in " +"a previous query or fetch. Unless you explicitly disable lazy fetching by " +"specifying lazy=\"false\", this second select will only " +"be executed when you actually access the association." msgstr "" +"子查询抓取(Subselect fetching) - 另外发送一条" +"SELECT 语句抓取在前面查询到(或者抓取到)的所有实体对象的" +"关联集合。除非你显式的指定lazy=\"false\" 禁止延迟抓取" +"(lazy fetching),否则只有当你真正访问关联关系的时候,才会执行第二条select语" +"句。" -#: index.docbook:48 -msgid "Batch fetching - an optimization strategy for select fetching - Hibernate retrieves a batch of entity instances or collections in a single SELECT, by specifying a list of primary keys or foreign keys." +#. Tag: para +#: performance.xml:48 +#, no-c-format +msgid "" +"Batch fetching - an optimization strategy for select " +"fetching - Hibernate retrieves a batch of entity instances or collections in " +"a single SELECT, by specifying a list of primary keys or " +"foreign keys." msgstr "" +"批量抓取(Batch fetching) - 对查询抓取的优化方案, 通过" +"指定一个主键或外键列表,Hibernate使用单条SELECT语句获取一" +"批对象实例或集合。" -#: index.docbook:57 +#. Tag: para +#: performance.xml:57 +#, no-c-format msgid "Hibernate also distinguishes between:" -msgstr "" +msgstr "Hibernate会区分下列各种情况:" -#: index.docbook:63 -msgid "Immediate fetching - an association, collection or attribute is fetched immediately, when the owner is loaded." +#. Tag: para +#: performance.xml:63 +#, no-c-format +msgid "" +"Immediate fetching - an association, collection or " +"attribute is fetched immediately, when the owner is loaded." msgstr "" +"Immediate fetching,立即抓取 - 当宿主被加载时,关联、集" +"合或属性被立即抓取。" -#: index.docbook:69 -msgid "Lazy collection fetching - a collection is fetched when the application invokes an operation upon that collection. (This is the default for collections.)" +#. Tag: para +#: performance.xml:69 +#, no-c-format +msgid "" +"Lazy collection fetching - a collection is fetched when " +"the application invokes an operation upon that collection. (This is the " +"default for collections.)" msgstr "" +"Lazy collection fetching,延迟集合抓取- 直到应用程序对集" +"合进行了一次操作时,集合才被抓取。(对集合而言这是默认行为。)" -#: index.docbook:76 -msgid "\"Extra-lazy\" collection fetching - individual elements of the collection are accessed from the database as needed. Hibernate tries not to fetch the whole collection into memory unless absolutely needed (suitable for very large collections)" +#. Tag: para +#: performance.xml:76 +#, no-c-format +msgid "" +"\"Extra-lazy\" collection fetching - individual " +"elements of the collection are accessed from the database as needed. " +"Hibernate tries not to fetch the whole collection into memory unless " +"absolutely needed (suitable for very large collections)" msgstr "" +"\"Extra-lazy\" collection fetching,\"Extra-lazy\"集合抓取 -对集合类中的每个元素而言,都是直到需要时才去访问数据库。除非绝对必" +"要,Hibernate不会试图去把整个集合都抓取到内存里来(适用于非常大的集合)。" -#: index.docbook:84 -msgid "Proxy fetching - a single-valued association is fetched when a method other than the identifier getter is invoked upon the associated object." +#. Tag: para +#: performance.xml:84 +#, no-c-format +msgid "" +"Proxy fetching - a single-valued association is fetched " +"when a method other than the identifier getter is invoked upon the " +"associated object." msgstr "" +"Proxy fetching,代理抓取 - 对返回单值的关联而言,当其某" +"个方法被调用,而非对其关键字进行get操作时才抓取。" -#: index.docbook:91 -msgid "\"No-proxy\" fetching - a single-valued association is fetched when the instance variable is accessed. Compared to proxy fetching, this approach is less lazy (the association is fetched even when only the identifier is accessed) but more transparent, since no proxy is visible to the application. This approach requires buildtime bytecode instrumentation and is rarely necessary." +#. Tag: para +#: performance.xml:91 +#, no-c-format +msgid "" +"\"No-proxy\" fetching - a single-valued association is " +"fetched when the instance variable is accessed. Compared to proxy fetching, " +"this approach is less lazy (the association is fetched even when only the " +"identifier is accessed) but more transparent, since no proxy is visible to " +"the application. This approach requires buildtime bytecode instrumentation " +"and is rarely necessary." msgstr "" +"\"No-proxy\" fetching,非代理抓取 - 对返回单值的关联而" +"言,当实例变量被访问的时候进行抓取。与上面的代理抓取相比,这种方法没有那么“延" +"迟”得厉害(就算只访问标识符,也会导致关联抓取)但是更加透明,因为对应用程序来" +"说,不再看到proxy。这种方法需要在编译期间进行字节码增强操作,因此很少需要用" +"到。" -#: index.docbook:101 -msgid "Lazy attribute fetching - an attribute or single valued association is fetched when the instance variable is accessed. This approach requires buildtime bytecode instrumentation and is rarely necessary." +#. Tag: para +#: performance.xml:101 +#, no-c-format +msgid "" +"Lazy attribute fetching - an attribute or single valued " +"association is fetched when the instance variable is accessed. This approach " +"requires buildtime bytecode instrumentation and is rarely necessary." msgstr "" +"Lazy attribute fetching,属性延迟加载 - 对属性或返回单值" +"的关联而言,当其实例变量被访问的时候进行抓取。需要编译期字节码强化,因此这一" +"方法很少是必要的。" -#: index.docbook:110 -msgid "We have two orthogonal notions here: when is the association fetched, and how is it fetched (what SQL is used). Don't confuse them! We use fetch to tune performance. We may use lazy to define a contract for what data is always available in any detached instance of a particular class." +#. Tag: para +#: performance.xml:110 +#, no-c-format +msgid "" +"We have two orthogonal notions here: when is the " +"association fetched, and how is it fetched (what SQL is " +"used). Don't confuse them! We use fetch to tune " +"performance. We may use lazy to define a contract for " +"what data is always available in any detached instance of a particular class." msgstr "" +"这里有两个正交的概念:关联何时被抓取,以及被如" +"何抓取(会采用什么样的SQL语句)。不要混淆它们!我们使用抓" +"取来改善性能。我们使用延迟来定义一些契约,对某特" +"定类的某个脱管的实例,知道有哪些数据是可以使用的。" -#: index.docbook:119 +#. Tag: title +#: performance.xml:119 +#, no-c-format msgid "Working with lazy associations" -msgstr "" +msgstr "操作延迟加载的关联" -#: index.docbook:121 -msgid "By default, Hibernate3 uses lazy select fetching for collections and lazy proxy fetching for single-valued associations. These defaults make sense for almost all associations in almost all applications." -msgstr "" - -#: index.docbook:127 -msgid "Note: if you set hibernate.default_batch_fetch_size, Hibernate will use the batch fetch optimization for lazy fetching (this optimization may also be enabled at a more granular level)." -msgstr "" - -#: index.docbook:134 -msgid "However, lazy fetching poses one problem that you must be aware of. Access to a lazy association outside of the context of an open Hibernate session will result in an exception. For example:" -msgstr "" - -#: index.docbook:140 +#. Tag: para +#: performance.xml:121 +#, no-c-format msgid "" - "" +"By default, Hibernate3 uses lazy select fetching for collections and lazy " +"proxy fetching for single-valued associations. These defaults make sense for " +"almost all associations in almost all applications." +msgstr "" +"默认情况下,Hibernate 3对集合使用延迟select抓取,对返回单值的关联使用延迟代理" +"抓取。对几乎是所有的应用而言,其绝大多数的关联,这种策略都是有效的。" + +#. Tag: para +#: performance.xml:127 +#, no-c-format +msgid "" +"Note: if you set hibernate." +"default_batch_fetch_size, Hibernate will use the batch fetch " +"optimization for lazy fetching (this optimization may also be enabled at a " +"more granular level)." +msgstr "" +"注意:假若你设置了hibernate." +"default_batch_fetch_size,Hibernate会对延迟加载采取批量抓取优化措施" +"(这种优化也可能会在更细化的级别打开)。" + +#. Tag: para +#: performance.xml:134 +#, no-c-format +msgid "" +"However, lazy fetching poses one problem that you must be aware of. Access " +"to a lazy association outside of the context of an open Hibernate session " +"will result in an exception. For example:" +msgstr "" +"然而,你必须了解延迟抓取带来的一个问题。在一个打开的Hibernate session上下文之" +"外调用延迟集合会导致一次意外。比如:" + +#. Tag: programlisting +#: performance.xml:140 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:142 -msgid "Since the permissions collection was not initialized when the Session was closed, the collection will not be able to load its state. Hibernate does not support lazy initialization for detached objects. The fix is to move the code that reads from the collection to just before the transaction is committed." +#. Tag: para +#: performance.xml:142 +#, no-c-format +msgid "" +"Since the permissions collection was not initialized when the " +"Session was closed, the collection will not be able to " +"load its state. Hibernate does not support lazy initialization for " +"detached objects. The fix is to move the code that reads from the " +"collection to just before the transaction is committed." msgstr "" +"在Session关闭后,permessions集合将是未实例化的、不再可用," +"因此无法正常载入其状态。 Hibernate对脱管对象不支持延迟实例化. 这里的修改方法是:将permissions读取数据的代码 移到tx.commit()之" +"前。" -#: index.docbook:150 -msgid "Alternatively, we could use a non-lazy collection or association, by specifying lazy=\"false\" for the association mapping. However, it is intended that lazy initialization be used for almost all collections and associations. If you define too many non-lazy associations in your object model, Hibernate will end up needing to fetch the entire database into memory in every transaction!" +#. Tag: para +#: performance.xml:150 +#, no-c-format +msgid "" +"Alternatively, we could use a non-lazy collection or association, by " +"specifying lazy=\"false\" for the association mapping. " +"However, it is intended that lazy initialization be used for almost all " +"collections and associations. If you define too many non-lazy associations " +"in your object model, Hibernate will end up needing to fetch the entire " +"database into memory in every transaction!" msgstr "" +"除此之外,通过对关联映射指定lazy=\"false\",我们也可以使用" +"非延迟的集合或关联。但是, 对绝大部分集合来说,更推荐使用延迟方式抓取数据。如" +"果在你的对象模型中定义了太多的非延迟关联,Hibernate最终几乎需要在每个事务中载" +"入整个数据库到内存中!" -#: index.docbook:159 -msgid "On the other hand, we often want to choose join fetching (which is non-lazy by nature) instead of select fetching in a particular transaction. We'll now see how to customize the fetching strategy. In Hibernate3, the mechanisms for choosing a fetch strategy are identical for single-valued associations and collections." +#. Tag: para +#: performance.xml:159 +#, no-c-format +msgid "" +"On the other hand, we often want to choose join fetching (which is non-lazy " +"by nature) instead of select fetching in a particular transaction. We'll now " +"see how to customize the fetching strategy. In Hibernate3, the mechanisms " +"for choosing a fetch strategy are identical for single-valued associations " +"and collections." msgstr "" +"但是,另一方面,在一些特殊的事务中,我们也经常需要使用到连接抓取(它本身上就" +"是非延迟的),以代替查询抓取。 下面我们将会很快明白如何具体的定制Hibernate中" +"的抓取策略。在Hibernate3中,具体选择哪种抓取策略的机制是和选择 单值关联或集合" +"关联相一致的。" -#: index.docbook:170 +#. Tag: title +#: performance.xml:170 +#, no-c-format msgid "Tuning fetch strategies" -msgstr "" +msgstr "调整抓取策略(Tuning fetch strategies)" -#: index.docbook:172 -msgid "Select fetching (the default) is extremely vulnerable to N+1 selects problems, so we might want to enable join fetching in the mapping document:" -msgstr "" - -#: index.docbook:177 +#. Tag: para +#: performance.xml:172 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "" +"Select fetching (the default) is extremely vulnerable to N+1 selects " +"problems, so we might want to enable join fetching in the mapping document:" +msgstr "" +"查询抓取(默认的)在N+1查询的情况下是极其脆弱的,因此我们可能会要求在映射文档" +"中定义使用连接抓取:" + +#. Tag: programlisting +#: performance.xml:177 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"" msgstr "" -#: index.docbook:179 +#. Tag: programlisting +#: performance.xml:179 +#, no-c-format msgid "]]>" msgstr "" -#: index.docbook:181 -msgid "The fetch strategy defined in the mapping document affects:" +#. Tag: para +#: performance.xml:181 +#, no-c-format +msgid "" +"The fetch strategy defined in the mapping document " +"affects:" msgstr "" +"在映射文档中定义的抓取策略将会对以下列表条目产生影响:" -#: index.docbook:187 +#. Tag: para +#: performance.xml:187 +#, no-c-format msgid "retrieval via get() or load()" -msgstr "" +msgstr "通过get()load()方法取得数据。" -#: index.docbook:192 +#. Tag: para +#: performance.xml:192 +#, no-c-format msgid "retrieval that happens implicitly when an association is navigated" -msgstr "" +msgstr "只有在关联之间进行导航时,才会隐式的取得数据。" -#: index.docbook:197 +#. Tag: para +#: performance.xml:197 +#, no-c-format msgid "Criteria queries" -msgstr "" +msgstr "条件查询" -#: index.docbook:202 +#. Tag: para +#: performance.xml:202 +#, no-c-format msgid "HQL queries if subselect fetching is used" -msgstr "" +msgstr "使用了subselect抓取的HQL查询" -#: index.docbook:208 -msgid "No matter what fetching strategy you use, the defined non-lazy graph is guaranteed to be loaded into memory. Note that this might result in several immediate selects being used to execute a particular HQL query." -msgstr "" - -#: index.docbook:214 -msgid "Usually, we don't use the mapping document to customize fetching. Instead, we keep the default behavior, and override it for a particular transaction, using left join fetch in HQL. This tells Hibernate to fetch the association eagerly in the first select, using an outer join. In the Criteria query API, you would use setFetchMode(FetchMode.JOIN)." -msgstr "" - -#: index.docbook:223 -msgid "If you ever feel like you wish you could change the fetching strategy used by get() or load(), simply use a Criteria query, for example:" -msgstr "" - -#: index.docbook:229 +#. Tag: para +#: performance.xml:208 +#, no-c-format msgid "" - "" +"No matter what fetching strategy you use, the defined non-lazy graph is " +"guaranteed to be loaded into memory. Note that this might result in several " +"immediate selects being used to execute a particular HQL query." +msgstr "" +"不管你使用哪种抓取策略,定义为非延迟的类图会被保证一定装载入内存。注意这可能" +"意味着在一条HQL查询后紧跟着一系列的查询。" + +#. Tag: para +#: performance.xml:214 +#, no-c-format +msgid "" +"Usually, we don't use the mapping document to customize fetching. Instead, " +"we keep the default behavior, and override it for a particular transaction, " +"using left join fetch in HQL. This tells Hibernate to " +"fetch the association eagerly in the first select, using an outer join. In " +"the Criteria query API, you would use " +"setFetchMode(FetchMode.JOIN)." +msgstr "" +"通常情况下,我们并不使用映射文档进行抓取策略的定制。更多的是,保持其默认值," +"然后在特定的事务中, 使用HQL的左连接抓取(left join fetch) 对其进行重载。这将通知 Hibernate在第一次查询中使用外部关联(outer " +"join),直接得到其关联数据。 在条件查询 API中,应该调用 " +"setFetchMode(FetchMode.JOIN)语句。" + +#. Tag: para +#: performance.xml:223 +#, no-c-format +msgid "" +"If you ever feel like you wish you could change the fetching strategy used " +"by get() or load(), simply use a " +"Criteria query, for example:" +msgstr "" +"也许你喜欢仅仅通过条件查询,就可以改变get() 或 " +"load()语句中的数据抓取策略。例如:" + +#. Tag: programlisting +#: performance.xml:229 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:231 -msgid "(This is Hibernate's equivalent of what some ORM solutions call a \"fetch plan\".)" +#. Tag: para +#: performance.xml:231 +#, no-c-format +msgid "" +"(This is Hibernate's equivalent of what some ORM solutions call a \"fetch " +"plan\".)" msgstr "" +"(这就是其他ORM解决方案的“抓取计划(fetch plan)”在Hibernate中的等价物。)" -#: index.docbook:235 -msgid "A completely different way to avoid problems with N+1 selects is to use the second-level cache." -msgstr "" +#. Tag: para +#: performance.xml:235 +#, no-c-format +msgid "" +"A completely different way to avoid problems with N+1 selects is to use the " +"second-level cache." +msgstr "截然不同的一种避免N+1次查询的方法是,使用二级缓存。" -#: index.docbook:243 +#. Tag: title +#: performance.xml:243 +#, no-c-format msgid "Single-ended association proxies" -msgstr "" +msgstr "单端关联代理(Single-ended association proxies)" -#: index.docbook:245 -msgid "Lazy fetching for collections is implemented using Hibernate's own implementation of persistent collections. However, a different mechanism is needed for lazy behavior in single-ended associations. The target entity of the association must be proxied. Hibernate implements lazy initializing proxies for persistent objects using runtime bytecode enhancement (via the excellent CGLIB library)." -msgstr "" - -#: index.docbook:253 -msgid "By default, Hibernate3 generates proxies (at startup) for all persistent classes and uses them to enable lazy fetching of many-to-one and one-to-one associations." -msgstr "" - -#: index.docbook:259 -msgid "The mapping file may declare an interface to use as the proxy interface for that class, with the proxy attribute. By default, Hibernate uses a subclass of the class. Note that the proxied class must implement a default constructor with at least package visibility. We recommend this constructor for all persistent classes!" -msgstr "" - -#: index.docbook:266 -msgid "There are some gotchas to be aware of when extending this approach to polymorphic classes, eg." -msgstr "" - -#: index.docbook:271 +#. Tag: para +#: performance.xml:245 +#, no-c-format msgid "" - "\n" - " ......\n" - " \n" - " .....\n" - " \n" - "]]>" +"Lazy fetching for collections is implemented using Hibernate's own " +"implementation of persistent collections. However, a different mechanism is " +"needed for lazy behavior in single-ended associations. The target entity of " +"the association must be proxied. Hibernate implements lazy initializing " +"proxies for persistent objects using runtime bytecode enhancement (via the " +"excellent CGLIB library)." msgstr "" +"在Hinerbate中,对集合的延迟抓取的采用了自己的实现方法。但是,对于单端关联的延" +"迟抓取,则需要采用 其他不同的机制。单端关联的目标实体必须使用代理,Hihernate" +"在运行期二进制级(通过优异的CGLIB库), 为持久对象实现了延迟载入代理。" -#: index.docbook:273 -msgid "Firstly, instances of Cat will never be castable to DomesticCat, even if the underlying instance is an instance of DomesticCat:" -msgstr "" - -#: index.docbook:279 +#. Tag: para +#: performance.xml:253 +#, no-c-format msgid "" - "" +"By default, Hibernate3 generates proxies (at startup) for all persistent " +"classes and uses them to enable lazy fetching of many-to-one and one-to-one associations." +msgstr "" +"默认的,Hibernate3将会为所有的持久对象产生代理(在启动阶段),然后使用他们实" +"现 多对一(many-to-one)关联和一对一(one-to-" +"one) 关联的延迟抓取。" + +#. Tag: para +#: performance.xml:259 +#, no-c-format +msgid "" +"The mapping file may declare an interface to use as the proxy interface for " +"that class, with the proxy attribute. By default, " +"Hibernate uses a subclass of the class. Note that the proxied " +"class must implement a default constructor with at least package visibility. " +"We recommend this constructor for all persistent classes!" +msgstr "" +"在映射文件中,可以通过设置proxy属性为目标class声明一个接口" +"供代理接口使用。 默认的,Hibernate将会使用该类的一个子类。 注意:被" +"代理的类必须实现一个至少包可见的默认构造函数,我们建议所有的持久类都应拥有这" +"样的构造函数" + +#. Tag: para +#: performance.xml:266 +#, no-c-format +msgid "" +"There are some gotchas to be aware of when extending this approach to " +"polymorphic classes, eg." +msgstr "在如此方式定义一个多态类的时候,有许多值得注意的常见性的问题,例如:" + +#. Tag: programlisting +#: performance.xml:271 +#, no-c-format +msgid "" +"\n" +" ......\n" +" \n" +" .....\n" +" \n" +"]]>" msgstr "" -#: index.docbook:281 +#. Tag: para +#: performance.xml:273 +#, no-c-format +msgid "" +"Firstly, instances of Cat will never be castable to " +"DomesticCat, even if the underlying instance is an " +"instance of DomesticCat:" +msgstr "" +"首先,Cat实例永远不可以被强制转换为DomesticCat, 即使它本身就是DomesticCat实例。" + +#. Tag: programlisting +#: performance.xml:279 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: performance.xml:281 +#, no-c-format msgid "Secondly, it is possible to break proxy ==." -msgstr "" +msgstr "其次,代理的“==”可能不再成立。" -#: index.docbook:285 +#. Tag: programlisting +#: performance.xml:285 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:287 -msgid "However, the situation is not quite as bad as it looks. Even though we now have two references to different proxy objects, the underlying instance will still be the same object:" -msgstr "" - -#: index.docbook:292 +#. Tag: para +#: performance.xml:287 +#, no-c-format msgid "" - "" +"However, the situation is not quite as bad as it looks. Even though we now " +"have two references to different proxy objects, the underlying instance will " +"still be the same object:" msgstr "" +"虽然如此,但实际情况并没有看上去那么糟糕。虽然我们现在有两个不同的引用,分别" +"指向这两个不同的代理对象, 但实际上,其底层应该是同一个实例对象:" -#: index.docbook:294 -msgid "Third, you may not use a CGLIB proxy for a final class or a class with any final methods." -msgstr "" - -#: index.docbook:299 -msgid "Finally, if your persistent object acquires any resources upon instantiation (eg. in initializers or default constructor), then those resources will also be acquired by the proxy. The proxy class is an actual subclass of the persistent class." -msgstr "" - -#: index.docbook:305 -msgid "These problems are all due to fundamental limitations in Java's single inheritance model. If you wish to avoid these problems your persistent classes must each implement an interface that declares its business methods. You should specify these interfaces in the mapping file. eg." -msgstr "" - -#: index.docbook:311 +#. Tag: programlisting +#: performance.xml:292 +#, no-c-format msgid "" - "\n" - " ......\n" - " \n" - " .....\n" - " \n" - "]]>" +"" msgstr "" -#: index.docbook:313 -msgid "where CatImpl implements the interface Cat and DomesticCatImpl implements the interface DomesticCat. Then proxies for instances of Cat and DomesticCat may be returned by load() or iterate(). (Note that list() does not usually return proxies.)" -msgstr "" - -#: index.docbook:321 +#. Tag: para +#: performance.xml:294 +#, no-c-format msgid "" - "" +"Third, you may not use a CGLIB proxy for a final class or " +"a class with any final methods." +msgstr "第三,你不能对“final类”或“具有final方法的类”使用CGLIB代理。" + +#. Tag: para +#: performance.xml:299 +#, no-c-format +msgid "" +"Finally, if your persistent object acquires any resources upon instantiation " +"(eg. in initializers or default constructor), then those resources will also " +"be acquired by the proxy. The proxy class is an actual subclass of the " +"persistent class." +msgstr "" +"最后,如果你的持久化对象在实例化时需要某些资源(例如,在实例化方法、默认构造" +"方法中), 那么代理对象也同样需要使用这些资源。实际上,代理类是持久化类的子" +"类。" + +#. Tag: para +#: performance.xml:305 +#, no-c-format +msgid "" +"These problems are all due to fundamental limitations in Java's single " +"inheritance model. If you wish to avoid these problems your persistent " +"classes must each implement an interface that declares its business methods. " +"You should specify these interfaces in the mapping file. eg." +msgstr "" +"这些问题都源于Java的单根继承模型的天生限制。如果你希望避免这些问题,那么你的" +"每个持久化类必须实现一个接口, 在此接口中已经声明了其业务方法。然后,你需要在" +"映射文档中再指定这些接口。例如:" + +#. Tag: programlisting +#: performance.xml:311 +#, no-c-format +msgid "" +"\n" +" ......\n" +" \n" +" .....\n" +" \n" +"]]>" msgstr "" -#: index.docbook:323 -msgid "Relationships are also lazily initialized. This means you must declare any properties to be of type Cat, not CatImpl." +#. Tag: para +#: performance.xml:313 +#, no-c-format +msgid "" +"where CatImpl implements the interface Cat and DomesticCatImpl implements the interface " +"DomesticCat. Then proxies for instances of Cat and DomesticCat may be returned by load" +"() or iterate(). (Note that list() does not usually return proxies.)" +msgstr "" +"这里CatImpl实现了Cat接口, " +"DomesticCatImpl实现DomesticCat接口。 在" +"load()iterate()方法中就会返回 " +"CatDomesticCat的代理对象。 (注意" +"list()并不会返回代理对象。)" + +#. Tag: programlisting +#: performance.xml:321 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:328 -msgid "Certain operations do not require proxy initialization" +#. Tag: para +#: performance.xml:323 +#, no-c-format +msgid "" +"Relationships are also lazily initialized. This means you must declare any " +"properties to be of type Cat, not CatImpl." msgstr "" +"这里,对象之间的关系也将被延迟载入。这就意味着,你应该将属性声明为" +"Cat,而不是CatImpl。" -#: index.docbook:334 -msgid "equals(), if the persistent class does not override equals()" +#. Tag: para +#: performance.xml:328 +#, no-c-format +msgid "" +"Certain operations do not require proxy initialization" +msgstr "但是,在有些方法中是不需要使用代理的。例如:" + +#. Tag: para +#: performance.xml:334 +#, no-c-format +msgid "" +"equals(), if the persistent class does not override " +"equals()" msgstr "" +"equals()方法,如果持久类没有重载equals()方法。" -#: index.docbook:340 -msgid "hashCode(), if the persistent class does not override hashCode()" +#. Tag: para +#: performance.xml:340 +#, no-c-format +msgid "" +"hashCode(), if the persistent class does not override " +"hashCode()" msgstr "" +"hashCode()方法,如果持久类没有重载hashCode()方法。" -#: index.docbook:346 +#. Tag: para +#: performance.xml:346 +#, no-c-format msgid "The identifier getter method" -msgstr "" +msgstr "标志符的getter方法。" -#: index.docbook:352 -msgid "Hibernate will detect persistent classes that override equals() or hashCode()." +#. Tag: para +#: performance.xml:352 +#, no-c-format +msgid "" +"Hibernate will detect persistent classes that override equals() or hashCode()." msgstr "" +"Hibernate将会识别出那些重载了equals()、或hashCode" +"()方法的持久化类。" -#: index.docbook:357 -msgid "By choosing lazy=\"no-proxy\" instead of the default lazy=\"proxy\", we can avoid the problems associated with typecasting. However, we will require buildtime bytecode instrumentation, and all operations will result in immediate proxy initialization." +#. Tag: para +#: performance.xml:357 +#, no-c-format +msgid "" +"By choosing lazy=\"no-proxy\" instead of the default " +"lazy=\"proxy\", we can avoid the problems associated with " +"typecasting. However, we will require buildtime bytecode instrumentation, " +"and all operations will result in immediate proxy initialization." msgstr "" +"若选择lazy=\"no-proxy\"而非默认的lazy=\"proxy\",我们可以避免类型转换带来的问题。然而,这样我们就需要编译期字节码增" +"强,并且所有的操作都会导致立刻进行代理初始化。" -#: index.docbook:367 +#. Tag: title +#: performance.xml:367 +#, no-c-format msgid "Initializing collections and proxies" +msgstr "实例化集合和代理(Initializing collections and proxies)" + +#. Tag: para +#: performance.xml:369 +#, no-c-format +msgid "" +"A LazyInitializationException will be thrown by Hibernate " +"if an uninitialized collection or proxy is accessed outside of the scope of " +"the Session, ie. when the entity owning the collection or " +"having the reference to the proxy is in the detached state." +msgstr "" +"在Session范围之外访问未初始化的集合或代理,Hibernate将会抛" +"出LazyInitializationException异常。 也就是说,在分离状态" +"下,访问一个实体所拥有的集合,或者访问其指向代理的属性时,会引发此异常。" + +#. Tag: para +#: performance.xml:375 +#, no-c-format +msgid "" +"Sometimes we need to ensure that a proxy or collection is initialized before " +"closing the Session. Of course, we can alway force " +"initialization by calling cat.getSex() or cat." +"getKittens().size(), for example. But that is confusing to readers " +"of the code and is not convenient for generic code." +msgstr "" +"有时候我们需要保证某个代理或者集合在Session关闭前就已经被初始化了。 当然,我" +"们可以通过强行调用cat.getSex()或者cat.getKittens" +"().size()之类的方法来确保这一点。 但是这样的程序会造成读者的疑惑," +"也不符合通常的代码规范。" + +#. Tag: para +#: performance.xml:382 +#, no-c-format +msgid "" +"The static methods Hibernate.initialize() and " +"Hibernate.isInitialized() provide the application with a " +"convenient way of working with lazily initialized collections or proxies. " +"Hibernate.initialize(cat) will force the initialization " +"of a proxy, cat, as long as its Session is still open. Hibernate.initialize( cat.getKittens() ) has a similar effect for the collection of kittens." +msgstr "" +"静态方法Hibernate.initialized() 为你的应用程序提供了一个便" +"捷的途径来延迟加载集合或代理。 只要它的Session处于open状态," +"Hibernate.initialize(cat) 将会为cat强制对代理实例化。 同" +"样,Hibernate.initialize( cat.getKittens() ) 对kittens的集" +"合具有同样的功能。" + +#. Tag: para +#: performance.xml:391 +#, no-c-format +msgid "" +"Another option is to keep the Session open until all " +"needed collections and proxies have been loaded. In some application " +"architectures, particularly where the code that accesses data using " +"Hibernate, and the code that uses it are in different application layers or " +"different physical processes, it can be a problem to ensure that the " +"Session is open when a collection is initialized. There " +"are two basic ways to deal with this issue:" +msgstr "" +"还有另外一种选择,就是保持Session一直处于open状态,直到所" +"有需要的集合或代理都被载入。 在某些应用架构中,特别是对于那些使用Hibernate进" +"行数据访问的代码,以及那些在不同应用层和不同物理进程中使用Hibernate的代码。 " +"在集合实例化时,如何保证Session处于open状态经常会是一个问" +"题。有两种方法可以解决此问题:" + +#. Tag: para +#: performance.xml:402 +#, no-c-format +msgid "" +"In a web-based application, a servlet filter can be used to close the " +"Session only at the very end of a user request, once the " +"rendering of the view is complete (the Open Session in View pattern). Of course, this places heavy demands on the correctness " +"of the exception handling of your application infrastructure. It is vitally " +"important that the Session is closed and the transaction " +"ended before returning to the user, even when an exception occurs during " +"rendering of the view. See the Hibernate Wiki for examples of this \"Open " +"Session in View\" pattern." +msgstr "" +"在一个基于Web的应用中,可以利用servlet过滤器(filter),在用户请求(request)" +"结束、页面生成 结束时关闭Session(这里使用了在展" +"示层保持打开Session模式(Open Session in View)), 当然,这将依赖" +"于应用框架中异常需要被正确的处理。在返回界面给用户之前,乃至在生成界面过程中" +"发生异常的情况下, 正确关闭Session和结束事务将是非常重要" +"的, 请参见Hibernate wiki上的\"Open Session in View\"模式,你可以找到示例。" + +#. Tag: para +#: performance.xml:415 +#, no-c-format +msgid "" +"In an application with a separate business tier, the business logic must " +"\"prepare\" all collections that will be needed by the web tier before " +"returning. This means that the business tier should load all the data and " +"return all the data already initialized to the presentation/web tier that is " +"required for a particular use case. Usually, the application calls " +"Hibernate.initialize() for each collection that will be " +"needed in the web tier (this call must occur before the session is closed) " +"or retrieves the collection eagerly using a Hibernate query with a " +"FETCH clause or a FetchMode.JOIN in " +"Criteria. This is usually easier if you adopt the " +"Command pattern instead of a Session Facade." +msgstr "" +"在一个拥有单独业务层的应用中,业务层必须在返回之前,为web层“准备”好其所需的数" +"据集合。这就意味着 业务层应该载入所有表现层/web层所需的数据,并将这些已实例化" +"完毕的数据返回。通常,应用程序应该 为web层所需的每个集合调用" +"Hibernate.initialize()(这个调用必须发生咱session关闭之" +"前); 或者使用带有FETCH从句,或FetchMode.JOIN的Hibernate查询, 事先取得所有的数据集合。如果你在应用中使用了" +"Command模式,代替Session Facade , " +"那么这项任务将会变得简单的多。" + +#. Tag: para +#: performance.xml:430 +#, no-c-format +msgid "" +"You may also attach a previously loaded object to a new Session with merge() or lock() before " +"accessing uninitialized collections (or other proxies). No, Hibernate does " +"not, and certainly should not do this automatically, " +"since it would introduce ad hoc transaction semantics!" +msgstr "" +"你也可以通过merge()lock()方法,在访问" +"未实例化的集合(或代理)之前, 为先前载入的对象绑定一个新的Session。 显然,Hibernate将不会,也不应该自动完成这些任" +"务,因为这将引入一个特殊的事务语义。" + +#. Tag: para +#: performance.xml:440 +#, no-c-format +msgid "" +"Sometimes you don't want to initialize a large collection, but still need " +"some information about it (like its size) or a subset of the data." +msgstr "" +"有时候,你并不需要完全实例化整个大的集合,仅需要了解它的部分信息(例如其大" +"小)、或者集合的部分内容。" + +#. Tag: para +#: performance.xml:445 +#, no-c-format +msgid "" +"You can use a collection filter to get the size of a collection without " +"initializing it:" +msgstr "你可以使用集合过滤器得到其集合的大小,而不必实例化整个集合:" + +#. Tag: programlisting +#: performance.xml:449 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:369 -msgid "A LazyInitializationException will be thrown by Hibernate if an uninitialized collection or proxy is accessed outside of the scope of the Session, ie. when the entity owning the collection or having the reference to the proxy is in the detached state." +#. Tag: para +#: performance.xml:451 +#, no-c-format +msgid "" +"The createFilter() method is also used to efficiently " +"retrieve subsets of a collection without needing to initialize the whole " +"collection:" +msgstr "" +"这里的createFilter()方法也可以被用来有效的抓取集合的部分内" +"容,而无需实例化整个集合:" + +#. Tag: programlisting +#: performance.xml:456 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:375 -msgid "Sometimes we need to ensure that a proxy or collection is initialized before closing the Session. Of course, we can alway force initialization by calling cat.getSex() or cat.getKittens().size(), for example. But that is confusing to readers of the code and is not convenient for generic code." -msgstr "" - -#: index.docbook:382 -msgid "The static methods Hibernate.initialize() and Hibernate.isInitialized() provide the application with a convenient way of working with lazily initialized collections or proxies. Hibernate.initialize(cat) will force the initialization of a proxy, cat, as long as its Session is still open. Hibernate.initialize( cat.getKittens() ) has a similar effect for the collection of kittens." -msgstr "" - -#: index.docbook:391 -msgid "Another option is to keep the Session open until all needed collections and proxies have been loaded. In some application architectures, particularly where the code that accesses data using Hibernate, and the code that uses it are in different application layers or different physical processes, it can be a problem to ensure that the Session is open when a collection is initialized. There are two basic ways to deal with this issue:" -msgstr "" - -#: index.docbook:402 -msgid "In a web-based application, a servlet filter can be used to close the Session only at the very end of a user request, once the rendering of the view is complete (the Open Session in View pattern). Of course, this places heavy demands on the correctness of the exception handling of your application infrastructure. It is vitally important that the Session is closed and the transaction ended before returning to the user, even when an exception occurs during rendering of the view. See the Hibernate Wiki for examples of this \"Open Session in View\" pattern." -msgstr "" - -#: index.docbook:415 -msgid "In an application with a separate business tier, the business logic must \"prepare\" all collections that will be needed by the web tier before returning. This means that the business tier should load all the data and return all the data already initialized to the presentation/web tier that is required for a particular use case. Usually, the application calls Hibernate.initialize() for each collection that will be needed in the web tier (this call must occur before the session is closed) or retrieves the collection eagerly using a Hibernate query with a FETCH clause or a FetchMode.JOIN in Criteria. This is usually easier if you adopt the Command pattern instead of a Session Facade." -msgstr "" - -#: index.docbook:430 -msgid "You may also attach a previously loaded object to a new Session with merge() or lock() before accessing uninitialized collections (or other proxies). No, Hibernate does not, and certainly should not do this automatically, since it would introduce ad hoc transaction semantics!" -msgstr "" - -#: index.docbook:440 -msgid "Sometimes you don't want to initialize a large collection, but still need some information about it (like its size) or a subset of the data." -msgstr "" - -#: index.docbook:445 -msgid "You can use a collection filter to get the size of a collection without initializing it:" -msgstr "" - -#: index.docbook:449 -msgid "" -msgstr "" - -#: index.docbook:451 -msgid "The createFilter() method is also used to efficiently retrieve subsets of a collection without needing to initialize the whole collection:" -msgstr "" - -#: index.docbook:456 -msgid "" -msgstr "" - -#: index.docbook:461 +#. Tag: title +#: performance.xml:461 +#, no-c-format msgid "Using batch fetching" -msgstr "" +msgstr "使用批量抓取(Using batch fetching)" -#: index.docbook:463 -msgid "Hibernate can make efficient use of batch fetching, that is, Hibernate can load several uninitialized proxies if one proxy is accessed (or collections. Batch fetching is an optimization of the lazy select fetching strategy. There are two ways you can tune batch fetching: on the class and the collection level." +#. Tag: para +#: performance.xml:463 +#, no-c-format +msgid "" +"Hibernate can make efficient use of batch fetching, that is, Hibernate can " +"load several uninitialized proxies if one proxy is accessed (or collections. " +"Batch fetching is an optimization of the lazy select fetching strategy. " +"There are two ways you can tune batch fetching: on the class and the " +"collection level." msgstr "" +"Hibernate可以充分有效的使用批量抓取,也就是说,如果仅一个访问代理(或集合)," +"那么Hibernate将不载入其他未实例化的代理。 批量抓取是延迟查询抓取的优化方案," +"你可以在两种批量抓取方案之间进行选择:在类级别和集合级别。" -#: index.docbook:469 -msgid "Batch fetching for classes/entities is easier to understand. Imagine you have the following situation at runtime: You have 25 Cat instances loaded in a Session, each Cat has a reference to its owner, a Person. The Person class is mapped with a proxy, lazy=\"true\". If you now iterate through all cats and call getOwner() on each, Hibernate will by default execute 25 SELECT statements, to retrieve the proxied owners. You can tune this behavior by specifying a batch-size in the mapping of Person:" +#. Tag: para +#: performance.xml:469 +#, no-c-format +msgid "" +"Batch fetching for classes/entities is easier to understand. Imagine you " +"have the following situation at runtime: You have 25 Cat " +"instances loaded in a Session, each Cat has a reference to its owner, a Person. The Person class is mapped with a proxy, " +"lazy=\"true\". If you now iterate through all cats and " +"call getOwner() on each, Hibernate will by default " +"execute 25 SELECT statements, to retrieve the proxied " +"owners. You can tune this behavior by specifying a batch-size in the mapping of Person:" msgstr "" +"类/实体级别的批量抓取很容易理解。假设你在运行时将需要面对下面的问题:你在一个" +"Session中载入了25个 Cat实例,每个" +"Cat实例都拥有一个引用成员owner, 其指向" +"Person,而Person类是代理,同时" +"lazy=\"true\"。 如果你必须遍历整个cats集合,对每个元素调用" +"getOwner()方法,Hibernate将会默认的执行25次" +"SELECT查询, 得到其owner的代理对象。这时,你可以通过在映射" +"文件的Person属性,显式声明batch-size," +"改变其行为:" -#: index.docbook:479 +#. Tag: programlisting +#: performance.xml:479 +#, no-c-format msgid "...]]>" msgstr "" -#: index.docbook:481 -msgid "Hibernate will now execute only three queries, the pattern is 10, 10, 5." -msgstr "" - -#: index.docbook:485 -msgid "You may also enable batch fetching of collections. For example, if each Person has a lazy collection of Cats, and 10 persons are currently loaded in the Sesssion, iterating through all persons will generate 10 SELECTs, one for every call to getCats(). If you enable batch fetching for the cats collection in the mapping of Person, Hibernate can pre-fetch collections:" -msgstr "" - -#: index.docbook:494 +#. Tag: para +#: performance.xml:481 +#, no-c-format msgid "" - "\n" - " \n" - " ...\n" - " \n" - "]]>" +"Hibernate will now execute only three queries, the pattern is 10, 10, 5." +msgstr "随之,Hibernate将只需要执行三次查询,分别为10、10、 5。" + +#. Tag: para +#: performance.xml:485 +#, no-c-format +msgid "" +"You may also enable batch fetching of collections. For example, if each " +"Person has a lazy collection of Cats, " +"and 10 persons are currently loaded in the Sesssion, " +"iterating through all persons will generate 10 SELECTs, " +"one for every call to getCats(). If you enable batch " +"fetching for the cats collection in the mapping of " +"Person, Hibernate can pre-fetch collections:" +msgstr "" +"你也可以在集合级别定义批量抓取。例如,如果每个Person都拥有" +"一个延迟载入的Cats集合, 现在,Sesssion" +"中载入了10个person对象,遍历person集合将会引起10次SELECT查" +"询, 每次查询都会调用getCats()方法。如果你在" +"Person的映射定义部分,允许对cats批量抓" +"取, 那么,Hibernate将可以预先抓取整个集合。请看例子:" + +#. Tag: programlisting +#: performance.xml:494 +#, no-c-format +msgid "" +"\n" +" \n" +" ...\n" +" \n" +"]]>" msgstr "" -#: index.docbook:496 -msgid "With a batch-size of 3, Hibernate will load 3, 3, 3, 1 collections in four SELECTs. Again, the value of the attribute depends on the expected number of uninitialized collections in a particular Session." +#. Tag: para +#: performance.xml:496 +#, no-c-format +msgid "" +"With a batch-size of 3, Hibernate will load 3, 3, 3, 1 " +"collections in four SELECTs. Again, the value of the " +"attribute depends on the expected number of uninitialized collections in a " +"particular Session." msgstr "" +"如果整个的batch-size是3(笔误?),那么Hibernate将会分四次" +"执行SELECT查询, 按照3、3、3、1的大小分别载入数据。这里的" +"每次载入的数据量还具体依赖于当前Session中未实例化集合的个" +"数。" -#: index.docbook:502 -msgid "Batch fetching of collections is particularly useful if you have a nested tree of items, ie. the typical bill-of-materials pattern. (Although a nested set or a materialized path might be a better option for read-mostly trees.)" +#. Tag: para +#: performance.xml:502 +#, no-c-format +msgid "" +"Batch fetching of collections is particularly useful if you have a nested " +"tree of items, ie. the typical bill-of-materials pattern. (Although a " +"nested set or a materialized path " +"might be a better option for read-mostly trees.)" msgstr "" +"如果你的模型中有嵌套的树状结构,例如典型的帐单-原料结构(bill-of-materials " +"pattern),集合的批量抓取是非常有用的。 (尽管在更多情况下对树进行读取时," +"嵌套集合(nested set)原料路径(materialized " +"path)(××) 是更好的解决方法。)" -#: index.docbook:511 +#. Tag: title +#: performance.xml:511 +#, no-c-format msgid "Using subselect fetching" -msgstr "" +msgstr "使用子查询抓取(Using subselect fetching)" -#: index.docbook:513 -msgid "If one lazy collection or single-valued proxy has to be fetched, Hibernate loads all of them, re-running the original query in a subselect. This works in the same way as batch-fetching, without the piecemeal loading." +#. Tag: para +#: performance.xml:513 +#, no-c-format +msgid "" +"If one lazy collection or single-valued proxy has to be fetched, Hibernate " +"loads all of them, re-running the original query in a subselect. This works " +"in the same way as batch-fetching, without the piecemeal loading." msgstr "" +"假若一个延迟集合或单值代理需要抓取,Hibernate会使用一个subselect重新运行原来" +"的查询,一次性读入所有的实例。这和批量抓取的实现方法是一样的,不会有破碎的加" +"载。" -#: index.docbook:524 +#. Tag: title +#: performance.xml:524 +#, no-c-format msgid "Using lazy property fetching" -msgstr "" +msgstr "使用延迟属性抓取(Using lazy property fetching)" -#: index.docbook:526 -msgid "Hibernate3 supports the lazy fetching of individual properties. This optimization technique is also known as fetch groups. Please note that this is mostly a marketing feature, as in practice, optimizing row reads is much more important than optimization of column reads. However, only loading some properties of a class might be useful in extreme cases, when legacy tables have hundreds of columns and the data model can not be improved." -msgstr "" - -#: index.docbook:535 -msgid "To enable lazy property loading, set the lazy attribute on your particular property mappings:" -msgstr "" - -#: index.docbook:540 +#. Tag: para +#: performance.xml:526 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"Hibernate3 supports the lazy fetching of individual properties. This " +"optimization technique is also known as fetch groups. " +"Please note that this is mostly a marketing feature, as in practice, " +"optimizing row reads is much more important than optimization of column " +"reads. However, only loading some properties of a class might be useful in " +"extreme cases, when legacy tables have hundreds of columns and the data " +"model can not be improved." +msgstr "" +"Hibernate3对单独的属性支持延迟抓取,这项优化技术也被称为组抓取" +"(fetch groups)。 请注意,该技术更多的属于市场特性。在实际应用" +"中,优化行读取比优化列读取更重要。但是,仅载入类的部分属性在某些特定情况下会" +"有用,例如在原有表中拥有几百列数据、数据模型无法改动的情况下。" + +#. Tag: para +#: performance.xml:535 +#, no-c-format +msgid "" +"To enable lazy property loading, set the lazy attribute " +"on your particular property mappings:" +msgstr "" +"可以在映射文件中对特定的属性设置lazy,定义该属性为延迟载" +"入。" + +#. Tag: programlisting +#: performance.xml:540 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:542 -msgid "Lazy property loading requires buildtime bytecode instrumentation! If your persistent classes are not enhanced, Hibernate will silently ignore lazy property settings and fall back to immediate fetching." +#. Tag: para +#: performance.xml:542 +#, no-c-format +msgid "" +"Lazy property loading requires buildtime bytecode instrumentation! If your " +"persistent classes are not enhanced, Hibernate will silently ignore lazy " +"property settings and fall back to immediate fetching." msgstr "" +"属性的延迟载入要求在其代码构建时加入二进制指示指令(bytecode " +"instrumentation),如果你的持久类代码中未含有这些指令, Hibernate将会忽略这些" +"属性的延迟设置,仍然将其直接载入。" -#: index.docbook:548 +#. Tag: para +#: performance.xml:548 +#, no-c-format msgid "For bytecode instrumentation, use the following Ant task:" -msgstr "" +msgstr "你可以在Ant的Task中,进行如下定义,对持久类代码加入“二进制指令。”" -#: index.docbook:552 +#. Tag: programlisting +#: performance.xml:552 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:554 -msgid "A different (better?) way to avoid unnecessary column reads, at least for read-only transactions is to use the projection features of HQL or Criteria queries. This avoids the need for buildtime bytecode processing and is certainly a prefered solution." +#. Tag: para +#: performance.xml:554 +#, no-c-format +msgid "" +"A different (better?) way to avoid unnecessary column reads, at least for " +"read-only transactions is to use the projection features of HQL or Criteria " +"queries. This avoids the need for buildtime bytecode processing and is " +"certainly a prefered solution." msgstr "" +"还有一种可以优化的方法,它使用HQL或条件查询的投影(projection)特性,可以避免" +"读取非必要的列, 这一点至少对只读事务是非常有用的。它无需在代码构建时“二进制" +"指令”处理,因此是一个更加值得选择的解决方法。" -#: index.docbook:561 -msgid "You may force the usual eager fetching of properties using fetch all properties in HQL." +#. Tag: para +#: performance.xml:561 +#, no-c-format +msgid "" +"You may force the usual eager fetching of properties using fetch " +"all properties in HQL." msgstr "" +"有时你需要在HQL中通过抓取所有属性,强行抓取所有内容。" -#: index.docbook:571 +#. Tag: title +#: performance.xml:571 +#, no-c-format msgid "The Second Level Cache" -msgstr "" +msgstr "二级缓存(The Second Level Cache)" -#: index.docbook:573 -msgid "A Hibernate Session is a transaction-level cache of persistent data. It is possible to configure a cluster or JVM-level (SessionFactory-level) cache on a class-by-class and collection-by-collection basis. You may even plug in a clustered cache. Be careful. Caches are never aware of changes made to the persistent store by another application (though they may be configured to regularly expire cached data)." +#. Tag: para +#: performance.xml:573 +#, no-c-format +msgid "" +"A Hibernate Session is a transaction-level cache of " +"persistent data. It is possible to configure a cluster or JVM-level " +"(SessionFactory-level) cache on a class-by-class and " +"collection-by-collection basis. You may even plug in a clustered cache. Be " +"careful. Caches are never aware of changes made to the persistent store by " +"another application (though they may be configured to regularly expire " +"cached data)." msgstr "" +"Hibernate的Session在事务级别进行持久化数据的缓存操作。 当" +"然,也有可能分别为每个类(或集合),配置集群、或JVM级别" +"(SessionFactory级别)的缓存。 你甚至可以为之插入一个集群的" +"缓存。注意,缓存永远不知道其他应用程序对持久化仓库(数据库)可能进行的修改 " +"(即使可以将缓存数据设定为定期失效)。" -#: index.docbook:581 -msgid "You have the option to tell Hibernate which caching implementation to use by specifying the name of a class that implements org.hibernate.cache.CacheProvider using the property hibernate.cache.provider_class. Hibernate comes bundled with a number of built-in integrations with open-source cache providers (listed below); additionally, you could implement your own and plug it in as outlined above. Note that versions prior to 3.2 defaulted to use EhCache as the default cache provider; that is no longer the case as of 3.2." +#. Tag: para +#: performance.xml:581 +#, no-c-format +msgid "" +"You have the option to tell Hibernate which caching implementation to use by " +"specifying the name of a class that implements org.hibernate.cache." +"CacheProvider using the property hibernate.cache." +"provider_class. Hibernate comes bundled with a number of built-in " +"integrations with open-source cache providers (listed below); additionally, " +"you could implement your own and plug it in as outlined above. Note that " +"versions prior to 3.2 defaulted to use EhCache as the default cache " +"provider; that is no longer the case as of 3.2." msgstr "" +"通过在hibernate.cache.provider_class属性中指定" +"org.hibernate.cache.CacheProvider的某个实现的类名,你可以选" +"择让Hibernate使用哪个缓存实现。Hibernate打包一些开源缓存实现,提供对它们的内" +"置支持(见下表)。除此之外,你也可以实现你自己的实现,将它们插入到系统中。注" +"意,在3.2版本之前,默认使用EhCache 作为缓存实现,但从3.2起就不再这样了。" -#: index.docbook:592 +#. Tag: title +#: performance.xml:592 +#, no-c-format msgid "Cache Providers" -msgstr "" +msgstr "缓存策略提供商(Cache Providers)" -#: index.docbook:601, index.docbook:774 +#. Tag: entry +#: performance.xml:601 performance.xml:774 +#, no-c-format msgid "Cache" -msgstr "" +msgstr "Cache" -#: index.docbook:602 +#. Tag: entry +#: performance.xml:602 +#, no-c-format msgid "Provider class" -msgstr "" +msgstr "Provider class" -#: index.docbook:603 +#. Tag: entry +#: performance.xml:603 +#, no-c-format msgid "Type" -msgstr "" +msgstr "Type" -#: index.docbook:604 +#. Tag: entry +#: performance.xml:604 +#, no-c-format msgid "Cluster Safe" -msgstr "" +msgstr "Cluster Safe" -#: index.docbook:605 +#. Tag: entry +#: performance.xml:605 +#, no-c-format msgid "Query Cache Supported" -msgstr "" +msgstr "Query Cache Supported" -#: index.docbook:610, index.docbook:783 +#. Tag: entry +#: performance.xml:610 performance.xml:783 +#, no-c-format msgid "Hashtable (not intended for production use)" -msgstr "" +msgstr "Hashtable (not intended for production use)" -#: index.docbook:611 +#. Tag: literal +#: performance.xml:611 +#, no-c-format msgid "org.hibernate.cache.HashtableCacheProvider" -msgstr "" +msgstr "org.hibernate.cache.HashtableCacheProvider" -#: index.docbook:612 +#. Tag: entry +#: performance.xml:612 +#, no-c-format msgid "memory" -msgstr "" +msgstr "memory" -#: index.docbook:614, index.docbook:621, index.docbook:628, index.docbook:784, index.docbook:785, index.docbook:786, index.docbook:791, index.docbook:792, index.docbook:793, index.docbook:798, index.docbook:799, index.docbook:800, index.docbook:805, index.docbook:806, index.docbook:812, index.docbook:815 +#. Tag: entry +#: performance.xml:614 performance.xml:621 performance.xml:628 +#: performance.xml:784 performance.xml:785 performance.xml:786 +#: performance.xml:791 performance.xml:792 performance.xml:793 +#: performance.xml:798 performance.xml:799 performance.xml:800 +#: performance.xml:805 performance.xml:806 performance.xml:812 +#: performance.xml:815 +#, no-c-format msgid "yes" msgstr "" -#: index.docbook:617, index.docbook:790 +#. Tag: entry +#: performance.xml:617 performance.xml:790 +#, no-c-format msgid "EHCache" -msgstr "" +msgstr "EHCache" -#: index.docbook:618 +#. Tag: literal +#: performance.xml:618 +#, no-c-format msgid "org.hibernate.cache.EhCacheProvider" -msgstr "" +msgstr "org.hibernate.cache.EhCacheProvider" -#: index.docbook:619, index.docbook:626 +#. Tag: entry +#: performance.xml:619 performance.xml:626 +#, no-c-format msgid "memory, disk" -msgstr "" +msgstr "memory, disk" -#: index.docbook:624, index.docbook:797 +#. Tag: entry +#: performance.xml:624 performance.xml:797 +#, no-c-format msgid "OSCache" -msgstr "" +msgstr "OSCache" -#: index.docbook:625 +#. Tag: literal +#: performance.xml:625 +#, no-c-format msgid "org.hibernate.cache.OSCacheProvider" -msgstr "" +msgstr "org.hibernate.cache.OSCacheProvider" -#: index.docbook:631, index.docbook:804 +#. Tag: entry +#: performance.xml:631 performance.xml:804 +#, no-c-format msgid "SwarmCache" -msgstr "" +msgstr "SwarmCache" -#: index.docbook:632 +#. Tag: literal +#: performance.xml:632 +#, no-c-format msgid "org.hibernate.cache.SwarmCacheProvider" -msgstr "" +msgstr "org.hibernate.cache.SwarmCacheProvider" -#: index.docbook:633 +#. Tag: entry +#: performance.xml:633 +#, no-c-format msgid "clustered (ip multicast)" -msgstr "" +msgstr "clustered (ip multicast)" -#: index.docbook:634 +#. Tag: entry +#: performance.xml:634 +#, no-c-format msgid "yes (clustered invalidation)" -msgstr "" +msgstr "yes (clustered invalidation)" -#: index.docbook:638, index.docbook:811 +#. Tag: entry +#: performance.xml:638 performance.xml:811 +#, no-c-format msgid "JBoss TreeCache" -msgstr "" +msgstr "JBoss TreeCache" -#: index.docbook:639 +#. Tag: literal +#: performance.xml:639 +#, no-c-format msgid "org.hibernate.cache.TreeCacheProvider" -msgstr "" +msgstr "org.hibernate.cache.TreeCacheProvider" -#: index.docbook:640 +#. Tag: entry +#: performance.xml:640 +#, no-c-format msgid "clustered (ip multicast), transactional" -msgstr "" +msgstr "clustered (ip multicast), transactional" -#: index.docbook:641 +#. Tag: entry +#: performance.xml:641 +#, no-c-format msgid "yes (replication)" -msgstr "" +msgstr "yes (replication)" -#: index.docbook:642 +#. Tag: entry +#: performance.xml:642 +#, no-c-format msgid "yes (clock sync req.)" -msgstr "" +msgstr "yes (clock sync req.)" -#: index.docbook:649 +#. Tag: title +#: performance.xml:649 +#, no-c-format msgid "Cache mappings" -msgstr "" +msgstr "缓存映射(Cache mappings)" -#: index.docbook:651 -msgid "The <cache> element of a class or collection mapping has the following form:" -msgstr "" - -#: index.docbook:662 +#. Tag: para +#: performance.xml:651 +#, no-c-format msgid "" - "]]>" +"The <cache> element of a class or collection " +"mapping has the following form:" +msgstr "类或者集合映射的“<cache>元素”可以有下列形式:" + +#. Tag: programlisting +#: performance.xml:662 +#, no-c-format +msgid "" +"]]>" msgstr "" -#: index.docbook:665 -msgid "usage (required) specifies the caching strategy: transactional, read-write, nonstrict-read-write or read-only" +#. Tag: para +#: performance.xml:665 +#, no-c-format +msgid "" +"usage (required) specifies the caching strategy: " +"transactional, read-write, " +"nonstrict-read-write or read-only" msgstr "" +"usage(必须)说明了缓存的策略: transactionalread-writenonstrict-read-writeread-only。" -#: index.docbook:674 -msgid "region (optional, defaults to the class or collection role name) specifies the name of the second level cache region" +#. Tag: para +#: performance.xml:674 +#, no-c-format +msgid "" +"region (optional, defaults to the class or collection " +"role name) specifies the name of the second level cache region" msgstr "" +"region (可选, 默认为类或者集合的名字(class or collection " +"role name)) 指定第二级缓存的区域名(name of the second level cache region)" -#: index.docbook:681 -msgid "include (optional, defaults to all) non-lazy specifies that properties of the entity mapped with lazy=\"true\" may not be cached when attribute-level lazy fetching is enabled" +#. Tag: para +#: performance.xml:681 +#, no-c-format +msgid "" +"include (optional, defaults to all) " +"non-lazy specifies that properties of the entity mapped " +"with lazy=\"true\" may not be cached when attribute-level " +"lazy fetching is enabled" msgstr "" +"include (可选,默认为 all) non-" +"lazy 当属性级延迟抓取打开时, 标记为lazy=\"true\"" +"的实体的属性可能无法被缓存" -#: index.docbook:691 -msgid "Alternatively (preferrably?), you may specify <class-cache> and <collection-cache> elements in hibernate.cfg.xml." +#. Tag: para +#: performance.xml:691 +#, no-c-format +msgid "" +"Alternatively (preferrably?), you may specify <class-cache> and <collection-cache> elements in " +"hibernate.cfg.xml." msgstr "" +"另外(首选?), 你可以在hibernate.cfg.xml中指定<class-cache><collection-cache> 元素。" -#: index.docbook:696 -msgid "The usage attribute specifies a cache concurrency strategy." +#. Tag: para +#: performance.xml:696 +#, no-c-format +msgid "" +"The usage attribute specifies a cache " +"concurrency strategy." msgstr "" +"这里的usage 属性指明了缓存并发策略(cache " +"concurrency strategy)。" -#: index.docbook:703 +#. Tag: title +#: performance.xml:703 +#, no-c-format msgid "Strategy: read only" -msgstr "" +msgstr "策略:只读缓存(Strategy: read only)" -#: index.docbook:705 -msgid "If your application needs to read but never modify instances of a persistent class, a read-only cache may be used. This is the simplest and best performing strategy. It's even perfectly safe for use in a cluster." -msgstr "" - -#: index.docbook:711 +#. Tag: para +#: performance.xml:705 +#, no-c-format msgid "" - "\n" - " \n" - " ....\n" - "]]>" +"If your application needs to read but never modify instances of a persistent " +"class, a read-only cache may be used. This is the " +"simplest and best performing strategy. It's even perfectly safe for use in a " +"cluster." +msgstr "" +"如果你的应用程序只需读取一个持久化类的实例,而无需对其修改, 那么就可以对其进" +"行只读 缓存。这是最简单,也是实用性最好的方法。甚至在集群" +"中,它也能完美地运作。" + +#. Tag: programlisting +#: performance.xml:711 +#, no-c-format +msgid "" +"\n" +" \n" +" ....\n" +"]]>" msgstr "" -#: index.docbook:717 +#. Tag: title +#: performance.xml:717 +#, no-c-format msgid "Strategy: read/write" -msgstr "" +msgstr "策略:读/写缓存(Strategy: read/write)" -#: index.docbook:719 -msgid "If the application needs to update data, a read-write cache might be appropriate. This cache strategy should never be used if serializable transaction isolation level is required. If the cache is used in a JTA environment, you must specify the property hibernate.transaction.manager_lookup_class, naming a strategy for obtaining the JTA TransactionManager. In other environments, you should ensure that the transaction is completed when Session.close() or Session.disconnect() is called. If you wish to use this strategy in a cluster, you should ensure that the underlying cache implementation supports locking. The built-in cache providers do not." -msgstr "" - -#: index.docbook:730 +#. Tag: para +#: performance.xml:719 +#, no-c-format msgid "" - "\n" - " \n" - " ....\n" - " \n" - " \n" - " ....\n" - " \n" - "]]>" +"If the application needs to update data, a read-write " +"cache might be appropriate. This cache strategy should never be used if " +"serializable transaction isolation level is required. If the cache is used " +"in a JTA environment, you must specify the property hibernate." +"transaction.manager_lookup_class, naming a strategy for obtaining " +"the JTA TransactionManager. In other environments, you " +"should ensure that the transaction is completed when Session.close()" +" or Session.disconnect() is called. If you wish " +"to use this strategy in a cluster, you should ensure that the underlying " +"cache implementation supports locking. The built-in cache providers do " +"not." +msgstr "" +"如果应用程序需要更新数据,那么使用读/写缓存 比较合适。 如" +"果应用程序要求“序列化事务”的隔离级别(serializable transaction isolation " +"level),那么就决不能使用这种缓存策略。 如果在JTA环境中使用缓存,你必须指定" +"hibernate.transaction.manager_lookup_class属性的值, 通过" +"它,Hibernate才能知道该应用程序中JTA的TransactionManager的" +"具体策略。 在其它环境中,你必须保证在Session.close()、或" +"Session.disconnect()调用前, 整个事务已经结束。 如果你想在" +"集群环境中使用此策略,你必须保证底层的缓存实现支持锁定(locking)。Hibernate内" +"置的缓存策略并不支持锁定功能。" + +#. Tag: programlisting +#: performance.xml:730 +#, no-c-format +msgid "" +"\n" +" \n" +" ....\n" +" \n" +" \n" +" ....\n" +" \n" +"]]>" msgstr "" -#: index.docbook:735 +#. Tag: title +#: performance.xml:735 +#, no-c-format msgid "Strategy: nonstrict read/write" -msgstr "" +msgstr "策略:非严格读/写缓存(Strategy: nonstrict read/write)" -#: index.docbook:737 -msgid "If the application only occasionally needs to update data (ie. if it is extremely unlikely that two transactions would try to update the same item simultaneously) and strict transaction isolation is not required, a nonstrict-read-write cache might be appropriate. If the cache is used in a JTA environment, you must specify hibernate.transaction.manager_lookup_class. In other environments, you should ensure that the transaction is completed when Session.close() or Session.disconnect() is called." +#. Tag: para +#: performance.xml:737 +#, no-c-format +msgid "" +"If the application only occasionally needs to update data (ie. if it is " +"extremely unlikely that two transactions would try to update the same item " +"simultaneously) and strict transaction isolation is not required, a " +"nonstrict-read-write cache might be appropriate. If the " +"cache is used in a JTA environment, you must specify hibernate." +"transaction.manager_lookup_class. In other environments, you " +"should ensure that the transaction is completed when Session.close()" +" or Session.disconnect() is called." msgstr "" +"如果应用程序只偶尔需要更新数据(也就是说,两个事务同时更新同一记录的情况很不" +"常见),也不需要十分严格的事务隔离, 那么比较适合使用非严格读/写缓存" +"策略。如果在JTA环境中使用该策略, 你必须为其指定hibernate." +"transaction.manager_lookup_class属性的值, 在其它环境中,你必须保证" +"在Session.close()、或Session.disconnect()调用前, 整个事务已经结束。" -#: index.docbook:749 +#. Tag: title +#: performance.xml:749 +#, no-c-format msgid "Strategy: transactional" -msgstr "" +msgstr "策略:事务缓存(transactional)" -#: index.docbook:751 -msgid "The transactional cache strategy provides support for fully transactional cache providers such as JBoss TreeCache. Such a cache may only be used in a JTA environment and you must specify hibernate.transaction.manager_lookup_class." +#. Tag: para +#: performance.xml:751 +#, no-c-format +msgid "" +"The transactional cache strategy provides support for " +"fully transactional cache providers such as JBoss TreeCache. Such a cache " +"may only be used in a JTA environment and you must specify " +"hibernate.transaction.manager_lookup_class." msgstr "" +"Hibernate的事务缓存策略提供了全事务的缓存支持, 例如对" +"JBoss TreeCache的支持。这样的缓存只能用于JTA环境中,你必须指定 为其" +"hibernate.transaction.manager_lookup_class属性。" -#: index.docbook:759 -msgid "None of the cache providers support all of the cache concurrency strategies. The following table shows which providers are compatible with which concurrency strategies." +#. Tag: para +#: performance.xml:759 +#, no-c-format +msgid "" +"None of the cache providers support all of the cache concurrency strategies. " +"The following table shows which providers are compatible with which " +"concurrency strategies." msgstr "" +"没有一种缓存提供商能够支持上列的所有缓存并发策略。下表中列出了各种提供器、及" +"其各自适用的并发策略。" -#: index.docbook:765 +#. Tag: title +#: performance.xml:765 +#, no-c-format msgid "Cache Concurrency Strategy Support" msgstr "" +"各种缓存提供商对缓存并发策略的支持情况(Cache Concurrency Strategy Support)" -#: index.docbook:775 +#. Tag: entry +#: performance.xml:775 +#, no-c-format msgid "read-only" -msgstr "" +msgstr "read-only" -#: index.docbook:776 +#. Tag: entry +#: performance.xml:776 +#, no-c-format msgid "nonstrict-read-write" -msgstr "" +msgstr "nonstrict-read-write" -#: index.docbook:777 +#. Tag: entry +#: performance.xml:777 +#, no-c-format msgid "read-write" -msgstr "" +msgstr "read-write" -#: index.docbook:778 +#. Tag: entry +#: performance.xml:778 +#, no-c-format msgid "transactional" -msgstr "" +msgstr "transactional" -#: index.docbook:824 +#. Tag: title +#: performance.xml:824 +#, no-c-format msgid "Managing the caches" -msgstr "" +msgstr "管理缓存(Managing the caches)" -#: index.docbook:826 -msgid "Whenever you pass an object to save(), update() or saveOrUpdate() and whenever you retrieve an object using load(), get(), list(), iterate() or scroll(), that object is added to the internal cache of the Session." -msgstr "" - -#: index.docbook:833 -msgid "When flush() is subsequently called, the state of that object will be synchronized with the database. If you do not want this synchronization to occur or if you are processing a huge number of objects and need to manage memory efficiently, the evict() method may be used to remove the object and its collections from the first-level cache." -msgstr "" - -#: index.docbook:841 +#. Tag: para +#: performance.xml:826 +#, no-c-format msgid "" - "" +"Whenever you pass an object to save(), update() or saveOrUpdate() and whenever you retrieve an " +"object using load(), get(), " +"list(), iterate() or scroll()" +", that object is added to the internal cache of the " +"Session." msgstr "" +"无论何时,当你给save()update()或 " +"saveOrUpdate()方法传递一个对象时,或使用load()get()list()、" +"iterate()scroll()方法获得一个对象" +"时, 该对象都将被加入到Session的内部缓存中。" -#: index.docbook:843 -msgid "The Session also provides a contains() method to determine if an instance belongs to the session cache." -msgstr "" - -#: index.docbook:848 -msgid "To completely evict all objects from the session cache, call Session.clear()" -msgstr "" - -#: index.docbook:852 -msgid "For the second-level cache, there are methods defined on SessionFactory for evicting the cached state of an instance, entire class, collection instance or entire collection role." -msgstr "" - -#: index.docbook:858 +#. Tag: para +#: performance.xml:833 +#, no-c-format msgid "" - "" +"When flush() is subsequently called, the state of that " +"object will be synchronized with the database. If you do not want this " +"synchronization to occur or if you are processing a huge number of objects " +"and need to manage memory efficiently, the evict() method " +"may be used to remove the object and its collections from the first-level " +"cache." msgstr "" +"当随后flush()方法被调用时,对象的状态会和数据库取得同步。 如果你不希望此同步" +"操作发生,或者你正处理大量对象、需要对有效管理内存时,你可以调用" +"evict() 方法,从一级缓存中去掉这些对象及其集合。" -#: index.docbook:860 -msgid "The CacheMode controls how a particular session interacts with the second-level cache." -msgstr "" - -#: index.docbook:867 -msgid "CacheMode.NORMAL - read items from and write items to the second-level cache" -msgstr "" - -#: index.docbook:872 -msgid "CacheMode.GET - read items from the second-level cache, but don't write to the second-level cache except when updating data" -msgstr "" - -#: index.docbook:878 -msgid "CacheMode.PUT - write items to the second-level cache, but don't read from the second-level cache" -msgstr "" - -#: index.docbook:884 -msgid "CacheMode.REFRESH - write items to the second-level cache, but don't read from the second-level cache, bypass the effect of hibernate.cache.use_minimal_puts, forcing a refresh of the second-level cache for all items read from the database" -msgstr "" - -#: index.docbook:892 -msgid "To browse the contents of a second-level or query cache region, use the Statistics API:" -msgstr "" - -#: index.docbook:897 +#. Tag: programlisting +#: performance.xml:841 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:899 -msgid "You'll need to enable statistics, and, optionally, force Hibernate to keep the cache entries in a more human-understandable format:" -msgstr "" - -#: index.docbook:904 +#. Tag: para +#: performance.xml:843 +#, no-c-format msgid "" - "" +"The Session also provides a contains() " +"method to determine if an instance belongs to the session cache." +msgstr "" +"Session还提供了一个contains()方法,用来判断某个实例是否处" +"于当前session的缓存中。" + +#. Tag: para +#: performance.xml:848 +#, no-c-format +msgid "" +"To completely evict all objects from the session cache, call " +"Session.clear()" +msgstr "" +"如若要把所有的对象从session缓存中彻底清除,则需要调用Session.clear()" +"。" + +#. Tag: para +#: performance.xml:852 +#, no-c-format +msgid "" +"For the second-level cache, there are methods defined on " +"SessionFactory for evicting the cached state of an " +"instance, entire class, collection instance or entire collection role." +msgstr "" +"对于二级缓存来说,在SessionFactory中定义了许多方法, 清除" +"缓存中实例、整个类、集合实例或者整个集合。" + +#. Tag: programlisting +#: performance.xml:858 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:909 +#. Tag: para +#: performance.xml:860 +#, no-c-format +msgid "" +"The CacheMode controls how a particular session interacts " +"with the second-level cache." +msgstr "" +"CacheMode参数用于控制具体的Session如何与二级缓存进行交互。" + +#. Tag: para +#: performance.xml:867 +#, no-c-format +msgid "" +"CacheMode.NORMAL - read items from and write items to the " +"second-level cache" +msgstr "CacheMode.NORMAL - 从二级缓存中读、写数据。" + +#. Tag: para +#: performance.xml:872 +#, no-c-format +msgid "" +"CacheMode.GET - read items from the second-level cache, " +"but don't write to the second-level cache except when updating data" +msgstr "" +"CacheMode.GET - 从二级缓存中读取数据,仅在数据更新时对二级" +"缓存写数据。" + +#. Tag: para +#: performance.xml:878 +#, no-c-format +msgid "" +"CacheMode.PUT - write items to the second-level cache, " +"but don't read from the second-level cache" +msgstr "" +"CacheMode.PUT - 仅向二级缓存写数据,但不从二级缓存中读数" +"据。" + +#. Tag: para +#: performance.xml:884 +#, no-c-format +msgid "" +"CacheMode.REFRESH - write items to the second-level " +"cache, but don't read from the second-level cache, bypass the effect of " +"hibernate.cache.use_minimal_puts, forcing a refresh of " +"the second-level cache for all items read from the database" +msgstr "" +"CacheMode.REFRESH - 仅向二级缓存写数据,但不从二级缓存中读" +"数据。通过 hibernate.cache.use_minimal_puts的设置,强制二" +"级缓存从数据库中读取数据,刷新缓存内容。" + +#. Tag: para +#: performance.xml:892 +#, no-c-format +msgid "" +"To browse the contents of a second-level or query cache region, use the " +"Statistics API:" +msgstr "" +"如若需要查看二级缓存或查询缓存区域的内容,你可以使用统计" +"(Statistics) API。" + +#. Tag: programlisting +#: performance.xml:897 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: performance.xml:899 +#, no-c-format +msgid "" +"You'll need to enable statistics, and, optionally, force Hibernate to keep " +"the cache entries in a more human-understandable format:" +msgstr "" +"此时,你必须手工打开统计选项。可选的,你可以让Hibernate更人工可读的方式维护缓" +"存内容。" + +#. Tag: programlisting +#: performance.xml:904 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: performance.xml:909 +#, no-c-format msgid "The Query Cache" -msgstr "" +msgstr "查询缓存(The Query Cache)" -#: index.docbook:911 -msgid "Query result sets may also be cached. This is only useful for queries that are run frequently with the same parameters. To use the query cache you must first enable it:" +#. Tag: para +#: performance.xml:911 +#, no-c-format +msgid "" +"Query result sets may also be cached. This is only useful for queries that " +"are run frequently with the same parameters. To use the query cache you must " +"first enable it:" msgstr "" +"查询的结果集也可以被缓存。只有当经常使用同样的参数进行查询时,这才会有些用" +"处。 要使用查询缓存,首先你必须打开它:" -#: index.docbook:916 +#. Tag: programlisting +#: performance.xml:916 +#, no-c-format msgid "" msgstr "" -#: index.docbook:918 -msgid "This setting causes the creation of two new cache regions - one holding cached query result sets (org.hibernate.cache.StandardQueryCache), the other holding timestamps of the most recent updates to queryable tables (org.hibernate.cache.UpdateTimestampsCache). Note that the query cache does not cache the state of the actual entities in the result set; it caches only identifier values and results of value type. So the query cache should always be used in conjunction with the second-level cache." -msgstr "" - -#: index.docbook:928 -msgid "Most queries do not benefit from caching, so by default queries are not cached. To enable caching, call Query.setCacheable(true). This call allows the query to look for existing cache results or add its results to the cache when it is executed." -msgstr "" - -#: index.docbook:935 -msgid "If you require fine-grained control over query cache expiration policies, you may specify a named cache region for a particular query by calling Query.setCacheRegion()." -msgstr "" - -#: index.docbook:941 +#. Tag: para +#: performance.xml:918 +#, no-c-format msgid "" - "" +"This setting causes the creation of two new cache regions - one holding " +"cached query result sets (org.hibernate.cache.StandardQueryCache), the other holding timestamps of the most recent updates to " +"queryable tables (org.hibernate.cache.UpdateTimestampsCache). Note that the query cache does not cache the state of the actual " +"entities in the result set; it caches only identifier values and results of " +"value type. So the query cache should always be used in conjunction with the " +"second-level cache." +msgstr "" +"该设置将会创建两个缓存区域 - 一个用于保存查询结果集(org.hibernate." +"cache.StandardQueryCache); 另一个则用于保存最近查询的一系列表的时" +"间戳(org.hibernate.cache.UpdateTimestampsCache)。 请注意:" +"在查询缓存中,它并不缓存结果集中所包含的实体的确切状态;它只缓存这些实体的标" +"识符属性的值、以及各值类型的结果。 所以查询缓存通常会和二级缓存一起使用。" + +#. Tag: para +#: performance.xml:928 +#, no-c-format +msgid "" +"Most queries do not benefit from caching, so by default queries are not " +"cached. To enable caching, call Query.setCacheable(true). " +"This call allows the query to look for existing cache results or add its " +"results to the cache when it is executed." +msgstr "" +"绝大多数的查询并不能从查询缓存中受益,所以Hibernate默认是不进行查询缓存的。如" +"若需要进行缓存,请调用 Query.setCacheable(true)方法。这个" +"调用会让查询在执行过程中时先从缓存中查找结果, 并将自己的结果集放到缓存中去。" + +#. Tag: para +#: performance.xml:935 +#, no-c-format +msgid "" +"If you require fine-grained control over query cache expiration policies, " +"you may specify a named cache region for a particular query by calling " +"Query.setCacheRegion()." +msgstr "" +"如果你要对查询缓存的失效政策进行精确的控制,你必须调用Query." +"setCacheRegion()方法, 为每个查询指定其命名的缓存区域。" + +#. Tag: programlisting +#: performance.xml:941 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:943 -msgid "If the query should force a refresh of its query cache region, you should call Query.setCacheMode(CacheMode.REFRESH). This is particularly useful in cases where underlying data may have been updated via a separate process (i.e., not modified through Hibernate) and allows the application to selectively refresh particular query result sets. This is a more efficient alternative to eviction of a query cache region via SessionFactory.evictQueries()." +#. Tag: para +#: performance.xml:943 +#, no-c-format +msgid "" +"If the query should force a refresh of its query cache region, you should " +"call Query.setCacheMode(CacheMode.REFRESH). This is " +"particularly useful in cases where underlying data may have been updated via " +"a separate process (i.e., not modified through Hibernate) and allows the " +"application to selectively refresh particular query result sets. This is a " +"more efficient alternative to eviction of a query cache region via " +"SessionFactory.evictQueries()." msgstr "" +"如果查询需要强行刷新其查询缓存区域,那么你应该调用Query.setCacheMode" +"(CacheMode.REFRESH)方法。 这对在其他进程中修改底层数据(例如,不通" +"过Hibernate修改数据),或对那些需要选择性更新特定查询结果集的情况特别有用。 " +"这是对SessionFactory.evictQueries()的更为有效的替代方案," +"同样可以清除查询缓存区域。" -#: index.docbook:955 +#. Tag: title +#: performance.xml:955 +#, no-c-format msgid "Understanding Collection performance" -msgstr "" +msgstr "理解集合性能(Understanding Collection performance)" -#: index.docbook:957 -msgid "We've already spent quite some time talking about collections. In this section we will highlight a couple more issues about how collections behave at runtime." +#. Tag: para +#: performance.xml:957 +#, no-c-format +msgid "" +"We've already spent quite some time talking about collections. In this " +"section we will highlight a couple more issues about how collections behave " +"at runtime." msgstr "" +"前面我们已经对集合进行了足够的讨论。本段中,我们将着重讲述集合在运行时的事" +"宜。" -#: index.docbook:964 +#. Tag: title +#: performance.xml:964 +#, no-c-format msgid "Taxonomy" -msgstr "" +msgstr "分类(Taxonomy)" -#: index.docbook:966 +#. Tag: para +#: performance.xml:966 +#, no-c-format msgid "Hibernate defines three basic kinds of collections:" -msgstr "" +msgstr "Hibernate定义了三种基本类型的集合:" -#: index.docbook:970 +#. Tag: para +#: performance.xml:970 +#, no-c-format msgid "collections of values" -msgstr "" +msgstr "值数据集合" -#: index.docbook:973 +#. Tag: para +#: performance.xml:973 +#, no-c-format msgid "one to many associations" -msgstr "" +msgstr "一对多关联" -#: index.docbook:976 +#. Tag: para +#: performance.xml:976 +#, no-c-format msgid "many to many associations" -msgstr "" +msgstr "多对多关联" -#: index.docbook:980 -msgid "This classification distinguishes the various table and foreign key relationships but does not tell us quite everything we need to know about the relational model. To fully understand the relational structure and performance characteristics, we must also consider the structure of the primary key that is used by Hibernate to update or delete collection rows. This suggests the following classification:" +#. Tag: para +#: performance.xml:980 +#, no-c-format +msgid "" +"This classification distinguishes the various table and foreign key " +"relationships but does not tell us quite everything we need to know about " +"the relational model. To fully understand the relational structure and " +"performance characteristics, we must also consider the structure of the " +"primary key that is used by Hibernate to update or delete collection rows. " +"This suggests the following classification:" msgstr "" +"这个分类是区分了不同的表和外键关系类型,但是它没有告诉我们关系模型的所有内" +"容。 要完全理解他们的关系结构和性能特点,我们必须同时考虑“用于Hibernate更新或" +"删除集合行数据的主键的结构”。 因此得到了如下的分类:" -#: index.docbook:991 +#. Tag: para +#: performance.xml:991 +#, no-c-format msgid "indexed collections" -msgstr "" +msgstr "有序集合类" -#: index.docbook:994 +#. Tag: para +#: performance.xml:994 +#, no-c-format msgid "sets" -msgstr "" +msgstr "集合(sets)" -#: index.docbook:997 +#. Tag: para +#: performance.xml:997 +#, no-c-format msgid "bags" -msgstr "" +msgstr "包(bags)" -#: index.docbook:1001 -msgid "All indexed collections (maps, lists, arrays) have a primary key consisting of the <key> and <index> columns. In this case collection updates are usually extremely efficient - the primary key may be efficiently indexed and a particular row may be efficiently located when Hibernate tries to update or delete it." +#. Tag: para +#: performance.xml:1001 +#, no-c-format +msgid "" +"All indexed collections (maps, lists, arrays) have a primary key consisting " +"of the <key> and <index> " +"columns. In this case collection updates are usually extremely efficient - " +"the primary key may be efficiently indexed and a particular row may be " +"efficiently located when Hibernate tries to update or delete it." msgstr "" +"所有的有序集合类(maps, lists, arrays)都拥有一个由<key><index>组成的主键。 这种情况下集合类的更" +"新是非常高效的——主键已经被有效的索引,因此当Hibernate试图更新或删除一行时,可" +"以迅速找到该行数据。" -#: index.docbook:1009 -msgid "Sets have a primary key consisting of <key> and element columns. This may be less efficient for some types of collection element, particularly composite elements or large text or binary fields; the database may not be able to index a complex primary key as efficently. On the other hand, for one to many or many to many associations, particularly in the case of synthetic identifiers, it is likely to be just as efficient. (Side-note: if you want SchemaExport to actually create the primary key of a <set> for you, you must declare all columns as not-null=\"true\".)" +#. Tag: para +#: performance.xml:1009 +#, no-c-format +msgid "" +"Sets have a primary key consisting of <key> and " +"element columns. This may be less efficient for some types of collection " +"element, particularly composite elements or large text or binary fields; the " +"database may not be able to index a complex primary key as efficently. On " +"the other hand, for one to many or many to many associations, particularly " +"in the case of synthetic identifiers, it is likely to be just as efficient. " +"(Side-note: if you want SchemaExport to actually create " +"the primary key of a <set> for you, you must " +"declare all columns as not-null=\"true\".)" msgstr "" +"集合(sets)的主键由<key>和其他元素字段构成。 对于有些" +"元素类型来说,这很低效,特别是组合元素或者大文本、大二进制字段; 数据库可能无" +"法有效的对复杂的主键进行索引。 另一方面,对于一对多、多对多关联,特别是合成的" +"标识符来说,集合也可以达到同样的高效性能。( 附注:如果你希望" +"SchemaExport为你的<set>创建主" +"键, 你必须把所有的字段都声明为not-null=\"true\"。)" -#: index.docbook:1020 -msgid "<idbag> mappings define a surrogate key, so they are always very efficient to update. In fact, they are the best case." +#. Tag: para +#: performance.xml:1020 +#, no-c-format +msgid "" +"<idbag> mappings define a surrogate key, so they " +"are always very efficient to update. In fact, they are the best case." msgstr "" +"<idbag>映射定义了代理键,因此它总是可以很高效的被更" +"新。事实上, <idbag>拥有着最好的性能表现。" -#: index.docbook:1025 -msgid "Bags are the worst case. Since a bag permits duplicate element values and has no index column, no primary key may be defined. Hibernate has no way of distinguishing between duplicate rows. Hibernate resolves this problem by completely removing (in a single DELETE) and recreating the collection whenever it changes. This might be very inefficient." +#. Tag: para +#: performance.xml:1025 +#, no-c-format +msgid "" +"Bags are the worst case. Since a bag permits duplicate element values and " +"has no index column, no primary key may be defined. Hibernate has no way of " +"distinguishing between duplicate rows. Hibernate resolves this problem by " +"completely removing (in a single DELETE) and recreating " +"the collection whenever it changes. This might be very inefficient." msgstr "" +"Bag是最差的。因为bag允许重复的元素值,也没有索引字段,因此不可能定义主键。 " +"Hibernate无法判断出重复的行。当这种集合被更改时,Hibernate将会先完整地移除 " +"(通过一个(in a single DELETE))整个集合,然后再重新创建整" +"个集合。 因此Bag是非常低效的。" -#: index.docbook:1033 -msgid "Note that for a one-to-many association, the \"primary key\" may not be the physical primary key of the database table - but even in this case, the above classification is still useful. (It still reflects how Hibernate \"locates\" individual rows of the collection.)" +#. Tag: para +#: performance.xml:1033 +#, no-c-format +msgid "" +"Note that for a one-to-many association, the \"primary key\" may not be the " +"physical primary key of the database table - but even in this case, the " +"above classification is still useful. (It still reflects how Hibernate " +"\"locates\" individual rows of the collection.)" msgstr "" +"请注意:对于一对多关联来说,“主键”很可能并不是数据库表的物理主键。 但就算在此" +"情况下,上面的分类仍然是有用的。(它仍然反映了Hibernate在集合的各数据行中是如" +"何进行“定位”的。)" -#: index.docbook:1043 -msgid "Lists, maps, idbags and sets are the most efficient collections to update" +#. Tag: title +#: performance.xml:1043 +#, no-c-format +msgid "" +"Lists, maps, idbags and sets are the most efficient collections to update" +msgstr "Lists, maps 和sets用于更新效率最高" + +#. Tag: para +#: performance.xml:1045 +#, no-c-format +msgid "" +"From the discussion above, it should be clear that indexed collections and " +"(usually) sets allow the most efficient operation in terms of adding, " +"removing and updating elements." msgstr "" +"根据我们上面的讨论,显然有序集合类型和大多数set都可以在增加、删除、修改元素中" +"拥有最好的性能。" -#: index.docbook:1045 -msgid "From the discussion above, it should be clear that indexed collections and (usually) sets allow the most efficient operation in terms of adding, removing and updating elements." +#. Tag: para +#: performance.xml:1051 +#, no-c-format +msgid "" +"There is, arguably, one more advantage that indexed collections have over " +"sets for many to many associations or collections of values. Because of the " +"structure of a Set, Hibernate doesn't ever " +"UPDATE a row when an element is \"changed\". Changes to a " +"Set always work via INSERT and " +"DELETE (of individual rows). Once again, this " +"consideration does not apply to one to many associations." msgstr "" +"可论证的是对于多对多关联、值数据集合而言,有序集合类比集合(set)有一个好处。因" +"为Set的内在结构, 如果“改变”了一个元素,Hibernate并不会" +"更新(UPDATE)这一行。 对于Set来说,只" +"有在插入(INSERT)删除(DELETE) 操作" +"时“改变”才有效。再次强调:这段讨论对“一对多关联”并不适用。" -#: index.docbook:1051 -msgid "There is, arguably, one more advantage that indexed collections have over sets for many to many associations or collections of values. Because of the structure of a Set, Hibernate doesn't ever UPDATE a row when an element is \"changed\". Changes to a Set always work via INSERT and DELETE (of individual rows). Once again, this consideration does not apply to one to many associations." +#. Tag: para +#: performance.xml:1060 +#, no-c-format +msgid "" +"After observing that arrays cannot be lazy, we would conclude that lists, " +"maps and idbags are the most performant (non-inverse) collection types, with " +"sets not far behind. Sets are expected to be the most common kind of " +"collection in Hibernate applications. This is because the \"set\" semantics " +"are most natural in the relational model." msgstr "" +"注意到数组无法延迟载入,我们可以得出结论,list, map和idbags是最高效的(非反" +"向)集合类型,set则紧随其后。 在Hibernate中,set应该时最通用的集合类型,这时" +"因为“set”的语义在关系模型中是最自然的。" -#: index.docbook:1060 -msgid "After observing that arrays cannot be lazy, we would conclude that lists, maps and idbags are the most performant (non-inverse) collection types, with sets not far behind. Sets are expected to be the most common kind of collection in Hibernate applications. This is because the \"set\" semantics are most natural in the relational model." +#. Tag: para +#: performance.xml:1068 +#, no-c-format +msgid "" +"However, in well-designed Hibernate domain models, we usually see that most " +"collections are in fact one-to-many associations with inverse=\"true" +"\". For these associations, the update is handled by the many-to-" +"one end of the association, and so considerations of collection update " +"performance simply do not apply." msgstr "" +"但是,在设计良好的Hibernate领域模型中,我们通常可以看到更多的集合事实上是带有" +"inverse=\"true\" 的一对多的关联。对于这些关联,更新操作将" +"会在多对一的这一端进行处理。因此对于此类情况,无需考虑其集合的更新性能。" -#: index.docbook:1068 -msgid "However, in well-designed Hibernate domain models, we usually see that most collections are in fact one-to-many associations with inverse=\"true\". For these associations, the update is handled by the many-to-one end of the association, and so considerations of collection update performance simply do not apply." -msgstr "" - -#: index.docbook:1078 +#. Tag: title +#: performance.xml:1078 +#, no-c-format msgid "Bags and lists are the most efficient inverse collections" -msgstr "" +msgstr "Bag和list是反向集合类中效率最高的" -#: index.docbook:1080 -msgid "Just before you ditch bags forever, there is a particular case in which bags (and also lists) are much more performant than sets. For a collection with inverse=\"true\" (the standard bidirectional one-to-many relationship idiom, for example) we can add elements to a bag or list without needing to initialize (fetch) the bag elements! This is because Collection.add() or Collection.addAll() must always return true for a bag or List (unlike a Set). This can make the following common code much faster." -msgstr "" - -#: index.docbook:1090 +#. Tag: para +#: performance.xml:1080 +#, no-c-format msgid "" - "" +"Just before you ditch bags forever, there is a particular case in which bags " +"(and also lists) are much more performant than sets. For a collection with " +"inverse=\"true\" (the standard bidirectional one-to-many " +"relationship idiom, for example) we can add elements to a bag or list " +"without needing to initialize (fetch) the bag elements! This is because " +"Collection.add() or Collection.addAll() must always return true for a bag or List " +"(unlike a Set). This can make the following common code " +"much faster." +msgstr "" +"在把bag扔进水沟之前,你必须了解,在一种情况下,bag的性能(包括list)要比set高得" +"多: 对于指明了inverse=\"true\"的集合类(比如说,标准的双" +"向的一对多关联), 我们可以在未初始化(fetch)包元素的情况下直接向bag或list添加" +"新元素! 这是因为Collection.add())或者Collection." +"addAll() 方法 对bag或者List总是返回true(这点与与Set不同)。因此对" +"于下面的相同代码来说,速度会快得多。" + +#. Tag: programlisting +#: performance.xml:1090 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:1095 +#. Tag: title +#: performance.xml:1095 +#, no-c-format msgid "One shot delete" -msgstr "" +msgstr "一次性删除(One shot delete)" -#: index.docbook:1097 -msgid "Occasionally, deleting collection elements one by one can be extremely inefficient. Hibernate isn't completely stupid, so it knows not to do that in the case of an newly-empty collection (if you called list.clear(), for example). In this case, Hibernate will issue a single DELETE and we are done!" +#. Tag: para +#: performance.xml:1097 +#, no-c-format +msgid "" +"Occasionally, deleting collection elements one by one can be extremely " +"inefficient. Hibernate isn't completely stupid, so it knows not to do that " +"in the case of an newly-empty collection (if you called list.clear()" +", for example). In this case, Hibernate will issue a single " +"DELETE and we are done!" msgstr "" +"偶尔的,逐个删除集合类中的元素是相当低效的。Hibernate并没那么笨, 如果你想要" +"把整个集合都删除(比如说调用list.clear()),Hibernate只需要一个DELETE就搞定" +"了。" -#: index.docbook:1104 -msgid "Suppose we add a single element to a collection of size twenty and then remove two elements. Hibernate will issue one INSERT statement and two DELETE statements (unless the collection is a bag). This is certainly desirable." +#. Tag: para +#: performance.xml:1104 +#, no-c-format +msgid "" +"Suppose we add a single element to a collection of size twenty and then " +"remove two elements. Hibernate will issue one INSERT " +"statement and two DELETE statements (unless the " +"collection is a bag). This is certainly desirable." msgstr "" +"假设我们在一个长度为20的集合类中新增加了一个元素,然后再删除两个。 Hibernate" +"会安排一条INSERT语句和两条DELETE语句" +"(除非集合类是一个bag)。 这当然是显而易见的。" -#: index.docbook:1110 -msgid "However, suppose that we remove eighteen elements, leaving two and then add thee new elements. There are two possible ways to proceed" +#. Tag: para +#: performance.xml:1110 +#, no-c-format +msgid "" +"However, suppose that we remove eighteen elements, leaving two and then add " +"thee new elements. There are two possible ways to proceed" msgstr "" +"但是,假设我们删除了18个数据,只剩下2个,然后新增3个。则有两种处理方式:" -#: index.docbook:1117 +#. Tag: para +#: performance.xml:1117 +#, no-c-format msgid "delete eighteen rows one by one and then insert three rows" -msgstr "" +msgstr "逐一的删除这18个数据,再新增三个;" -#: index.docbook:1120 -msgid "remove the whole collection (in one SQL DELETE) and insert all five current elements (one by one)" -msgstr "" +#. Tag: para +#: performance.xml:1120 +#, no-c-format +msgid "" +"remove the whole collection (in one SQL DELETE) and " +"insert all five current elements (one by one)" +msgstr "删除整个集合类(只用一句DELETE语句),然后增加5个数据。" -#: index.docbook:1125 -msgid "Hibernate isn't smart enough to know that the second option is probably quicker in this case. (And it would probably be undesirable for Hibernate to be that smart; such behaviour might confuse database triggers, etc.)" +#. Tag: para +#: performance.xml:1125 +#, no-c-format +msgid "" +"Hibernate isn't smart enough to know that the second option is probably " +"quicker in this case. (And it would probably be undesirable for Hibernate to " +"be that smart; such behaviour might confuse database triggers, etc.)" msgstr "" +"Hibernate还没那么聪明,知道第二种选择可能会比较快。 (也许让Hibernate不这么聪" +"明也是好事,否则可能会引发意外的“数据库触发器”之类的问题。)" -#: index.docbook:1131 -msgid "Fortunately, you can force this behaviour (ie. the second strategy) at any time by discarding (ie. dereferencing) the original collection and returning a newly instantiated collection with all the current elements. This can be very useful and powerful from time to time." +#. Tag: para +#: performance.xml:1131 +#, no-c-format +msgid "" +"Fortunately, you can force this behaviour (ie. the second strategy) at any " +"time by discarding (ie. dereferencing) the original collection and returning " +"a newly instantiated collection with all the current elements. This can be " +"very useful and powerful from time to time." msgstr "" +"幸运的是,你可以强制使用第二种策略。你需要取消原来的整个集合类(解除其引" +"用), 然后再返回一个新的实例化的集合类,只包含需要的元素。有些时候这是非常有" +"用的。" -#: index.docbook:1137 -msgid "Of course, one-shot-delete does not apply to collections mapped inverse=\"true\"." +#. Tag: para +#: performance.xml:1137 +#, no-c-format +msgid "" +"Of course, one-shot-delete does not apply to collections mapped " +"inverse=\"true\"." msgstr "" +"显然,一次性删除并不适用于被映射为inverse=\"true\"的集合。" -#: index.docbook:1146 +#. Tag: title +#: performance.xml:1146 +#, no-c-format msgid "Monitoring performance" -msgstr "" +msgstr "监测性能(Monitoring performance)" -#: index.docbook:1148 -msgid "Optimization is not much use without monitoring and access to performance numbers. Hibernate provides a full range of figures about its internal operations. Statistics in Hibernate are available per SessionFactory." +#. Tag: para +#: performance.xml:1148 +#, no-c-format +msgid "" +"Optimization is not much use without monitoring and access to performance " +"numbers. Hibernate provides a full range of figures about its internal " +"operations. Statistics in Hibernate are available per " +"SessionFactory." msgstr "" +"没有监测和性能参数而进行优化是毫无意义的。Hibernate为其内部操作提供了一系列的" +"示意图,因此可以从 每个SessionFactory抓取其统计数据。" -#: index.docbook:1155 +#. Tag: title +#: performance.xml:1155 +#, no-c-format msgid "Monitoring a SessionFactory" -msgstr "" +msgstr "监测SessionFactory" -#: index.docbook:1157 -msgid "You can access SessionFactory metrics in two ways. Your first option is to call sessionFactory.getStatistics() and read or display the Statistics yourself." -msgstr "" - -#: index.docbook:1163 -msgid "Hibernate can also use JMX to publish metrics if you enable the StatisticsService MBean. You may enable a single MBean for all your SessionFactory or one per factory. See the following code for minimalistic configuration examples:" -msgstr "" - -#: index.docbook:1170 +#. Tag: para +#: performance.xml:1157 +#, no-c-format msgid "" - "" +"You can access SessionFactory metrics in two ways. Your " +"first option is to call sessionFactory.getStatistics() " +"and read or display the Statistics yourself." msgstr "" +"你可以有两种方式访问SessionFactory的数据记录,第一种就是自" +"己直接调用 sessionFactory.getStatistics()方法读取、显示" +"统计数据。" -#: index.docbook:1173 +#. Tag: para +#: performance.xml:1163 +#, no-c-format msgid "" - "" +"Hibernate can also use JMX to publish metrics if you enable the " +"StatisticsService MBean. You may enable a single MBean " +"for all your SessionFactory or one per factory. See the " +"following code for minimalistic configuration examples:" +msgstr "" +"此外,如果你打开StatisticsService MBean选项,那么Hibernate" +"则可以使用JMX技术 发布其数据记录。你可以让应用中所有的" +"SessionFactory同时共享一个MBean,也可以每个 SessionFactory" +"分配一个MBean。下面的代码即是其演示代码:" + +#. Tag: programlisting +#: performance.xml:1170 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:1175 -msgid "TODO: This doesn't make sense: In the first case, we retrieve and use the MBean directly. In the second one, we must give the JNDI name in which the session factory is held before using it. Use hibernateStatsBean.setSessionFactoryJNDIName(\"my/JNDI/Name\")" +#. Tag: programlisting +#: performance.xml:1173 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:1180 -msgid "You can (de)activate the monitoring for a SessionFactory" +#. Tag: para +#: performance.xml:1175 +#, no-c-format +msgid "" +"TODO: This doesn't make sense: In the first case, we retrieve and use the " +"MBean directly. In the second one, we must give the JNDI name in which the " +"session factory is held before using it. Use hibernateStatsBean." +"setSessionFactoryJNDIName(\"my/JNDI/Name\")" msgstr "" +"TODO:仍需要说明的是:在第一个例子中,我们直接得到和使用MBean;而在第二个例子" +"中,在使用MBean之前 我们则需要给出SessionFactory的JNDI名,使用" +"hibernateStatsBean.setSessionFactoryJNDIName(\"my/JNDI/Name\") 得到SessionFactory,然后将MBean保存于其中。" -#: index.docbook:1185 -msgid "at configuration time, set hibernate.generate_statistics to false" +#. Tag: para +#: performance.xml:1180 +#, no-c-format +msgid "" +"You can (de)activate the monitoring for a SessionFactory" msgstr "" +"你可以通过以下方法打开或关闭SessionFactory的监测功能:" -#: index.docbook:1192 -msgid "at runtime: sf.getStatistics().setStatisticsEnabled(true) or hibernateStatsBean.setStatisticsEnabled(true)" +#. Tag: para +#: performance.xml:1185 +#, no-c-format +msgid "" +"at configuration time, set hibernate.generate_statistics " +"to false" msgstr "" +"在配置期间,将hibernate.generate_statistics设置为" +"truefalse;" -#: index.docbook:1199 -msgid "Statistics can be reset programatically using the clear() method. A summary can be sent to a logger (info level) using the logSummary() method." +#. Tag: para +#: performance.xml:1192 +#, no-c-format +msgid "" +"at runtime: sf.getStatistics().setStatisticsEnabled(true) " +"or hibernateStatsBean.setStatisticsEnabled(true)" msgstr "" +"在运行期间,则可以可以通过sf.getStatistics().setStatisticsEnabled" +"(true)hibernateStatsBean.setStatisticsEnabled(true)" -#: index.docbook:1208 +#. Tag: para +#: performance.xml:1199 +#, no-c-format +msgid "" +"Statistics can be reset programatically using the clear() " +"method. A summary can be sent to a logger (info level) using the " +"logSummary() method." +msgstr "" +"你也可以在程序中调用clear()方法重置统计数据,调用" +"logSummary() 在日志中记录(info级别)其总结。" + +#. Tag: title +#: performance.xml:1208 +#, no-c-format msgid "Metrics" -msgstr "" +msgstr "数据记录(Metrics)" -#: index.docbook:1210 -msgid "Hibernate provides a number of metrics, from very basic to the specialized information only relevant in certain scenarios. All available counters are described in the Statistics interface API, in three categories:" -msgstr "" - -#: index.docbook:1217 -msgid "Metrics related to the general Session usage, such as number of open sessions, retrieved JDBC connections, etc." -msgstr "" - -#: index.docbook:1223 -msgid "Metrics related to he entities, collections, queries, and caches as a whole (aka global metrics)," -msgstr "" - -#: index.docbook:1229 -msgid "Detailed metrics related to a particular entity, collection, query or cache region." -msgstr "" - -#: index.docbook:1236 -msgid "For exampl,e you can check the cache hit, miss, and put ratio of entities, collections and queries, and the average time a query needs. Beware that the number of milliseconds is subject to approximation in Java. Hibernate is tied to the JVM precision, on some platforms this might even only be accurate to 10 seconds." -msgstr "" - -#: index.docbook:1243 -msgid "Simple getters are used to access the global metrics (i.e. not tied to a particular entity, collection, cache region, etc.). You can access the metrics of a particular entity, collection or cache region through its name, and through its HQL or SQL representation for queries. Please refer to the Statistics, EntityStatistics, CollectionStatistics, SecondLevelCacheStatistics, and QueryStatistics API Javadoc for more information. The following code shows a simple example:" -msgstr "" - -#: index.docbook:1253 +#. Tag: para +#: performance.xml:1210 +#, no-c-format msgid "" - "" +"Hibernate provides a number of metrics, from very basic to the specialized " +"information only relevant in certain scenarios. All available counters are " +"described in the Statistics interface API, in three " +"categories:" +msgstr "" +"Hibernate提供了一系列数据记录,其记录的内容包括从最基本的信息到与具体场景的特" +"殊信息。所有的测量值都可以由 Statistics接口进行访问,主要" +"分为三类:" + +#. Tag: para +#: performance.xml:1217 +#, no-c-format +msgid "" +"Metrics related to the general Session usage, such as " +"number of open sessions, retrieved JDBC connections, etc." +msgstr "" +"使用Session的普通数据记录,例如打开的Session的个数、取得的" +"JDBC的连接数等;" + +#. Tag: para +#: performance.xml:1223 +#, no-c-format +msgid "" +"Metrics related to he entities, collections, queries, and caches as a whole " +"(aka global metrics)," +msgstr "实体、集合、查询、缓存等内容的统一数据记录" + +#. Tag: para +#: performance.xml:1229 +#, no-c-format +msgid "" +"Detailed metrics related to a particular entity, collection, query or cache " +"region." +msgstr "和具体实体、集合、查询、缓存相关的详细数据记录" + +#. Tag: para +#: performance.xml:1236 +#, no-c-format +msgid "" +"For exampl,e you can check the cache hit, miss, and put ratio of entities, " +"collections and queries, and the average time a query needs. Beware that the " +"number of milliseconds is subject to approximation in Java. Hibernate is " +"tied to the JVM precision, on some platforms this might even only be " +"accurate to 10 seconds." +msgstr "" +"例如:你可以检查缓存的命中成功次数,缓存的命中失败次数,实体、集合和查询的使" +"用概率,查询的平均时间等。请注意 Java中时间的近似精度是毫秒。Hibernate的数据" +"精度和具体的JVM有关,在有些平台上其精度甚至只能精确到10秒。" + +#. Tag: para +#: performance.xml:1243 +#, no-c-format +msgid "" +"Simple getters are used to access the global metrics (i.e. not tied to a " +"particular entity, collection, cache region, etc.). You can access the " +"metrics of a particular entity, collection or cache region through its name, " +"and through its HQL or SQL representation for queries. Please refer to the " +"Statistics, EntityStatistics, " +"CollectionStatistics, " +"SecondLevelCacheStatistics, and QueryStatistics API Javadoc for more information. The following code shows a simple " +"example:" +msgstr "" +"你可以直接使用getter方法得到全局数据记录(例如,和具体的实体、集合、缓存区无" +"关的数据),你也可以在具体查询中通过标记实体名、 或HQL、SQL语句得到某实体的数" +"据记录。请参考StatisticsEntityStatisticsCollectionStatistics、" +"SecondLevelCacheStatistics、 和QueryStatistics的API文档以抓取更多信息。下面的代码则是个简单的例子:" + +#. Tag: programlisting +#: performance.xml:1253 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:1255 -msgid "To work on all entities, collections, queries and region caches, you can retrieve the list of names of entities, collections, queries and region caches with the following methods: getQueries(), getEntityNames(), getCollectionRoleNames(), and getSecondLevelCacheRegionNames()." +#. Tag: para +#: performance.xml:1255 +#, no-c-format +msgid "" +"To work on all entities, collections, queries and region caches, you can " +"retrieve the list of names of entities, collections, queries and region " +"caches with the following methods: getQueries(), " +"getEntityNames(), getCollectionRoleNames(), and getSecondLevelCacheRegionNames()." msgstr "" +"如果你想得到所有实体、集合、查询和缓存区的数据,你可以通过以下方法获得实体、" +"集合、查询和缓存区列表: getQueries()、" +"getEntityNames()getCollectionRoleNames()getSecondLevelCacheRegionNames()。" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +#~ msgid "yes" +#~ msgstr "yes" diff --git a/documentation/manual/translations/zh-CN/content/persistent_classes.po b/documentation/manual/translations/zh-CN/content/persistent_classes.po index bdddce03e1..f756c83501 100644 --- a/documentation/manual/translations/zh-CN/content/persistent_classes.po +++ b/documentation/manual/translations/zh-CN/content/persistent_classes.po @@ -1,446 +1,809 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: persistent_classes.xml:5 +#, no-c-format msgid "Persistent Classes" -msgstr "" +msgstr "持久化类(Persistent Classes)" -#: index.docbook:7 -msgid "Persistent classes are classes in an application that implement the entities of the business problem (e.g. Customer and Order in an E-commerce application). Not all instances of a persistent class are considered to be in the persistent state - an instance may instead be transient or detached." +#. Tag: para +#: persistent_classes.xml:7 +#, no-c-format +msgid "" +"Persistent classes are classes in an application that implement the entities " +"of the business problem (e.g. Customer and Order in an E-commerce " +"application). Not all instances of a persistent class are considered to be " +"in the persistent state - an instance may instead be transient or detached." msgstr "" +"在应用程序中,用来实现业务问题实体的(如,在电子商务应用程序中的Customer和" +"Order) 类就是持久化类。不能认为所有的持久化类的实例都是持久的状态——一个实例" +"的状态也可能 是瞬时的或脱管的。" -#: index.docbook:14 -msgid "Hibernate works best if these classes follow some simple rules, also known as the Plain Old Java Object (POJO) programming model. However, none of these rules are hard requirements. Indeed, Hibernate3 assumes very little about the nature of your persistent objects. You may express a domain model in other ways: using trees of Map instances, for example." +#. Tag: para +#: persistent_classes.xml:14 +#, no-c-format +msgid "" +"Hibernate works best if these classes follow some simple rules, also known " +"as the Plain Old Java Object (POJO) programming model. However, none of " +"these rules are hard requirements. Indeed, Hibernate3 assumes very little " +"about the nature of your persistent objects. You may express a domain model " +"in other ways: using trees of Map instances, for example." msgstr "" +"如果这些持久化类遵循一些简单的规则,Hibernate能够工作得更好,这些规则也被称" +"作 简单传统Java对象(POJO:Plain Old Java Object)编程模型。但是这些规则并不是必" +"需的。 实际上,Hibernate3对于你的持久化类几乎不做任何设想。你可以用其他的方法" +"来表达领域模型: 比如,使用Map实例的树型结构。" -#: index.docbook:23 +#. Tag: title +#: persistent_classes.xml:23 +#, no-c-format msgid "A simple POJO example" -msgstr "" +msgstr "一个简单的POJO例子" -#: index.docbook:25 +#. Tag: para +#: persistent_classes.xml:25 +#, no-c-format msgid "Most Java applications require a persistent class representing felines." -msgstr "" +msgstr "大多数Java程序需要用一个持久化类来表示猫科动物。" -#: index.docbook:29 +#. Tag: programlisting +#: persistent_classes.xml:29 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:31 +#. Tag: para +#: persistent_classes.xml:31 +#, no-c-format msgid "There are four main rules to follow here:" -msgstr "" +msgstr "这里要遵循四条主要的规则:" -#: index.docbook:37 +#. Tag: title +#: persistent_classes.xml:37 +#, no-c-format msgid "Implement a no-argument constructor" -msgstr "" +msgstr "实现一个默认的(即无参数的)构造方法(constructor)" -#: index.docbook:39 -msgid "Cat has a no-argument constructor. All persistent classes must have a default constructor (which may be non-public) so that Hibernate can instantiate them using Constructor.newInstance(). We strongly recommend having a default constructor with at least package visibility for runtime proxy generation in Hibernate." +#. Tag: para +#: persistent_classes.xml:39 +#, no-c-format +msgid "" +"Cat has a no-argument constructor. All persistent classes " +"must have a default constructor (which may be non-public) so that Hibernate " +"can instantiate them using Constructor.newInstance(). We " +"strongly recommend having a default constructor with at least " +"package visibility for runtime proxy generation in " +"Hibernate." msgstr "" +"Cat有一个无参数的构造方法。所有的持久化类都必须有一个 默认" +"的构造方法(可以不是public的),这样的话Hibernate就可以使用 " +"Constructor.newInstance()来实例化它们。 我们强烈建议,在" +"Hibernate中,为了运行期代理的生成,构造方法至少是 包(package)内可见的。" -#: index.docbook:49 +#. Tag: title +#: persistent_classes.xml:49 +#, no-c-format msgid "Provide an identifier property (optional)" -msgstr "" +msgstr "提供一个标识属性(identifier property)(可选)" -#: index.docbook:51 -msgid "Cat has a property called id. This property maps to the primary key column of a database table. The property might have been called anything, and its type might have been any primitive type, any primitive \"wrapper\" type, java.lang.String or java.util.Date. (If your legacy database table has composite keys, you can even use a user-defined class with properties of these types - see the section on composite identifiers later.)" +#. Tag: para +#: persistent_classes.xml:51 +#, no-c-format +msgid "" +"Cat has a property called id. This " +"property maps to the primary key column of a database table. The property " +"might have been called anything, and its type might have been any primitive " +"type, any primitive \"wrapper\" type, java.lang.String or " +"java.util.Date. (If your legacy database table has " +"composite keys, you can even use a user-defined class with properties of " +"these types - see the section on composite identifiers later.)" msgstr "" +"Cat有一个属性叫做id。这个属性映射数据库" +"表的主 键字段。这个属性可以叫任何名字,其类型可以是任何的原始类型、原始类型的" +"包装类型、 java.lang.String 或者是 java.util." +"Date。 (如果你的遗留数据库表有联合主键,你甚至可以用一个用户自定义" +"的类,该类拥有这些类型 的属性。参见后面的关于联合标识符的章节。)" -#: index.docbook:60 -msgid "The identifier property is strictly optional. You can leave them off and let Hibernate keep track of object identifiers internally. We do not recommend this, however." +#. Tag: para +#: persistent_classes.xml:60 +#, no-c-format +msgid "" +"The identifier property is strictly optional. You can leave them off and let " +"Hibernate keep track of object identifiers internally. We do not recommend " +"this, however." msgstr "" +"标识符属性是可选的。可以不用管它,让Hibernate内部来追踪对象的识别。 但是我们" +"并不推荐这样做。" -#: index.docbook:65 -msgid "In fact, some functionality is available only to classes which declare an identifier property:" +#. Tag: para +#: persistent_classes.xml:65 +#, no-c-format +msgid "" +"In fact, some functionality is available only to classes which declare an " +"identifier property:" +msgstr "实际上,一些功能只对那些声明了标识符属性的类起作用:" + +#. Tag: para +#: persistent_classes.xml:72 +#, fuzzy, no-c-format +msgid "" +"Transitive reattachment for detached objects (cascade update or cascade " +"merge) - see" msgstr "" +"托管对象的传播性再连接(级联更新或级联合并) ——参阅 " -#: index.docbook:72 -msgid "Transitive reattachment for detached objects (cascade update or cascade merge) - see" -msgstr "" - -#: index.docbook:79 +#. Tag: literal +#: persistent_classes.xml:79 +#, no-c-format msgid "Session.saveOrUpdate()" -msgstr "" +msgstr "Session.saveOrUpdate()" -#: index.docbook:84 +#. Tag: literal +#: persistent_classes.xml:84 +#, no-c-format msgid "Session.merge()" -msgstr "" +msgstr "Session.merge()" -#: index.docbook:89 -msgid "We recommend you declare consistently-named identifier properties on persistent classes. We further recommend that you use a nullable (ie. non-primitive) type." +#. Tag: para +#: persistent_classes.xml:89 +#, no-c-format +msgid "" +"We recommend you declare consistently-named identifier properties on " +"persistent classes. We further recommend that you use a nullable (ie. non-" +"primitive) type." msgstr "" +"我们建议你对持久化类声明命名一致的标识属性。我们还建议你使用一 个可以为空(也" +"就是说,不是原始类型)的类型。" -#: index.docbook:96 +#. Tag: title +#: persistent_classes.xml:96 +#, no-c-format msgid "Prefer non-final classes (optional)" -msgstr "" +msgstr "使用非final的类 (可选)" -#: index.docbook:97 -msgid "A central feature of Hibernate, proxies, depends upon the persistent class being either non-final, or the implementation of an interface that declares all public methods." +#. Tag: para +#: persistent_classes.xml:97 +#, no-c-format +msgid "" +"A central feature of Hibernate, proxies, depends upon " +"the persistent class being either non-final, or the implementation of an " +"interface that declares all public methods." msgstr "" +"代理(proxies)是Hibernate的一个重要的功能,它依赖的条件" +"是,持久 化类或者是非final的,或者是实现了一个所有方法都声明为public的接口。" -#: index.docbook:102 -msgid "You can persist final classes that do not implement an interface with Hibernate, but you won't be able to use proxies for lazy association fetching - which will limit your options for performance tuning." +#. Tag: para +#: persistent_classes.xml:102 +#, no-c-format +msgid "" +"You can persist final classes that do not implement an " +"interface with Hibernate, but you won't be able to use proxies for lazy " +"association fetching - which will limit your options for performance tuning." msgstr "" +"你可以用Hibernate持久化一个没有实现任何接口的final类,但是" +"你 不能使用代理来延迟关联加载,这会限制你进行性能优化的选择。" -#: index.docbook:107 -msgid "You should also avoid declaring public final methods on the non-final classes. If you want to use a class with a public final method, you must explicitly disable proxying by setting lazy=\"false\"." +#. Tag: para +#: persistent_classes.xml:107 +#, no-c-format +msgid "" +"You should also avoid declaring public final methods on " +"the non-final classes. If you want to use a class with a public " +"final method, you must explicitly disable proxying by setting " +"lazy=\"false\"." msgstr "" +"你也应该避免在非final类中声明 public final的方法。如果你想" +"使用一 个有public final方法的类,你必须通过设置" +"lazy=\"false\" 来明确地禁用代理。" -#: index.docbook:115 +#. Tag: title +#: persistent_classes.xml:115 +#, no-c-format msgid "Declare accessors and mutators for persistent fields (optional)" -msgstr "" +msgstr "为持久化字段声明访问器(accessors)和是否可变的标志(mutators)(可选)" -#: index.docbook:117 -msgid "Cat declares accessor methods for all its persistent fields. Many other ORM tools directly persist instance variables. We believe it is better to provide an indirection between the relational schema and internal data structures of the class. By default, Hibernate persists JavaBeans style properties, and recognizes method names of the form getFoo, isFoo and setFoo. You may switch to direct field access for particular properties, if needed." +#. Tag: para +#: persistent_classes.xml:117 +#, no-c-format +msgid "" +"Cat declares accessor methods for all its persistent " +"fields. Many other ORM tools directly persist instance variables. We believe " +"it is better to provide an indirection between the relational schema and " +"internal data structures of the class. By default, Hibernate persists " +"JavaBeans style properties, and recognizes method names of the form " +"getFoo, isFoo and setFoo. You may switch to direct field access for particular properties, " +"if needed." msgstr "" +"Cat为它的所有持久化字段声明了访问方法。很多其他ORM工具直接" +"对 实例变量进行持久化。我们相信,在关系数据库schema和类的内部数据结构之间引入" +"间接层(原文为\"非直接\",indirection)会好一些。默认情况下Hibernate持久化" +"JavaBeans风格的属性,认可 getFooisFoosetFoo这种形式的方法名。 如果需要,你可以对某" +"些特定属性实行直接字段访问。" -#: index.docbook:127 -msgid "Properties need not be declared public - Hibernate can persist a property with a default, protected or private get / set pair." +#. Tag: para +#: persistent_classes.xml:127 +#, no-c-format +msgid "" +"Properties need not be declared public - Hibernate can " +"persist a property with a default, protected or " +"private get / set pair." msgstr "" +"属性不需要要声明为public的。Hibernate可以持久化一个有 " +"defaultprotectedprivate的get/set方法对 的属性进行持久化。" -#: index.docbook:138 +#. Tag: title +#: persistent_classes.xml:138 +#, no-c-format msgid "Implementing inheritance" -msgstr "" +msgstr "实现继承(Inheritance)" -#: index.docbook:140 -msgid "A subclass must also observe the first and second rules. It inherits its identifier property from the superclass, Cat." -msgstr "" - -#: index.docbook:145 +#. Tag: para +#: persistent_classes.xml:140 +#, no-c-format msgid "" - "" +"A subclass must also observe the first and second rules. It inherits its " +"identifier property from the superclass, Cat." +msgstr "" +"子类也必须遵守第一条和第二条规则。它从超类Cat继承了标识属" +"性。" + +#. Tag: programlisting +#: persistent_classes.xml:145 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:149 -msgid "Implementing equals() and hashCode()" -msgstr "" +#. Tag: title +#: persistent_classes.xml:149 +#, no-c-format +msgid "" +"Implementing equals() and hashCode()" +msgstr "实现equals()hashCode()" -#: index.docbook:151 -msgid "You have to override the equals() and hashCode() methods if you" +#. Tag: para +#: persistent_classes.xml:151 +#, no-c-format +msgid "" +"You have to override the equals() and hashCode()" +" methods if you" msgstr "" +"如果你有如下需求,你必须重载 equals()hashCode" +"()方法:" -#: index.docbook:157 -msgid "intend to put instances of persistent classes in a Set (the recommended way to represent many-valued associations) and" +#. Tag: para +#: persistent_classes.xml:157 +#, no-c-format +msgid "" +"intend to put instances of persistent classes in a Set " +"(the recommended way to represent many-valued associations) and" msgstr "" +"想把持久类的实例放入Set中(当表示多值关联时,推荐这么做)" -#: index.docbook:164 +#. Tag: para +#: persistent_classes.xml:164 +#, no-c-format msgid "intend to use reattachment of detached instances" -msgstr "" +msgstr "想重用脱管实例" -#: index.docbook:170 -msgid "Hibernate guarantees equivalence of persistent identity (database row) and Java identity only inside a particular session scope. So as soon as we mix instances retrieved in different sessions, we must implement equals() and hashCode() if we wish to have meaningful semantics for Sets." -msgstr "" - -#: index.docbook:178 -msgid "The most obvious way is to implement equals()/hashCode() by comparing the identifier value of both objects. If the value is the same, both must be the same database row, they are therefore equal (if both are added to a Set, we will only have one element in the Set). Unfortunately, we can't use that approach with generated identifiers! Hibernate will only assign identifier values to objects that are persistent, a newly created instance will not have any identifier value! Furthermore, if an instance is unsaved and currently in a Set, saving it will assign an identifier value to the object. If equals() and hashCode() are based on the identifier value, the hash code would change, breaking the contract of the Set. See the Hibernate website for a full discussion of this problem. Note that this is not a Hibernate issue, but normal Java semantics of object identity and equality." -msgstr "" - -#: index.docbook:192 -msgid "We recommend implementing equals() and hashCode() using Business key equality. Business key equality means that the equals() method compares only the properties that form the business key, a key that would identify our instance in the real world (a natural candidate key):" -msgstr "" - -#: index.docbook:200 +#. Tag: para +#: persistent_classes.xml:170 +#, no-c-format msgid "" - "" +"Hibernate guarantees equivalence of persistent identity (database row) and " +"Java identity only inside a particular session scope. So as soon as we mix " +"instances retrieved in different sessions, we must implement equals" +"() and hashCode() if we wish to have meaningful " +"semantics for Sets." +msgstr "" +"Hibernate保证,仅在特定会话范围内,持久化标识(数据库的行)和Java标识是等价" +"的。因此,一旦 我们混合了从不同会话中获取的实例,如果希望Set有明确的语义,就必 须实现equals() 和" +"hashCode()。" + +#. Tag: para +#: persistent_classes.xml:178 +#, no-c-format +msgid "" +"The most obvious way is to implement equals()/" +"hashCode() by comparing the identifier value of both " +"objects. If the value is the same, both must be the same database row, they " +"are therefore equal (if both are added to a Set, we will " +"only have one element in the Set). Unfortunately, we " +"can't use that approach with generated identifiers! Hibernate will only " +"assign identifier values to objects that are persistent, a newly created " +"instance will not have any identifier value! Furthermore, if an instance is " +"unsaved and currently in a Set, saving it will assign an " +"identifier value to the object. If equals() and " +"hashCode() are based on the identifier value, the hash " +"code would change, breaking the contract of the Set. See " +"the Hibernate website for a full discussion of this problem. Note that this " +"is not a Hibernate issue, but normal Java semantics of object identity and " +"equality." +msgstr "" +"实现equals()/hashCode()最显而易见的方法" +"是比较两个对象 标识符的值。如果值相同,则两个对象对应于数据库的同一行,因此它" +"们是相等的(如果都被添加到 Set,则在Set" +"中只有一个元素)。不幸的是,对生成的标识不能 使用这种方法。Hibernate仅对那些" +"持久化对象赋标识值,一个新创建的实例将不会有任何标识值。此外, 如果一个实例没" +"有被保存(unsaved),并且它当前正在一个Set中,保存它将会给这" +"个对象 赋一个标识值。如果equals()hashCode()是基于标识值 实现的,则其哈希码将会改变,这违反了Set的契约。建议去Hibernate的站点阅读关于这个 问题的全部讨论。注意,这不" +"是Hibernate的问题,而是一般的Java对象标识和Java对象等价的语义问题。" + +#. Tag: para +#: persistent_classes.xml:192 +#, no-c-format +msgid "" +"We recommend implementing equals() and hashCode()" +" using Business key equality. Business key " +"equality means that the equals() method compares only the " +"properties that form the business key, a key that would identify our " +"instance in the real world (a natural candidate key):" +msgstr "" +"我们建议使用业务键值相等(Business key equality)来实现" +"equals()hashCode()。业务键值相等的" +"意思是,equals()方法 仅仅比较形成业务键的属性,它能在现实" +"世界里标识我们的实例(是一个自然的候选码)。" + +#. Tag: programlisting +#: persistent_classes.xml:200 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:202 -msgid "Note that a business key does not have to be as solid as a database primary key candidate (see ). Immutable or unique properties are usually good candidates for a business key." +#. Tag: para +#: persistent_classes.xml:202 +#, no-c-format +msgid "" +"Note that a business key does not have to be as solid as a database primary " +"key candidate (see ). " +"Immutable or unique properties are usually good candidates for a business " +"key." msgstr "" +"注意,业务键不必像数据库的主键那样固定不变(参见)。 对业务键而言,不可变或唯一的属性是不错的选择。" -#: index.docbook:212 +#. Tag: title +#: persistent_classes.xml:212 +#, no-c-format msgid "Dynamic models" -msgstr "" +msgstr "动态模型(Dynamic models)" -#: index.docbook:215 -msgid "Note that the following features are currently considered experimental and may change in the near future." -msgstr "" - -#: index.docbook:219 -msgid "Persistent entities don't necessarily have to be represented as POJO classes or as JavaBean objects at runtime. Hibernate also supports dynamic models (using Maps of Maps at runtime) and the representation of entities as DOM4J trees. With this approach, you don't write persistent classes, only mapping files." -msgstr "" - -#: index.docbook:227 -msgid "By default, Hibernate works in normal POJO mode. You may set a default entity representation mode for a particular SessionFactory using the default_entity_mode configuration option (see ." -msgstr "" - -#: index.docbook:234 -msgid "The following examples demonstrates the representation using Maps. First, in the mapping file, an entity-name has to be declared instead of (or in addition to) a class name:" -msgstr "" - -#: index.docbook:240 +#. Tag: emphasis +#: persistent_classes.xml:215 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - "]]>" -msgstr "" +"Note that the following features are currently considered experimental and " +"may change in the near future." +msgstr "注意,以下特性在当前处于试验阶段,将来可能会有变化。" -#: index.docbook:242 -msgid "Note that even though associations are declared using target class names, the target type of an associations may also be a dynamic entity instead of a POJO." -msgstr "" - -#: index.docbook:249 -msgid "After setting the default entity mode to dynamic-map for the SessionFactory, we can at runtime work with Maps of Maps:" -msgstr "" - -#: index.docbook:255 +#. Tag: para +#: persistent_classes.xml:219 +#, no-c-format msgid "" - "" +"Persistent entities don't necessarily have to be represented as POJO classes " +"or as JavaBean objects at runtime. Hibernate also supports dynamic models " +"(using Maps of Maps at runtime) and " +"the representation of entities as DOM4J trees. With this approach, you don't " +"write persistent classes, only mapping files." msgstr "" +"运行期的持久化实体没有必要一定表示为像POJO类或JavaBean对象那样的形式。" +"Hibernate也支持动态模型 (在运行期使用MapMap)和象DOM4J的树模型那 样的实体表示。使用这种方法,你不用写持久化类," +"只写映射文件就行了。" -#: index.docbook:257 -msgid "The advantages of a dynamic mapping are quick turnaround time for prototyping without the need for entity class implementation. However, you lose compile-time type checking and will very likely deal with many exceptions at runtime. Thanks to the Hibernate mapping, the database schema can easily be normalized and sound, allowing to add a proper domain model implementation on top later on." -msgstr "" - -#: index.docbook:265 -msgid "Entity representation modes can also be set on a per Session basis:" -msgstr "" - -#: index.docbook:270 +#. Tag: para +#: persistent_classes.xml:227 +#, no-c-format msgid "" - "" +"By default, Hibernate works in normal POJO mode. You may set a default " +"entity representation mode for a particular SessionFactory using the default_entity_mode configuration " +"option (see ." +msgstr "" +"Hibernate默认工作在普通POJO模式。你可以使用配置选项" +"default_entity_mode, 对特定的SessionFactory,设置一个默认的实体表示模式。 (参见。)" + +#. Tag: para +#: persistent_classes.xml:234 +#, no-c-format +msgid "" +"The following examples demonstrates the representation using Maps. First, in the mapping file, an entity-name has " +"to be declared instead of (or in addition to) a class name:" +msgstr "" +"下面是用Map来表示的例子。首先,在映射文件中,要声明 " +"entity-name来代替一个类名(或作为一种附属)。" + +#. Tag: programlisting +#: persistent_classes.xml:240 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:273 -msgid "Please note that the call to getSession() using an EntityMode is on the Session API, not the SessionFactory. That way, the new Session shares the underlying JDBC connection, transaction, and other context information. This means you don't have tocall flush() and close() on the secondary Session, and also leave the transaction and connection handling to the primary unit of work." +#. Tag: para +#: persistent_classes.xml:242 +#, no-c-format +msgid "" +"Note that even though associations are declared using target class names, " +"the target type of an associations may also be a dynamic entity instead of a " +"POJO." +msgstr "" +"注意,虽然是用目标类名来声明关联的,但是关联的目标类型除了是POJO之外,也可以 " +"是一个动态的实体。" + +#. Tag: para +#: persistent_classes.xml:249 +#, no-c-format +msgid "" +"After setting the default entity mode to dynamic-map for " +"the SessionFactory, we can at runtime work with " +"Maps of Maps:" +msgstr "" +"在使用dynamic-mapSessionFactory 设置" +"了默认的实体模式之后,可以在运行期使用MapMap。" + +#. Tag: programlisting +#: persistent_classes.xml:255 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:283 -msgid "More information about the XML representation capabilities can be found in ." +#. Tag: para +#: persistent_classes.xml:257 +#, no-c-format +msgid "" +"The advantages of a dynamic mapping are quick turnaround time for " +"prototyping without the need for entity class implementation. However, you " +"lose compile-time type checking and will very likely deal with many " +"exceptions at runtime. Thanks to the Hibernate mapping, the database schema " +"can easily be normalized and sound, allowing to add a proper domain model " +"implementation on top later on." +msgstr "" +"动态映射的好处是,变化所需要的时间少了,因为原型不需要实现实体类。然而,你无" +"法进行 编译期的类型检查,并可能由此会处理很多的运行期异常。幸亏有了Hibernate" +"映射,它使得数 据库的schema能容易的规格化和合理化,并允许稍后在此之上添加合适" +"的领域模型实现。" + +#. Tag: para +#: persistent_classes.xml:265 +#, no-c-format +msgid "" +"Entity representation modes can also be set on a per Session basis:" +msgstr "实体表示模式也能在每个Session的基础上设置:" + +#. Tag: programlisting +#: persistent_classes.xml:270 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:291 +#. Tag: para +#: persistent_classes.xml:273 +#, no-c-format +msgid "" +"Please note that the call to getSession() using an " +"EntityMode is on the Session API, not " +"the SessionFactory. That way, the new Session shares the underlying JDBC connection, transaction, and other " +"context information. This means you don't have tocall flush() and close() on the secondary Session, and also leave the transaction and connection handling to the " +"primary unit of work." +msgstr "" +"请注意,用EntityMode调用getSession()是" +"在 Session的API中,而不是SessionFactory。 这样,新的Session共享底层的JDBC连接,事务,和其" +"他的上下文信 息。这意味着,你不需要在第二个Session中调用 " +"flush()close(),同样的,把事务和连接" +"的处理 交给原来的工作单元。" + +#. Tag: para +#: persistent_classes.xml:283 +#, no-c-format +msgid "" +"More information about the XML representation capabilities can be found in " +"." +msgstr "关于XML表示能力的更多信息可以在中找到。" + +#. Tag: title +#: persistent_classes.xml:291 +#, no-c-format msgid "Tuplizers" -msgstr "" +msgstr "元组片断映射(Tuplizers)" -#: index.docbook:293 -msgid "org.hibernate.tuple.Tuplizer, and its sub-interfaces, are responsible for managing a particular representation of a piece of data, given that representation's org.hibernate.EntityMode. If a given piece of data is thought of as a data structure, then a tuplizer is the thing which knows how to create such a data structure and how to extract values from and inject values into such a data structure. For example, for the POJO entity mode, the correpsonding tuplizer knows how create the POJO through its constructor and how to access the POJO properties using the defined property accessors. There are two high-level types of Tuplizers, represented by the org.hibernate.tuple.entity.EntityTuplizer and org.hibernate.tuple.component.ComponentTuplizer interfaces. EntityTuplizers are responsible for managing the above mentioned contracts in regards to entities, while ComponentTuplizers do the same for components." -msgstr "" - -#: index.docbook:308 -msgid "Users may also plug in their own tuplizers. Perhaps you require that a java.util.Map implementation other than java.util.HashMap be used while in the dynamic-map entity-mode; or perhaps you need to define a different proxy generation strategy than the one used by default. Both would be achieved by defining a custom tuplizer implementation. Tuplizers definitions are attached to the entity or component mapping they are meant to manage. Going back to the example of our customer entity:" -msgstr "" - -#: index.docbook:317 +#. Tag: para +#: persistent_classes.xml:293 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - " ...\n" - " \n" - "\n" - "\n" - "\n" - "public class CustomMapTuplizerImpl\n" - " extends org.hibernate.tuple.entity.DynamicMapEntityTuplizer {\n" - " // override the buildInstantiator() method to plug in our custom map...\n" - " protected final Instantiator buildInstantiator(\n" - " org.hibernate.mapping.PersistentClass mappingInfo) {\n" - " return new CustomMapInstantiator( mappingInfo );\n" - " }\n" - "\n" - " private static final class CustomMapInstantiator\n" - " extends org.hibernate.tuple.DynamicMapInstantitor {\n" - " // override the generateMap() method to return our custom map...\n" - " protected final Map generateMap() {\n" - " return new CustomMap();\n" - " }\n" - " }\n" - "}]]>" +"org.hibernate.tuple.Tuplizer, and its sub-interfaces, are " +"responsible for managing a particular representation of a piece of data, " +"given that representation's org.hibernate.EntityMode. If " +"a given piece of data is thought of as a data structure, then a tuplizer is " +"the thing which knows how to create such a data structure and how to extract " +"values from and inject values into such a data structure. For example, for " +"the POJO entity mode, the correpsonding tuplizer knows how create the POJO " +"through its constructor and how to access the POJO properties using the " +"defined property accessors. There are two high-level types of Tuplizers, " +"represented by the org.hibernate.tuple.entity.EntityTuplizer and org.hibernate.tuple.component.ComponentTuplizer interfaces. EntityTuplizers are responsible for " +"managing the above mentioned contracts in regards to entities, while " +"ComponentTuplizers do the same for components." +msgstr "" +"org.hibernate.tuple.Tuplizer,以及其子接口,负责根据给定的" +"org.hibernate.EntityMode,来复现片断数据。如果给定的片断数" +"据被认为其是一种数据结构,\"tuplizer\"就是一个知道如何创建这样的数据结构,以" +"及如何给这个数据结构赋值的东西。比如说,对于POJO这种Entity Mode,对应的" +"tuplizer知道通过其构造方法来创建一个POJO,再通过其属性访问器来访问POJO属性。" +"有两大类高层Tuplizer,分别是org.hibernate.tuple.entity." +"EntityTuplizerorg.hibernate.tuple.entity." +"ComponentTuplizer接口。EntityTuplizer负责管理上" +"面提到的实体的契约,而ComponentTuplizer则是针对组件的。" + +#. Tag: para +#: persistent_classes.xml:308 +#, no-c-format +msgid "" +"Users may also plug in their own tuplizers. Perhaps you require that a " +"java.util.Map implementation other than java." +"util.HashMap be used while in the dynamic-map entity-mode; or " +"perhaps you need to define a different proxy generation strategy than the " +"one used by default. Both would be achieved by defining a custom tuplizer " +"implementation. Tuplizers definitions are attached to the entity or " +"component mapping they are meant to manage. Going back to the example of our " +"customer entity:" +msgstr "" +"用户也可以插入其自定义的tuplizer。或许您需要一种不同于dynamic-map entity-mode" +"中使用的java.util.HashMapjava.util.Map实现;或许您需要与默认策略不同的代理生成策略(proxy generation " +"strategy)。通过自定义tuplizer实现,这两个目标您都可以达到。Tuplizer定义被附加" +"到它们期望管理的entity或者component映射中。回到我们的customer entity例子:" + +#. Tag: programlisting +#: persistent_classes.xml:317 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +" ...\n" +" \n" +"\n" +"\n" +"\n" +"public class CustomMapTuplizerImpl\n" +" extends org.hibernate.tuple.entity.DynamicMapEntityTuplizer {\n" +" // override the buildInstantiator() method to plug in our custom map...\n" +" protected final Instantiator buildInstantiator(\n" +" org.hibernate.mapping.PersistentClass mappingInfo) {\n" +" return new CustomMapInstantiator( mappingInfo );\n" +" }\n" +"\n" +" private static final class CustomMapInstantiator\n" +" extends org.hibernate.tuple.DynamicMapInstantitor {\n" +" // override the generateMap() method to return our custom map...\n" +" protected final Map generateMap() {\n" +" return new CustomMap();\n" +" }\n" +" }\n" +"}]]>" msgstr "" -#: index.docbook:322 -msgid "TODO: Document user-extension framework in the property and proxy packages" -msgstr "" - -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +#. Tag: para +#: persistent_classes.xml:322 +#, no-c-format +msgid "" +"TODO: Document user-extension framework in the property and proxy packages" +msgstr "TODO:property和proxy包里的用户扩展框架文档。" diff --git a/documentation/manual/translations/zh-CN/content/preface.po b/documentation/manual/translations/zh-CN/content/preface.po index 61caab996b..e47b9f1c7e 100644 --- a/documentation/manual/translations/zh-CN/content/preface.po +++ b/documentation/manual/translations/zh-CN/content/preface.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:21 +"Language-Team: LANGUAGE \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 "前言" +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 for a tutorial with step-by-step instructions. The source code for the tutorial is included in the distribution in the doc/reference/tutorial/ directory." -msgstr "阅读,这是一篇包含详细的逐步指导的指南。本指南的源代码包含在发行包中,你可以在doc/reference/tutorial/目录下找到。" +#. Tag: para +#: preface.xml:55 +#, no-c-format +msgid "" +"Read for a tutorial with step-by-step " +"instructions. The source code for the tutorial is included in the " +"distribution in the doc/reference/tutorial/ directory." +msgstr "" +"阅读,这是一篇包含详细的逐步指导的指南。本指南的" +"源代码包含在发行包中,你可以在doc/reference/tutorial/目录" +"下找到。" -#: index.docbook:63 -msgid "Read to understand the environments where Hibernate can be used." +#. Tag: para +#: preface.xml:63 +#, no-c-format +msgid "" +"Read to understand the environments where " +"Hibernate can be used." msgstr "阅读来理解Hibernate可以使用的环境。" -#: index.docbook:69 -msgid "Have a look at the eg/ directory in the Hibernate distribution, it contains a simple standalone application. Copy your JDBC driver to the lib/ directory and edit etc/hibernate.properties, specifying correct values for your database. From a command prompt in the distribution directory, type ant eg (using Ant), or under Windows, type build eg." -msgstr "查看Hibernate发行包中的eg/目录,里面有一个简单的独立运行的程序。把你的JDBC驱动拷贝到lib/目录下,修改一下src/hibernate.properties,指定其中你的数据库的信息。进入命令行,切换到你的发行包的目录,输入ant eg(使用了Ant),或者在Windows操作系统中使用build eg。" +#. Tag: para +#: preface.xml:69 +#, no-c-format +msgid "" +"Have a look at the eg/ directory in the Hibernate " +"distribution, it contains a simple standalone application. Copy your JDBC " +"driver to the lib/ directory and edit etc/" +"hibernate.properties, specifying correct values for your database. " +"From a command prompt in the distribution directory, type ant eg (using Ant), or under Windows, type build eg." +msgstr "" +"查看Hibernate发行包中的eg/目录,里面有一个简单的独立运行的" +"程序。把你的JDBC驱动拷贝到lib/目录下,修改一下" +"src/hibernate.properties,指定其中你的数据库的信息。进入命" +"令行,切换到你的发行包的目录,输入ant eg(使用了Ant),或者" +"在Windows操作系统中使用build eg。" -#: index.docbook:80 -msgid "Use this reference documentation as your primary source of information. Consider reading Java Persistence with Hibernate (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 Java Persistence with Hibernate " +"(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 "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" +#. 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企业级中间件系统的一个核心组件。" diff --git a/documentation/manual/translations/zh-CN/content/query_criteria.po b/documentation/manual/translations/zh-CN/content/query_criteria.po index 6dc8e9247d..5cf8435424 100644 --- a/documentation/manual/translations/zh-CN/content/query_criteria.po +++ b/documentation/manual/translations/zh-CN/content/query_criteria.po @@ -1,484 +1,750 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: query_criteria.xml:5 +#, no-c-format msgid "Criteria Queries" -msgstr "" +msgstr "条件查询(Criteria Queries)" -#: index.docbook:7 +#. Tag: para +#: query_criteria.xml:7 +#, no-c-format msgid "Hibernate features an intuitive, extensible criteria query API." -msgstr "" +msgstr "具有一个直观的、可扩展的条件查询API是Hibernate的特色。" -#: index.docbook:12 +#. Tag: title +#: query_criteria.xml:12 +#, no-c-format msgid "Creating a Criteria instance" -msgstr "" +msgstr "创建一个Criteria 实例" -#: index.docbook:14 -msgid "The interface org.hibernate.Criteria represents a query against a particular persistent class. The Session is a factory for Criteria instances." -msgstr "" - -#: index.docbook:20 +#. Tag: para +#: query_criteria.xml:14 +#, no-c-format msgid "" - "" +"The interface org.hibernate.Criteria represents a query " +"against a particular persistent class. The Session is a " +"factory for Criteria instances." +msgstr "" +"org.hibernate.Criteria接口表示特定持久类的一个查询。" +"SessionCriteria实例的工厂。" + +#. Tag: programlisting +#: query_criteria.xml:20 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:25 +#. Tag: title +#: query_criteria.xml:25 +#, no-c-format msgid "Narrowing the result set" -msgstr "" +msgstr "限制结果集内容" -#: index.docbook:27 -msgid "An individual query criterion is an instance of the interface org.hibernate.criterion.Criterion. The class org.hibernate.criterion.Restrictions defines factory methods for obtaining certain built-in Criterion types." -msgstr "" - -#: index.docbook:35 +#. Tag: para +#: query_criteria.xml:27 +#, no-c-format msgid "" - "" +"An individual query criterion is an instance of the interface org." +"hibernate.criterion.Criterion. The class org.hibernate." +"criterion.Restrictions defines factory methods for obtaining " +"certain built-in Criterion types." +msgstr "" +"一个单独的查询条件是org.hibernate.criterion.Criterion 接口" +"的一个实例。org.hibernate.criterion.Restrictions类 定义了" +"获得某些内置Criterion类型的工厂方法。" + +#. Tag: programlisting +#: query_criteria.xml:35 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:37 +#. Tag: para +#: query_criteria.xml:37 +#, no-c-format msgid "Restrictions may be grouped logically." -msgstr "" +msgstr "约束可以按逻辑分组。" -#: index.docbook:41 +#. Tag: programlisting +#: query_criteria.xml:41 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:43 +#. Tag: programlisting +#: query_criteria.xml:43 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:45 -msgid "There are quite a range of built-in criterion types (Restrictions subclasses), but one that is especially useful lets you specify SQL directly." -msgstr "" - -#: index.docbook:50 +#. Tag: para +#: query_criteria.xml:45 +#, no-c-format msgid "" - "" +"There are quite a range of built-in criterion types (Restrictions subclasses), but one that is especially useful lets you specify SQL " +"directly." msgstr "" +"Hibernate提供了相当多的内置criterion类型(Restrictions 子" +"类), 但是尤其有用的是可以允许你直接使用SQL。" -#: index.docbook:52 -msgid "The {alias} placeholder with be replaced by the row alias of the queried entity." -msgstr "" - -#: index.docbook:57 -msgid "An alternative approach to obtaining a criterion is to get it from a Property instance. You can create a Property by calling Property.forName()." -msgstr "" - -#: index.docbook:63 +#. Tag: programlisting +#: query_criteria.xml:50 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:68 +#. Tag: para +#: query_criteria.xml:52 +#, no-c-format +msgid "" +"The {alias} placeholder with be replaced by the row alias " +"of the queried entity." +msgstr "{alias}占位符应当被替换为被查询实体的列别名。" + +#. Tag: para +#: query_criteria.xml:57 +#, no-c-format +msgid "" +"An alternative approach to obtaining a criterion is to get it from a " +"Property instance. You can create a Property by calling Property.forName()." +msgstr "" +"Property实例是获得一个条件的另外一种途径。你可以通过调用" +"Property.forName() 创建一个Property。" + +#. Tag: programlisting +#: query_criteria.xml:63 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: query_criteria.xml:68 +#, no-c-format msgid "Ordering the results" -msgstr "" +msgstr "结果集排序" -#: index.docbook:70 -msgid "You may order the results using org.hibernate.criterion.Order." -msgstr "" - -#: index.docbook:74 +#. Tag: para +#: query_criteria.xml:70 +#, no-c-format msgid "" - "" +"You may order the results using org.hibernate.criterion.Order." msgstr "" +"你可以使用org.hibernate.criterion.Order来为查询结果排序。" -#: index.docbook:76 +#. Tag: programlisting +#: query_criteria.xml:74 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:81 +#. Tag: programlisting +#: query_criteria.xml:76 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: query_criteria.xml:81 +#, no-c-format msgid "Associations" -msgstr "" +msgstr "关联" -#: index.docbook:83 -msgid "You may easily specify constraints upon related entities by navigating associations using createCriteria()." -msgstr "" - -#: index.docbook:88 +#. Tag: para +#: query_criteria.xml:83 +#, no-c-format msgid "" - "" +"You may easily specify constraints upon related entities by navigating " +"associations using createCriteria()." +msgstr "" +"你可以使用createCriteria()非常容易的在互相关联的实体间建" +"立 约束。" + +#. Tag: programlisting +#: query_criteria.xml:88 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:90 -msgid "note that the second createCriteria() returns a new instance of Criteria, which refers to the elements of the kittens collection." +#. Tag: para +#: query_criteria.xml:90 +#, no-c-format +msgid "" +"note that the second createCriteria() returns a new " +"instance of Criteria, which refers to the elements of the " +"kittens collection." msgstr "" +"注意第二个 createCriteria()返回一个新的 " +"Criteria实例,该实例引用kittens 集合中" +"的元素。" -#: index.docbook:96 +#. Tag: para +#: query_criteria.xml:96 +#, no-c-format msgid "The following, alternate form is useful in certain circumstances." -msgstr "" +msgstr "接下来,替换形态在某些情况下也是很有用的。" -#: index.docbook:100 +#. Tag: programlisting +#: query_criteria.xml:100 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:102 -msgid "(createAlias() does not create a new instance of Criteria.)" -msgstr "" - -#: index.docbook:107 -msgid "Note that the kittens collections held by the Cat instances returned by the previous two queries are not pre-filtered by the criteria! If you wish to retrieve just the kittens that match the criteria, you must use a ResultTransformer." -msgstr "" - -#: index.docbook:114 +#. Tag: para +#: query_criteria.xml:102 +#, no-c-format msgid "" - "" +"(createAlias() does not create a new instance of " +"Criteria.)" +msgstr "" +"(createAlias()并不创建一个新的 Criteria" +"实例。)" + +#. Tag: para +#: query_criteria.xml:107 +#, no-c-format +msgid "" +"Note that the kittens collections held by the Cat " +"instances returned by the previous two queries are not " +"pre-filtered by the criteria! If you wish to retrieve just the kittens that " +"match the criteria, you must use a ResultTransformer." +msgstr "" +"Cat实例所保存的之前两次查询所返回的kittens集合是 " +"没有被条件预过滤的。如果你希望只获得符合条件的kittens, " +"你必须使用ResultTransformer。" + +#. Tag: programlisting +#: query_criteria.xml:114 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:119 +#. Tag: title +#: query_criteria.xml:119 +#, no-c-format msgid "Dynamic association fetching" -msgstr "" +msgstr "动态关联抓取" -#: index.docbook:121 -msgid "You may specify association fetching semantics at runtime using setFetchMode()." -msgstr "" - -#: index.docbook:126 +#. Tag: para +#: query_criteria.xml:121 +#, no-c-format msgid "" - "" +"You may specify association fetching semantics at runtime using " +"setFetchMode()." +msgstr "" +"你可以使用setFetchMode()在运行时定义动态关联抓取的语义。" + +#. Tag: programlisting +#: query_criteria.xml:126 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:128 -msgid "This query will fetch both mate and kittens by outer join. See for more information." +#. Tag: para +#: query_criteria.xml:128 +#, no-c-format +msgid "" +"This query will fetch both mate and kittens by outer join. See for " +"more information." msgstr "" +"这个查询可以通过外连接抓取matekittens。 查看可以获得更多信息。" -#: index.docbook:136 +#. Tag: title +#: query_criteria.xml:136 +#, no-c-format msgid "Example queries" -msgstr "" +msgstr "查询示例" -#: index.docbook:138 -msgid "The class org.hibernate.criterion.Example allows you to construct a query criterion from a given instance." -msgstr "" - -#: index.docbook:143 +#. Tag: para +#: query_criteria.xml:138 +#, no-c-format msgid "" - "" +"The class org.hibernate.criterion.Example allows you to " +"construct a query criterion from a given instance." +msgstr "" +"org.hibernate.criterion.Example类允许你通过一个给定实例 构" +"建一个条件查询。" + +#. Tag: programlisting +#: query_criteria.xml:143 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:145 -msgid "Version properties, identifiers and associations are ignored. By default, null valued properties are excluded." -msgstr "" +#. Tag: para +#: query_criteria.xml:145 +#, no-c-format +msgid "" +"Version properties, identifiers and associations are ignored. By default, " +"null valued properties are excluded." +msgstr "版本属性、标识符和关联被忽略。默认情况下值为null的属性将被排除。" -#: index.docbook:150 +#. Tag: para +#: query_criteria.xml:150 +#, no-c-format msgid "You can adjust how the Example is applied." -msgstr "" +msgstr "你可以自行调整Example使之更实用。" -#: index.docbook:154 +#. Tag: programlisting +#: query_criteria.xml:154 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:156 +#. Tag: para +#: query_criteria.xml:156 +#, no-c-format msgid "You can even use examples to place criteria upon associated objects." -msgstr "" +msgstr "你甚至可以使用examples在关联对象上放置条件。" -#: index.docbook:160 +#. Tag: programlisting +#: query_criteria.xml:160 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:165 +#. Tag: title +#: query_criteria.xml:165 +#, no-c-format msgid "Projections, aggregation and grouping" -msgstr "" +msgstr "投影(Projections)、聚合(aggregation)和分组(grouping)" -#: index.docbook:166 -msgid "The class org.hibernate.criterion.Projections is a factory for Projection instances. We apply a projection to a query by calling setProjection()." -msgstr "" - -#: index.docbook:172 +#. Tag: para +#: query_criteria.xml:166 +#, no-c-format msgid "" - "" +"The class org.hibernate.criterion.Projections is a " +"factory for Projection instances. We apply a projection " +"to a query by calling setProjection()." msgstr "" +"org.hibernate.criterion.Projections是 " +"Projection 的实例工厂。我们通过调用 setProjection" +"()应用投影到一个查询。" -#: index.docbook:174 +#. Tag: programlisting +#: query_criteria.xml:172 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:176 -msgid "There is no explicit \"group by\" necessary in a criteria query. Certain projection types are defined to be grouping projections, which also appear in the SQL group by clause." -msgstr "" - -#: index.docbook:182 -msgid "An alias may optionally be assigned to a projection, so that the projected value may be referred to in restrictions or orderings. Here are two different ways to do this:" -msgstr "" - -#: index.docbook:188 +#. Tag: programlisting +#: query_criteria.xml:174 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:190 +#. Tag: para +#: query_criteria.xml:176 +#, no-c-format msgid "" - "" +"There is no explicit \"group by\" necessary in a criteria query. Certain " +"projection types are defined to be grouping projections, which also appear in the SQL group by clause." msgstr "" +"在一个条件查询中没有必要显式的使用 \"group by\" 。某些投影类型就是被定义为" +" 分组投影,他们也出现在SQL的group by" +"子句中。" -#: index.docbook:192 -msgid "The alias() and as() methods simply wrap a projection instance in another, aliased, instance of Projection. As a shortcut, you can assign an alias when you add the projection to a projection list:" -msgstr "" - -#: index.docbook:199 +#. Tag: para +#: query_criteria.xml:182 +#, no-c-format msgid "" - "" +"An alias may optionally be assigned to a projection, so that the projected " +"value may be referred to in restrictions or orderings. Here are two " +"different ways to do this:" msgstr "" +"你可以选择把一个别名指派给一个投影,这样可以使投影值被约束或排序所引用。下面" +"是两种不同的实现方式:" -#: index.docbook:201 +#. Tag: programlisting +#: query_criteria.xml:188 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:203 -msgid "You can also use Property.forName() to express projections:" -msgstr "" - -#: index.docbook:207 +#. Tag: programlisting +#: query_criteria.xml:190 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:209 +#. Tag: para +#: query_criteria.xml:192 +#, no-c-format msgid "" - "" +"The alias() and as() methods simply " +"wrap a projection instance in another, aliased, instance of " +"Projection. As a shortcut, you can assign an alias when " +"you add the projection to a projection list:" +msgstr "" +"alias()as()方法简便的将一个投影实例包" +"装到另外一个 别名的Projection实例中。简而言之,当你添加一" +"个投影到一个投影列表中时 你可以为它指定一个别名:" + +#. Tag: programlisting +#: query_criteria.xml:199 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:214 +#. Tag: programlisting +#: query_criteria.xml:201 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: query_criteria.xml:203 +#, no-c-format +msgid "" +"You can also use Property.forName() to express " +"projections:" +msgstr "你也可以使用Property.forName()来表示投影:" + +#. Tag: programlisting +#: query_criteria.xml:207 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: programlisting +#: query_criteria.xml:209 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: query_criteria.xml:214 +#, no-c-format msgid "Detached queries and subqueries" -msgstr "" +msgstr "离线(detached)查询和子查询" -#: index.docbook:215 -msgid "The DetachedCriteria class lets you create a query outside the scope of a session, and then later execute it using some arbitrary Session." -msgstr "" - -#: index.docbook:220 +#. Tag: para +#: query_criteria.xml:215 +#, no-c-format msgid "" - "" +"The DetachedCriteria class lets you create a query " +"outside the scope of a session, and then later execute it using some " +"arbitrary Session." msgstr "" +"DetachedCriteria类使你在一个session范围之外创建一个查询," +"并且可以使用任意的 Session来执行它。" -#: index.docbook:222 -msgid "A DetachedCriteria may also be used to express a subquery. Criterion instances involving subqueries may be obtained via Subqueries or Property." -msgstr "" - -#: index.docbook:228 +#. Tag: programlisting +#: query_criteria.xml:220 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:230 +#. Tag: para +#: query_criteria.xml:222 +#, no-c-format msgid "" - "" +"A DetachedCriteria may also be used to express a " +"subquery. Criterion instances involving subqueries may be obtained via " +"Subqueries or Property." +msgstr "" +"DetachedCriteria也可以用以表示子查询。条件实例包含子查询可" +"以通过 Subqueries或者Property获得。" + +#. Tag: programlisting +#: query_criteria.xml:228 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:232 +#. Tag: programlisting +#: query_criteria.xml:230 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: query_criteria.xml:232 +#, no-c-format msgid "Even correlated subqueries are possible:" -msgstr "" +msgstr "甚至相互关联的子查询也是有可能的:" -#: index.docbook:236 +#. Tag: programlisting +#: query_criteria.xml:236 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:245 +#. Tag: title +#: query_criteria.xml:245 +#, no-c-format msgid "Queries by natural identifier" -msgstr "" +msgstr "根据自然标识查询(Queries by natural identifier)" -#: index.docbook:247 -msgid "For most queries, including criteria queries, the query cache is not very efficient, because query cache invalidation occurs too frequently. However, there is one special kind of query where we can optimize the cache invalidation algorithm: lookups by a constant natural key. In some applications, this kind of query occurs frequently. The criteria API provides special provision for this use case." -msgstr "" - -#: index.docbook:255 -msgid "First, you should map the natural key of your entity using <natural-id>, and enable use of the second-level cache." -msgstr "" - -#: index.docbook:260 +#. Tag: para +#: query_criteria.xml:247 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"For most queries, including criteria queries, the query cache is not very " +"efficient, because query cache invalidation occurs too frequently. However, " +"there is one special kind of query where we can optimize the cache " +"invalidation algorithm: lookups by a constant natural key. In some " +"applications, this kind of query occurs frequently. The criteria API " +"provides special provision for this use case." +msgstr "" +"对大多数查询,包括条件查询而言,因为查询缓存的失效(invalidation)发生得太频" +"繁,查询缓存不是非常高效。然而,有一种特别的查询,可以通过不变的自然键优化缓" +"存的失效算法。在某些应用中,这种类型的查询比较常见。条件查询API对这种用例提供" +"了特别规约。" + +#. Tag: para +#: query_criteria.xml:255 +#, no-c-format +msgid "" +"First, you should map the natural key of your entity using <" +"natural-id>, and enable use of the second-level cache." +msgstr "" +"首先,你应该对你的entity使用<natural-id>来映射自然" +"键,然后打开第二级缓存。" + +#. Tag: programlisting +#: query_criteria.xml:260 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:262 -msgid "Note that this functionality is not intended for use with entities with mutable natural keys." -msgstr "" +#. Tag: para +#: query_criteria.xml:262 +#, no-c-format +msgid "" +"Note that this functionality is not intended for use with entities with " +"mutable natural keys." +msgstr "注意,此功能对具有mutable自然键的entity并不适用。" -#: index.docbook:267 +#. Tag: para +#: query_criteria.xml:267 +#, no-c-format msgid "Next, enable the Hibernate query cache." -msgstr "" +msgstr "然后,打开Hibernate 查询缓存。" -#: index.docbook:271 -msgid "Now, Restrictions.naturalId() allows us to make use of the more efficient cache algorithm." -msgstr "" - -#: index.docbook:276 +#. Tag: para +#: query_criteria.xml:271 +#, no-c-format msgid "" - "" +"Now, Restrictions.naturalId() allows us to make use of " +"the more efficient cache algorithm." msgstr "" +"现在,我们可以用Restrictions.naturalId()来使用更加高效的缓" +"存算法。" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +#. Tag: programlisting +#: query_criteria.xml:276 +#, no-c-format +msgid "" +"" +msgstr "" diff --git a/documentation/manual/translations/zh-CN/content/query_hql.po b/documentation/manual/translations/zh-CN/content/query_hql.po index 58bea7c361..9aed70bcad 100644 --- a/documentation/manual/translations/zh-CN/content/query_hql.po +++ b/documentation/manual/translations/zh-CN/content/query_hql.po @@ -1,1275 +1,2347 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: query_hql.xml:5 +#, no-c-format msgid "HQL: The Hibernate Query Language" -msgstr "" +msgstr "HQL: Hibernate查询语言" -#: index.docbook:7 -msgid "Hibernate is equipped with an extremely powerful query language that (quite intentionally) looks very much like SQL. But don't be fooled by the syntax; HQL is fully object-oriented, understanding notions like inheritence, polymorphism and association." +#. Tag: para +#: query_hql.xml:7 +#, no-c-format +msgid "" +"Hibernate is equipped with an extremely powerful query language that (quite " +"intentionally) looks very much like SQL. But don't be fooled by the syntax; " +"HQL is fully object-oriented, understanding notions like inheritence, " +"polymorphism and association." msgstr "" +"Hibernate配备了一种非常强大的查询语言,这种语言看上去很像SQL。但是不要被语法" +"结构 上的相似所迷惑,HQL是非常有意识的被设计为完全面向对象的查询,它可以理解" +"如继承、多态 和关联之类的概念。" -#: index.docbook:14 +#. Tag: title +#: query_hql.xml:14 +#, no-c-format msgid "Case Sensitivity" -msgstr "" +msgstr "大小写敏感性问题" -#: index.docbook:16 -msgid "Queries are case-insensitive, except for names of Java classes and properties. So SeLeCT is the same as sELEct is the same as SELECT but org.hibernate.eg.FOO is not org.hibernate.eg.Foo and foo.barSet is not foo.BARSET." +#. Tag: para +#: query_hql.xml:16 +#, no-c-format +msgid "" +"Queries are case-insensitive, except for names of Java classes and " +"properties. So SeLeCT is the same as sELEct is the same as SELECT but org.hibernate." +"eg.FOO is not org.hibernate.eg.Foo and " +"foo.barSet is not foo.BARSET." msgstr "" +"除了Java类与属性的名称外,查询语句对大小写并不敏感。 所以 SeLeCTsELEct 以及 SELECT 是相同" +"的,但是 org.hibernate.eg.FOO 并不等价于 org." +"hibernate.eg.Foo 并且 foo.barSet 也不等价于 " +"foo.BARSET。" -#: index.docbook:27 -msgid "This manual uses lowercase HQL keywords. Some users find queries with uppercase keywords more readable, but we find this convention ugly when embedded in Java code." +#. Tag: para +#: query_hql.xml:27 +#, no-c-format +msgid "" +"This manual uses lowercase HQL keywords. Some users find queries with " +"uppercase keywords more readable, but we find this convention ugly when " +"embedded in Java code." msgstr "" +"本手册中的HQL关键字将使用小写字母. 很多用户发现使用完全大写的关键字会使查询语" +"句 的可读性更强, 但我们发现,当把查询语句嵌入到Java语句中的时候使用大写关键字" +"比较难看。" -#: index.docbook:35 +#. Tag: title +#: query_hql.xml:35 +#, no-c-format msgid "The from clause" -msgstr "" +msgstr "from子句" -#: index.docbook:37 +#. Tag: para +#: query_hql.xml:37 +#, no-c-format msgid "The simplest possible Hibernate query is of the form:" -msgstr "" +msgstr "Hibernate中最简单的查询语句的形式如下:" -#: index.docbook:41 +#. Tag: programlisting +#: query_hql.xml:41 +#, no-c-format msgid "" msgstr "" -#: index.docbook:43 -msgid "which simply returns all instances of the class eg.Cat. We don't usually need to qualify the class name, since auto-import is the default. So we almost always just write:" +#. Tag: para +#: query_hql.xml:43 +#, no-c-format +msgid "" +"which simply returns all instances of the class eg.Cat. " +"We don't usually need to qualify the class name, since auto-import is the default. So we almost always just write:" msgstr "" +"该子句简单的返回eg.Cat类的所有实例。 通常我们不需要使用类" +"的全限定名, 因为 auto-import(自动引入) 是缺省的情况。 所" +"以我们几乎只使用如下的简单写法:" -#: index.docbook:49 +#. Tag: programlisting +#: query_hql.xml:49 +#, no-c-format msgid "" msgstr "" -#: index.docbook:51 -msgid "Most of the time, you will need to assign an alias, since you will want to refer to the Cat in other parts of the query." +#. Tag: para +#: query_hql.xml:51 +#, no-c-format +msgid "" +"Most of the time, you will need to assign an alias, " +"since you will want to refer to the Cat in other parts of " +"the query." msgstr "" +"大多数情况下, 你需要指定一个别名, 原因是你可能需要 在查" +"询语句的其它部分引用到Cat" -#: index.docbook:57, index.docbook:372 +#. Tag: programlisting +#: query_hql.xml:57 query_hql.xml:372 +#, no-c-format msgid "" msgstr "" -#: index.docbook:59 -msgid "This query assigns the alias cat to Cat instances, so we could use that alias later in the query. The as keyword is optional; we could also write:" +#. Tag: para +#: query_hql.xml:59 +#, no-c-format +msgid "" +"This query assigns the alias cat to Cat instances, so we could use that alias later in the query. The " +"as keyword is optional; we could also write:" msgstr "" +"这个语句把别名cat指定给类Cat 的实例, 这" +"样我们就可以在随后的查询中使用此别名了。 关键字as 是可选" +"的,我们也可以这样写:" -#: index.docbook:65 +#. Tag: programlisting +#: query_hql.xml:65 +#, no-c-format msgid "" msgstr "" -#: index.docbook:67 -msgid "Multiple classes may appear, resulting in a cartesian product or \"cross\" join." +#. Tag: para +#: query_hql.xml:67 +#, no-c-format +msgid "" +"Multiple classes may appear, resulting in a cartesian product or \"cross\" " +"join." msgstr "" +"子句中可以同时出现多个类, 其查询结果是产生一个笛卡儿积或产生跨表的连接。" -#: index.docbook:71 +#. Tag: programlisting +#: query_hql.xml:71 +#, no-c-format msgid "" msgstr "" -#: index.docbook:72 +#. Tag: programlisting +#: query_hql.xml:72 +#, no-c-format msgid "" msgstr "" -#: index.docbook:74 -msgid "It is considered good practice to name query aliases using an initial lowercase, consistent with Java naming standards for local variables (eg. domesticCat)." -msgstr "" - -#: index.docbook:83 -msgid "Associations and joins" -msgstr "" - -#: index.docbook:85 -msgid "We may also assign aliases to associated entities, or even to elements of a collection of values, using a join." -msgstr "" - -#: index.docbook:90 +#. Tag: para +#: query_hql.xml:74 +#, no-c-format msgid "" - "" +"It is considered good practice to name query aliases using an initial " +"lowercase, consistent with Java naming standards for local variables (eg. " +"domesticCat)." +msgstr "" +"查询语句中别名的开头部分小写被认为是实践中的好习惯, 这样做与Java变量的命名标" +"准保持了一致 (比如,domesticCat)。" + +#. Tag: title +#: query_hql.xml:83 +#, no-c-format +msgid "Associations and joins" +msgstr "关联(Association)与连接(Join)" + +#. Tag: para +#: query_hql.xml:85 +#, no-c-format +msgid "" +"We may also assign aliases to associated entities, or even to elements of a " +"collection of values, using a join." +msgstr "" +"我们也可以为相关联的实体甚至是对一个集合中的全部元素指定一个别名, 这时要使用" +"关键字join。" + +#. Tag: programlisting +#: query_hql.xml:90 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:92 +#. Tag: programlisting +#: query_hql.xml:92 +#, no-c-format msgid "" msgstr "" -#: index.docbook:94 +#. Tag: programlisting +#: query_hql.xml:94 +#, no-c-format msgid "" msgstr "" -#: index.docbook:96 +#. Tag: para +#: query_hql.xml:96 +#, no-c-format msgid "The supported join types are borrowed from ANSI SQL" -msgstr "" +msgstr "受支持的连接类型是从ANSI SQL中借鉴来的。" -#: index.docbook:103 +#. Tag: literal +#: query_hql.xml:103 +#, no-c-format msgid "inner join" -msgstr "" +msgstr "inner join(内连接)" -#: index.docbook:108 +#. Tag: literal +#: query_hql.xml:108 +#, no-c-format msgid "left outer join" -msgstr "" +msgstr "left outer join(左外连接)" -#: index.docbook:113 +#. Tag: literal +#: query_hql.xml:113 +#, no-c-format msgid "right outer join" -msgstr "" +msgstr "right outer join(右外连接)" -#: index.docbook:117 +#. Tag: para +#: query_hql.xml:117 +#, no-c-format msgid "full join (not usually useful)" -msgstr "" +msgstr "full join (全连接,并不常用)" -#: index.docbook:123 -msgid "The inner join, left outer join and right outer join constructs may be abbreviated." -msgstr "" - -#: index.docbook:128 +#. Tag: para +#: query_hql.xml:123 +#, no-c-format msgid "" - "" +"The inner join, left outer join and " +"right outer join constructs may be abbreviated." msgstr "" +"语句inner join, left outer join 以及 " +"right outer join 可以简写。" -#: index.docbook:130 -msgid "You may supply extra join conditions using the HQL with keyword." -msgstr "" - -#: index.docbook:135 +#. Tag: programlisting +#: query_hql.xml:128 +#, no-c-format msgid "" - " 10.0]]>" +"" msgstr "" -#: index.docbook:137 -msgid "In addition, a \"fetch\" join allows associations or collections of values to be initialized along with their parent objects, using a single select. This is particularly useful in the case of a collection. It effectively overrides the outer join and lazy declarations of the mapping file for associations and collections. See for more information." -msgstr "" - -#: index.docbook:145 +#. Tag: para +#: query_hql.xml:130 +#, no-c-format msgid "" - "" -msgstr "" +"You may supply extra join conditions using the HQL with " +"keyword." +msgstr "通过HQL的with关键字,你可以提供额外的join条件。" -#: index.docbook:147 -msgid "A fetch join does not usually need to assign an alias, because the associated objects should not be used in the where clause (or any other clause). Also, the associated objects are not returned directly in the query results. Instead, they may be accessed via the parent object. The only reason we might need an alias is if we are recursively join fetching a further collection:" -msgstr "" - -#: index.docbook:155 +#. Tag: programlisting +#: query_hql.xml:135 +#, no-c-format msgid "" - "" +" 10.0]]>" msgstr "" -#: index.docbook:157 -msgid "Note that the fetch construct may not be used in queries called using iterate() (though scroll() can be used). Nor should fetch be used together with setMaxResults() or setFirstResult() as these operations are based on the result rows, which usually contain duplicates for eager collection fetching, hence, the number of rows is not what you'd expect. Nor may fetch be used together with an ad hoc with condition. It is possible to create a cartesian product by join fetching more than one collection in a query, so take care in this case. Join fetching multiple collection roles also sometimes gives unexpected results for bag mappings, so be careful about how you formulate your queries in this case. Finally, note that full join fetch and right join fetch are not meaningful." +#. Tag: para +#: query_hql.xml:137 +#, no-c-format +msgid "" +"In addition, a \"fetch\" join allows associations or collections of values " +"to be initialized along with their parent objects, using a single select. " +"This is particularly useful in the case of a collection. It effectively " +"overrides the outer join and lazy declarations of the mapping file for " +"associations and collections. See " +"for more information." +msgstr "" +"还有,一个\"fetch\"连接允许仅仅使用一个选择语句就将相关联的对象或一组值的集合" +"随着他们的父对象的初始化而被初始化,这种方法在使用到集合的情况下尤其有用,对" +"于关联和集合来说,它有效的代替了映射文件中的外联接 与延迟声明(lazy " +"declarations). 查看 以获得等多的信" +"息。" + +#. Tag: programlisting +#: query_hql.xml:145 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:172 -msgid "If you are using property-level lazy fetching (with bytecode instrumentation), it is possible to force Hibernate to fetch the lazy properties immediately (in the first query) using fetch all properties." +#. Tag: para +#: query_hql.xml:147 +#, no-c-format +msgid "" +"A fetch join does not usually need to assign an alias, because the " +"associated objects should not be used in the where clause " +"(or any other clause). Also, the associated objects are not returned " +"directly in the query results. Instead, they may be accessed via the parent " +"object. The only reason we might need an alias is if we are recursively join " +"fetching a further collection:" +msgstr "" +"一个fetch连接通常不需要被指定别名, 因为相关联的对象不应当被用在 " +"where 子句 (或其它任何子句)中。同时,相关联的对象 并不在查" +"询的结果中直接返回,但可以通过他们的父对象来访问到他们。" + +#. Tag: programlisting +#: query_hql.xml:155 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:178 +#. Tag: para +#: query_hql.xml:157 +#, no-c-format +msgid "" +"Note that the fetch construct may not be used in queries " +"called using iterate() (though scroll() can be used). Nor should fetch be used together " +"with setMaxResults() or setFirstResult() as these operations are based on the result rows, which usually " +"contain duplicates for eager collection fetching, hence, the number of rows " +"is not what you'd expect. Nor may fetch be used together " +"with an ad hoc with condition. It is possible to create a " +"cartesian product by join fetching more than one collection in a query, so " +"take care in this case. Join fetching multiple collection roles also " +"sometimes gives unexpected results for bag mappings, so be careful about how " +"you formulate your queries in this case. Finally, note that full " +"join fetch and right join fetch are not " +"meaningful." +msgstr "" +"假若使用iterate()来调用查询,请注意fetch构造是不能使用的(scroll() 可以使用)。" +"fetch也不应该与setMaxResults() 或" +"setFirstResult()共用,这是因为这些操作是基于结果集的,而在" +"预先抓取集合类时可能包含重复的数据,也就是说无法预先知道精确的行数。" +"fetch还不能与独立的 with条件一起使用。" +"通过在一次查询中fetch多个集合,可以制造出笛卡尔积,因此请多加注意。对bag映射" +"来说,同时join fetch多个集合角色可能在某些情况下给出并非预期的结果,也请小" +"心。最后注意,使用full join fetchright join " +"fetch是没有意义的。" + +#. Tag: para +#: query_hql.xml:172 +#, no-c-format +msgid "" +"If you are using property-level lazy fetching (with bytecode " +"instrumentation), it is possible to force Hibernate to fetch the lazy " +"properties immediately (in the first query) using fetch all " +"properties." +msgstr "" +"如果你使用属性级别的延迟获取(lazy fetching)(这是通过重新编写字节码实现" +"的),可以使用 fetch all properties 来强制Hibernate立即取" +"得那些原本需要延迟加载的属性(在第一个查询中)。" + +#. Tag: programlisting +#: query_hql.xml:178 +#, no-c-format msgid "" msgstr "" -#: index.docbook:179 -msgid "" +#. Tag: programlisting +#: query_hql.xml:179 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:184 +#. Tag: title +#: query_hql.xml:184 +#, no-c-format msgid "Forms of join syntax" -msgstr "" +msgstr "join 语法的形式" -#: index.docbook:186 -msgid "HQL supports two forms of association joining: implicit and explicit." +#. Tag: para +#: query_hql.xml:186 +#, no-c-format +msgid "" +"HQL supports two forms of association joining: implicit " +"and explicit." msgstr "" +"HQL支持两种关联join的形式:implicit(隐式) 与" +"explicit(显式)。" -#: index.docbook:190 -msgid "The queries shown in the previous section all use the explicit form where the join keyword is explicitly used in the from clause. This is the recommended form." +#. Tag: para +#: query_hql.xml:190 +#, no-c-format +msgid "" +"The queries shown in the previous section all use the explicit form where the join keyword is explicitly used in the from clause. " +"This is the recommended form." msgstr "" +"上一节中给出的查询都是使用explicit(显式)形式的,其中form子" +"句中明确给出了join关键字。这是建议使用的方式。" -#: index.docbook:195 -msgid "The implicit form does not use the join keyword. Instead, the associations are \"dereferenced\" using dot-notation. implicit joins can appear in any of the HQL clauses. implicit join result in inner joins in the resulting SQL statement." +#. Tag: para +#: query_hql.xml:195 +#, no-c-format +msgid "" +"The implicit form does not use the join keyword. Instead, " +"the associations are \"dereferenced\" using dot-notation. implicit joins can appear in any of the HQL clauses. implicit join result in inner joins in the resulting SQL statement." msgstr "" +"implicit(隐式)形式不使用join关键字。关联使用\"点号\"来进" +"行“引用”。implicit join可以在任何HQL子句中出现." +"implicit join在最终的SQL语句中以inner join的方式出现。" -#: index.docbook:202 +#. Tag: programlisting +#: query_hql.xml:202 +#, no-c-format msgid "" msgstr "" -#: index.docbook:206 +#. Tag: title +#: query_hql.xml:206 +#, no-c-format msgid "Refering to identifier property" -msgstr "" +msgstr "Refering to identifier property" -#: index.docbook:208 -msgid "There are, generally speaking, 2 ways to refer to an entity's identifier property:" -msgstr "" - -#: index.docbook:213 -msgid "The special property (lowercase) id may be used to reference the identifier property of an entity provided that entity does not define a non-identifier property named id." -msgstr "" - -#: index.docbook:220 -msgid "If the entity defines a named identifier property, you may use that property name." -msgstr "" - -#: index.docbook:226 -msgid "References to composite identifier properties follow the same naming rules. If the entity has a non-identifier property named id, the composite identifier property can only be referenced by its defined named; otherwise, the special id property can be used to rerference the identifier property." -msgstr "" - -#: index.docbook:233 -msgid "Note: this has changed significantly starting in version 3.2.2. In previous versions, id always referred to the identifier property no matter what its actual name. A ramification of that decision was that non-identifier properties named id could never be referenced in Hibernate queries." -msgstr "" - -#: index.docbook:242 -msgid "The select clause" -msgstr "" - -#: index.docbook:244 -msgid "The select clause picks which objects and properties to return in the query result set. Consider:" -msgstr "" - -#: index.docbook:249 +#. Tag: para +#: query_hql.xml:208 +#, no-c-format msgid "" - "" +"There are, generally speaking, 2 ways to refer to an entity's identifier " +"property:" +msgstr "" +"There are, generally speaking, 2 ways to refer to an entity's identifier " +"property:" + +#. Tag: para +#: query_hql.xml:213 +#, no-c-format +msgid "" +"The special property (lowercase) id may be used to " +"reference the identifier property of an entity provided that " +"entity does not define a non-identifier property named id." +msgstr "" +"The special property (lowercase) id may be used to " +"reference the identifier property of an entity provided that " +"entity does not define a non-identifier property named id." + +#. Tag: para +#: query_hql.xml:220 +#, no-c-format +msgid "" +"If the entity defines a named identifier property, you may use that property " +"name." +msgstr "" +"If the entity defines a named identifier property, you may use that property " +"name." + +#. Tag: para +#: query_hql.xml:226 +#, no-c-format +msgid "" +"References to composite identifier properties follow the same naming rules. " +"If the entity has a non-identifier property named id, the composite " +"identifier property can only be referenced by its defined named; otherwise, " +"the special id property can be used to rerference the " +"identifier property." +msgstr "" +"References to composite identifier properties follow the same naming rules. " +"If the entity has a non-identifier property named id, the composite " +"identifier property can only be referenced by its defined named; otherwise, " +"the special id property can be used to rerference the " +"identifier property." + +#. Tag: para +#: query_hql.xml:233 +#, fuzzy, no-c-format +msgid "" +"Note: this has changed significantly starting in version 3.2.2. In previous " +"versions, id always referred to the " +"identifier property no matter what its actual name. A ramification of that " +"decision was that non-identifier properties named id " +"could never be referenced in Hibernate queries." +msgstr "" +"Note: this has changed significantly starting in version 3.2.2. In previous " +"versions, idalways referred to the " +"identifier property no matter what its actual name. A ramification of that " +"decision was that non-identifier properties named id " +"could never be referenced in Hibernate queries." + +#. Tag: title +#: query_hql.xml:242 +#, no-c-format +msgid "The select clause" +msgstr "select子句" + +#. Tag: para +#: query_hql.xml:244 +#, no-c-format +msgid "" +"The select clause picks which objects and properties to " +"return in the query result set. Consider:" +msgstr "" +"select 子句选择将哪些对象与属性返 回到查询结果集中. 考虑如" +"下情况:" + +#. Tag: programlisting +#: query_hql.xml:249 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:251 -msgid "The query will select mates of other Cats. Actually, you may express this query more compactly as:" +#. Tag: para +#: query_hql.xml:251 +#, no-c-format +msgid "" +"The query will select mates of other Cats. Actually, you may express this query more compactly as:" msgstr "" +"该语句将选择mates of other Cats。(其他" +"猫的配偶) 实际上, 你可以更简洁的用以下的查询语句表达相同的含义:" -#: index.docbook:256 +#. Tag: programlisting +#: query_hql.xml:256 +#, no-c-format msgid "" msgstr "" -#: index.docbook:258 -msgid "Queries may return properties of any value type including properties of component type:" -msgstr "" - -#: index.docbook:262 +#. Tag: para +#: query_hql.xml:258 +#, no-c-format msgid "" - "" +"Queries may return properties of any value type including properties of " +"component type:" +msgstr "" +"查询语句可以返回值为任何类型的属性,包括返回类型为某种组件(Component)的属性:" + +#. Tag: programlisting +#: query_hql.xml:262 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:264 +#. Tag: programlisting +#: query_hql.xml:264 +#, no-c-format msgid "" msgstr "" -#: index.docbook:266 -msgid "Queries may return multiple objects and/or properties as an array of type Object[]," -msgstr "" - -#: index.docbook:271 +#. Tag: para +#: query_hql.xml:266 +#, no-c-format msgid "" - "" +"Queries may return multiple objects and/or properties as an array of type " +"Object[]," +msgstr "" +"查询语句可以返回多个对象和(或)属性,存放在 Object[]队列" +"中," + +#. Tag: programlisting +#: query_hql.xml:271 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:273 +#. Tag: para +#: query_hql.xml:273 +#, no-c-format msgid "or as a List," -msgstr "" +msgstr "或存放在一个List对象中," -#: index.docbook:277 +#. Tag: programlisting +#: query_hql.xml:277 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:279 +#. Tag: para +#: query_hql.xml:279 +#, no-c-format msgid "or as an actual typesafe Java object," -msgstr "" +msgstr "也可能直接返回一个实际的类型安全的Java对象," -#: index.docbook:283 +#. Tag: programlisting +#: query_hql.xml:283 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:285 -msgid "assuming that the class Family has an appropriate constructor." -msgstr "" - -#: index.docbook:289 -msgid "You may assign aliases to selected expressions using as:" -msgstr "" - -#: index.docbook:293 +#. Tag: para +#: query_hql.xml:285 +#, no-c-format msgid "" - "" -msgstr "" +"assuming that the class Family has an appropriate " +"constructor." +msgstr "假设类Family有一个合适的构造函数." -#: index.docbook:295 -msgid "This is most useful when used together with select new map:" -msgstr "" - -#: index.docbook:299 +#. Tag: para +#: query_hql.xml:289 +#, no-c-format msgid "" - "" +"You may assign aliases to selected expressions using as:" +msgstr "你可以使用关键字as给“被选择了的表达式”指派别名:" + +#. Tag: programlisting +#: query_hql.xml:293 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:301 -msgid "This query returns a Map from aliases to selected values." +#. Tag: para +#: query_hql.xml:295 +#, no-c-format +msgid "" +"This is most useful when used together with select new map:" +msgstr "这种做法在与子句select new map一起使用时最有用:" + +#. Tag: programlisting +#: query_hql.xml:299 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:308 +#. Tag: para +#: query_hql.xml:301 +#, no-c-format +msgid "" +"This query returns a Map from aliases to selected values." +msgstr "" +"该查询返回了一个Map的对象,内容是别名与被选择的值组成的名-" +"值映射。" + +#. Tag: title +#: query_hql.xml:308 +#, no-c-format msgid "Aggregate functions" -msgstr "" +msgstr "聚集函数" -#: index.docbook:310 -msgid "HQL queries may even return the results of aggregate functions on properties:" -msgstr "" - -#: index.docbook:314 +#. Tag: para +#: query_hql.xml:310 +#, no-c-format msgid "" - "" +"HQL queries may even return the results of aggregate functions on properties:" +msgstr "HQL查询甚至可以返回作用于属性之上的聚集函数的计算结果:" + +#. Tag: programlisting +#: query_hql.xml:314 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:325 +#. Tag: para +#: query_hql.xml:325 +#, no-c-format msgid "The supported aggregate functions are" -msgstr "" +msgstr "受支持的聚集函数如下:" -#: index.docbook:332 +#. Tag: literal +#: query_hql.xml:332 +#, no-c-format msgid "avg(...), sum(...), min(...), max(...)" -msgstr "" +msgstr "avg(...), sum(...), min(...), max(...)" -#: index.docbook:337 +#. Tag: literal +#: query_hql.xml:337 +#, no-c-format msgid "count(*)" -msgstr "" +msgstr "count(*)" -#: index.docbook:342 +#. Tag: literal +#: query_hql.xml:342 +#, no-c-format msgid "count(...), count(distinct ...), count(all...)" -msgstr "" +msgstr "count(...), count(distinct ...), count(all...)" -#: index.docbook:347 -msgid "You may use arithmetic operators, concatenation, and recognized SQL functions in the select clause:" -msgstr "" - -#: index.docbook:352 +#. Tag: para +#: query_hql.xml:347 +#, no-c-format msgid "" - "" -msgstr "" +"You may use arithmetic operators, concatenation, and recognized SQL " +"functions in the select clause:" +msgstr "你可以在选择子句中使用数学操作符、连接以及经过验证的SQL函数:" -#: index.docbook:354 -msgid "" -msgstr "" - -#: index.docbook:356 -msgid "The distinct and all keywords may be used and have the same semantics as in SQL." -msgstr "" - -#: index.docbook:361 +#. Tag: programlisting +#: query_hql.xml:352 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:366 +#. Tag: programlisting +#: query_hql.xml:354 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: query_hql.xml:356 +#, no-c-format +msgid "" +"The distinct and all keywords may be " +"used and have the same semantics as in SQL." +msgstr "" +"关键字distinctall 也可以使用,它们具" +"有与SQL相同的语义." + +#. Tag: programlisting +#: query_hql.xml:361 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: query_hql.xml:366 +#, no-c-format msgid "Polymorphic queries" -msgstr "" +msgstr "多态查询" -#: index.docbook:368 +#. Tag: para +#: query_hql.xml:368 +#, no-c-format msgid "A query like:" -msgstr "" +msgstr "一个如下的查询语句:" -#: index.docbook:374 -msgid "returns instances not only of Cat, but also of subclasses like DomesticCat. Hibernate queries may name any Java class or interface in the from clause. The query will return instances of all persistent classes that extend that class or implement the interface. The following query would return all persistent objects:" +#. Tag: para +#: query_hql.xml:374 +#, no-c-format +msgid "" +"returns instances not only of Cat, but also of subclasses " +"like DomesticCat. Hibernate queries may name " +"any Java class or interface in the from clause. The query will return instances of all persistent classes " +"that extend that class or implement the interface. The following query would " +"return all persistent objects:" msgstr "" +"不仅返回Cat类的实例, 也同时返回子类 DomesticCat的实例. Hibernate 可以在from子句中指定任" +"何 Java 类或接口. 查询会返回继承了该类的所有持久化子类 的实例或返" +"回声明了该接口的所有持久化类的实例。下面的查询语句返回所有的被持久化的对象:" -#: index.docbook:382 +#. Tag: programlisting +#: query_hql.xml:382 +#, no-c-format msgid "" msgstr "" -#: index.docbook:384 -msgid "The interface Named might be implemented by various persistent classes:" -msgstr "" +#. Tag: para +#: query_hql.xml:384 +#, no-c-format +msgid "" +"The interface Named might be implemented by various " +"persistent classes:" +msgstr "接口Named 可能被各种各样的持久化类声明:" -#: index.docbook:389 +#. Tag: programlisting +#: query_hql.xml:389 +#, no-c-format msgid "" msgstr "" -#: index.docbook:391 -msgid "Note that these last two queries will require more than one SQL SELECT. This means that the order by clause does not correctly order the whole result set. (It also means you can't call these queries using Query.scroll().)" +#. Tag: para +#: query_hql.xml:391 +#, no-c-format +msgid "" +"Note that these last two queries will require more than one SQL " +"SELECT. This means that the order by " +"clause does not correctly order the whole result set. (It also means you " +"can't call these queries using Query.scroll().)" msgstr "" +"注意,最后的两个查询将需要超过一个的SQL SELECT.这表明" +"order by子句 没有对整个结果集进行正确的排序. (这也说明你不" +"能对这样的查询使用Query.scroll()方法.)" -#: index.docbook:400 +#. Tag: title +#: query_hql.xml:400 +#, no-c-format msgid "The where clause" -msgstr "" +msgstr "where子句" -#: index.docbook:402 -msgid "The where clause allows you to narrow the list of instances returned. If no alias exists, you may refer to properties by name:" +#. Tag: para +#: query_hql.xml:402 +#, no-c-format +msgid "" +"The where clause allows you to narrow the list of " +"instances returned. If no alias exists, you may refer to properties by name:" msgstr "" +"where子句允许你将返回的实例列表的范围缩小. 如果没有指定别" +"名,你可以使用属性名来直接引用属性:" -#: index.docbook:407 +#. Tag: programlisting +#: query_hql.xml:407 +#, no-c-format msgid "" msgstr "" -#: index.docbook:409 +#. Tag: para +#: query_hql.xml:409 +#, no-c-format msgid "If there is an alias, use a qualified property name:" -msgstr "" +msgstr "如果指派了别名,需要使用完整的属性名:" -#: index.docbook:413 +#. Tag: programlisting +#: query_hql.xml:413 +#, no-c-format msgid "" msgstr "" -#: index.docbook:415 +#. Tag: para +#: query_hql.xml:415 +#, no-c-format msgid "returns instances of Cat named 'Fritz'." -msgstr "" +msgstr "返回名为(属性name等于)'Fritz'的Cat类的实例。" -#: index.docbook:419 +#. Tag: programlisting +#: query_hql.xml:419 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:421 -msgid "will return all instances of Foo for which there exists an instance of bar with a date property equal to the startDate property of the Foo. Compound path expressions make the where clause extremely powerful. Consider:" +#. Tag: para +#: query_hql.xml:421 +#, no-c-format +msgid "" +"will return all instances of Foo for which there exists " +"an instance of bar with a date " +"property equal to the startDate property of the " +"Foo. Compound path expressions make the where clause extremely powerful. Consider:" msgstr "" +"将返回所有满足下面条件的Foo类的实例: 存在如下的" +"bar的一个实例,其date属性等于 " +"FoostartDate属性。 复合路径表达式使得" +"where子句非常的强大,考虑如下情况:" -#: index.docbook:430 +#. Tag: programlisting +#: query_hql.xml:430 +#, no-c-format msgid "" msgstr "" -#: index.docbook:432 -msgid "This query translates to an SQL query with a table (inner) join. If you were to write something like" -msgstr "" - -#: index.docbook:437 +#. Tag: para +#: query_hql.xml:432 +#, no-c-format msgid "" - "" +"This query translates to an SQL query with a table (inner) join. If you were " +"to write something like" +msgstr "" +"该查询将被翻译成为一个含有表连接(内连接)的SQL查询。如果你打算写像这样的查询" +"语句" + +#. Tag: programlisting +#: query_hql.xml:437 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:439 -msgid "you would end up with a query that would require four table joins in SQL." -msgstr "" +#. Tag: para +#: query_hql.xml:439 +#, no-c-format +msgid "" +"you would end up with a query that would require four table joins in SQL." +msgstr "在SQL中,你为达此目的将需要进行一个四表连接的查询。" -#: index.docbook:443 -msgid "The = operator may be used to compare not only properties, but also instances:" +#. Tag: para +#: query_hql.xml:443 +#, no-c-format +msgid "" +"The = operator may be used to compare not only " +"properties, but also instances:" msgstr "" +"=运算符不仅可以被用来比较属性的值,也可以用来比较实例:" -#: index.docbook:448 +#. Tag: programlisting +#: query_hql.xml:448 +#, no-c-format msgid "" msgstr "" -#: index.docbook:450 +#. Tag: programlisting +#: query_hql.xml:450 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:452 -msgid "The special property (lowercase) id may be used to reference the unique identifier of an object. See for more information." -msgstr "" - -#: index.docbook:458 +#. Tag: para +#: query_hql.xml:452 +#, no-c-format msgid "" - "" +"The special property (lowercase) id may be used to " +"reference the unique identifier of an object. See for more information." +msgstr "" +"特殊属性(小写)id可以用来表示一个对象的唯一的标识符。(你" +"也可以使用该对象的属性名。)" + +#. Tag: programlisting +#: query_hql.xml:458 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:460 +#. Tag: para +#: query_hql.xml:460 +#, no-c-format msgid "The second query is efficient. No table join is required!" -msgstr "" +msgstr "第二个查询是有效的。此时不需要进行表连接!" -#: index.docbook:464 -msgid "Properties of composite identifiers may also be used. Suppose Person has a composite identifier consisting of country and medicareNumber. Again, see for more information regarding referencing identifier properties." -msgstr "" - -#: index.docbook:471 +#. Tag: para +#: query_hql.xml:464 +#, no-c-format msgid "" - "" +"Properties of composite identifiers may also be used. Suppose " +"Person has a composite identifier consisting of " +"country and medicareNumber. Again, see " +" for more information " +"regarding referencing identifier properties." msgstr "" +"同样也可以使用复合标识符。比如Person类有一个复合标识符,它" +"由country属性 与medicareNumber属性组" +"成。" -#: index.docbook:473 +#. Tag: programlisting +#: query_hql.xml:471 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:475 +#. Tag: programlisting +#: query_hql.xml:473 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: query_hql.xml:475 +#, no-c-format msgid "Once again, the second query requires no table join." -msgstr "" +msgstr "第二个查询也不需要进行表连接。" -#: index.docbook:479 -msgid "Likewise, the special property class accesses the discriminator value of an instance in the case of polymorphic persistence. A Java class name embedded in the where clause will be translated to its discriminator value." +#. Tag: para +#: query_hql.xml:479 +#, no-c-format +msgid "" +"Likewise, the special property class accesses the " +"discriminator value of an instance in the case of polymorphic persistence. A " +"Java class name embedded in the where clause will be translated to its " +"discriminator value." msgstr "" +"同样的,特殊属性class在进行多态持久化的情况下被用来存取一" +"个实例的鉴别值(discriminator value)。 一个嵌入到where子句中的Java类的名字将" +"被转换为该类的鉴别值。" -#: index.docbook:485 +#. Tag: programlisting +#: query_hql.xml:485 +#, no-c-format msgid "" msgstr "" -#: index.docbook:487 -msgid "You may also use components or composite user types, or properties of said component types. See for more details." -msgstr "" - -#: index.docbook:492 -msgid "An \"any\" type has the special properties id and class, allowing us to express a join in the following way (where AuditLog.item is a property mapped with <any>)." -msgstr "" - -#: index.docbook:498 +#. Tag: para +#: query_hql.xml:487 +#, no-c-format msgid "" - "" +"You may also use components or composite user types, or properties of said " +"component types. See for more " +"details." +msgstr "" +"你也可以声明一个属性的类型是组件或者复合用户类型(以及由组件构成的组件等" +"等)。永远不要尝试使用以组件类型来结尾的路径表达式(path-expression) (与此" +"相反,你应当使用组件的一个属性来结尾)。 举例来说,如果store.owner含有一个包含了组件的实体address" + +#. Tag: para +#: query_hql.xml:492 +#, no-c-format +msgid "" +"An \"any\" type has the special properties id and " +"class, allowing us to express a join in the following way " +"(where AuditLog.item is a property mapped with " +"<any>)." +msgstr "" +"一个“任意”类型有两个特殊的属性idclass, 来允许我们按照下面的方式表达一个连接(AuditLog.item 是一个属性,该属性被映射为<any>)。" + +#. Tag: programlisting +#: query_hql.xml:498 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:500 -msgid "Notice that log.item.class and payment.class would refer to the values of completely different database columns in the above query." +#. Tag: para +#: query_hql.xml:500 +#, no-c-format +msgid "" +"Notice that log.item.class and payment.class would refer to the values of completely different database columns " +"in the above query." msgstr "" +"注意,在上面的查询与句中,log.item.class 和 " +"payment.class 将涉及到完全不同的数据库中的列。" -#: index.docbook:508 +#. Tag: title +#: query_hql.xml:508 +#, no-c-format msgid "Expressions" -msgstr "" +msgstr "表达式" -#: index.docbook:510 -msgid "Expressions allowed in the where clause include most of the kind of things you could write in SQL:" +#. Tag: para +#: query_hql.xml:510 +#, no-c-format +msgid "" +"Expressions allowed in the where clause include most of " +"the kind of things you could write in SQL:" msgstr "" +"在where子句中允许使用的表达式包括 大多数你可以在SQL使用的" +"表达式种类:" -#: index.docbook:517 +#. Tag: para +#: query_hql.xml:517 +#, no-c-format msgid "mathematical operators +, -, *, /" -msgstr "" +msgstr "数学运算符+, -, *, /" -#: index.docbook:522 -msgid "binary comparison operators =, >=, <=, <>, !=, like" -msgstr "" +#. Tag: para +#: query_hql.xml:522 +#, no-c-format +msgid "" +"binary comparison operators =, >=, <=, <>, !=, like" +msgstr "二进制比较运算符=, >=, <=, <>, !=, like" -#: index.docbook:527 +#. Tag: para +#: query_hql.xml:527 +#, no-c-format msgid "logical operations and, or, not" -msgstr "" +msgstr "逻辑运算符and, or, not" -#: index.docbook:532 +#. Tag: para +#: query_hql.xml:532 +#, no-c-format msgid "Parentheses ( ), indicating grouping" -msgstr "" +msgstr "Parentheses ( ), indicating grouping" -#: index.docbook:537 -msgid "in, not in, between, is null, is not null, is empty, is not empty, member of and not member of" +#. Tag: para +#: query_hql.xml:537 +#, no-c-format +msgid "" +"in, not in, between, is null, is not null, " +"is empty, is not empty, " +"member of and not member of" msgstr "" +"in, not in, between, is null, is not null, " +"is empty, is not empty, " +"member of and not member of" -#: index.docbook:550 -msgid "\"Simple\" case, case ... when ... then ... else ... end, and \"searched\" case, case when ... then ... else ... end" +#. Tag: para +#: query_hql.xml:550 +#, no-c-format +msgid "" +"\"Simple\" case, case ... when ... then ... else ... end, " +"and \"searched\" case, case when ... then ... else ... end" msgstr "" +"\"简单的\" case, case ... when ... then ... else ... end," +"和 \"搜索\" case, case when ... then ... else ... end" -#: index.docbook:556 -msgid "string concatenation ...||... or concat(...,...)" +#. Tag: para +#: query_hql.xml:556 +#, no-c-format +msgid "" +"string concatenation ...||... or concat(...,...)" +"" msgstr "" +"字符串连接符...||... or concat(...,...)" -#: index.docbook:561 -msgid "current_date(), current_time(), current_timestamp()" +#. Tag: para +#: query_hql.xml:561 +#, no-c-format +msgid "" +"current_date(), current_time(), " +"current_timestamp()" msgstr "" +"current_date(), current_time(), " +"current_timestamp()" -#: index.docbook:567 -msgid "second(...), minute(...), hour(...), day(...), month(...), year(...)," +#. Tag: para +#: query_hql.xml:567 +#, no-c-format +msgid "" +"second(...), minute(...), hour" +"(...), day(...), month(...), " +"year(...)," msgstr "" +"second(...), minute(...), hour" +"(...), day(...), month(...), " +"year(...)," -#: index.docbook:574 -msgid "Any function or operator defined by EJB-QL 3.0: substring(), trim(), lower(), upper(), length(), locate(), abs(), sqrt(), bit_length(), mod()" +#. Tag: para +#: query_hql.xml:574 +#, no-c-format +msgid "" +"Any function or operator defined by EJB-QL 3.0: substring(), trim" +"(), lower(), upper(), length(), locate(), abs(), sqrt(), bit_length(), mod()" +"" msgstr "" +"EJB-QL 3.0定义的任何函数或操作:substring(), trim(), lower(), upper" +"(), length(), locate(), abs(), sqrt(), bit_length(), mod()" -#: index.docbook:580 +#. Tag: para +#: query_hql.xml:580 +#, no-c-format msgid "coalesce() and nullif()" -msgstr "" +msgstr "coalesce()nullif()" -#: index.docbook:585 -msgid "str() for converting numeric or temporal values to a readable string" -msgstr "" +#. Tag: para +#: query_hql.xml:585 +#, no-c-format +msgid "" +"str() for converting numeric or temporal values to a " +"readable string" +msgstr "str() 把数字或者时间值转换为可读的字符串" -#: index.docbook:591 -msgid "cast(... as ...), where the second argument is the name of a Hibernate type, and extract(... from ...) if ANSI cast() and extract() is supported by the underlying database" +#. Tag: para +#: query_hql.xml:591 +#, no-c-format +msgid "" +"cast(... as ...), where the second argument is the name " +"of a Hibernate type, and extract(... from ...) if ANSI " +"cast() and extract() is supported by " +"the underlying database" msgstr "" +"cast(... as ...), 其第二个参数是某Hibernate类型的名字,以" +"及extract(... from ...),只要ANSI cast()extract() 被底层数据库支持" -#: index.docbook:599 -msgid "the HQL index() function, that applies to aliases of a joined indexed collection" +#. Tag: para +#: query_hql.xml:599 +#, no-c-format +msgid "" +"the HQL index() function, that applies to aliases of a " +"joined indexed collection" +msgstr "HQL index() 函数,作用于join的有序集合的别名。" + +#. Tag: para +#: query_hql.xml:605 +#, no-c-format +msgid "" +"HQL functions that take collection-valued path expressions: size(), " +"minelement(), maxelement(), minindex(), maxindex(), along with the " +"special elements() and indices " +"functions which may be quantified using some, all, exists, any, in." msgstr "" +"HQL函数,把集合作为参数:size(), minelement(), maxelement(), minindex" +"(), maxindex(),还有特别的elements() 和" +"indices函数,可以与数量词加以限定:some, all, " +"exists, any, in。" -#: index.docbook:605 -msgid "HQL functions that take collection-valued path expressions: size(), minelement(), maxelement(), minindex(), maxindex(), along with the special elements() and indices functions which may be quantified using some, all, exists, any, in." +#. Tag: para +#: query_hql.xml:613 +#, no-c-format +msgid "" +"Any database-supported SQL scalar function like sign(), " +"trunc(), rtrim(), sin()" msgstr "" +"任何数据库支持的SQL标量函数,比如sign(), trunc()" +", rtrim(), sin()" -#: index.docbook:613 -msgid "Any database-supported SQL scalar function like sign(), trunc(), rtrim(), sin()" -msgstr "" - -#: index.docbook:619 +#. Tag: para +#: query_hql.xml:619 +#, no-c-format msgid "JDBC-style positional parameters ?" -msgstr "" +msgstr "JDBC风格的参数传入 ?" -#: index.docbook:624 -msgid "named parameters :name, :start_date, :x1" +#. Tag: para +#: query_hql.xml:624 +#, no-c-format +msgid "" +"named parameters :name, :start_date, " +":x1" msgstr "" +"命名参数:name, :start_date, :" +"x1" -#: index.docbook:629 -msgid "SQL literals 'foo', 69, 6.66E+2, '1970-01-01 10:00:01.0'" +#. Tag: para +#: query_hql.xml:629 +#, no-c-format +msgid "" +"SQL literals 'foo', 69, 6.66E" +"+2, '1970-01-01 10:00:01.0'" msgstr "" +"SQL 直接常量 'foo', 69, 6.66E" +"+2, '1970-01-01 10:00:01.0'" -#: index.docbook:635 -msgid "Java public static final constants eg.Color.TABBY" +#. Tag: para +#: query_hql.xml:635 +#, no-c-format +msgid "" +"Java public static final constants eg.Color." +"TABBY" msgstr "" +"Java public static final 类型的常量 eg.Color." +"TABBY" -#: index.docbook:641 -msgid "in and between may be used as follows:" +#. Tag: para +#: query_hql.xml:641 +#, no-c-format +msgid "" +"in and between may be used as follows:" msgstr "" +"关键字inbetween可按如下方法使用:" -#: index.docbook:645 +#. Tag: programlisting +#: query_hql.xml:645 +#, no-c-format msgid "" msgstr "" -#: index.docbook:647 -msgid "" +#. Tag: programlisting +#: query_hql.xml:647 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:649 +#. Tag: para +#: query_hql.xml:649 +#, no-c-format msgid "and the negated forms may be written" -msgstr "" +msgstr "而且否定的格式也可以如下书写:" -#: index.docbook:653 +#. Tag: programlisting +#: query_hql.xml:653 +#, no-c-format msgid "" msgstr "" -#: index.docbook:655 -msgid "" +#. Tag: programlisting +#: query_hql.xml:655 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:657 -msgid "Likewise, is null and is not null may be used to test for null values." +#. Tag: para +#: query_hql.xml:657 +#, no-c-format +msgid "" +"Likewise, is null and is not null may " +"be used to test for null values." +msgstr "" +"同样, 子句is nullis not null可以被用" +"来测试空值(null)." + +#. Tag: para +#: query_hql.xml:662 +#, no-c-format +msgid "" +"Booleans may be easily used in expressions by declaring HQL query " +"substitutions in Hibernate configuration:" +msgstr "" +"在Hibernate配置文件中声明HQL“查询替代(query substitutions)”之后, 布尔表达" +"式(Booleans)可以在其他表达式中轻松的使用:" + +#. Tag: programlisting +#: query_hql.xml:667 +#, no-c-format +msgid "" +"true 1, false 0]]>" msgstr "" -#: index.docbook:662 -msgid "Booleans may be easily used in expressions by declaring HQL query substitutions in Hibernate configuration:" +#. Tag: para +#: query_hql.xml:669 +#, no-c-format +msgid "" +"This will replace the keywords true and false with the literals 1 and 0 in " +"the translated SQL from this HQL:" msgstr "" +"系统将该HQL转换为SQL语句时,该设置表明将用字符 1 和 " +"0 来 取代关键字truefalse:" -#: index.docbook:667 -msgid "true 1, false 0]]>" -msgstr "" - -#: index.docbook:669 -msgid "This will replace the keywords true and false with the literals 1 and 0 in the translated SQL from this HQL:" -msgstr "" - -#: index.docbook:674 +#. Tag: programlisting +#: query_hql.xml:674 +#, no-c-format msgid "" msgstr "" -#: index.docbook:676 -msgid "You may test the size of a collection with the special property size, or the special size() function." +#. Tag: para +#: query_hql.xml:676 +#, no-c-format +msgid "" +"You may test the size of a collection with the special property " +"size, or the special size() function." msgstr "" +"你可以用特殊属性size, 或是特殊函数size()测试一个集合的大小。" -#: index.docbook:681 +#. Tag: programlisting +#: query_hql.xml:681 +#, no-c-format msgid " 0]]>" msgstr "" -#: index.docbook:683 +#. Tag: programlisting +#: query_hql.xml:683 +#, no-c-format msgid " 0]]>" msgstr "" -#: index.docbook:685 -msgid "For indexed collections, you may refer to the minimum and maximum indices using minindex and maxindex functions. Similarly, you may refer to the minimum and maximum elements of a collection of basic type using the minelement and maxelement functions." +#. Tag: para +#: query_hql.xml:685 +#, no-c-format +msgid "" +"For indexed collections, you may refer to the minimum and maximum indices " +"using minindex and maxindex functions. " +"Similarly, you may refer to the minimum and maximum elements of a collection " +"of basic type using the minelement and " +"maxelement functions." +msgstr "" +"对于索引了(有序)的集合,你可以使用minindex 与 " +"maxindex函数来引用到最小与最大的索引序数。 同理,你可以使" +"用minelementmaxelement函数来 引用到" +"一个基本数据类型的集合中最小与最大的元素。" + +#. Tag: programlisting +#: query_hql.xml:693 +#, no-c-format +msgid "" +" current_date]]>" msgstr "" -#: index.docbook:693 -msgid " current_date]]>" -msgstr "" - -#: index.docbook:695 +#. Tag: programlisting +#: query_hql.xml:695 +#, no-c-format msgid " 100]]>" msgstr "" -#: index.docbook:697 +#. Tag: programlisting +#: query_hql.xml:697 +#, no-c-format msgid " 10000]]>" msgstr "" -#: index.docbook:699 -msgid "The SQL functions any, some, all, exists, in are supported when passed the element or index set of a collection (elements and indices functions) or the result of a subquery (see below)." -msgstr "" - -#: index.docbook:705 +#. Tag: para +#: query_hql.xml:699 +#, no-c-format msgid "" - "" +"The SQL functions any, some, all, exists, in are " +"supported when passed the element or index set of a collection " +"(elements and indices functions) or " +"the result of a subquery (see below)." msgstr "" +"在传递一个集合的索引集或者是元素集(elements与" +"indices 函数) 或者传递一个子查询的结果的时候,可以使用SQL" +"函数any, some, all, exists, in" -#: index.docbook:707 +#. Tag: programlisting +#: query_hql.xml:705 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:709 +#. Tag: programlisting +#: query_hql.xml:707 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: programlisting +#: query_hql.xml:709 +#, no-c-format msgid "" msgstr "" -#: index.docbook:711 +#. Tag: programlisting +#: query_hql.xml:711 +#, no-c-format msgid " all elements(p.scores)]]>" msgstr "" -#: index.docbook:713 +#. Tag: programlisting +#: query_hql.xml:713 +#, no-c-format msgid "" msgstr "" -#: index.docbook:715 -msgid "Note that these constructs - size, elements, indices, minindex, maxindex, minelement, maxelement - may only be used in the where clause in Hibernate3." +#. Tag: para +#: query_hql.xml:715 +#, no-c-format +msgid "" +"Note that these constructs - size, elements, indices, minindex, " +"maxindex, minelement, " +"maxelement - may only be used in the where clause in " +"Hibernate3." msgstr "" +"注意,在Hibernate3种,这些结构变量- size, " +"elements, indices, minindex, maxindex, minelement, " +"maxelement - 只能在where子句中使用。" -#: index.docbook:722 -msgid "Elements of indexed collections (arrays, lists, maps) may be referred to by index (in a where clause only):" +#. Tag: para +#: query_hql.xml:722 +#, no-c-format +msgid "" +"Elements of indexed collections (arrays, lists, maps) may be referred to by " +"index (in a where clause only):" msgstr "" +"一个被索引过的(有序的)集合的元素(arrays, lists, maps)可以在其他索引中被引用" +"(只能在where子句中):" -#: index.docbook:727 +#. Tag: programlisting +#: query_hql.xml:727 +#, no-c-format msgid "" msgstr "" -#: index.docbook:729 +#. Tag: programlisting +#: query_hql.xml:729 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:731 +#. Tag: programlisting +#: query_hql.xml:731 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:733 +#. Tag: programlisting +#: query_hql.xml:733 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:735 -msgid "The expression inside [] may even be an arithmetic expression." -msgstr "" - -#: index.docbook:739 +#. Tag: para +#: query_hql.xml:735 +#, no-c-format msgid "" - "" -msgstr "" +"The expression inside [] may even be an arithmetic " +"expression." +msgstr "在[]中的表达式甚至可以是一个算数表达式。" -#: index.docbook:741 -msgid "HQL also provides the built-in index() function, for elements of a one-to-many association or collection of values." -msgstr "" - -#: index.docbook:746 +#. Tag: programlisting +#: query_hql.xml:739 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:748 +#. Tag: para +#: query_hql.xml:741 +#, no-c-format +msgid "" +"HQL also provides the built-in index() function, for " +"elements of a one-to-many association or collection of values." +msgstr "" +"对于一个一对多的关联(one-to-many association)或是值的集合中的元素, HQL也提" +"供内建的index()函数," + +#. Tag: programlisting +#: query_hql.xml:746 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: query_hql.xml:748 +#, no-c-format msgid "Scalar SQL functions supported by the underlying database may be used" -msgstr "" +msgstr "如果底层数据库支持标量的SQL函数,它们也可以被使用" -#: index.docbook:752 +#. Tag: programlisting +#: query_hql.xml:752 +#, no-c-format msgid "" msgstr "" -#: index.docbook:754 -msgid "If you are not yet convinced by all this, think how much longer and less readable the following query would be in SQL:" -msgstr "" - -#: index.docbook:759 +#. Tag: para +#: query_hql.xml:754 +#, no-c-format msgid "" - "" +"If you are not yet convinced by all this, think how much longer and less " +"readable the following query would be in SQL:" +msgstr "" +"如果你还不能对所有的这些深信不疑,想想下面的查询。如果使用SQL,语句长度会增长" +"多少,可读性会下降多少:" + +#. Tag: programlisting +#: query_hql.xml:759 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:761 +#. Tag: para +#: query_hql.xml:761 +#, no-c-format msgid "Hint: something like" -msgstr "" +msgstr "提示: 会像如下的语句" -#: index.docbook:765 +#. Tag: programlisting +#: query_hql.xml:765 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:770 +#. Tag: title +#: query_hql.xml:770 +#, no-c-format msgid "The order by clause" -msgstr "" +msgstr "order by子句" -#: index.docbook:772 -msgid "The list returned by a query may be ordered by any property of a returned class or components:" -msgstr "" - -#: index.docbook:776 +#. Tag: para +#: query_hql.xml:772 +#, no-c-format msgid "" - "" +"The list returned by a query may be ordered by any property of a returned " +"class or components:" +msgstr "" +"查询返回的列表(list)可以按照一个返回的类或组件(components)中的任何属性" +"(property)进行排序:" + +#. Tag: programlisting +#: query_hql.xml:776 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:778 -msgid "The optional asc or desc indicate ascending or descending order respectively." +#. Tag: para +#: query_hql.xml:778 +#, no-c-format +msgid "" +"The optional asc or desc indicate " +"ascending or descending order respectively." msgstr "" +"可选的ascdesc关键字指明了按照升序或降" +"序进行排序." -#: index.docbook:785 +#. Tag: title +#: query_hql.xml:785 +#, no-c-format msgid "The group by clause" -msgstr "" +msgstr "group by子句" -#: index.docbook:787 -msgid "A query that returns aggregate values may be grouped by any property of a returned class or components:" -msgstr "" - -#: index.docbook:791 +#. Tag: para +#: query_hql.xml:787 +#, no-c-format msgid "" - "" +"A query that returns aggregate values may be grouped by any property of a " +"returned class or components:" msgstr "" +"一个返回聚集值(aggregate values)的查询可以按照一个返回的类或组件(components)" +"中的任何属性(property)进行分组:" -#: index.docbook:793 +#. Tag: programlisting +#: query_hql.xml:791 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:795 +#. Tag: programlisting +#: query_hql.xml:793 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: query_hql.xml:795 +#, no-c-format msgid "A having clause is also allowed." -msgstr "" +msgstr "having子句在这里也允许使用." -#: index.docbook:799 +#. Tag: programlisting +#: query_hql.xml:799 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:801 -msgid "SQL functions and aggregate functions are allowed in the having and order by clauses, if supported by the underlying database (eg. not in MySQL)." -msgstr "" - -#: index.docbook:807 +#. Tag: para +#: query_hql.xml:801 +#, no-c-format msgid "" - " 100\n" - "order by count(kitten) asc, sum(kitten.weight) desc]]>" +"SQL functions and aggregate functions are allowed in the having and order by clauses, if supported by the " +"underlying database (eg. not in MySQL)." +msgstr "" +"如果底层的数据库支持的话(例如不能在MySQL中使用),SQL的一般函数与聚集函数也可" +"以出现 在havingorder by 子句中。" + +#. Tag: programlisting +#: query_hql.xml:807 +#, no-c-format +msgid "" +" 100\n" +"order by count(kitten) asc, sum(kitten.weight) desc]]>" msgstr "" -#: index.docbook:809 -msgid "Note that neither the group by clause nor the order by clause may contain arithmetic expressions. Also note that Hibernate currently does not expand a grouped entity, so you can't write group by cat if all properties of cat are non-aggregated. You have to list all non-aggregated properties explicitly." +#. Tag: para +#: query_hql.xml:809 +#, no-c-format +msgid "" +"Note that neither the group by clause nor the " +"order by clause may contain arithmetic expressions. Also " +"note that Hibernate currently does not expand a grouped entity, so you can't " +"write group by cat if all properties of cat are non-aggregated. You have to list all non-aggregated properties " +"explicitly." msgstr "" +"注意group by子句与 order by子句中都不能" +"包含算术表达式(arithmetic expressions). 也要注意Hibernate目前不会扩展group" +"的实体,因此你不能写group by cat,除非cat" +"的所有属性都不是聚集的(non-aggregated)。你必须明确的列出所有的非聚集属性。" -#: index.docbook:821 +#. Tag: title +#: query_hql.xml:821 +#, no-c-format msgid "Subqueries" -msgstr "" +msgstr "子查询" -#: index.docbook:823 -msgid "For databases that support subselects, Hibernate supports subqueries within queries. A subquery must be surrounded by parentheses (often by an SQL aggregate function call). Even correlated subqueries (subqueries that refer to an alias in the outer query) are allowed." -msgstr "" - -#: index.docbook:829 +#. Tag: para +#: query_hql.xml:823 +#, no-c-format msgid "" - " (\n" - " select avg(cat.weight) from DomesticCat cat\n" - ")]]>" +"For databases that support subselects, Hibernate supports subqueries within " +"queries. A subquery must be surrounded by parentheses (often by an SQL " +"aggregate function call). Even correlated subqueries (subqueries that refer " +"to an alias in the outer query) are allowed." msgstr "" +"对于支持子查询的数据库,Hibernate支持在查询中使用子查询。一个子查询必须被圆括" +"号包围起来(经常是SQL聚集函数的圆括号)。 甚至相互关联的子查询(引用到外部查" +"询中的别名的子查询)也是允许的。" -#: index.docbook:831 +#. Tag: programlisting +#: query_hql.xml:829 +#, no-c-format msgid "" - "" +" (\n" +" select avg(cat.weight) from DomesticCat cat\n" +")]]>" msgstr "" -#: index.docbook:833 +#. Tag: programlisting +#: query_hql.xml:831 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:835 +#. Tag: programlisting +#: query_hql.xml:833 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:837 +#. Tag: programlisting +#: query_hql.xml:835 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:839 +#. Tag: programlisting +#: query_hql.xml:837 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: query_hql.xml:839 +#, no-c-format msgid "Note that HQL subqueries may occur only in the select or where clauses." -msgstr "" +msgstr "注意,HQL自查询只可以在select或者where子句中出现。" -#: index.docbook:843 -msgid "Note that subqueries can also utilize row value constructor syntax. See for more details." +#. Tag: para +#: query_hql.xml:843 +#, no-c-format +msgid "" +"Note that subqueries can also utilize row value constructor syntax. See for more details." msgstr "" +"Note that subqueries can also utilize row value constructor syntax. See for more details." -#: index.docbook:851 +#. Tag: title +#: query_hql.xml:851 +#, no-c-format msgid "HQL examples" -msgstr "" +msgstr "HQL示例" -#: index.docbook:853 -msgid "Hibernate queries can be quite powerful and complex. In fact, the power of the query language is one of Hibernate's main selling points. Here are some example queries very similar to queries that I used on a recent project. Note that most queries you will write are much simpler than these!" -msgstr "" - -#: index.docbook:859 -msgid "The following query returns the order id, number of items and total value of the order for all unpaid orders for a particular customer and given minimum total value, ordering the results by total value. In determining the prices, it uses the current catalog. The resulting SQL query, against the ORDER, ORDER_LINE, PRODUCT, CATALOG and PRICE tables has four inner joins and an (uncorrelated) subselect." -msgstr "" - -#: index.docbook:868 +#. Tag: para +#: query_hql.xml:853 +#, no-c-format msgid "" - "= all (\n" - " select cat.effectiveDate\n" - " from Catalog as cat\n" - " where cat.effectiveDate < sysdate\n" - " )\n" - "group by order\n" - "having sum(price.amount) > :minAmount\n" - "order by sum(price.amount) desc]]>" +"Hibernate queries can be quite powerful and complex. In fact, the power of " +"the query language is one of Hibernate's main selling points. Here are some " +"example queries very similar to queries that I used on a recent project. " +"Note that most queries you will write are much simpler than these!" msgstr "" +"Hibernate查询可以非常的强大与复杂。实际上,Hibernate的一个主要卖点就是查询语" +"句的威力。这里有一些例子,它们与我在最近的 一个项目中使用的查询非常相似。注意" +"你能用到的大多数查询比这些要简单的多!" -#: index.docbook:870 -msgid "What a monster! Actually, in real life, I'm not very keen on subqueries, so my query was really more like this:" -msgstr "" - -#: index.docbook:875 +#. Tag: para +#: query_hql.xml:859 +#, no-c-format msgid "" - " :minAmount\n" - "order by sum(price.amount) desc]]>" +"The following query returns the order id, number of items and total value of " +"the order for all unpaid orders for a particular customer and given minimum " +"total value, ordering the results by total value. In determining the prices, " +"it uses the current catalog. The resulting SQL query, against the " +"ORDER, ORDER_LINE, PRODUCT, CATALOG and PRICE tables has " +"four inner joins and an (uncorrelated) subselect." msgstr "" +"下面的查询对于某个特定的客户的所有未支付的账单,在给定给最小总价值的情况下," +"返回订单的id,条目的数量和总价值, 返回值按照总价值的结果进行排序。为了决定价" +"格,查询使用了当前目录。作为转换结果的SQL查询,使用了ORDER, ORDER_LINE, PRODUCT, " +"CATALOGPRICE 库表。" -#: index.docbook:877 -msgid "The next query counts the number of payments in each status, excluding all payments in the AWAITING_APPROVAL status where the most recent status change was made by the current user. It translates to an SQL query with two inner joins and a correlated subselect against the PAYMENT, PAYMENT_STATUS and PAYMENT_STATUS_CHANGE tables." -msgstr "" - -#: index.docbook:885 +#. Tag: programlisting +#: query_hql.xml:868 +#, no-c-format msgid "" - " PaymentStatus.AWAITING_APPROVAL\n" - " or (\n" - " statusChange.timeStamp = (\n" - " select max(change.timeStamp)\n" - " from PaymentStatusChange change\n" - " where change.payment = payment\n" - " )\n" - " and statusChange.user <> :currentUser\n" - " )\n" - "group by status.name, status.sortOrder\n" - "order by status.sortOrder]]>" +"= all (\n" +" select cat.effectiveDate\n" +" from Catalog as cat\n" +" where cat.effectiveDate < sysdate\n" +" )\n" +"group by order\n" +"having sum(price.amount) > :minAmount\n" +"order by sum(price.amount) desc]]>" msgstr "" -#: index.docbook:887 -msgid "If I would have mapped the statusChanges collection as a list, instead of a set, the query would have been much simpler to write." -msgstr "" - -#: index.docbook:892 +#. Tag: para +#: query_hql.xml:870 +#, no-c-format msgid "" - " PaymentStatus.AWAITING_APPROVAL\n" - " or payment.statusChanges[ maxIndex(payment.statusChanges) ].user <> :currentUser\n" - "group by status.name, status.sortOrder\n" - "order by status.sortOrder]]>" +"What a monster! Actually, in real life, I'm not very keen on subqueries, so " +"my query was really more like this:" msgstr "" +"这简直是一个怪物!实际上,在现实生活中,我并不热衷于子查询,所以我的查询语句" +"看起来更像这个:" -#: index.docbook:894 -msgid "The next query uses the MS SQL Server isNull() function to return all the accounts and unpaid payments for the organization to which the current user belongs. It translates to an SQL query with three inner joins, an outer join and a subselect against the ACCOUNT, PAYMENT, PAYMENT_STATUS, ACCOUNT_TYPE, ORGANIZATION and ORG_USER tables." -msgstr "" - -#: index.docbook:903 +#. Tag: programlisting +#: query_hql.xml:875 +#, no-c-format msgid "" - "" +" :minAmount\n" +"order by sum(price.amount) desc]]>" msgstr "" -#: index.docbook:905 -msgid "For some databases, we would need to do away with the (correlated) subselect." -msgstr "" - -#: index.docbook:909 +#. Tag: para +#: query_hql.xml:877 +#, no-c-format msgid "" - "" +"The next query counts the number of payments in each status, excluding all " +"payments in the AWAITING_APPROVAL status where the most " +"recent status change was made by the current user. It translates to an SQL " +"query with two inner joins and a correlated subselect against the " +"PAYMENT, PAYMENT_STATUS and " +"PAYMENT_STATUS_CHANGE tables." +msgstr "" +"下面一个查询计算每一种状态下的支付的数目,除去所有处于" +"AWAITING_APPROVAL状态的支付,因为在该状态下 当前的用户作出" +"了状态的最新改变。该查询被转换成含有两个内连接以及一个相关联的子选择的SQL查" +"询,该查询使用了表 PAYMENT, PAYMENT_STATUS 以及 PAYMENT_STATUS_CHANGE。" + +#. Tag: programlisting +#: query_hql.xml:885 +#, no-c-format +msgid "" +" PaymentStatus.AWAITING_APPROVAL\n" +" or (\n" +" statusChange.timeStamp = (\n" +" select max(change.timeStamp)\n" +" from PaymentStatusChange change\n" +" where change.payment = payment\n" +" )\n" +" and statusChange.user <> :currentUser\n" +" )\n" +"group by status.name, status.sortOrder\n" +"order by status.sortOrder]]>" msgstr "" -#: index.docbook:914 +#. Tag: para +#: query_hql.xml:887 +#, no-c-format +msgid "" +"If I would have mapped the statusChanges collection as a " +"list, instead of a set, the query would have been much simpler to write." +msgstr "" +"如果我把statusChanges实例集映射为一个列表(list)而不是一" +"个集合(set), 书写查询语句将更加简单." + +#. Tag: programlisting +#: query_hql.xml:892 +#, no-c-format +msgid "" +" PaymentStatus.AWAITING_APPROVAL\n" +" or payment.statusChanges[ maxIndex(payment.statusChanges) ].user <> :" +"currentUser\n" +"group by status.name, status.sortOrder\n" +"order by status.sortOrder]]>" +msgstr "" + +#. Tag: para +#: query_hql.xml:894 +#, no-c-format +msgid "" +"The next query uses the MS SQL Server isNull() function " +"to return all the accounts and unpaid payments for the organization to which " +"the current user belongs. It translates to an SQL query with three inner " +"joins, an outer join and a subselect against the ACCOUNT, " +"PAYMENT, PAYMENT_STATUS, " +"ACCOUNT_TYPE, ORGANIZATION and " +"ORG_USER tables." +msgstr "" +"下面一个查询使用了MS SQL Server的 isNull()函数用以返回当前" +"用户所属组织的组织帐号及组织未支付的账。 它被转换成一个对表ACCOUNT, PAYMENT, PAYMENT_STATUS, " +"ACCOUNT_TYPE, ORGANIZATION 以及 " +"ORG_USER进行的三个内连接, 一个外连接和一个子选择的SQL查" +"询。" + +#. Tag: programlisting +#: query_hql.xml:903 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: query_hql.xml:905 +#, no-c-format +msgid "" +"For some databases, we would need to do away with the (correlated) subselect." +msgstr "对于一些数据库,我们需要弃用(相关的)子选择。" + +#. Tag: programlisting +#: query_hql.xml:909 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: query_hql.xml:914 +#, no-c-format msgid "Bulk update and delete" -msgstr "" +msgstr "批量的UPDATE和DELETE" -#: index.docbook:916 -msgid "HQL now supports update, delete and insert ... select ... statements. See for details." -msgstr "" - -#: index.docbook:924 -msgid "Tips & Tricks" -msgstr "" - -#: index.docbook:926 -msgid "You can count the number of query results without actually returning them:" -msgstr "" - -#: index.docbook:930 -msgid "" -msgstr "" - -#: index.docbook:932 -msgid "To order a result by the size of a collection, use the following query:" -msgstr "" - -#: index.docbook:936 +#. Tag: para +#: query_hql.xml:916 +#, no-c-format msgid "" - "" +"HQL now supports update, delete and " +"insert ... select ... statements. See for details." +msgstr "" +"HQL现在支持 update, delete 和 " +"insert ... select ...语句. 查阅 以获得更多信息。" + +#. Tag: title +#: query_hql.xml:924 +#, no-c-format +msgid "Tips & Tricks" +msgstr "小技巧 & 小窍门" + +#. Tag: para +#: query_hql.xml:926 +#, no-c-format +msgid "" +"You can count the number of query results without actually returning them:" +msgstr "你可以统计查询结果的数目而不必实际的返回他们:" + +#. Tag: programlisting +#: query_hql.xml:930 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:938 -msgid "If your database supports subselects, you can place a condition upon selection size in the where clause of your query:" +#. Tag: para +#: query_hql.xml:932 +#, no-c-format +msgid "To order a result by the size of a collection, use the following query:" +msgstr "若想根据一个集合的大小来进行排序,可以使用如下的语句:" + +#. Tag: programlisting +#: query_hql.xml:936 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:943 +#. Tag: para +#: query_hql.xml:938 +#, no-c-format +msgid "" +"If your database supports subselects, you can place a condition upon " +"selection size in the where clause of your query:" +msgstr "" +"如果你的数据库支持子选择,你可以在你的查询的where子句中为选择的大小" +"(selection size)指定一个条件:" + +#. Tag: programlisting +#: query_hql.xml:943 +#, no-c-format msgid "= 1]]>" msgstr "" -#: index.docbook:945 +#. Tag: para +#: query_hql.xml:945 +#, no-c-format msgid "If your database doesn't support subselects, use the following query:" -msgstr "" +msgstr "如果你的数据库不支持子选择语句,使用下面的查询:" -#: index.docbook:949 +#. Tag: programlisting +#: query_hql.xml:949 +#, no-c-format msgid "" - "= 1]]>" +"= 1]]>" msgstr "" -#: index.docbook:951 -msgid "As this solution can't return a User with zero messages because of the inner join, the following form is also useful:" -msgstr "" - -#: index.docbook:956 +#. Tag: para +#: query_hql.xml:951 +#, no-c-format msgid "" - "" +"As this solution can't return a User with zero messages " +"because of the inner join, the following form is also useful:" +msgstr "" +"因为内连接(inner join)的原因,这个解决方案不能返回含有零个信息的" +"User 类的实例, 所以这种情况下使用下面的格式将是有帮助的:" + +#. Tag: programlisting +#: query_hql.xml:956 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:958 +#. Tag: para +#: query_hql.xml:958 +#, no-c-format msgid "Properties of a JavaBean can be bound to named query parameters:" -msgstr "" +msgstr "JavaBean的属性可以被绑定到一个命名查询(named query)的参数上:" -#: index.docbook:962 +#. Tag: programlisting +#: query_hql.xml:962 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:964 -msgid "Collections are pageable by using the Query interface with a filter:" -msgstr "" - -#: index.docbook:968 +#. Tag: para +#: query_hql.xml:964 +#, no-c-format msgid "" - "" +"Collections are pageable by using the Query interface " +"with a filter:" +msgstr "" +"通过将接口Query与一个过滤器(filter)一起使用,集合" +"(Collections)是可以分页的:" + +#. Tag: programlisting +#: query_hql.xml:968 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:970 +#. Tag: para +#: query_hql.xml:970 +#, no-c-format msgid "Collection elements may be ordered or grouped using a query filter:" msgstr "" +"通过使用查询过滤器(query filter)可以将集合(Collection)的原素分组或排序:" -#: index.docbook:974 +#. Tag: programlisting +#: query_hql.xml:974 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:976 +#. Tag: para +#: query_hql.xml:976 +#, no-c-format msgid "You can find the size of a collection without initializing it:" +msgstr "不用通过初始化,你就可以知道一个集合(Collection)的大小:" + +#. Tag: programlisting +#: query_hql.xml:980 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:980 -msgid "" -msgstr "" - -#: index.docbook:985 +#. Tag: title +#: query_hql.xml:985 +#, no-c-format msgid "Components" +msgstr "translator-credits" + +#. Tag: para +#: query_hql.xml:987 +#, no-c-format +msgid "" +"Components might be used in just about every way that simple value types can " +"be used in HQL queries. They can appear in the select " +"clause:" msgstr "" -#: index.docbook:987 -msgid "Components might be used in just about every way that simple value types can be used in HQL queries. They can appear in the select clause:" -msgstr "" - -#: index.docbook:992, index.docbook:1038 +#. Tag: programlisting +#: query_hql.xml:992 query_hql.xml:1038 +#, no-c-format msgid "" msgstr "" -#: index.docbook:993 +#. Tag: programlisting +#: query_hql.xml:993 +#, no-c-format msgid "" msgstr "" -#: index.docbook:995 -msgid "where the Person's name property is a component. Components can also be used in the where clause:" +#. Tag: para +#: query_hql.xml:995 +#, no-c-format +msgid "" +"where the Person's name property is a component. Components can also be used " +"in the where clause:" msgstr "" -#: index.docbook:1000 +#. Tag: programlisting +#: query_hql.xml:1000 +#, no-c-format msgid "" msgstr "" -#: index.docbook:1001 +#. Tag: programlisting +#: query_hql.xml:1001 +#, no-c-format msgid "" msgstr "" -#: index.docbook:1003 +#. Tag: para +#: query_hql.xml:1003 +#, no-c-format msgid "Components can also be used in the order by clause:" msgstr "" -#: index.docbook:1007 +#. Tag: programlisting +#: query_hql.xml:1007 +#, no-c-format msgid "" msgstr "" -#: index.docbook:1008 +#. Tag: programlisting +#: query_hql.xml:1008 +#, no-c-format msgid "" msgstr "" -#: index.docbook:1010 -msgid "Another common use of components is in row value constructors." +#. Tag: para +#: query_hql.xml:1010 +#, no-c-format +msgid "" +"Another common use of components is in row " +"value constructors." msgstr "" -#: index.docbook:1016 +#. Tag: title +#: query_hql.xml:1016 +#, no-c-format msgid "Row value constructor syntax" msgstr "" -#: index.docbook:1018 -msgid "HQL supports the use of ANSI SQL row value constructor syntax (sometimes called tuple syntax), even though the underlying database may not support that notion. Here we are generally referring to multi-valued comparisons, typically associated with components. Consider an entity Person which defines a name component:" +#. Tag: para +#: query_hql.xml:1018 +#, no-c-format +msgid "" +"HQL supports the use of ANSI SQL row value constructor " +"syntax (sometimes called tuple syntax), even though the " +"underlying database may not support that notion. Here we are generally " +"referring to multi-valued comparisons, typically associated with components. " +"Consider an entity Person which defines a name component:" msgstr "" -#: index.docbook:1025 -msgid "" +#. Tag: programlisting +#: query_hql.xml:1025 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:1027 -msgid "That's valid syntax, although a little verbose. It be nice to make this a bit more concise and use row value constructor syntax:" +#. Tag: para +#: query_hql.xml:1027 +#, no-c-format +msgid "" +"That's valid syntax, although a little verbose. It be nice to make this a " +"bit more concise and use row value constructor syntax:" msgstr "" -#: index.docbook:1032 +#. Tag: programlisting +#: query_hql.xml:1032 +#, no-c-format msgid "" msgstr "" -#: index.docbook:1034 -msgid "It can also be useful to specify this in the select clause:" -msgstr "" - -#: index.docbook:1040 -msgid "Another time using row value constructor syntax can be beneficial is when using subqueries needing to compare against multiple values:" -msgstr "" - -#: index.docbook:1045 +#. Tag: para +#: query_hql.xml:1034 +#, no-c-format msgid "" - "" +"It can also be useful to specify this in the select " +"clause:" msgstr "" -#: index.docbook:1047 -msgid "One thing to consider when deciding if you want to use this syntax is that the query will be dependent upon the ordering of the component sub-properties in the metadata." +#. Tag: para +#: query_hql.xml:1040 +#, no-c-format +msgid "" +"Another time using row value constructor syntax can be " +"beneficial is when using subqueries needing to compare against multiple " +"values:" msgstr "" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" +#. Tag: programlisting +#: query_hql.xml:1045 +#, no-c-format +msgid "" +"" +msgstr "" +#. Tag: para +#: query_hql.xml:1047 +#, no-c-format +msgid "" +"One thing to consider when deciding if you want to use this syntax is that " +"the query will be dependent upon the ordering of the component sub-" +"properties in the metadata." +msgstr "" diff --git a/documentation/manual/translations/zh-CN/content/query_sql.po b/documentation/manual/translations/zh-CN/content/query_sql.po index 05f7d703f1..fd20bab74e 100644 --- a/documentation/manual/translations/zh-CN/content/query_sql.po +++ b/documentation/manual/translations/zh-CN/content/query_sql.po @@ -1,818 +1,1426 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: query_sql.xml:5 +#, no-c-format msgid "Native SQL" -msgstr "" +msgstr "Native SQL查询" -#: index.docbook:7 -msgid "You may also express queries in the native SQL dialect of your database. This is useful if you want to utilize database specific features such as query hints or the CONNECT keyword in Oracle. It also provides a clean migration path from a direct SQL/JDBC based application to Hibernate." +#. Tag: para +#: query_sql.xml:7 +#, no-c-format +msgid "" +"You may also express queries in the native SQL dialect of your database. " +"This is useful if you want to utilize database specific features such as " +"query hints or the CONNECT keyword in Oracle. It also " +"provides a clean migration path from a direct SQL/JDBC based application to " +"Hibernate." msgstr "" +"你也可以使用你的数据库的Native SQL语言来查询数据。这对你在要使用数据库的某些" +"特性的时候(比如说在查询提示或者Oracle中的 CONNECT关键字)," +"这是非常有用的。这就能够扫清你把原来直接使用SQL/JDBC 的程序迁移到基于 " +"Hibernate应用的道路上的障碍。" -#: index.docbook:13 -msgid "Hibernate3 allows you to specify handwritten SQL (including stored procedures) for all create, update, delete, and load operations." +#. Tag: para +#: query_sql.xml:13 +#, no-c-format +msgid "" +"Hibernate3 allows you to specify handwritten SQL (including stored " +"procedures) for all create, update, delete, and load operations." msgstr "" +"Hibernate3允许你使用手写的sql来完成所有的create,update,delete,和load操作(包" +"括存储过程)" -#: index.docbook:17 +#. Tag: title +#: query_sql.xml:17 +#, no-c-format msgid "Using a SQLQuery" -msgstr "" +msgstr "使用SQLQuery" -#: index.docbook:19 -msgid "Execution of native SQL queries is controlled via the SQLQuery interface, which is obtained by calling Session.createSQLQuery(). The following describes how to use this API for querying." +#. Tag: para +#: query_sql.xml:19 +#, no-c-format +msgid "" +"Execution of native SQL queries is controlled via the SQLQuery interface, which is obtained by calling Session." +"createSQLQuery(). The following describes how to use this API for " +"querying." msgstr "" +"对原生SQL查询执行的控制是通过SQLQuery接口进行的,通过执行" +"Session.createSQLQuery()获取这个接口。下面来描述如何使用这" +"个API进行查询。" -#: index.docbook:25 +#. Tag: title +#: query_sql.xml:25 +#, no-c-format msgid "Scalar queries" -msgstr "" +msgstr "标量查询(Scalar queries)" -#: index.docbook:27 +#. Tag: para +#: query_sql.xml:27 +#, no-c-format msgid "The most basic SQL query is to get a list of scalars (values)." -msgstr "" +msgstr "最基本的SQL查询就是获得一个标量(数值)的列表。" -#: index.docbook:30 +#. Tag: programlisting +#: query_sql.xml:30 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:32 -msgid "These will both return a List of Object arrays (Object[]) with scalar values for each column in the CATS table. Hibernate will use ResultSetMetadata to deduce the actual order and types of the returned scalar values." -msgstr "" - -#: index.docbook:37 -msgid "To avoid the overhead of using ResultSetMetadata or simply to be more explicit in what is returned one can use addScalar()." -msgstr "" - -#: index.docbook:41 +#. Tag: para +#: query_sql.xml:32 +#, no-c-format msgid "" - "" +"These will both return a List of Object arrays (Object[]) with scalar values " +"for each column in the CATS table. Hibernate will use ResultSetMetadata to " +"deduce the actual order and types of the returned scalar values." +msgstr "" +"它们都将返回一个Object数组(Object[])组成的List,数组每个元素都是CATS表的一个" +"字段值。Hibernate会使用ResultSetMetadata来判定返回的标量值的实际顺序和类型。" + +#. Tag: para +#: query_sql.xml:37 +#, no-c-format +msgid "" +"To avoid the overhead of using ResultSetMetadata or " +"simply to be more explicit in what is returned one can use addScalar" +"()." +msgstr "" +"如果要避免过多的使用ResultSetMetadata,或者只是为了更加明确" +"的指名返回值,可以使用addScalar()。" + +#. Tag: programlisting +#: query_sql.xml:41 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:43, index.docbook:89, index.docbook:170, index.docbook:321 +#. Tag: para +#: query_sql.xml:43 query_sql.xml:89 query_sql.xml:170 query_sql.xml:321 +#, fuzzy, no-c-format msgid "This query specified:" msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"这个查询指定了:\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"这个查询指定:\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"这个查询指明:\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"这个查询指定:" -#: index.docbook:47, index.docbook:93, index.docbook:325 +#. Tag: para +#: query_sql.xml:47 query_sql.xml:93 query_sql.xml:325 +#, no-c-format msgid "the SQL query string" -msgstr "" +msgstr "SQL查询字符串" -#: index.docbook:51 +#. Tag: para +#: query_sql.xml:51 +#, no-c-format msgid "the columns and types to return" -msgstr "" +msgstr "要返回的字段和类型" -#: index.docbook:55 -msgid "This will still return Object arrays, but now it will not use ResultSetMetdata but will instead explicitly get the ID, NAME and BIRTHDATE column as respectively a Long, String and a Short from the underlying resultset. This also means that only these three columns will be returned, even though the query is using * and could return more than the three listed columns." -msgstr "" - -#: index.docbook:63 -msgid "It is possible to leave out the type information for all or some of the scalars." -msgstr "" - -#: index.docbook:66 +#. Tag: para +#: query_sql.xml:55 +#, no-c-format msgid "" - "" +"This will still return Object arrays, but now it will not use " +"ResultSetMetdata but will instead explicitly get the ID, " +"NAME and BIRTHDATE column as respectively a Long, String and a Short from " +"the underlying resultset. This also means that only these three columns will " +"be returned, even though the query is using * and could " +"return more than the three listed columns." +msgstr "" +"它仍然会返回Object数组,但是此时不再使用ResultSetMetdata,而" +"是明确的将ID,NAME和BIRTHDATE按照Long,String和Short类型从resultset中取出。同" +"时,也指明了就算query是使用*来查询的,可能获得超过列出的这" +"三个字段,也仅仅会返回这三个字段。" + +#. Tag: para +#: query_sql.xml:63 +#, no-c-format +msgid "" +"It is possible to leave out the type information for all or some of the " +"scalars." +msgstr "对全部或者部分的标量值不设置类型信息也是可以的。" + +#. Tag: programlisting +#: query_sql.xml:66 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:68 -msgid "This is essentially the same query as before, but now ResultSetMetaData is used to decide the type of NAME and BIRTHDATE where as the type of ID is explicitly specified." +#. Tag: para +#: query_sql.xml:68 +#, no-c-format +msgid "" +"This is essentially the same query as before, but now " +"ResultSetMetaData is used to decide the type of NAME and " +"BIRTHDATE where as the type of ID is explicitly specified." msgstr "" +"基本上这和前面一个查询相同,只是此时使用ResultSetMetaData来" +"决定NAME和BIRTHDATE的类型,而ID的类型是明确指出的。" -#: index.docbook:72 -msgid "How the java.sql.Types returned from ResultSetMetaData is mapped to Hibernate types is controlled by the Dialect. If a specific type is not mapped or does not result in the expected type it is possible to customize it via calls to registerHibernateType in the Dialect." +#. Tag: para +#: query_sql.xml:72 +#, no-c-format +msgid "" +"How the java.sql.Types returned from ResultSetMetaData is mapped to " +"Hibernate types is controlled by the Dialect. If a specific type is not " +"mapped or does not result in the expected type it is possible to customize " +"it via calls to registerHibernateType in the Dialect." msgstr "" +"关于从ResultSetMetaData返回的java.sql.Types是如何映射到Hibernate类型,是由方" +"言(Dialect)控制的。假若某个指定的类型没有被映射,或者不是你所预期的类型,你可" +"以通过Dialet的registerHibernateType调用自行定义。" -#: index.docbook:80 +#. Tag: title +#: query_sql.xml:80 +#, no-c-format msgid "Entity queries" -msgstr "" +msgstr "实体查询(Entity queries)" -#: index.docbook:82 -msgid "The above queries were all about returning scalar values, basically returning the \"raw\" values from the resultset. The following shows how to get entity objects from a native sql query via addEntity()." -msgstr "" - -#: index.docbook:87 +#. Tag: para +#: query_sql.xml:82 +#, no-c-format msgid "" - "" +"The above queries were all about returning scalar values, basically " +"returning the \"raw\" values from the resultset. The following shows how to " +"get entity objects from a native sql query via addEntity()." +msgstr "" +"上面的查询都是返回标量值的,也就是从resultset中返回的“裸”数据。下面展示如何通" +"过addEntity()让原生查询返回实体对象。" + +#. Tag: programlisting +#: query_sql.xml:87 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:97 +#. Tag: para +#: query_sql.xml:97 +#, no-c-format msgid "the entity returned by the query" -msgstr "" +msgstr "要返回的实体" -#: index.docbook:101 -msgid "Assuming that Cat is mapped as a class with the columns ID, NAME and BIRTHDATE the above queries will both return a List where each element is a Cat entity." -msgstr "" - -#: index.docbook:105 -msgid "If the entity is mapped with a many-to-one to another entity it is required to also return this when performing the native query, otherwise a database specific \"column not found\" error will occur. The additional columns will automatically be returned when using the * notation, but we prefer to be explicit as in the following example for a many-to-one to a Dog:" -msgstr "" - -#: index.docbook:113 +#. Tag: para +#: query_sql.xml:101 +#, no-c-format msgid "" - "" +"Assuming that Cat is mapped as a class with the columns ID, NAME and " +"BIRTHDATE the above queries will both return a List where each element is a " +"Cat entity." +msgstr "" +"假设Cat被映射为拥有ID,NAME和BIRTHDATE三个字段的类,以上的两个查询都返回一个" +"List,每个元素都是一个Cat实体。" + +#. Tag: para +#: query_sql.xml:105 +#, no-c-format +msgid "" +"If the entity is mapped with a many-to-one to another " +"entity it is required to also return this when performing the native query, " +"otherwise a database specific \"column not found\" error will occur. The " +"additional columns will automatically be returned when using the * notation, " +"but we prefer to be explicit as in the following example for a many-" +"to-one to a Dog:" +msgstr "" +"假若实体在映射时有一个many-to-one的关联指向另外一个实体," +"在查询时必须也返回那个实体,否则会导致发生一个\"column not found\"的数据库错" +"误。这些附加的字段可以使用*标注来自动返回,但我们希望还是明确指明,看下面这个" +"具有指向Dogmany-to-one的例子:" + +#. Tag: programlisting +#: query_sql.xml:113 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:115 +#. Tag: para +#: query_sql.xml:115 +#, no-c-format msgid "This will allow cat.getDog() to function properly." -msgstr "" +msgstr "这样cat.getDog()就能正常运作。" -#: index.docbook:119 +#. Tag: title +#: query_sql.xml:119 +#, no-c-format msgid "Handling associations and collections" -msgstr "" +msgstr "处理关联和集合类(Handling associations and collections)" -#: index.docbook:121 -msgid "It is possible to eagerly join in the Dog to avoid the possible extra roundtrip for initializing the proxy. This is done via the addJoin() method, which allows you to join in an association or collection." -msgstr "" - -#: index.docbook:126 +#. Tag: para +#: query_sql.xml:121 +#, no-c-format msgid "" - "" +"It is possible to eagerly join in the Dog to avoid the " +"possible extra roundtrip for initializing the proxy. This is done via the " +"addJoin() method, which allows you to join in an " +"association or collection." msgstr "" +"通过提前抓取将Dog连接获得,而避免初始化proxy带来的额外开销" +"也是可能的。这是通过addJoin()方法进行的,这个方法可以让你" +"将关联或集合连接进来。" -#: index.docbook:128 -msgid "In this example the returned Cat's will have their dog property fully initialized without any extra roundtrip to the database. Notice that we added a alias name (\"cat\") to be able to specify the target property path of the join. It is possible to do the same eager joining for collections, e.g. if the Cat had a one-to-many to Dog instead." -msgstr "" - -#: index.docbook:136 +#. Tag: programlisting +#: query_sql.xml:126 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:138 -msgid "At this stage we are reaching the limits of what is possible with native queries without starting to enhance the sql queries to make them usable in Hibernate; the problems starts to arise when returning multiple entities of the same type or when the default alias/column names are not enough." +#. Tag: para +#: query_sql.xml:128 +#, no-c-format +msgid "" +"In this example the returned Cat's will have their " +"dog property fully initialized without any extra " +"roundtrip to the database. Notice that we added a alias name (\"cat\") to be " +"able to specify the target property path of the join. It is possible to do " +"the same eager joining for collections, e.g. if the Cat " +"had a one-to-many to Dog instead." +msgstr "" +"上面这个例子中,返回的Cat对象,其dog属" +"性被完全初始化了,不再需要数据库的额外操作。注意,我们加了一个别名(\"cat\")," +"以便指明join的目标属性路径。通过同样的提前连接也可以作用于集合类,例如,假若" +"Cat有一个指向Dog的一对多关联。" + +#. Tag: programlisting +#: query_sql.xml:136 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:146 +#. Tag: p +#: query_sql.xml:138 +#, no-c-format +msgid "" +"At this stage we are reaching the limits of what is possible with native " +"queries without starting to enhance the sql queries to make them usable in " +"Hibernate; the problems starts to arise when returning multiple entities of " +"the same type or when the default alias/column names are not enough." +msgstr "" +"到此为止,我们碰到了天花板:若不对SQL查询进行增强,这些已经是在Hibernate中使" +"用原生SQL查询所能做到的最大可能了。下面的问题即将出现:返回多个同样类型的实体" +"怎么办?或者默认的别名/字段不够又怎么办?" + +#. Tag: title +#: query_sql.xml:146 +#, no-c-format msgid "Returning multiple entities" -msgstr "" +msgstr "返回多个实体(Returning multiple entities)" -#: index.docbook:148 -msgid "Until now the result set column names are assumed to be the same as the column names specified in the mapping document. This can be problematic for SQL queries which join multiple tables, since the same column names may appear in more than one table." -msgstr "" - -#: index.docbook:153 -msgid "Column alias injection is needed in the following query (which most likely will fail):" -msgstr "" - -#: index.docbook:156 +#. Tag: para +#: query_sql.xml:148 +#, no-c-format msgid "" - "" +"Until now the result set column names are assumed to be the same as the " +"column names specified in the mapping document. This can be problematic for " +"SQL queries which join multiple tables, since the same column names may " +"appear in more than one table." +msgstr "" +"到目前为止,结果集字段名被假定为和映射文件中指定的的字段名是一致的。假若SQL查" +"询连接了多个表,同一个字段名可能在多个表中出现多次,这就会造成问题。" + +#. Tag: para +#: query_sql.xml:153 +#, no-c-format +msgid "" +"Column alias injection is needed in the following query (which most likely " +"will fail):" +msgstr "下面的查询中需要使用字段别名注射(这个例子本身会失败):" + +#. Tag: programlisting +#: query_sql.xml:156 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:158 -msgid "The intention for this query is to return two Cat instances per row, a cat and its mother. This will fail since there is a conflict of names since they are mapped to the same column names and on some databases the returned column aliases will most likely be on the form \"c.ID\", \"c.NAME\", etc. which are not equal to the columns specificed in the mappings (\"ID\" and \"NAME\")." +#. Tag: para +#: query_sql.xml:158 +#, no-c-format +msgid "" +"The intention for this query is to return two Cat instances per row, a cat " +"and its mother. This will fail since there is a conflict of names since they " +"are mapped to the same column names and on some databases the returned " +"column aliases will most likely be on the form \"c.ID\", \"c.NAME\", etc. " +"which are not equal to the columns specificed in the mappings (\"ID\" and " +"\"NAME\")." msgstr "" +"这个查询的本意是希望每行返回两个Cat实例,一个是cat,另一个是它的妈妈。但是因为" +"它们的字段名被映射为相同的,而且在某些数据库中,返回的字段别名是“c.ID”,\"c." +"NAME\"这样的形式,而它们和在映射文件中的名字(\"ID\"和\"NAME\")不匹配,这就" +"会造成失败。" -#: index.docbook:165 +#. Tag: para +#: query_sql.xml:165 +#, no-c-format msgid "The following form is not vulnerable to column name duplication:" -msgstr "" +msgstr "下面的形式可以解决字段名重复:" -#: index.docbook:168 +#. Tag: programlisting +#: query_sql.xml:168 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:174 -msgid "the SQL query string, with placeholders for Hibernate to inject column aliases" -msgstr "" +#. Tag: para +#: query_sql.xml:174 +#, no-c-format +msgid "" +"the SQL query string, with placeholders for Hibernate to inject column " +"aliases" +msgstr "SQL查询语句,其中包含占位附来让Hibernate注射字段别名" -#: index.docbook:179 +#. Tag: para +#: query_sql.xml:179 +#, no-c-format msgid "the entities returned by the query" -msgstr "" +msgstr "查询返回的实体" -#: index.docbook:183 -msgid "The {cat.*} and {mother.*} notation used above is a shorthand for \"all properties\". Alternatively, you may list the columns explicity, but even in this case we let Hibernate inject the SQL column aliases for each property. The placeholder for a column alias is just the property name qualified by the table alias. In the following example, we retrieve Cats and their mothers from a different table (cat_log) to the one declared in the mapping metadata. Notice that we may even use the property aliases in the where clause if we like." -msgstr "" - -#: index.docbook:192 +#. Tag: para +#: query_sql.xml:183 +#, no-c-format msgid "" - "" +"The {cat.*} and {mother.*} notation used above is a shorthand for \"all " +"properties\". Alternatively, you may list the columns explicity, but even in " +"this case we let Hibernate inject the SQL column aliases for each property. " +"The placeholder for a column alias is just the property name qualified by " +"the table alias. In the following example, we retrieve Cats and their " +"mothers from a different table (cat_log) to the one declared in the mapping " +"metadata. Notice that we may even use the property aliases in the where " +"clause if we like." +msgstr "" +"上面使用的{cat.*}和{mother.*}标记是作为“所有属性”的简写形式出现的。当然你也可" +"以明确地罗列出字段名,但在这个例子里面我们让Hibernate来为每个属性注射SQL字段" +"别名。字段别名的占位符是属性名加上表别名的前缀。在下面的例子中,我们从另外一" +"个表(cat_log)中通过映射元数据中的指定获取Cat和它的妈妈。注意,要是我们愿" +"意,我们甚至可以在where子句中使用属性别名。" + +#. Tag: programlisting +#: query_sql.xml:192 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:195 +#. Tag: title +#: query_sql.xml:195 +#, no-c-format msgid "Alias and property references" -msgstr "" +msgstr "别名和属性引用(Alias and property references)" -#: index.docbook:197 -msgid "For most cases the above alias injection is needed, but for queries relating to more complex mappings like composite properties, inheritance discriminators, collections etc. there are some specific aliases to use to allow Hibernate to inject the proper aliases." +#. Tag: para +#: query_sql.xml:197 +#, no-c-format +msgid "" +"For most cases the above alias injection is needed, but for queries relating " +"to more complex mappings like composite properties, inheritance " +"discriminators, collections etc. there are some specific aliases to use to " +"allow Hibernate to inject the proper aliases." msgstr "" +"大多数情况下,都需要上面的属性注射,但在使用更加复杂的映射,比如复合属性、通" +"过标识符构造继承树,以及集合类等等情况下,也有一些特别的别名,来允许Hibernate" +"注射合适的别名。" -#: index.docbook:202 -msgid "The following table shows the different possibilities of using the alias injection. Note: the alias names in the result are examples, each alias will have a unique and probably different name when used." +#. Tag: para +#: query_sql.xml:202 +#, no-c-format +msgid "" +"The following table shows the different possibilities of using the alias " +"injection. Note: the alias names in the result are examples, each alias will " +"have a unique and probably different name when used." msgstr "" +"下表列出了使用别名注射参数的不同可能性。注意:下面结果中的别名只是示例,实用" +"时每个别名需要唯一并且不同的名字。" -#: index.docbook:208 +#. Tag: title +#: query_sql.xml:208 +#, no-c-format msgid "Alias injection names" -msgstr "" +msgstr "别名注射(alias injection names)" -#: index.docbook:219 +#. Tag: entry +#: query_sql.xml:219 +#, no-c-format msgid "Description" -msgstr "" +msgstr "描述" -#: index.docbook:221 +#. Tag: entry +#: query_sql.xml:221 +#, no-c-format msgid "Syntax" -msgstr "" +msgstr "语法" -#: index.docbook:223 +#. Tag: entry +#: query_sql.xml:223 +#, no-c-format msgid "Example" -msgstr "" +msgstr "示例" -#: index.docbook:229 +#. Tag: entry +#: query_sql.xml:229 +#, no-c-format msgid "A simple property" -msgstr "" +msgstr "简单属性" -#: index.docbook:231 +#. Tag: literal +#: query_sql.xml:231 +#, no-c-format msgid "{[aliasname].[propertyname]" -msgstr "" +msgstr "{[aliasname].[propertyname]" -#: index.docbook:233 +#. Tag: literal +#: query_sql.xml:233 +#, no-c-format msgid "A_NAME as {item.name}" -msgstr "" +msgstr "A_NAME as {item.name}" -#: index.docbook:237 +#. Tag: entry +#: query_sql.xml:237 +#, no-c-format msgid "A composite property" -msgstr "" +msgstr "复合属性" -#: index.docbook:239 +#. Tag: literal +#: query_sql.xml:239 +#, no-c-format msgid "{[aliasname].[componentname].[propertyname]}" -msgstr "" +msgstr "{[aliasname].[componentname].[propertyname]}" -#: index.docbook:241 +#. Tag: literal +#: query_sql.xml:241 +#, no-c-format msgid "CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}" -msgstr "" +msgstr "CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}" -#: index.docbook:246 +#. Tag: entry +#: query_sql.xml:246 +#, no-c-format msgid "Discriminator of an entity" -msgstr "" +msgstr "实体辨别器(Discriminator of an entity)" -#: index.docbook:248 +#. Tag: literal +#: query_sql.xml:248 +#, no-c-format msgid "{[aliasname].class}" -msgstr "" +msgstr "{[aliasname].class}" -#: index.docbook:250 +#. Tag: literal +#: query_sql.xml:250 +#, no-c-format msgid "DISC as {item.class}" -msgstr "" +msgstr "DISC as {item.class}" -#: index.docbook:254 +#. Tag: entry +#: query_sql.xml:254 +#, no-c-format msgid "All properties of an entity" -msgstr "" +msgstr "实体的所有属性" -#: index.docbook:256, index.docbook:304 +#. Tag: literal +#: query_sql.xml:256 query_sql.xml:304 +#, no-c-format msgid "{[aliasname].*}" -msgstr "" +msgstr "{[aliasname].*}" -#: index.docbook:258 +#. Tag: literal +#: query_sql.xml:258 +#, no-c-format msgid "{item.*}" -msgstr "" +msgstr "{item.*}" -#: index.docbook:262 +#. Tag: entry +#: query_sql.xml:262 +#, no-c-format msgid "A collection key" -msgstr "" +msgstr "集合键(collection key)" -#: index.docbook:264 +#. Tag: literal +#: query_sql.xml:264 +#, no-c-format msgid "{[aliasname].key}" -msgstr "" +msgstr "{[aliasname].key}" -#: index.docbook:266 +#. Tag: literal +#: query_sql.xml:266 +#, no-c-format msgid "ORGID as {coll.key}" -msgstr "" +msgstr "ORGID as {coll.key}" -#: index.docbook:270 +#. Tag: entry +#: query_sql.xml:270 +#, no-c-format msgid "The id of an collection" -msgstr "" +msgstr "集合id" -#: index.docbook:272 +#. Tag: literal +#: query_sql.xml:272 +#, no-c-format msgid "{[aliasname].id}" -msgstr "" +msgstr "{[aliasname].id}" -#: index.docbook:274 +#. Tag: literal +#: query_sql.xml:274 +#, no-c-format msgid "EMPID as {coll.id}" -msgstr "" +msgstr "EMPID as {coll.id}" -#: index.docbook:278 +#. Tag: entry +#: query_sql.xml:278 +#, no-c-format msgid "The element of an collection" -msgstr "" +msgstr "集合元素" -#: index.docbook:280 +#. Tag: literal +#: query_sql.xml:280 +#, no-c-format msgid "{[aliasname].element}" -msgstr "" +msgstr "{[aliasname].element}" -#: index.docbook:282 +#. Tag: literal +#: query_sql.xml:282 +#, no-c-format msgid "XID as {coll.element}" -msgstr "" +msgstr "XID as {coll.element}" -#: index.docbook:286 +#. Tag: entry +#: query_sql.xml:286 +#, no-c-format msgid "roperty of the element in the collection" -msgstr "" +msgstr "集合元素的属性" -#: index.docbook:288 +#. Tag: literal +#: query_sql.xml:288 +#, no-c-format msgid "{[aliasname].element.[propertyname]}" -msgstr "" +msgstr "{[aliasname].element.[propertyname]}" -#: index.docbook:290 +#. Tag: literal +#: query_sql.xml:290 +#, no-c-format msgid "NAME as {coll.element.name}" -msgstr "" +msgstr "NAME as {coll.element.name}" -#: index.docbook:294 +#. Tag: entry +#: query_sql.xml:294 +#, no-c-format msgid "All properties of the element in the collection" -msgstr "" +msgstr "集合元素的所有属性" -#: index.docbook:296 +#. Tag: literal +#: query_sql.xml:296 +#, no-c-format msgid "{[aliasname].element.*}" -msgstr "" +msgstr "{[aliasname].element.*}" -#: index.docbook:298 +#. Tag: literal +#: query_sql.xml:298 +#, no-c-format msgid "{coll.element.*}" -msgstr "" +msgstr "{coll.element.*}" -#: index.docbook:302 +#. Tag: entry +#: query_sql.xml:302 +#, no-c-format msgid "All properties of the the collection" -msgstr "" +msgstr "集合的所有属性" -#: index.docbook:306 +#. Tag: literal +#: query_sql.xml:306 +#, no-c-format msgid "{coll.*}" -msgstr "" +msgstr "{coll.*}" -#: index.docbook:315 +#. Tag: title +#: query_sql.xml:315 +#, no-c-format msgid "Returning non-managed entities" -msgstr "" +msgstr "返回非受管实体(Returning non-managed entities)" -#: index.docbook:317 -msgid "It is possible to apply a ResultTransformer to native sql queries. Allowing it to e.g. return non-managed entities." -msgstr "" - -#: index.docbook:319 +#. Tag: para +#: query_sql.xml:317 +#, no-c-format msgid "" - "" +"It is possible to apply a ResultTransformer to native sql queries. Allowing " +"it to e.g. return non-managed entities." +msgstr "" +"可以对原生sql 查询使用ResultTransformer。这会返回不受Hibernate管理的实体。" + +#. Tag: programlisting +#: query_sql.xml:319 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:329 +#. Tag: para +#: query_sql.xml:329 +#, no-c-format msgid "a result transformer" -msgstr "" +msgstr "结果转换器(result transformer)" -#: index.docbook:333 -msgid "The above query will return a list of CatDTO which has been instantiated and injected the values of NAME and BIRTHNAME into its corresponding properties or fields." +#. Tag: para +#: query_sql.xml:333 +#, no-c-format +msgid "" +"The above query will return a list of CatDTO which has " +"been instantiated and injected the values of NAME and BIRTHNAME into its " +"corresponding properties or fields." msgstr "" +"上面的查询将会返回CatDTO的列表,它将被实例化并且将NAME和" +"BIRTHDAY的值注射入对应的属性或者字段。" -#: index.docbook:340 +#. Tag: title +#: query_sql.xml:340 +#, no-c-format msgid "Handling inheritance" -msgstr "" +msgstr "处理继承(Handling inheritance)" -#: index.docbook:342 -msgid "Native sql queries which query for entities that is mapped as part of an inheritance must include all properties for the baseclass and all it subclasses." +#. Tag: para +#: query_sql.xml:342 +#, no-c-format +msgid "" +"Native sql queries which query for entities that is mapped as part of an " +"inheritance must include all properties for the baseclass and all it " +"subclasses." msgstr "" +"原生SQL查询假若其查询结果实体是继承树中的一部分,它必须包含基类和所有子类的所" +"有属性。" -#: index.docbook:348 +#. Tag: title +#: query_sql.xml:348 +#, no-c-format msgid "Parameters" -msgstr "" +msgstr "参数(Parameters)" -#: index.docbook:350 +#. Tag: para +#: query_sql.xml:350 +#, no-c-format msgid "Native sql queries support positional as well as named parameters:" -msgstr "" +msgstr "原生查询支持位置参数和命名参数:" -#: index.docbook:353 +#. Tag: programlisting +#: query_sql.xml:353 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:361 +#. Tag: title +#: query_sql.xml:361 +#, no-c-format msgid "Named SQL queries" -msgstr "" +msgstr "命名SQL查询" -#: index.docbook:363 -msgid "Named SQL queries may be defined in the mapping document and called in exactly the same way as a named HQL query. In this case, we do not need to call addEntity()." -msgstr "" - -#: index.docbook:368 +#. Tag: para +#: query_sql.xml:363 +#, no-c-format msgid "" - "\n" - " \n" - " SELECT person.NAME AS {person.name},\n" - " person.AGE AS {person.age},\n" - " person.SEX AS {person.sex}\n" - " FROM PERSON person\n" - " WHERE person.NAME LIKE :namePattern\n" - "]]>" +"Named SQL queries may be defined in the mapping document and called in " +"exactly the same way as a named HQL query. In this case, we do " +"not need to call addEntity()." msgstr "" +"可以在映射文档中定义查询的名字,然后就可以象调用一个命名的HQL查询一样直接调用" +"命名SQL查询.在这种情况下,我们 需要调用" +"addEntity()方法." -#: index.docbook:370 +#. Tag: programlisting +#: query_sql.xml:368 +#, no-c-format msgid "" - "" +"\n" +" \n" +" SELECT person.NAME AS {person.name},\n" +" person.AGE AS {person.age},\n" +" person.SEX AS {person.sex}\n" +" FROM PERSON person\n" +" WHERE person.NAME LIKE :namePattern\n" +"]]>" msgstr "" -#: index.docbook:372 -msgid "The <return-join> and <load-collection> elements are used to join associations and define queries which initialize collections, respectively." -msgstr "" - -#: index.docbook:377 +#. Tag: programlisting +#: query_sql.xml:370 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " SELECT person.NAME AS {person.name},\n" - " person.AGE AS {person.age},\n" - " person.SEX AS {person.sex},\n" - " address.STREET AS {address.street},\n" - " address.CITY AS {address.city},\n" - " address.STATE AS {address.state},\n" - " address.ZIP AS {address.zip}\n" - " FROM PERSON person\n" - " JOIN ADDRESS address\n" - " ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'\n" - " WHERE person.NAME LIKE :namePattern\n" - "]]>" +"" msgstr "" -#: index.docbook:379 -msgid "A named SQL query may return a scalar value. You must declare the column alias and Hibernate type using the <return-scalar> element:" -msgstr "" - -#: index.docbook:383 +#. Tag: para +#: query_sql.xml:372 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " SELECT p.NAME AS name,\n" - " p.AGE AS age,\n" - " FROM PERSON p WHERE p.NAME LIKE 'Hiber%'\n" - "]]>" +"The <return-join> and <load-" +"collection> elements are used to join associations and define " +"queries which initialize collections, respectively." msgstr "" +"<return-join><load-collection> 元素是用来连接关联以及将查询定义为预先初始化各个集合的。" -#: index.docbook:385 -msgid "You can externalize the resultset mapping informations in a <resultset> element to either reuse them accross several named queries or through the setResultSetMapping() API." -msgstr "" - -#: index.docbook:390 +#. Tag: programlisting +#: query_sql.xml:377 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "\n" - "\n" - "\n" - " SELECT person.NAME AS {person.name},\n" - " person.AGE AS {person.age},\n" - " person.SEX AS {person.sex},\n" - " address.STREET AS {address.street},\n" - " address.CITY AS {address.city},\n" - " address.STATE AS {address.state},\n" - " address.ZIP AS {address.zip}\n" - " FROM PERSON person\n" - " JOIN ADDRESS address\n" - " ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'\n" - " WHERE person.NAME LIKE :namePattern\n" - "]]>" +"\n" +" \n" +" \n" +" SELECT person.NAME AS {person.name},\n" +" person.AGE AS {person.age},\n" +" person.SEX AS {person.sex},\n" +" address.STREET AS {address.street},\n" +" address.CITY AS {address.city},\n" +" address.STATE AS {address.state},\n" +" address.ZIP AS {address.zip}\n" +" FROM PERSON person\n" +" JOIN ADDRESS address\n" +" ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'\n" +" WHERE person.NAME LIKE :namePattern\n" +"]]>" msgstr "" -#: index.docbook:392 -msgid "You can alternatively use the resultset mapping information in your hbm files directly in java code." -msgstr "" - -#: index.docbook:395 +#. Tag: para +#: query_sql.xml:379 +#, no-c-format msgid "" - "" +"A named SQL query may return a scalar value. You must declare the column " +"alias and Hibernate type using the <return-scalar> " +"element:" +msgstr "" +"一个命名查询可能会返回一个标量值.你必须使用<return-scalar>元素来指定字段的别名和 Hibernate类型" + +#. Tag: programlisting +#: query_sql.xml:383 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" SELECT p.NAME AS name,\n" +" p.AGE AS age,\n" +" FROM PERSON p WHERE p.NAME LIKE 'Hiber%'\n" +"]]>" msgstr "" -#: index.docbook:398 +#. Tag: para +#: query_sql.xml:385 +#, no-c-format +msgid "" +"You can externalize the resultset mapping informations in a <" +"resultset> element to either reuse them accross several named " +"queries or through the setResultSetMapping() API." +msgstr "" +"你可以把结果集映射的信息放在外部的<resultset>元素" +"中,这样就可以在多个命名查询间,或者通过setResultSetMapping()API来访问。(此处原文即存疑。原文为:You can externalize the " +"resultset mapping informations in a <resultset> " +"element to either reuse them accross several named queries or through the " +"setResultSetMapping() API.)" + +#. Tag: programlisting +#: query_sql.xml:390 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"\n" +"\n" +"\n" +" SELECT person.NAME AS {person.name},\n" +" person.AGE AS {person.age},\n" +" person.SEX AS {person.sex},\n" +" address.STREET AS {address.street},\n" +" address.CITY AS {address.city},\n" +" address.STATE AS {address.state},\n" +" address.ZIP AS {address.zip}\n" +" FROM PERSON person\n" +" JOIN ADDRESS address\n" +" ON person.ID = address.PERSON_ID AND address.TYPE='MAILING'\n" +" WHERE person.NAME LIKE :namePattern\n" +"]]>" +msgstr "" + +#. Tag: para +#: query_sql.xml:392 +#, no-c-format +msgid "" +"You can alternatively use the resultset mapping information in your hbm " +"files directly in java code." +msgstr "另外,你可以在java代码中直接使用hbm文件中的结果集定义信息。" + +#. Tag: programlisting +#: query_sql.xml:395 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: query_sql.xml:398 +#, no-c-format msgid "Using return-property to explicitly specify column/alias names" -msgstr "" +msgstr "使用return-property来明确地指定字段/别名" -#: index.docbook:401 -msgid "With <return-property> you can explicitly tell Hibernate what column aliases to use, instead of using the {}-syntax to let Hibernate inject its own aliases." -msgstr "" - -#: index.docbook:406 +#. Tag: para +#: query_sql.xml:401 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " SELECT person.NAME AS myName,\n" - " person.AGE AS myAge,\n" - " person.SEX AS mySex,\n" - " FROM PERSON person WHERE person.NAME LIKE :name\n" - "\n" - "]]>" +"With <return-property> you can explicitly tell " +"Hibernate what column aliases to use, instead of using the {}-syntax to let Hibernate inject its own aliases." msgstr "" +"使用<return-property>你可以明确的告诉Hibernate使用哪" +"些字段别名,这取代了使用{}-语法 来让Hibernate注入它自己的别" +"名." -#: index.docbook:408 -msgid "<return-property> also works with multiple columns. This solves a limitation with the {}-syntax which can not allow fine grained control of multi-column properties." -msgstr "" - -#: index.docbook:413 +#. Tag: programlisting +#: query_sql.xml:406 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer},\n" - " STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate},\n" - " REGIONCODE as {emp.regionCode}, EID AS {emp.id}, VALUE, CURRENCY\n" - " FROM EMPLOYMENT\n" - " WHERE EMPLOYER = :id AND ENDDATE IS NULL\n" - " ORDER BY STARTDATE ASC\n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" SELECT person.NAME AS myName,\n" +" person.AGE AS myAge,\n" +" person.SEX AS mySex,\n" +" FROM PERSON person WHERE person.NAME LIKE :name\n" +"\n" +"]]>" msgstr "" -#: index.docbook:415 -msgid "Notice that in this example we used <return-property> in combination with the {}-syntax for injection. Allowing users to choose how they want to refer column and properties." +#. Tag: para +#: query_sql.xml:408 +#, no-c-format +msgid "" +"<return-property> also works with multiple columns. " +"This solves a limitation with the {}-syntax which can not " +"allow fine grained control of multi-column properties." +msgstr "" +"<return-property>也可用于多个字段,它解决了使用" +"{}-语法不能细粒度控制多个字段的限制" + +#. Tag: programlisting +#: query_sql.xml:413 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer},\n" +" STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate},\n" +" REGIONCODE as {emp.regionCode}, EID AS {emp.id}, VALUE, CURRENCY\n" +" FROM EMPLOYMENT\n" +" WHERE EMPLOYER = :id AND ENDDATE IS NULL\n" +" ORDER BY STARTDATE ASC\n" +"]]>" msgstr "" -#: index.docbook:420 -msgid "If your mapping has a discriminator you must use <return-discriminator> to specify the discriminator column." +#. Tag: para +#: query_sql.xml:415 +#, no-c-format +msgid "" +"Notice that in this example we used <return-property> in combination with the {}-syntax for injection. " +"Allowing users to choose how they want to refer column and properties." msgstr "" +"注意在这个例子中,我们使用了<return-property>结合" +"{}的注入语法. 允许用户来选择如何引用字段以及属性." -#: index.docbook:426 +#. Tag: para +#: query_sql.xml:420 +#, no-c-format +msgid "" +"If your mapping has a discriminator you must use <return-" +"discriminator> to specify the discriminator column." +msgstr "" +"如果你映射一个识别器(discriminator),你必须使用<return-" +"discriminator> 来指定识别器字段" + +#. Tag: title +#: query_sql.xml:426 +#, no-c-format msgid "Using stored procedures for querying" -msgstr "" +msgstr "使用存储过程来查询" -#: index.docbook:428 -msgid "Hibernate 3 introduces support for queries via stored procedures and functions. Most of the following documentation is equivalent for both. The stored procedure/function must return a resultset as the first out-parameter to be able to work with Hibernate. An example of such a stored function in Oracle 9 and higher is as follows:" -msgstr "" - -#: index.docbook:434 +#. Tag: para +#: query_sql.xml:428 +#, no-c-format msgid "" - "" +"Hibernate 3 introduces support for queries via stored procedures and " +"functions. Most of the following documentation is equivalent for both. The " +"stored procedure/function must return a resultset as the first out-parameter " +"to be able to work with Hibernate. An example of such a stored function in " +"Oracle 9 and higher is as follows:" +msgstr "" +"Hibernate 3引入了对存储过程查询(stored procedure)和函数(function)的支持.以下" +"的说明中,这二者一般都适用。 存储过程/函数必须返回一个结果集,作为Hibernate能" +"够使用的第一个外部参数. 下面是一个Oracle9和更高版本的存储过程例子." + +#. Tag: programlisting +#: query_sql.xml:434 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:436 +#. Tag: para +#: query_sql.xml:436 +#, no-c-format msgid "To use this query in Hibernate you need to map it via a named query." -msgstr "" +msgstr "在Hibernate里要要使用这个查询,你需要通过命名查询来映射它." -#: index.docbook:439 +#. Tag: programlisting +#: query_sql.xml:439 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " { ? = call selectAllEmployments() }\n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" { ? = call selectAllEmployments() }\n" +"]]>" msgstr "" -#: index.docbook:441 -msgid "Notice stored procedures currently only return scalars and entities. <return-join> and <load-collection> are not supported." +#. Tag: para +#: query_sql.xml:441 +#, no-c-format +msgid "" +"Notice stored procedures currently only return scalars and entities. " +"<return-join> and <load-collection> are not supported." msgstr "" +"注意存储过程当前仅仅返回标量和实体.现在不支持<return-join><load-collection>" -#: index.docbook:446 +#. Tag: title +#: query_sql.xml:446 +#, no-c-format msgid "Rules/limitations for using stored procedures" -msgstr "" +msgstr "使用存储过程的规则和限制" -#: index.docbook:448 -msgid "To use stored procedures with Hibernate the procedures/functions have to follow some rules. If they do not follow those rules they are not usable with Hibernate. If you still want to use these procedures you have to execute them via session.connection(). The rules are different for each database, since database vendors have different stored procedure semantics/syntax." +#. Tag: para +#: query_sql.xml:448 +#, no-c-format +msgid "" +"To use stored procedures with Hibernate the procedures/functions have to " +"follow some rules. If they do not follow those rules they are not usable " +"with Hibernate. If you still want to use these procedures you have to " +"execute them via session.connection(). The rules are " +"different for each database, since database vendors have different stored " +"procedure semantics/syntax." msgstr "" +"为了在Hibernate中使用存储过程,你必须遵循一些规则.不遵循这些规则的存储过程将不" +"可用.如果你仍然想要使用他们, 你必须通过session.connection()来执行他们.这些规则针对于不同的数据库.因为数据库 提供商有各种不同的存" +"储过程语法和语义." -#: index.docbook:455 -msgid "Stored procedure queries can't be paged with setFirstResult()/setMaxResults()." +#. Tag: para +#: query_sql.xml:455 +#, no-c-format +msgid "" +"Stored procedure queries can't be paged with setFirstResult()/" +"setMaxResults()." msgstr "" +"对存储过程进行的查询无法使用setFirstResult()/setMaxResults()进行分页。" -#: index.docbook:458 -msgid "Recommended call form is standard SQL92: { ? = call functionName(<parameters>) } or { ? = call procedureName(<parameters>}. Native call syntax is not supported." +#. Tag: para +#: query_sql.xml:458 +#, no-c-format +msgid "" +"Recommended call form is standard SQL92: { ? = call functionName" +"(<parameters>) } or { ? = call procedureName(<" +"parameters>}. Native call syntax is not supported." msgstr "" +"建议采用的调用方式是标准SQL92: { ? = call functionName(<" +"parameters>) } 或者 { ? = call procedureName(<" +"parameters>}.原生调用语法不被支持。" -#: index.docbook:463 +#. Tag: para +#: query_sql.xml:463 +#, no-c-format msgid "For Oracle the following rules apply:" -msgstr "" +msgstr "对于Oracle有如下规则:" -#: index.docbook:467 -msgid "A function must return a result set. The first parameter of a procedure must be an OUT that returns a result set. This is done by using a SYS_REFCURSOR type in Oracle 9 or 10. In Oracle you need to define a REF CURSOR type, see Oracle literature." +#. Tag: para +#: query_sql.xml:467 +#, no-c-format +msgid "" +"A function must return a result set. The first parameter of a procedure must " +"be an OUT that returns a result set. This is done by " +"using a SYS_REFCURSOR type in Oracle 9 or 10. In Oracle " +"you need to define a REF CURSOR type, see Oracle " +"literature." msgstr "" +"函数必须返回一个结果集。存储过程的第一个参数必须是OUT,它" +"返回一个结果集。这是通过Oracle 9或10的SYS_REFCURSOR类型来" +"完成的。在Oracle中你需要定义一个REF CURSOR类型,参见Oracle" +"的手册。" -#: index.docbook:476 +#. Tag: para +#: query_sql.xml:476 +#, no-c-format msgid "For Sybase or MS SQL server the following rules apply:" -msgstr "" +msgstr "对于Sybase或者MS SQL server有如下规则:" -#: index.docbook:480 -msgid "The procedure must return a result set. Note that since these servers can/will return multiple result sets and update counts, Hibernate will iterate the results and take the first result that is a result set as its return value. Everything else will be discarded." +#. Tag: para +#: query_sql.xml:480 +#, no-c-format +msgid "" +"The procedure must return a result set. Note that since these servers can/" +"will return multiple result sets and update counts, Hibernate will iterate " +"the results and take the first result that is a result set as its return " +"value. Everything else will be discarded." msgstr "" +"存储过程必须返回一个结果集。.注意这些servers可能返回多个结果集以及更新的数目." +"Hibernate将取出第一条结果集作为它的返回值, 其他将被丢弃。" -#: index.docbook:488 -msgid "If you can enable SET NOCOUNT ON in your procedure it will probably be more efficient, but this is not a requirement." +#. Tag: para +#: query_sql.xml:488 +#, no-c-format +msgid "" +"If you can enable SET NOCOUNT ON in your procedure it " +"will probably be more efficient, but this is not a requirement." msgstr "" +"如果你能够在存储过程里设定SET NOCOUNT ON,这可能会效率更" +"高,但这不是必需的。" -#: index.docbook:498 +#. Tag: title +#: query_sql.xml:498 +#, no-c-format msgid "Custom SQL for create, update and delete" -msgstr "" +msgstr "定制SQL用来create,update和delete" -#: index.docbook:500 -msgid "Hibernate3 can use custom SQL statements for create, update, and delete operations. The class and collection persisters in Hibernate already contain a set of configuration time generated strings (insertsql, deletesql, updatesql etc.). The mapping tags <sql-insert>, <sql-delete>, and <sql-update> override these strings:" -msgstr "" - -#: index.docbook:508 +#. Tag: para +#: query_sql.xml:500 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " INSERT INTO PERSON (NAME, ID) VALUES ( UPPER(?), ? )\n" - " UPDATE PERSON SET NAME=UPPER(?) WHERE ID=?\n" - " DELETE FROM PERSON WHERE ID=?\n" - "]]>" +"Hibernate3 can use custom SQL statements for create, update, and delete " +"operations. The class and collection persisters in Hibernate already contain " +"a set of configuration time generated strings (insertsql, deletesql, " +"updatesql etc.). The mapping tags <sql-insert>, " +"<sql-delete>, and <sql-update> override these strings:" msgstr "" +"Hibernate3能够使用定制的SQL语句来执行create,update和delete操作。在Hibernate" +"中,持久化的类和集合已经 包含了一套配置期产生的语句(insertsql, deletesql, " +"updatesql等等),这些映射标记 <sql-insert>, " +"<sql-delete>, and <sql-update>重载了 这些语句。" -#: index.docbook:510 -msgid "The SQL is directly executed in your database, so you are free to use any dialect you like. This will of course reduce the portability of your mapping if you use database specific SQL." -msgstr "" - -#: index.docbook:514 -msgid "Stored procedures are supported if the callable attribute is set:" -msgstr "" - -#: index.docbook:517 +#. Tag: programlisting +#: query_sql.xml:508 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " {call createPerson (?, ?)}\n" - " {? = call deletePerson (?)}\n" - " {? = call updatePerson (?, ?)}\n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" INSERT INTO PERSON (NAME, ID) VALUES ( UPPER(?), ? )\n" +" UPDATE PERSON SET NAME=UPPER(?) WHERE ID=?\n" +" DELETE FROM PERSON WHERE ID=?\n" +"]]>" msgstr "" -#: index.docbook:519 -msgid "The order of the positional parameters are currently vital, as they must be in the same sequence as Hibernate expects them." -msgstr "" - -#: index.docbook:522 -msgid "You can see the expected order by enabling debug logging for the org.hibernate.persister.entity level. With this level enabled Hibernate will print out the static SQL that is used to create, update, delete etc. entities. (To see the expected sequence, remember to not include your custom SQL in the mapping files as that will override the Hibernate generated static sql.)" -msgstr "" - -#: index.docbook:529 -msgid "The stored procedures are in most cases (read: better do it than not) required to return the number of rows inserted/updated/deleted, as Hibernate has some runtime checks for the success of the statement. Hibernate always registers the first statement parameter as a numeric output parameter for the CUD operations:" -msgstr "" - -#: index.docbook:535 +#. Tag: para +#: query_sql.xml:510 +#, no-c-format msgid "" - "" +"The SQL is directly executed in your database, so you are free to use any " +"dialect you like. This will of course reduce the portability of your mapping " +"if you use database specific SQL." +msgstr "" +"这些SQL直接在你的数据库里执行,所以你可以自由的使用你喜欢的任意语法。但如果你" +"使用数据库特定的语法, 这当然会降低你映射的可移植性。" + +#. Tag: para +#: query_sql.xml:514 +#, no-c-format +msgid "" +"Stored procedures are supported if the callable attribute " +"is set:" +msgstr "如果设定callable,则能够支持存储过程了。" + +#. Tag: programlisting +#: query_sql.xml:517 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" {call createPerson (?, ?)}\n" +" {? = call deletePerson (?)}\n" +" {? = call updatePerson (?, ?)}\n" +"]]>" msgstr "" -#: index.docbook:539 +#. Tag: para +#: query_sql.xml:519 +#, no-c-format +msgid "" +"The order of the positional parameters are currently vital, as they must be " +"in the same sequence as Hibernate expects them." +msgstr "参数的位置顺序是非常重要的,他们必须和Hibernate所期待的顺序相同。" + +#. Tag: para +#: query_sql.xml:522 +#, no-c-format +msgid "" +"You can see the expected order by enabling debug logging for the " +"org.hibernate.persister.entity level. With this level " +"enabled Hibernate will print out the static SQL that is used to create, " +"update, delete etc. entities. (To see the expected sequence, remember to not " +"include your custom SQL in the mapping files as that will override the " +"Hibernate generated static sql.)" +msgstr "" +"你能够通过设定日志调试级别为org.hiberante.persister.entity,来查看Hibernate所期待的顺序。在这个级别下, Hibernate将会打印出" +"create,update和delete实体的静态SQL。(如果想看到预计的顺序。记得不要将定制SQL" +"包含在映射文件里, 因为他们会重载Hibernate生成的静态SQL。)" + +#. Tag: para +#: query_sql.xml:529 +#, no-c-format +msgid "" +"The stored procedures are in most cases (read: better do it than not) " +"required to return the number of rows inserted/updated/deleted, as Hibernate " +"has some runtime checks for the success of the statement. Hibernate always " +"registers the first statement parameter as a numeric output parameter for " +"the CUD operations:" +msgstr "" +"在大多数情况下(最好这么做),存储过程需要返回插入/更新/删除的行数,因为" +"Hibernate对语句的成功执行有些运行时的检查。 Hibernate常会把进行CUD操作的语句" +"的第一个参数注册为一个数值型输出参数。" + +#. Tag: programlisting +#: query_sql.xml:535 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: query_sql.xml:539 +#, no-c-format msgid "Custom SQL for loading" -msgstr "" +msgstr "定制装载SQL" -#: index.docbook:541 +#. Tag: para +#: query_sql.xml:541 +#, no-c-format msgid "You may also declare your own SQL (or HQL) queries for entity loading:" -msgstr "" +msgstr "你可能需要声明你自己的SQL(或HQL)来装载实体" -#: index.docbook:544 +#. Tag: programlisting +#: query_sql.xml:544 +#, no-c-format msgid "" - "\n" - " \n" - " SELECT NAME AS {pers.name}, ID AS {pers.id}\n" - " FROM PERSON\n" - " WHERE ID=?\n" - " FOR UPDATE\n" - "]]>" +"\n" +" \n" +" SELECT NAME AS {pers.name}, ID AS {pers.id}\n" +" FROM PERSON\n" +" WHERE ID=?\n" +" FOR UPDATE\n" +"]]>" msgstr "" -#: index.docbook:546 -msgid "This is just a named query declaration, as discussed earlier. You may reference this named query in a class mapping:" -msgstr "" - -#: index.docbook:549 +#. Tag: para +#: query_sql.xml:546 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"This is just a named query declaration, as discussed earlier. You may " +"reference this named query in a class mapping:" +msgstr "这只是一个前面讨论过的命名查询声明,你可以在类映射里引用这个命名查询。" + +#. Tag: programlisting +#: query_sql.xml:549 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:551 +#. Tag: para +#: query_sql.xml:551 +#, no-c-format msgid "This even works with stored procedures." -msgstr "" +msgstr "这也可以用于存储过程" -#: index.docbook:553 +#. Tag: para +#: query_sql.xml:553 +#, no-c-format msgid "You may even define a query for collection loading:" -msgstr "" +msgstr "你甚至可以定一个用于集合装载的查询:" -#: index.docbook:555 +#. Tag: programlisting +#: query_sql.xml:555 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:557 +#. Tag: programlisting +#: query_sql.xml:557 +#, no-c-format msgid "" - "\n" - " \n" - " SELECT {emp.*}\n" - " FROM EMPLOYMENT emp\n" - " WHERE EMPLOYER = :id\n" - " ORDER BY STARTDATE ASC, EMPLOYEE ASC\n" - "]]>" +"\n" +" \n" +" SELECT {emp.*}\n" +" FROM EMPLOYMENT emp\n" +" WHERE EMPLOYER = :id\n" +" ORDER BY STARTDATE ASC, EMPLOYEE ASC\n" +"]]>" msgstr "" -#: index.docbook:559 -msgid "You could even define an entity loader that loads a collection by join fetching:" -msgstr "" - -#: index.docbook:562 +#. Tag: para +#: query_sql.xml:559 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " SELECT NAME AS {pers.*}, {emp.*}\n" - " FROM PERSON pers\n" - " LEFT OUTER JOIN EMPLOYMENT emp\n" - " ON pers.ID = emp.PERSON_ID\n" - " WHERE ID=?\n" - "]]>" +"You could even define an entity loader that loads a collection by join " +"fetching:" +msgstr "你甚至还可以定义一个实体装载器,它通过连接抓取装载一个集合:" + +#. Tag: programlisting +#: query_sql.xml:562 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" SELECT NAME AS {pers.*}, {emp.*}\n" +" FROM PERSON pers\n" +" LEFT OUTER JOIN EMPLOYMENT emp\n" +" ON pers.ID = emp.PERSON_ID\n" +" WHERE ID=?\n" +"]]>" msgstr "" - -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - diff --git a/documentation/manual/translations/zh-CN/content/session_api.po b/documentation/manual/translations/zh-CN/content/session_api.po index beb817b3d1..aa6c1fe4cd 100644 --- a/documentation/manual/translations/zh-CN/content/session_api.po +++ b/documentation/manual/translations/zh-CN/content/session_api.po @@ -1,982 +1,2127 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: session_api.xml:5 +#, no-c-format msgid "Working with objects" -msgstr "" +msgstr "与对象共事" -#: index.docbook:7 -msgid "Hibernate is a full object/relational mapping solution that not only shields the developer from the details of the underlying database management system, but also offers state management of objects. This is, contrary to the management of SQL statements in common JDBC/SQL persistence layers, a very natural object-oriented view of persistence in Java applications." +#. Tag: para +#: session_api.xml:7 +#, no-c-format +msgid "" +"Hibernate is a full object/relational mapping solution that not only shields " +"the developer from the details of the underlying database management system, " +"but also offers state management of objects. This is, " +"contrary to the management of SQL statements in common " +"JDBC/SQL persistence layers, a very natural object-oriented view of " +"persistence in Java applications." msgstr "" +"Hibernate是完整的对象/关系映射解决方案,它提供了对象状态管理(state " +"management)的功能,使开发者不再需要理会底层数据库系统的细节。 也就" +"是说,相对于常见的JDBC/SQL持久层方案中需要管理SQL语句," +"Hibernate采用了更自然的面向对象的视角来持久化Java应用中的数据。" -#: index.docbook:16 -msgid "In other words, Hibernate application developers should always think about the state of their objects, and not necessarily about the execution of SQL statements. This part is taken care of by Hibernate and is only relevant for the application developer when tuning the performance of the system." +#. Tag: para +#: session_api.xml:16 +#, no-c-format +msgid "" +"In other words, Hibernate application developers should always think about " +"the state of their objects, and not necessarily about " +"the execution of SQL statements. This part is taken care of by Hibernate and " +"is only relevant for the application developer when tuning the performance " +"of the system." msgstr "" +"换句话说,使用Hibernate的开发者应该总是关注对象的状态(state),不必考虑SQL语句的执行。 这部分细节已经由Hibernate掌管妥当,只有开" +"发者在进行系统性能调优的时候才需要进行了解。" -#: index.docbook:24 +#. Tag: title +#: session_api.xml:24 +#, no-c-format msgid "Hibernate object states" -msgstr "" +msgstr "Hibernate对象状态(object states)" -#: index.docbook:26 +#. Tag: para +#: session_api.xml:26 +#, no-c-format msgid "Hibernate defines and supports the following object states:" -msgstr "" +msgstr "Hibernate定义并支持下列对象状态(state):" -#: index.docbook:32 -msgid "Transient - an object is transient if it has just been instantiated using the new operator, and it is not associated with a Hibernate Session. It has no persistent representation in the database and no identifier value has been assigned. Transient instances will be destroyed by the garbage collector if the application doesn't hold a reference anymore. Use the Hibernate Session to make an object persistent (and let Hibernate take care of the SQL statements that need to be executed for this transition)." +#. Tag: para +#: session_api.xml:32 +#, no-c-format +msgid "" +"Transient - an object is transient if it has just been " +"instantiated using the new operator, and it is not " +"associated with a Hibernate Session. It has no persistent " +"representation in the database and no identifier value has been assigned. " +"Transient instances will be destroyed by the garbage collector if the " +"application doesn't hold a reference anymore. Use the Hibernate " +"Session to make an object persistent (and let Hibernate " +"take care of the SQL statements that need to be executed for this " +"transition)." msgstr "" +"瞬时(Transient) - 由new操作符创建,且" +"尚未与Hibernate Session 关联的对象被认定为瞬时(Transient)" +"的。瞬时(Transient)对象不会被持久化到数据库中,也不会被赋予持久化标识" +"(identifier)。 如果瞬时(Transient)对象在程序中没有被引用,它会被垃圾回收器" +"(garbage collector)销毁。 使用Hibernate Session可以将其变" +"为持久(Persistent)状态。(Hibernate会自动执行必要的SQL语句)" -#: index.docbook:44 -msgid "Persistent - a persistent instance has a representation in the database and an identifier value. It might just have been saved or loaded, however, it is by definition in the scope of a Session. Hibernate will detect any changes made to an object in persistent state and synchronize the state with the database when the unit of work completes. Developers don't execute manual UPDATE statements, or DELETE statements when an object should be made transient." +#. Tag: para +#: session_api.xml:44 +#, no-c-format +msgid "" +"Persistent - a persistent instance has a representation " +"in the database and an identifier value. It might just have been saved or " +"loaded, however, it is by definition in the scope of a Session. Hibernate will detect any changes made to an object in persistent " +"state and synchronize the state with the database when the unit of work " +"completes. Developers don't execute manual UPDATE " +"statements, or DELETE statements when an object should be " +"made transient." msgstr "" +"持久(Persistent) - 持久(Persistent)的实例在数据库中有对" +"应的记录,并拥有一个持久化标识(identifier)。 持久(Persistent)的实例可能是刚被" +"保存的,或刚被加载的,无论哪一种,按定义,它存在于相关联的Session作用范围内。 Hibernate会检测到处于持久(Persistent)状态的对象的任何改" +"动,在当前操作单元(unit of work)执行完毕时将对象数据(state)与数据库同步" +"(synchronize)。 开发者不需要手动执行UPDATE。将对象从持久" +"(Persistent)状态变成瞬时(Transient)状态同样也不需要手动执行DELETE语句。" -#: index.docbook:55 -msgid "Detached - a detached instance is an object that has been persistent, but its Session has been closed. The reference to the object is still valid, of course, and the detached instance might even be modified in this state. A detached instance can be reattached to a new Session at a later point in time, making it (and all the modifications) persistent again. This feature enables a programming model for long running units of work that require user think-time. We call them application transactions, i.e. a unit of work from the point of view of the user." +#. Tag: para +#: session_api.xml:55 +#, no-c-format +msgid "" +"Detached - a detached instance is an object that has " +"been persistent, but its Session has been closed. The " +"reference to the object is still valid, of course, and the detached instance " +"might even be modified in this state. A detached instance can be reattached " +"to a new Session at a later point in time, making it (and " +"all the modifications) persistent again. This feature enables a programming " +"model for long running units of work that require user think-time. We call " +"them application transactions, i.e. a unit of work from " +"the point of view of the user." msgstr "" +"脱管(Detached) - 与持久(Persistent)对象关联的" +"Session被关闭后,对象就变为脱管(Detached)的。 对脱管" +"(Detached)对象的引用依然有效,对象可继续被修改。脱管(Detached)对象如果重新关" +"联到某个新的Session上, 会再次转变为持久(Persistent)的(在" +"Detached其间的改动将被持久化到数据库)。 这个功能使得一种编程模型,即中间会给" +"用户思考时间(user think-time)的长时间运行的操作单元(unit of work)的编程模型成" +"为可能。 我们称之为应用程序事务,即从用户观点看是一个操" +"作单元(unit of work)。" -#: index.docbook:69 -msgid "We'll now discuss the states and state transitions (and the Hibernate methods that trigger a transition) in more detail." +#. Tag: para +#: session_api.xml:69 +#, no-c-format +msgid "" +"We'll now discuss the states and state transitions (and the Hibernate " +"methods that trigger a transition) in more detail." msgstr "" +"接下来我们来细致的讨论下状态(states)及状态间的转换(state transitions)(以及触" +"发状态转换的Hibernate方法)。" -#: index.docbook:77 +#. Tag: title +#: session_api.xml:77 +#, no-c-format msgid "Making objects persistent" -msgstr "" +msgstr "使对象持久化" -#: index.docbook:79 -msgid "Newly instantiated instances of a a persistent class are considered transient by Hibernate. We can make a transient instance persistent by associating it with a session:" -msgstr "" - -#: index.docbook:86 +#. Tag: para +#: session_api.xml:79 +#, no-c-format msgid "" - "" +"Newly instantiated instances of a a persistent class are considered " +"transient by Hibernate. We can make a transient " +"instance persistent by associating it with a session:" msgstr "" +"Hibernate认为持久化类(persistent class)新实例化的对象是瞬时" +"(Transient)的。 我们可通过将瞬时(Transient)对象与session关联而把它" +"变为持久(Persistent)的。" -#: index.docbook:88 -msgid "If Cat has a generated identifier, the identifier is generated and assigned to the cat when save() is called. If Cat has an assigned identifier, or a composite key, the identifier should be assigned to the cat instance before calling save(). You may also use persist() instead of save(), with the semantics defined in the EJB3 early draft." -msgstr "" - -#: index.docbook:100 -msgid "persist() makes a transient instance persistent. However, it doesn't guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time. persist() also guarantees that it will not execute an INSERT statement if it is called outside of transaction boundaries. This is useful in long-running conversations with an extended Session/persistence context." -msgstr "" - -#: index.docbook:111 -msgid "save() does guarantee to return an identifier. If an INSERT has to be executed to get the identifier ( e.g. \"identity\" generator, not \"sequence\"), this INSERT happens immediately, no matter if you are inside or outside of a transaction. This is problematic in a long-running conversation with an extended Session/persistence context." -msgstr "" - -#: index.docbook:121 -msgid "Alternatively, you may assign the identifier using an overloaded version of save()." -msgstr "" - -#: index.docbook:126 +#. Tag: programlisting +#: session_api.xml:86 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:128 -msgid "If the object you make persistent has associated objects (e.g. the kittens collection in the previous example), these objects may be made persistent in any order you like unless you have a NOT NULL constraint upon a foreign key column. There is never a risk of violating foreign key constraints. However, you might violate a NOT NULL constraint if you save() the objects in the wrong order." +#. Tag: para +#: session_api.xml:88 +#, no-c-format +msgid "" +"If Cat has a generated identifier, the identifier is " +"generated and assigned to the cat when save() is called. If Cat has an assigned identifier, or a composite key, the identifier should be assigned " +"to the cat instance before calling save(). You may also use persist() instead of " +"save(), with the semantics defined in the EJB3 early " +"draft." +msgstr "" +"如果Cat的持久化标识(identifier)是generated类型的, 那么该标识(identifier)会自动在save()被调" +"用时产生并分配给cat。 如果Cat的持久化标" +"识(identifier)是assigned类型的,或是一个复合主键" +"(composite key), 那么该标识(identifier)应当在调用save()之" +"前手动赋予给cat。 你也可以按照EJB3 early draft中定义的语" +"义,使用persist()替代save()。" + +#. Tag: para +#: session_api.xml:100 +#, no-c-format +msgid "" +"persist() makes a transient instance persistent. However, " +"it doesn't guarantee that the identifier value will be assigned to the " +"persistent instance immediately, the assignment might happen at flush time. " +"persist() also guarantees that it will not execute an " +"INSERT statement if it is called outside of transaction " +"boundaries. This is useful in long-running conversations with an extended " +"Session/persistence context." +msgstr "" +"persist() makes a transient instance persistent. However, " +"it doesn't guarantee that the identifier value will be assigned to the " +"persistent instance immediately, the assignment might happen at flush time. " +"persist() also guarantees that it will not execute an " +"INSERT statement if it is called outside of transaction " +"boundaries. This is useful in long-running conversations with an extended " +"Session/persistence context." + +#. Tag: para +#: session_api.xml:111 +#, no-c-format +msgid "" +"save() does guarantee to return an identifier. If an " +"INSERT has to be executed to get the identifier ( e.g. \"identity\" " +"generator, not \"sequence\"), this INSERT happens immediately, no matter if " +"you are inside or outside of a transaction. This is problematic in a long-" +"running conversation with an extended Session/persistence context." +msgstr "" +"save() does guarantee to return an identifier. If an " +"INSERT has to be executed to get the identifier ( e.g. \"identity\" " +"generator, not \"sequence\"), this INSERT happens immediately, no matter if " +"you are inside or outside of a transaction. This is problematic in a long-" +"running conversation with an extended Session/persistence context." + +#. Tag: para +#: session_api.xml:121 +#, no-c-format +msgid "" +"Alternatively, you may assign the identifier using an overloaded version of " +"save()." +msgstr "此外,你可以用一个重载版本的save()方法。" + +#. Tag: programlisting +#: session_api.xml:126 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:138 -msgid "Usually you don't bother with this detail, as you'll very likely use Hibernate's transitive persistence feature to save the associated objects automatically. Then, even NOT NULL constraint violations don't occur - Hibernate will take care of everything. Transitive persistence is discussed later in this chapter." +#. Tag: para +#: session_api.xml:128 +#, no-c-format +msgid "" +"If the object you make persistent has associated objects (e.g. the " +"kittens collection in the previous example), these " +"objects may be made persistent in any order you like unless you have a " +"NOT NULL constraint upon a foreign key column. There is " +"never a risk of violating foreign key constraints. However, you might " +"violate a NOT NULL constraint if you save() the objects in the wrong order." msgstr "" +"如果你持久化的对象有关联的对象(associated objects)(例如上例中的" +"kittens集合) 那么对这些对象(译注:pk和kittens)进行持久" +"化的顺序是任意的(也就是说可以先对kittens进行持久化也可以先对pk进行持久" +"化), 除非你在外键列上有NOT NULL约束。 Hibernate不会违反" +"外键约束,但是如果你用错误的顺序持久化对象(译注:在pk持久化之前持久化" +"kitten),那么可能会违反NOT NULL约束。" -#: index.docbook:149 +#. Tag: para +#: session_api.xml:138 +#, no-c-format +msgid "" +"Usually you don't bother with this detail, as you'll very likely use " +"Hibernate's transitive persistence feature to save the " +"associated objects automatically. Then, even NOT NULL " +"constraint violations don't occur - Hibernate will take care of everything. " +"Transitive persistence is discussed later in this chapter." +msgstr "" +"通常你不会为这些细节烦心,因为你很可能会使用Hibernate的 传播性持久" +"化(transitive persistence)功能自动保存相关联那些对象。 这样连违反" +"NOT NULL约束的情况都不会出现了 - Hibernate会管好所有的事" +"情。 传播性持久化(transitive persistence)将在本章稍后讨论。" + +#. Tag: title +#: session_api.xml:149 +#, no-c-format msgid "Loading an object" -msgstr "" +msgstr "装载对象" -#: index.docbook:151 -msgid "The load() methods of Session gives you a way to retrieve a persistent instance if you already know its identifier. load() takes a class object and will load the state into a newly instantiated instance of that class, in persistent state." +#. Tag: para +#: session_api.xml:151 +#, no-c-format +msgid "" +"The load() methods of Session gives " +"you a way to retrieve a persistent instance if you already know its " +"identifier. load() takes a class object and will load the " +"state into a newly instantiated instance of that class, in persistent state." msgstr "" +"如果你知道某个实例的持久化标识(identifier),你就可以使用Sessionload()方法 来获取它。 load()" +"的另一个参数是指定类的.class对象。 本方法会创建指定类的持久化实例,并从数据库" +"加载其数据(state)。" -#: index.docbook:158 +#. Tag: programlisting +#: session_api.xml:158 +#, no-c-format msgid "" msgstr "" -#: index.docbook:160 +#. Tag: programlisting +#: session_api.xml:160 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:162 +#. Tag: para +#: session_api.xml:162 +#, no-c-format msgid "Alternatively, you can load state into a given instance:" msgstr "" +"此外, 你可以把数据(state)加载到指定的对象实例上(覆盖掉该实例原来的数据)。" -#: index.docbook:166 +#. Tag: programlisting +#: session_api.xml:166 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:168 -msgid "Note that load() will throw an unrecoverable exception if there is no matching database row. If the class is mapped with a proxy, load() just returns an uninitialized proxy and does not actually hit the database until you invoke a method of the proxy. This behaviour is very useful if you wish to create an association to an object without actually loading it from the database. It also allows multiple instances to be loaded as a batch if batch-size is defined for the class mapping." -msgstr "" - -#: index.docbook:179 -msgid "If you are not certain that a matching row exists, you should use the get() method, which hits the database immediately and returns null if there is no matching row." -msgstr "" - -#: index.docbook:185 +#. Tag: para +#: session_api.xml:168 +#, no-c-format msgid "" - "" +"Note that load() will throw an unrecoverable exception if " +"there is no matching database row. If the class is mapped with a proxy, " +"load() just returns an uninitialized proxy and does not " +"actually hit the database until you invoke a method of the proxy. This " +"behaviour is very useful if you wish to create an association to an object " +"without actually loading it from the database. It also allows multiple " +"instances to be loaded as a batch if batch-size is " +"defined for the class mapping." +msgstr "" +"请注意如果没有匹配的数据库记录,load()方法可能抛出无法恢复" +"的异常(unrecoverable exception)。 如果类的映射使用了代理(proxy)," +"load()方法会返回一个未初始化的代理,直到你调用该代理的某方" +"法时才会去访问数据库。 若你希望在某对象中创建一个指向另一个对象的关联,又不想" +"在从数据库中装载该对象时同时装载相关联的那个对象,那么这种操作方式就用得上的" +"了。 如果为相应类映射关系设置了batch-size, 那么使用这种操" +"作方式允许多个对象被一批装载(因为返回的是代理,无需从数据库中抓取所有对象的" +"数据)。" + +#. Tag: para +#: session_api.xml:179 +#, no-c-format +msgid "" +"If you are not certain that a matching row exists, you should use the " +"get() method, which hits the database immediately and " +"returns null if there is no matching row." +msgstr "" +"如果你不确定是否有匹配的行存在,应该使用get()方法,它会立" +"刻访问数据库,如果没有对应的记录,会返回null。" + +#. Tag: programlisting +#: session_api.xml:185 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:187 -msgid "You may even load an object using an SQL SELECT ... FOR UPDATE, using a LockMode. See the API documentation for more information." +#. Tag: para +#: session_api.xml:187 +#, no-c-format +msgid "" +"You may even load an object using an SQL SELECT ... FOR UPDATE, using a LockMode. See the API documentation for " +"more information." msgstr "" +"你甚至可以选用某个LockMode,用SQL的SELECT ... " +"FOR UPDATE装载对象。 请查阅API文档以获取更多信息。" -#: index.docbook:192 +#. Tag: programlisting +#: session_api.xml:192 +#, no-c-format msgid "" msgstr "" -#: index.docbook:194 -msgid "Note that any associated instances or contained collections are not selected FOR UPDATE, unless you decide to specify lock or all as a cascade style for the association." -msgstr "" - -#: index.docbook:201 -msgid "It is possible to re-load an object and all its collections at any time, using the refresh() method. This is useful when database triggers are used to initialize some of the properties of the object." -msgstr "" - -#: index.docbook:207 +#. Tag: para +#: session_api.xml:194 +#, no-c-format msgid "" - "" +"Note that any associated instances or contained collections are " +"not selected FOR UPDATE, unless you " +"decide to specify lock or all as a " +"cascade style for the association." +msgstr "" +"注意,任何关联的对象或者包含的集合都不会被以" +"FOR UPDATE方式返回, 除非你指定了lock或" +"者all作为关联(association)的级联风格(cascade style)。" + +#. Tag: para +#: session_api.xml:201 +#, no-c-format +msgid "" +"It is possible to re-load an object and all its collections at any time, " +"using the refresh() method. This is useful when database " +"triggers are used to initialize some of the properties of the object." +msgstr "" +"任何时候都可以使用refresh()方法强迫装载对象和它的集合。如" +"果你使用数据库触发器功能来处理对象的某些属性,这个方法就很有用了。" + +#. Tag: programlisting +#: session_api.xml:207 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:209 -msgid "An important question usually appears at this point: How much does Hibernate load from the database and how many SQL SELECTs will it use? This depends on the fetching strategy and is explained in ." +#. Tag: para +#: session_api.xml:209 +#, no-c-format +msgid "" +"An important question usually appears at this point: How much does Hibernate " +"load from the database and how many SQL SELECTs will it " +"use? This depends on the fetching strategy and is " +"explained in ." msgstr "" +"此处通常会出现一个重要问题: Hibernate会从数据库中装载多少东西?会执行多少条相" +"应的SQLSELECT语句? 这取决于抓取策略(fetching " +"strategy),会在中解释。" -#: index.docbook:219 +#. Tag: title +#: session_api.xml:219 +#, no-c-format msgid "Querying" -msgstr "" +msgstr "查询" -#: index.docbook:221 -msgid "If you don't know the identifiers of the objects you are looking for, you need a query. Hibernate supports an easy-to-use but powerful object oriented query language (HQL). For programmatic query creation, Hibernate supports a sophisticated Criteria and Example query feature (QBC and QBE). You may also express your query in the native SQL of your database, with optional support from Hibernate for result set conversion into objects." +#. Tag: para +#: session_api.xml:221 +#, no-c-format +msgid "" +"If you don't know the identifiers of the objects you are looking for, you " +"need a query. Hibernate supports an easy-to-use but powerful object oriented " +"query language (HQL). For programmatic query creation, Hibernate supports a " +"sophisticated Criteria and Example query feature (QBC and QBE). You may also " +"express your query in the native SQL of your database, with optional support " +"from Hibernate for result set conversion into objects." msgstr "" +"如果不知道所要寻找的对象的持久化标识,那么你需要使用查询。Hibernate支持强大且" +"易于使用的面向对象查询语言(HQL)。 如果希望通过编程的方式创建查询,Hibernate提" +"供了完善的按条件(Query By Criteria, QBC)以及按样例(Query By Example, QBE)进行" +"查询的功能。 你也可以用原生SQL(native SQL)描述查询,Hibernate额外提供了将结果" +"集(result set)转化为对象的支持。" -#: index.docbook:231 +#. Tag: title +#: session_api.xml:231 +#, no-c-format msgid "Executing queries" -msgstr "" +msgstr "执行查询" -#: index.docbook:233 -msgid "HQL and native SQL queries are represented with an instance of org.hibernate.Query. This interface offers methods for parameter binding, result set handling, and for the execution of the actual query. You always obtain a Query using the current Session:" -msgstr "" - -#: index.docbook:240 +#. Tag: para +#: session_api.xml:233 +#, no-c-format msgid "" - "" +"HQL and native SQL queries are represented with an instance of org." +"hibernate.Query. This interface offers methods for parameter " +"binding, result set handling, and for the execution of the actual query. You " +"always obtain a Query using the current Session:" +msgstr "" +"HQL和原生SQL(native SQL)查询要通过为org.hibernate.Query的" +"实例来表达。 这个接口提供了参数绑定、结果集处理以及运行实际查询的方法。 你总" +"是可以通过当前Session获取一个Query对" +"象:" + +#. Tag: programlisting +#: session_api.xml:240 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:242 -msgid "A query is usually executed by invoking list(), the result of the query will be loaded completely into a collection in memory. Entity instances retrieved by a query are in persistent state. The uniqueResult() method offers a shortcut if you know your query will only return a single object. Note that queries that make use of eager fetching of collections usually return duplicates of the root objects (but with their collections initialized). You can filter these duplicates simply through a Set." +#. Tag: para +#: session_api.xml:242 +#, no-c-format +msgid "" +"A query is usually executed by invoking list(), the " +"result of the query will be loaded completely into a collection in memory. " +"Entity instances retrieved by a query are in persistent state. The " +"uniqueResult() method offers a shortcut if you know your " +"query will only return a single object. Note that queries that make use of " +"eager fetching of collections usually return duplicates of the root objects " +"(but with their collections initialized). You can filter these duplicates " +"simply through a Set." msgstr "" +"一个查询通常在调用list()时被执行,执行结果会完全装载进内存" +"中的一个集合(collection)。 查询返回的对象处于持久(persistent)状态。如果你知道" +"的查询只会返回一个对象,可使用list()的快捷方式" +"uniqueResult()。 注意,使用集合预先抓取的查询往往会返回多" +"次根对象(他们的集合类都被初始化了)。你可以通过一个集合来过滤这些重复对象。" -#: index.docbook:254 +#. Tag: title +#: session_api.xml:254 +#, no-c-format msgid "Iterating results" -msgstr "" +msgstr "迭代式获取结果(Iterating results)" -#: index.docbook:256 -msgid "Occasionally, you might be able to achieve better performance by executing the query using the iterate() method. This will only usually be the case if you expect that the actual entity instances returned by the query will already be in the session or second-level cache. If they are not already cached, iterate() will be slower than list() and might require many database hits for a simple query, usually 1 for the initial select which only returns identifiers, and n additional selects to initialize the actual instances." -msgstr "" - -#: index.docbook:268 +#. Tag: para +#: session_api.xml:256 +#, no-c-format msgid "" - "" +"Occasionally, you might be able to achieve better performance by executing " +"the query using the iterate() method. This will only " +"usually be the case if you expect that the actual entity instances returned " +"by the query will already be in the session or second-level cache. If they " +"are not already cached, iterate() will be slower than " +"list() and might require many database hits for a simple " +"query, usually 1 for the initial select which only " +"returns identifiers, and n additional selects to " +"initialize the actual instances." +msgstr "" +"某些情况下,你可以使用iterate()方法得到更好的性能。 这通常" +"是你预期返回的结果在session,或二级缓存(second-level cache)中已经存在时的情" +"况。 如若不然,iterate()会比list()慢," +"而且可能简单查询也需要进行多次数据库访问: iterate()会首先" +"使用1条语句得到所有对象的持久化标识(identifiers),再根据" +"持久化标识执行n条附加的select语句实例化实际的对象。" + +#. Tag: programlisting +#: session_api.xml:268 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:272 +#. Tag: title +#: session_api.xml:272 +#, no-c-format msgid "Queries that return tuples" -msgstr "" +msgstr "返回元组(tuples)的查询" -#: index.docbook:274 -msgid "Hibernate queries sometimes return tuples of objects, in which case each tuple is returned as an array:" -msgstr "" - -#: index.docbook:279 +#. Tag: para +#: session_api.xml:274 +#, no-c-format msgid "" - "" +"Hibernate queries sometimes return tuples of objects, in which case each " +"tuple is returned as an array:" +msgstr "" +"(译注:元组(tuples)指一条结果行包含多个对象) Hibernate查询有时返回元组" +"(tuples),每个元组(tuples)以数组的形式返回:" + +#. Tag: programlisting +#: session_api.xml:279 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:284 +#. Tag: title +#: session_api.xml:284 +#, no-c-format msgid "Scalar results" -msgstr "" +msgstr "标量(Scalar)结果" -#: index.docbook:286 -msgid "Queries may specify a property of a class in the select clause. They may even call SQL aggregate functions. Properties or aggregates are considered \"scalar\" results (and not entities in persistent state)." -msgstr "" - -#: index.docbook:292 +#. Tag: para +#: session_api.xml:286 +#, no-c-format msgid "" - "" +"Queries may specify a property of a class in the select " +"clause. They may even call SQL aggregate functions. Properties or aggregates " +"are considered \"scalar\" results (and not entities in persistent state)." +msgstr "" +"查询可在select从句中指定类的属性,甚至可以调用SQL统计" +"(aggregate)函数。 属性或统计结果被认定为\"标量(Scalar)\"的结果(而不是持久" +"(persistent state)的实体)。" + +#. Tag: programlisting +#: session_api.xml:292 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:297 +#. Tag: title +#: session_api.xml:297 +#, no-c-format msgid "Bind parameters" -msgstr "" +msgstr "绑定参数" -#: index.docbook:299 -msgid "Methods on Query are provided for binding values to named parameters or JDBC-style ? parameters. Contrary to JDBC, Hibernate numbers parameters from zero. Named parameters are identifiers of the form :name in the query string. The advantages of named parameters are:" +#. Tag: para +#: session_api.xml:299 +#, no-c-format +msgid "" +"Methods on Query are provided for binding values to named " +"parameters or JDBC-style ? parameters. Contrary " +"to JDBC, Hibernate numbers parameters from zero. Named parameters " +"are identifiers of the form :name in the query string. " +"The advantages of named parameters are:" msgstr "" +"接口Query提供了对命名参数(named parameters)、JDBC风格的" +"问号(?)参数进行绑定的方法。 不同于JDBC," +"Hibernate对参数从0开始计数。 命名参数(named parameters)在查询字符" +"串中是形如:name的标识符。 命名参数(named parameters)的优点" +"是:" -#: index.docbook:309 -msgid "named parameters are insensitive to the order they occur in the query string" -msgstr "" +#. Tag: para +#: session_api.xml:309 +#, no-c-format +msgid "" +"named parameters are insensitive to the order they occur in the query string" +msgstr "命名参数(named parameters)与其在查询串中出现的顺序无关" -#: index.docbook:315 +#. Tag: para +#: session_api.xml:315 +#, no-c-format msgid "they may occur multiple times in the same query" -msgstr "" +msgstr "它们可在同一查询串中多次出现" -#: index.docbook:320 +#. Tag: para +#: session_api.xml:320 +#, no-c-format msgid "they are self-documenting" -msgstr "" +msgstr "它们本身是自我说明的" -#: index.docbook:326 +#. Tag: programlisting +#: session_api.xml:326 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:328 +#. Tag: programlisting +#: session_api.xml:328 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:330 +#. Tag: programlisting +#: session_api.xml:330 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:335 +#. Tag: title +#: session_api.xml:335 +#, no-c-format msgid "Pagination" -msgstr "" +msgstr "分页" -#: index.docbook:337 -msgid "If you need to specify bounds upon your result set (the maximum number of rows you want to retrieve and / or the first row you want to retrieve) you should use methods of the Query interface:" -msgstr "" - -#: index.docbook:343 +#. Tag: para +#: session_api.xml:337 +#, no-c-format msgid "" - "" +"If you need to specify bounds upon your result set (the maximum number of " +"rows you want to retrieve and / or the first row you want to retrieve) you " +"should use methods of the Query interface:" +msgstr "" +"如果你需要指定结果集的范围(希望返回的最大行数/或开始的行数),应该使用" +"Query接口提供的方法:" + +#. Tag: programlisting +#: session_api.xml:343 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:345 -msgid "Hibernate knows how to translate this limit query into the native SQL of your DBMS." +#. Tag: para +#: session_api.xml:345 +#, no-c-format +msgid "" +"Hibernate knows how to translate this limit query into the native SQL of " +"your DBMS." msgstr "" +"Hibernate 知道如何将这个有限定条件的查询转换成你的数据库的原生SQL(native " +"SQL)。" -#: index.docbook:353 +#. Tag: title +#: session_api.xml:353 +#, no-c-format msgid "Scrollable iteration" -msgstr "" +msgstr "可滚动遍历(Scrollable iteration)" -#: index.docbook:355 -msgid "If your JDBC driver supports scrollable ResultSets, the Query interface may be used to obtain a ScrollableResults object, which allows flexible navigation of the query results." -msgstr "" - -#: index.docbook:362 +#. Tag: para +#: session_api.xml:355 +#, no-c-format msgid "" - " i++ ) && cats.next() ) pageOfCats.add( cats.get(1) );\n" - "\n" - "}\n" - "cats.close()]]>" +"If your JDBC driver supports scrollable ResultSets, the " +"Query interface may be used to obtain a " +"ScrollableResults object, which allows flexible " +"navigation of the query results." +msgstr "" +"如果你的JDBC驱动支持可滚动的ResuleSetQuery接口可以使用ScrollableResults,允许你在查询结果中" +"灵活游走。" + +#. Tag: programlisting +#: session_api.xml:362 +#, no-c-format +msgid "" +" i++ ) && cats.next() ) pageOfCats.add( cats.get" +"(1) );\n" +"\n" +"}\n" +"cats.close()]]>" msgstr "" -#: index.docbook:364 -msgid "Note that an open database connection (and cursor) is required for this functionality, use setMaxResult()/setFirstResult() if you need offline pagination functionality." +#. Tag: para +#: session_api.xml:364 +#, no-c-format +msgid "" +"Note that an open database connection (and cursor) is required for this " +"functionality, use setMaxResult()/setFirstResult" +"() if you need offline pagination functionality." msgstr "" +"请注意,使用此功能需要保持数据库连接(以及游标(cursor))处于一直打开状态。 如" +"果你需要断开连接使用分页功能,请使用setMaxResult()/" +"setFirstResult()" -#: index.docbook:373 +#. Tag: title +#: session_api.xml:373 +#, no-c-format msgid "Externalizing named queries" -msgstr "" +msgstr "外置命名查询(Externalizing named queries)" -#: index.docbook:375 -msgid "You may also define named queries in the mapping document. (Remember to use a CDATA section if your query contains characters that could be interpreted as markup.)" -msgstr "" - -#: index.docbook:381 +#. Tag: para +#: session_api.xml:375 +#, no-c-format msgid "" - " ?\n" - "] ]>]]>" +"You may also define named queries in the mapping document. (Remember to use " +"a CDATA section if your query contains characters that " +"could be interpreted as markup.)" +msgstr "" +"你可以在映射文件中定义命名查询(named queries)。 (如果你的查询串中包含可能被" +"解释为XML标记(markup)的字符,别忘了用CDATA包裹起来。)" + +#. Tag: programlisting +#: session_api.xml:381 +#, no-c-format +msgid "" +" ?\n" +"] ]>]]>" msgstr "" -#: index.docbook:383 +#. Tag: para +#: session_api.xml:383 +#, no-c-format msgid "Parameter binding and executing is done programatically:" -msgstr "" +msgstr "参数绑定及执行以编程方式(programatically)完成:" -#: index.docbook:387 +#. Tag: programlisting +#: session_api.xml:387 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:389 -msgid "Note that the actual program code is independent of the query language that is used, you may also define native SQL queries in metadata, or migrate existing queries to Hibernate by placing them in mapping files." +#. Tag: para +#: session_api.xml:389 +#, no-c-format +msgid "" +"Note that the actual program code is independent of the query language that " +"is used, you may also define native SQL queries in metadata, or migrate " +"existing queries to Hibernate by placing them in mapping files." msgstr "" +"请注意实际的程序代码与所用的查询语言无关,你也可在元数据中定义原生SQL(native " +"SQL)查询, 或将原有的其他的查询语句放在配置文件中,这样就可以让Hibernate统一" +"管理,达到迁移的目的。" -#: index.docbook:395 -msgid "Also note that a query declaration inside a <hibernate-mapping> element requires a global unique name for the query, while a query declaration inside a <class> element is made unique automatically by prepending the fully qualified name of the class, for example eg.Cat.ByNameAndMaximumWeight." +#. Tag: para +#: session_api.xml:395 +#, no-c-format +msgid "" +"Also note that a query declaration inside a <hibernate-" +"mapping> element requires a global unique name for the query, " +"while a query declaration inside a <class> element " +"is made unique automatically by prepending the fully qualified name of the " +"class, for example eg.Cat.ByNameAndMaximumWeight." msgstr "" +"也请注意在<hibernate-mapping>元素中声明的查询必须有" +"一个全局唯一的名字,而在<class>元素中声明的查询自动具" +"有全局名,是通过类的全名加以限定的。比如eg.Cat." +"ByNameAndMaximumWeight。" -#: index.docbook:408 +#. Tag: title +#: session_api.xml:408 +#, no-c-format msgid "Filtering collections" -msgstr "" +msgstr "过滤集合" -#: index.docbook:409 -msgid "A collection filter is a special type of query that may be applied to a persistent collection or array. The query string may refer to this, meaning the current collection element." -msgstr "" - -#: index.docbook:415 +#. Tag: para +#: session_api.xml:409 +#, no-c-format msgid "" - "" +"A collection filter is a special type of query that may " +"be applied to a persistent collection or array. The query string may refer " +"to this, meaning the current collection element." msgstr "" +"集合过滤器(filter)是一种用于一个持久化集合或者数组的特殊" +"的查询。查询字符串中可以使用\"this\"来引用集合中的当前元" +"素。" -#: index.docbook:417 -msgid "The returned collection is considered a bag, and it's a copy of the given collection. The original collection is not modified (this is contrary to the implication of the name \"filter\", but consistent with expected behavior)." -msgstr "" - -#: index.docbook:423 -msgid "Observe that filters do not require a from clause (though they may have one if required). Filters are not limited to returning the collection elements themselves." -msgstr "" - -#: index.docbook:428 +#. Tag: programlisting +#: session_api.xml:415 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:430 -msgid "Even an empty filter query is useful, e.g. to load a subset of elements in a huge collection:" -msgstr "" - -#: index.docbook:435 +#. Tag: para +#: session_api.xml:417 +#, no-c-format msgid "" - "" +"The returned collection is considered a bag, and it's a copy of the given " +"collection. The original collection is not modified (this is contrary to the " +"implication of the name \"filter\", but consistent with expected behavior)." +msgstr "" +"返回的集合可以被认为是一个包(bag, 无顺序可重复的集合(collection)),它是所给集" +"合的副本。 原来的集合不会被改动(这与“过滤器(filter)”的隐含的含义不符,不过与" +"我们期待的行为一致)。" + +#. Tag: para +#: session_api.xml:423 +#, no-c-format +msgid "" +"Observe that filters do not require a from clause (though " +"they may have one if required). Filters are not limited to returning the " +"collection elements themselves." +msgstr "" +"请注意过滤器(filter)并不需要from子句(当然需要的话它们也可" +"以加上)。过滤器(filter)不限定于只能返回集合元素本身。" + +#. Tag: programlisting +#: session_api.xml:428 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:440 +#. Tag: para +#: session_api.xml:430 +#, no-c-format +msgid "" +"Even an empty filter query is useful, e.g. to load a subset of elements in a " +"huge collection:" +msgstr "" +"即使无条件的过滤器(filter)也是有意义的。例如,用于加载一个大集合的子集:" + +#. Tag: programlisting +#: session_api.xml:435 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: title +#: session_api.xml:440 +#, no-c-format msgid "Criteria queries" -msgstr "" +msgstr "条件查询(Criteria queries)" -#: index.docbook:442 -msgid "HQL is extremely powerful but some developers prefer to build queries dynamically, using an object-oriented API, rather than building query strings. Hibernate provides an intuitive Criteria query API for these cases:" -msgstr "" - -#: index.docbook:448 +#. Tag: para +#: session_api.xml:442 +#, no-c-format msgid "" - "" +"HQL is extremely powerful but some developers prefer to build queries " +"dynamically, using an object-oriented API, rather than building query " +"strings. Hibernate provides an intuitive Criteria query " +"API for these cases:" +msgstr "" +"HQL极为强大,但是有些人希望能够动态的使用一种面向对象API创建查询,而非在他们" +"的Java代码中嵌入字符串。对于那部分人来说,Hibernate提供了直观的" +"Criteria查询API。" + +#. Tag: programlisting +#: session_api.xml:448 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:450 -msgid "The Criteria and the associated Example API are discussed in more detail in ." +#. Tag: para +#: session_api.xml:450 +#, no-c-format +msgid "" +"The Criteria and the associated Example API are discussed in more detail in ." msgstr "" +"Criteria以及相关的样例(Example)API将会" +"再中详细讨论。" -#: index.docbook:458 +#. Tag: title +#: session_api.xml:458 +#, no-c-format msgid "Queries in native SQL" -msgstr "" +msgstr "使用原生SQL的查询" -#: index.docbook:460 -msgid "You may express a query in SQL, using createSQLQuery() and let Hibernate take care of the mapping from result sets to objects. Note that you may at any time call session.connection() and use the JDBC Connection directly. If you chose to use the Hibernate API, you must enclose SQL aliases in braces:" -msgstr "" - -#: index.docbook:468 +#. Tag: para +#: session_api.xml:460 +#, no-c-format msgid "" - "" +"You may express a query in SQL, using createSQLQuery() " +"and let Hibernate take care of the mapping from result sets to objects. Note " +"that you may at any time call session.connection() and " +"use the JDBC Connection directly. If you chose to use the " +"Hibernate API, you must enclose SQL aliases in braces:" msgstr "" +"你可以使用createSQLQuery()方法,用SQL来描述查询,并由" +"Hibernate将结果集转换成对象。 请注意,你可以在任何时候调用session." +"connection()来获得并使用JDBC Connection对象。 如" +"果你选择使用Hibernate的API, 你必须把SQL别名用大括号包围起来:" -#: index.docbook:470 +#. Tag: programlisting +#: session_api.xml:468 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:472 -msgid "SQL queries may contain named and positional parameters, just like Hibernate queries. More information about native SQL queries in Hibernate can be found in ." +#. Tag: programlisting +#: session_api.xml:470 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:483 +#. Tag: para +#: session_api.xml:472 +#, no-c-format +msgid "" +"SQL queries may contain named and positional parameters, just like Hibernate " +"queries. More information about native SQL queries in Hibernate can be found " +"in ." +msgstr "" +"和Hibernate查询一样,SQL查询也可以包含命名参数和占位参数。 可以在找到更多关于Hibernate中原生SQL(native SQL)的信息。" + +#. Tag: title +#: session_api.xml:483 +#, no-c-format msgid "Modifying persistent objects" -msgstr "" +msgstr "修改持久对象" -#: index.docbook:485 -msgid "Transactional persistent instances (ie. objects loaded, saved, created or queried by the Session) may be manipulated by the application and any changes to persistent state will be persisted when the Session is flushed (discussed later in this chapter). There is no need to call a particular method (like update(), which has a different purpose) to make your modifications persistent. So the most straightforward way to update the state of an object is to load() it, and then manipulate it directly, while the Session is open:" -msgstr "" - -#: index.docbook:496 +#. Tag: para +#: session_api.xml:485 +#, no-c-format msgid "" - "" +"Transactional persistent instances (ie. objects loaded, " +"saved, created or queried by the Session) may be " +"manipulated by the application and any changes to persistent state will be " +"persisted when the Session is flushed (discussed later in this chapter). There is no need to call a " +"particular method (like update(), which has a different " +"purpose) to make your modifications persistent. So the most straightforward " +"way to update the state of an object is to load() it, and " +"then manipulate it directly, while the Session is open:" +msgstr "" +"事务中的持久实例(就是通过session装" +"载、保存、创建或者查询出的对象) 被应用程序操作所造成的任何修改都会在" +"Session刷出(flushed)的时候被持久" +"化(本章后面会详细讨论)。 这里不需要调用某个特定的方法(比如update" +"(),设计它的目的是不同的)将你的修改持久化。 所以最直接的更新一个对" +"象的方法就是在Session处于打开状态时load()它,然后直接修改即可:" + +#. Tag: programlisting +#: session_api.xml:496 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:498 -msgid "Sometimes this programming model is inefficient since it would require both an SQL SELECT (to load an object) and an SQL UPDATE (to persist its updated state) in the same session. Therefore Hibernate offers an alternate approach, using detached instances." +#. Tag: para +#: session_api.xml:498 +#, no-c-format +msgid "" +"Sometimes this programming model is inefficient since it would require both " +"an SQL SELECT (to load an object) and an SQL " +"UPDATE (to persist its updated state) in the same " +"session. Therefore Hibernate offers an alternate approach, using detached " +"instances." msgstr "" +"有时这种程序模型效率低下,因为它在同一Session里需要一条SQL SELECT语句(用于加载对象) 以及一条SQL UPDATE语句(持久化" +"更新的状态)。 为此Hibernate提供了另一种途径,使用脱管(detached)实例。" -#: index.docbook:506 -msgid "Note that Hibernate does not offer its own API for direct execution of UPDATE or DELETE statements. Hibernate is a state management service, you don't have to think in statements to use it. JDBC is a perfect API for executing SQL statements, you can get a JDBC Connection at any time by calling session.connection(). Furthermore, the notion of mass operations conflicts with object/relational mapping for online transaction processing-oriented applications. Future versions of Hibernate may however provide special mass operation functions. See for some possible batch operation tricks." +#. Tag: emphasis +#: session_api.xml:506 +#, fuzzy, no-c-format +msgid "" +"Note that Hibernate does not offer its own API for direct execution of " +"UPDATE or DELETE statements. Hibernate " +"is a state management service, you don't have to think " +"in statements to use it. JDBC is a perfect API for " +"executing SQL statements, you can get a JDBC Connection " +"at any time by calling session.connection(). Furthermore, " +"the notion of mass operations conflicts with object/relational mapping for " +"online transaction processing-oriented applications. Future versions of " +"Hibernate may however provide special mass operation functions. See for some possible batch operation tricks." msgstr "" +"请注意Hibernate本身不提供直接执行语句的" +"API。 Hibernate提供的是服务,你不必考虑要使用的。 JDBC是出色的执行SQL语句的API,任何时候调用你都可以得到" +"一个JDBC 对象。 此外,在联机事务处理(OLTP)程序中,大量操作" +"(mass operations)与对象/关系映射的观点是相冲突的。 Hibernate的将来版本可能会" +"提供专门的进行大量操作(mass operation)的功能。 参考,寻找一些可用的批量(batch)操作技巧。" -#: index.docbook:521 +#. Tag: title +#: session_api.xml:521 +#, no-c-format msgid "Modifying detached objects" -msgstr "" +msgstr "修改脱管(Detached)对象" -#: index.docbook:523 -msgid "Many applications need to retrieve an object in one transaction, send it to the UI layer for manipulation, then save the changes in a new transaction. Applications that use this kind of approach in a high-concurrency environment usually use versioned data to ensure isolation for the \"long\" unit of work." -msgstr "" - -#: index.docbook:530 -msgid "Hibernate supports this model by providing for reattachment of detached instances using the Session.update() or Session.merge() methods:" -msgstr "" - -#: index.docbook:536 +#. Tag: para +#: session_api.xml:523 +#, no-c-format msgid "" - "" +"Many applications need to retrieve an object in one transaction, send it to " +"the UI layer for manipulation, then save the changes in a new transaction. " +"Applications that use this kind of approach in a high-concurrency " +"environment usually use versioned data to ensure isolation for the \"long\" " +"unit of work." msgstr "" +"很多程序需要在某个事务中获取对象,然后将对象发送到界面层去操作,最后在一个新" +"的事务保存所做的修改。 在高并发访问的环境中使用这种方式,通常使用附带版本信息" +"的数据来保证这些“长“工作单元之间的隔离。" -#: index.docbook:538 -msgid "If the Cat with identifier catId had already been loaded by secondSession when the application tried to reattach it, an exception would have been thrown." -msgstr "" - -#: index.docbook:544 -msgid "Use update() if you are sure that the session does not contain an already persistent instance with the same identifier, and merge() if you want to merge your modifications at any time without consideration of the state of the session. In other words, update() is usually the first method you would call in a fresh session, ensuring that reattachment of your detached instances is the first operation that is executed." -msgstr "" - -#: index.docbook:553 -msgid "The application should individually update() detached instances reachable from the given detached instance if and only if it wants their state also updated. This can be automated of course, using transitive persistence, see ." -msgstr "" - -#: index.docbook:560 -msgid "The lock() method also allows an application to reassociate an object with a new session. However, the detached instance has to be unmodified!" -msgstr "" - -#: index.docbook:565 +#. Tag: para +#: session_api.xml:530 +#, no-c-format msgid "" - "" +"Hibernate supports this model by providing for reattachment of detached " +"instances using the Session.update() or Session." +"merge() methods:" +msgstr "" +"Hibernate通过提供Session.update()Session.merge" +"() 重新关联脱管实例的办法来支持这种模型。" + +#. Tag: programlisting +#: session_api.xml:536 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:567 -msgid "Note that lock() can be used with various LockModes, see the API documentation and the chapter on transaction handling for more information. Reattachment is not the only usecase for lock()." +#. Tag: para +#: session_api.xml:538 +#, no-c-format +msgid "" +"If the Cat with identifier catId had " +"already been loaded by secondSession when the application " +"tried to reattach it, an exception would have been thrown." +msgstr "" +"如果具有catId持久化标识的Cat之前已经被" +"另一Session(secondSession)装载了, 应用程序进行重关联操作" +"(reattach)的时候会抛出一个异常。" + +#. Tag: para +#: session_api.xml:544 +#, no-c-format +msgid "" +"Use update() if you are sure that the session does not " +"contain an already persistent instance with the same identifier, and " +"merge() if you want to merge your modifications at any " +"time without consideration of the state of the session. In other words, " +"update() is usually the first method you would call in a " +"fresh session, ensuring that reattachment of your detached instances is the " +"first operation that is executed." +msgstr "" +"如果你确定当前session没有包含与之具有相同持久化标识的持久实例,使用" +"update()。 如果想随时合并你的的改动而不考虑session的状态," +"使用merge()。 换句话说,在一个新session中通常第一个调用的" +"是update()方法,以便保证重新关联脱管(detached)对象的操作首" +"先被执行。" + +#. Tag: para +#: session_api.xml:553 +#, no-c-format +msgid "" +"The application should individually update() detached " +"instances reachable from the given detached instance if and only if it wants their state also updated. This can be automated of " +"course, using transitive persistence, see ." +msgstr "" +"如果希望相关联的脱管对象(通过引用“可到达”的脱管对象)的数据也要更新到数据库" +"时(并且也仅仅在这种情况), 可以对该相关联的脱管对象单" +"独调用update() 当然这些可以自动完成,即通过使用" +"传播性持久化(transitive persistence),请看。" + +#. Tag: para +#: session_api.xml:560 +#, no-c-format +msgid "" +"The lock() method also allows an application to " +"reassociate an object with a new session. However, the detached instance has " +"to be unmodified!" +msgstr "" +"lock()方法也允许程序重新关联某个对象到一个新session上。不" +"过,该脱管(detached)的对象必须是没有修改过的!" + +#. Tag: programlisting +#: session_api.xml:565 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:574 -msgid "Other models for long units of work are discussed in ." +#. Tag: para +#: session_api.xml:567 +#, no-c-format +msgid "" +"Note that lock() can be used with various " +"LockModes, see the API documentation and the chapter on " +"transaction handling for more information. Reattachment is not the only " +"usecase for lock()." msgstr "" +"请注意,lock()可以搭配多种LockMode, 更" +"多信息请阅读API文档以及关于事务处理(transaction handling)的章节。重新关联不是" +"lock()的唯一用途。" -#: index.docbook:581 +#. Tag: para +#: session_api.xml:574 +#, no-c-format +msgid "" +"Other models for long units of work are discussed in ." +msgstr "" +"其他用于长时间工作单元的模型会在中" +"讨论。" + +#. Tag: title +#: session_api.xml:581 +#, no-c-format msgid "Automatic state detection" -msgstr "" +msgstr "自动状态检测" -#: index.docbook:583 -msgid "Hibernate users have requested a general purpose method that either saves a transient instance by generating a new identifier or updates/reattaches the detached instances associated with its current identifier. The saveOrUpdate() method implements this functionality." -msgstr "" - -#: index.docbook:590 +#. Tag: para +#: session_api.xml:583 +#, no-c-format msgid "" - "" +"Hibernate users have requested a general purpose method that either saves a " +"transient instance by generating a new identifier or updates/reattaches the " +"detached instances associated with its current identifier. The " +"saveOrUpdate() method implements this functionality." +msgstr "" +"Hibernate的用户曾要求一个既可自动分配新持久化标识(identifier)保存瞬时" +"(transient)对象,又可更新/重新关联脱管(detached)实例的通用方法。 " +"saveOrUpdate()方法实现了这个功能。" + +#. Tag: programlisting +#: session_api.xml:590 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:592 -msgid "The usage and semantics of saveOrUpdate() seems to be confusing for new users. Firstly, so long as you are not trying to use instances from one session in another new session, you should not need to use update(), saveOrUpdate(), or merge(). Some whole applications will never use either of these methods." +#. Tag: para +#: session_api.xml:592 +#, no-c-format +msgid "" +"The usage and semantics of saveOrUpdate() seems to be " +"confusing for new users. Firstly, so long as you are not trying to use " +"instances from one session in another new session, you should not need to " +"use update(), saveOrUpdate(), or " +"merge(). Some whole applications will never use either of " +"these methods." msgstr "" +"saveOrUpdate()用途和语义可能会使新用户感到迷惑。 首先,只" +"要你没有尝试在某个session中使用来自另一session的实例,你就应该不需要使用" +"update()saveOrUpdate(),或" +"merge()。有些程序从来不用这些方法。" -#: index.docbook:600 -msgid "Usually update() or saveOrUpdate() are used in the following scenario:" +#. Tag: para +#: session_api.xml:600 +#, no-c-format +msgid "" +"Usually update() or saveOrUpdate() are " +"used in the following scenario:" msgstr "" +"通常下面的场景会使用update()saveOrUpdate():" -#: index.docbook:607 +#. Tag: para +#: session_api.xml:607 +#, no-c-format msgid "the application loads an object in the first session" -msgstr "" +msgstr "程序在第一个session中加载对象" -#: index.docbook:612 +#. Tag: para +#: session_api.xml:612 +#, no-c-format msgid "the object is passed up to the UI tier" -msgstr "" +msgstr "该对象被传递到表现层" -#: index.docbook:617 +#. Tag: para +#: session_api.xml:617 +#, no-c-format msgid "some modifications are made to the object" -msgstr "" +msgstr "对象发生了一些改动" -#: index.docbook:622 +#. Tag: para +#: session_api.xml:622 +#, no-c-format msgid "the object is passed back down to the business logic tier" -msgstr "" +msgstr "该对象被返回到业务逻辑层" -#: index.docbook:627 -msgid "the application persists these modifications by calling update() in a second session" -msgstr "" +#. Tag: para +#: session_api.xml:627 +#, no-c-format +msgid "" +"the application persists these modifications by calling update() in a second session" +msgstr "程序调用第二个session的update()方法持久这些改动" -#: index.docbook:634 +#. Tag: para +#: session_api.xml:634 +#, no-c-format msgid "saveOrUpdate() does the following:" -msgstr "" +msgstr "saveOrUpdate()做下面的事:" -#: index.docbook:640 +#. Tag: para +#: session_api.xml:640 +#, no-c-format msgid "if the object is already persistent in this session, do nothing" -msgstr "" +msgstr "如果对象已经在本session中持久化了,不做任何事" -#: index.docbook:645 -msgid "if another object associated with the session has the same identifier, throw an exception" +#. Tag: para +#: session_api.xml:645 +#, no-c-format +msgid "" +"if another object associated with the session has the same identifier, throw " +"an exception" msgstr "" +"如果另一个与本session关联的对象拥有相同的持久化标识(identifier),抛出一个异常" -#: index.docbook:651 +#. Tag: para +#: session_api.xml:651 +#, no-c-format msgid "if the object has no identifier property, save() it" msgstr "" +"如果对象没有持久化标识(identifier)属性,对其调用save()" -#: index.docbook:656 -msgid "if the object's identifier has the value assigned to a newly instantiated object, save() it" +#. Tag: para +#: session_api.xml:656 +#, no-c-format +msgid "" +"if the object's identifier has the value assigned to a newly instantiated " +"object, save() it" msgstr "" +"如果对象的持久标识(identifier)表明其是一个新实例化的对象,对其调用" +"save()" -#: index.docbook:662 -msgid "if the object is versioned (by a <version> or <timestamp>), and the version property value is the same value assigned to a newly instantiated object, save() it" +#. Tag: para +#: session_api.xml:662 +#, no-c-format +msgid "" +"if the object is versioned (by a <version> or " +"<timestamp>), and the version property value is the " +"same value assigned to a newly instantiated object, save() it" msgstr "" +"如果对象是附带版本信息的(通过<version>或" +"<timestamp>) 并且版本属性的值表明其是一个新实例化的" +"对象,save()它。" -#: index.docbook:670 +#. Tag: para +#: session_api.xml:670 +#, no-c-format msgid "otherwise update() the object" -msgstr "" +msgstr "否则update() 这个对象" -#: index.docbook:676 +#. Tag: para +#: session_api.xml:676 +#, no-c-format msgid "and merge() is very different:" -msgstr "" +msgstr "merge()可非常不同:" -#: index.docbook:682 -msgid "if there is a persistent instance with the same identifier currently associated with the session, copy the state of the given object onto the persistent instance" +#. Tag: para +#: session_api.xml:682 +#, no-c-format +msgid "" +"if there is a persistent instance with the same identifier currently " +"associated with the session, copy the state of the given object onto the " +"persistent instance" msgstr "" +"如果session中存在相同持久化标识(identifier)的实例,用用户给出的对象的状态覆盖" +"旧有的持久实例" -#: index.docbook:689 -msgid "if there is no persistent instance currently associated with the session, try to load it from the database, or create a new persistent instance" +#. Tag: para +#: session_api.xml:689 +#, no-c-format +msgid "" +"if there is no persistent instance currently associated with the session, " +"try to load it from the database, or create a new persistent instance" msgstr "" +"如果session没有相应的持久实例,则尝试从数据库中加载,或创建新的持久化实例" -#: index.docbook:695 +#. Tag: para +#: session_api.xml:695 +#, no-c-format msgid "the persistent instance is returned" -msgstr "" +msgstr "最后返回该持久实例" -#: index.docbook:700 -msgid "the given instance does not become associated with the session, it remains detached" -msgstr "" +#. Tag: para +#: session_api.xml:700 +#, no-c-format +msgid "" +"the given instance does not become associated with the session, it remains " +"detached" +msgstr "用户给出的这个对象没有被关联到session上,它依旧是脱管的" -#: index.docbook:710 +#. Tag: title +#: session_api.xml:710 +#, no-c-format msgid "Deleting persistent objects" -msgstr "" +msgstr "删除持久对象" -#: index.docbook:712 -msgid "Session.delete() will remove an object's state from the database. Of course, your application might still hold a reference to a deleted object. It's best to think of delete() as making a persistent instance transient." +#. Tag: para +#: session_api.xml:712 +#, no-c-format +msgid "" +"Session.delete() will remove an object's state from the " +"database. Of course, your application might still hold a reference to a " +"deleted object. It's best to think of delete() as making " +"a persistent instance transient." msgstr "" +"使用Session.delete()会把对象的状态从数据库中移除。 当然," +"你的应用程序可能仍然持有一个指向已删除对象的引用。所以,最好这样理解:" +"delete()的用途是把一个持久实例变成瞬时(transient)实例。" -#: index.docbook:719 +#. Tag: programlisting +#: session_api.xml:719 +#, no-c-format msgid "" msgstr "" -#: index.docbook:721 -msgid "You may delete objects in any order you like, without risk of foreign key constraint violations. It is still possible to violate a NOT NULL constraint on a foreign key column by deleting objects in the wrong order, e.g. if you delete the parent, but forget to delete the children." +#. Tag: para +#: session_api.xml:721 +#, no-c-format +msgid "" +"You may delete objects in any order you like, without risk of foreign key " +"constraint violations. It is still possible to violate a NOT NULL constraint on a foreign key column by deleting objects in the wrong " +"order, e.g. if you delete the parent, but forget to delete the children." msgstr "" +"你可以用你喜欢的任何顺序删除对象,不用担心外键约束冲突。当然,如果你搞错了顺" +"序,还是有可能引发在外键字段定义的NOT NULL约束冲突。 例如" +"你删除了父对象,但是忘记删除孩子们。" -#: index.docbook:732 +#. Tag: title +#: session_api.xml:732 +#, no-c-format msgid "Replicating object between two different datastores" -msgstr "" +msgstr "在两个不同数据库间复制对象" -#: index.docbook:734 -msgid "It is occasionally useful to be able to take a graph of persistent instances and make them persistent in a different datastore, without regenerating identifier values." -msgstr "" - -#: index.docbook:740 +#. Tag: para +#: session_api.xml:734 +#, no-c-format msgid "" - "" +"It is occasionally useful to be able to take a graph of persistent instances " +"and make them persistent in a different datastore, without regenerating " +"identifier values." +msgstr "" +"偶尔会用到不重新生成持久化标识(identifier),将持久实例以及其关联的实例持久到" +"不同的数据库中的操作。" + +#. Tag: programlisting +#: session_api.xml:740 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:742 -msgid "The ReplicationMode determines how replicate() will deal with conflicts with existing rows in the database." +#. Tag: para +#: session_api.xml:742 +#, no-c-format +msgid "" +"The ReplicationMode determines how replicate() will deal with conflicts with existing rows in the database." msgstr "" +"ReplicationMode决定在和数据库中已存在记录由冲突时," +"replicate()如何处理。" -#: index.docbook:749 -msgid "ReplicationMode.IGNORE - ignore the object when there is an existing database row with the same identifier" +#. Tag: para +#: session_api.xml:749 +#, no-c-format +msgid "" +"ReplicationMode.IGNORE - ignore the object when there is " +"an existing database row with the same identifier" +msgstr "ReplicationMode.IGNORE - 忽略它" + +#. Tag: para +#: session_api.xml:755 +#, no-c-format +msgid "" +"ReplicationMode.OVERWRITE - overwrite any existing " +"database row with the same identifier" +msgstr "ReplicationMode.OVERWRITE - 覆盖相同的行" + +#. Tag: para +#: session_api.xml:761 +#, no-c-format +msgid "" +"ReplicationMode.EXCEPTION - throw an exception if there " +"is an existing database row with the same identifier" +msgstr "ReplicationMode.EXCEPTION - 抛出异常" + +#. Tag: para +#: session_api.xml:767 +#, no-c-format +msgid "" +"ReplicationMode.LATEST_VERSION - overwrite the row if its " +"version number is earlier than the version number of the object, or ignore " +"the object otherwise" msgstr "" +"ReplicationMode.LATEST_VERSION - 如果当前的版本较新,则覆" +"盖,否则忽略" -#: index.docbook:755 -msgid "ReplicationMode.OVERWRITE - overwrite any existing database row with the same identifier" +#. Tag: para +#: session_api.xml:775 +#, no-c-format +msgid "" +"Usecases for this feature include reconciling data entered into different " +"database instances, upgrading system configuration information during " +"product upgrades, rolling back changes made during non-ACID transactions and " +"more." msgstr "" +"这个功能的用途包括使录入的数据在不同数据库中一致,产品升级时升级系统配置信" +"息,回滚non-ACID事务中的修改等等。 (译注,non-ACID,非ACID;ACID,Atomic," +"Consistent,Isolated and Durable的缩写)" -#: index.docbook:761 -msgid "ReplicationMode.EXCEPTION - throw an exception if there is an existing database row with the same identifier" -msgstr "" - -#: index.docbook:767 -msgid "ReplicationMode.LATEST_VERSION - overwrite the row if its version number is earlier than the version number of the object, or ignore the object otherwise" -msgstr "" - -#: index.docbook:775 -msgid "Usecases for this feature include reconciling data entered into different database instances, upgrading system configuration information during product upgrades, rolling back changes made during non-ACID transactions and more." -msgstr "" - -#: index.docbook:784 +#. Tag: title +#: session_api.xml:784 +#, no-c-format msgid "Flushing the Session" -msgstr "" +msgstr "Session刷出(flush)" -#: index.docbook:786 -msgid "From time to time the Session will execute the SQL statements needed to synchronize the JDBC connection's state with the state of objects held in memory. This process, flush, occurs by default at the following points" -msgstr "" - -#: index.docbook:795 -msgid "before some query executions" -msgstr "" - -#: index.docbook:800 -msgid "from org.hibernate.Transaction.commit()" -msgstr "" - -#: index.docbook:805 -msgid "from Session.flush()" -msgstr "" - -#: index.docbook:811 -msgid "The SQL statements are issued in the following order" -msgstr "" - -#: index.docbook:817 -msgid "all entity insertions, in the same order the corresponding objects were saved using Session.save()" -msgstr "" - -#: index.docbook:823 -msgid "all entity updates" -msgstr "" - -#: index.docbook:828 -msgid "all collection deletions" -msgstr "" - -#: index.docbook:833 -msgid "all collection element deletions, updates and insertions" -msgstr "" - -#: index.docbook:838 -msgid "all collection insertions" -msgstr "" - -#: index.docbook:843 -msgid "all entity deletions, in the same order the corresponding objects were deleted using Session.delete()" -msgstr "" - -#: index.docbook:850 -msgid "(An exception is that objects using native ID generation are inserted when they are saved.)" -msgstr "" - -#: index.docbook:855 -msgid "Except when you explicity flush(), there are absolutely no guarantees about when the Session executes the JDBC calls, only the order in which they are executed. However, Hibernate does guarantee that the Query.list(..) will never return stale data; nor will they return the wrong data." -msgstr "" - -#: index.docbook:863 -msgid "It is possible to change the default behavior so that flush occurs less frequently. The FlushMode class defines three different modes: only flush at commit time (and only when the Hibernate Transaction API is used), flush automatically using the explained routine, or never flush unless flush() is called explicitly. The last mode is useful for long running units of work, where a Session is kept open and disconnected for a long time (see )." -msgstr "" - -#: index.docbook:873 +#. Tag: para +#: session_api.xml:786 +#, no-c-format msgid "" - "" +"From time to time the Session will execute the SQL " +"statements needed to synchronize the JDBC connection's state with the state " +"of objects held in memory. This process, flush, occurs " +"by default at the following points" +msgstr "" +"每间隔一段时间,Session会执行一些必需的SQL语句来把内存中的" +"对象的状态同步到JDBC连接中。这个过程被称为刷出(flush)," +"默认会在下面的时间点执行:" + +#. Tag: para +#: session_api.xml:795 +#, no-c-format +msgid "before some query executions" +msgstr "在某些查询执行之前" + +#. Tag: para +#: session_api.xml:800 +#, no-c-format +msgid "from org.hibernate.Transaction.commit()" +msgstr "在调用org.hibernate.Transaction.commit()的时候" + +#. Tag: para +#: session_api.xml:805 +#, no-c-format +msgid "from Session.flush()" +msgstr "在调用Session.flush()的时候" + +#. Tag: para +#: session_api.xml:811 +#, no-c-format +msgid "The SQL statements are issued in the following order" +msgstr "涉及的SQL语句会按照下面的顺序发出执行:" + +#. Tag: para +#: session_api.xml:817 +#, no-c-format +msgid "" +"all entity insertions, in the same order the corresponding objects were " +"saved using Session.save()" +msgstr "" +"所有对实体进行插入的语句,其顺序按照对象执行Session.save()" +"的时间顺序" + +#. Tag: para +#: session_api.xml:823 +#, no-c-format +msgid "all entity updates" +msgstr "所有对实体进行更新的语句" + +#. Tag: para +#: session_api.xml:828 +#, no-c-format +msgid "all collection deletions" +msgstr "所有进行集合删除的语句" + +#. Tag: para +#: session_api.xml:833 +#, no-c-format +msgid "all collection element deletions, updates and insertions" +msgstr "所有对集合元素进行删除,更新或者插入的语句" + +#. Tag: para +#: session_api.xml:838 +#, no-c-format +msgid "all collection insertions" +msgstr "所有进行集合插入的语句" + +#. Tag: para +#: session_api.xml:843 +#, no-c-format +msgid "" +"all entity deletions, in the same order the corresponding objects were " +"deleted using Session.delete()" +msgstr "" +"所有对实体进行删除的语句,其顺序按照对象执行Session.delete()的时间顺序" + +#. Tag: para +#: session_api.xml:850 +#, no-c-format +msgid "" +"(An exception is that objects using native ID generation " +"are inserted when they are saved.)" +msgstr "" +"(有一个例外是,如果对象使用native方式来生成ID(持久化标" +"识)的话,它们一执行save就会被插入。)" + +#. Tag: para +#: session_api.xml:855 +#, no-c-format +msgid "" +"Except when you explicity flush(), there are absolutely " +"no guarantees about when the Session " +"executes the JDBC calls, only the order in which they " +"are executed. However, Hibernate does guarantee that the Query.list" +"(..) will never return stale data; nor will they return the wrong " +"data." +msgstr "" +"除非你明确地发出了flush()指令,关于Session何时会执行这些JDBC调用是完全无法保证的,只能保证它们执行的前后顺序。 当" +"然,Hibernate保证,Query.list(..)绝对不会返回已经失效的数" +"据,也不会返回错误数据。" + +#. Tag: para +#: session_api.xml:863 +#, no-c-format +msgid "" +"It is possible to change the default behavior so that flush occurs less " +"frequently. The FlushMode class defines three different " +"modes: only flush at commit time (and only when the Hibernate " +"Transaction API is used), flush automatically using the " +"explained routine, or never flush unless flush() is " +"called explicitly. The last mode is useful for long running units of work, " +"where a Session is kept open and disconnected for a long " +"time (see )." +msgstr "" +"也可以改变默认的设置,来让刷出(flush)操作发生的不那么频繁。 " +"FlushMode类定义了三种不同的方式。 仅在提交时刷出(仅当" +"Hibernate的Transaction API被使用时有效), 按照刚才说的方式" +"刷出, 以及除非明确使用flush()否则从不刷出。 最后一种模式" +"对于那些需要长时间保持Session为打开或者断线状态的长时间运" +"行的工作单元很有用。 (参见 )." + +#. Tag: programlisting +#: session_api.xml:873 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:875 -msgid "During flush, an exception might occur (e.g. if a DML operation violates a constraint). Since handling exceptions involves some understanding of Hibernate's transactional behavior, we discuss it in ." +#. Tag: para +#: session_api.xml:875 +#, no-c-format +msgid "" +"During flush, an exception might occur (e.g. if a DML operation violates a " +"constraint). Since handling exceptions involves some understanding of " +"Hibernate's transactional behavior, we discuss it in ." msgstr "" +"刷出(flush)期间,可能会抛出异常。(例如一个DML操作违反了约束) 异常处理涉及到" +"对Hibernate事务性行为的理解,因此我们将在中讨" +"论。" -#: index.docbook:884 +#. Tag: title +#: session_api.xml:884 +#, no-c-format msgid "Transitive persistence" -msgstr "" +msgstr "传播性持久化(transitive persistence)" -#: index.docbook:886 -msgid "It is quite cumbersome to save, delete, or reattach individual objects, especially if you deal with a graph of associated objects. A common case is a parent/child relationship. Consider the following example:" +#. Tag: para +#: session_api.xml:886 +#, no-c-format +msgid "" +"It is quite cumbersome to save, delete, or reattach individual objects, " +"especially if you deal with a graph of associated objects. A common case is " +"a parent/child relationship. Consider the following example:" msgstr "" +"对每一个对象都要执行保存,删除或重关联操作让人感觉有点麻烦,尤其是在处理许多" +"彼此关联的对象的时候。 一个常见的例子是父子关系。考虑下面的例子:" -#: index.docbook:892 -msgid "If the children in a parent/child relationship would be value typed (e.g. a collection of addresses or strings), their life cycle would depend on the parent and no further action would be required for convenient \"cascading\" of state changes. When the parent is saved, the value-typed child objects are saved as well, when the parent is deleted, the children will be deleted, etc. This even works for operations such as the removal of a child from the collection; Hibernate will detect this and, since value-typed objects can't have shared references, delete the child from the database." +#. Tag: para +#: session_api.xml:892 +#, no-c-format +msgid "" +"If the children in a parent/child relationship would be value typed (e.g. a " +"collection of addresses or strings), their life cycle would depend on the " +"parent and no further action would be required for convenient \"cascading\" " +"of state changes. When the parent is saved, the value-typed child objects " +"are saved as well, when the parent is deleted, the children will be deleted, " +"etc. This even works for operations such as the removal of a child from the " +"collection; Hibernate will detect this and, since value-typed objects can't " +"have shared references, delete the child from the database." msgstr "" +"如果一个父子关系中的子对象是值类型(value typed)(例如,地址或字符串的集合)" +"的,他们的生命周期会依赖于父对象,可以享受方便的级联操作(Cascading),不需要额" +"外的动作。 父对象被保存时,这些值类型(value typed)子对象也将被保存;父对象被" +"删除时,子对象也将被删除。 这对将一个子对象从集合中移除是同样有效:Hibernate" +"会检测到,并且因为值类型(value typed)的对象不可能被其他对象引用,所以" +"Hibernate会在数据库中删除这个子对象。" -#: index.docbook:903 -msgid "Now consider the same scenario with parent and child objects being entities, not value-types (e.g. categories and items, or parent and child cats). Entities have their own life cycle, support shared references (so removing an entity from the collection does not mean it can be deleted), and there is by default no cascading of state from one entity to any other associated entities. Hibernate does not implement persistence by reachability by default." +#. Tag: para +#: session_api.xml:903 +#, no-c-format +msgid "" +"Now consider the same scenario with parent and child objects being entities, " +"not value-types (e.g. categories and items, or parent and child cats). " +"Entities have their own life cycle, support shared references (so removing " +"an entity from the collection does not mean it can be deleted), and there is " +"by default no cascading of state from one entity to any other associated " +"entities. Hibernate does not implement persistence by " +"reachability by default." msgstr "" +"现在考虑同样的场景,不过父子对象都是实体(entities)类型,而非值类型(value " +"typed)(例如,类别与个体,或母猫和小猫)。 实体有自己的生命期,允许共享对其的" +"引用(因此从集合中移除一个实体,不意味着它可以被删除), 并且实体到其他关联实" +"体之间默认没有级联操作的设置。 Hibernate默认不实现所谓的可到达即持" +"久化(persistence by reachability)的策略。" -#: index.docbook:912 -msgid "For each basic operation of the Hibernate session - including persist(), merge(), saveOrUpdate(), delete(), lock(), refresh(), evict(), replicate() - there is a corresponding cascade style. Respectively, the cascade styles are named create, merge, save-update, delete, lock, refresh, evict, replicate. If you want an operation to be cascaded along an association, you must indicate that in the mapping document. For example:" +#. Tag: para +#: session_api.xml:912 +#, no-c-format +msgid "" +"For each basic operation of the Hibernate session - including " +"persist(), merge(), saveOrUpdate(), delete(), lock(), refresh(), " +"evict(), replicate() - there is a corresponding cascade style. " +"Respectively, the cascade styles are named create, merge, save-" +"update, delete, lock, refresh, evict, replicate. If you want an " +"operation to be cascaded along an association, you must indicate that in the " +"mapping document. For example:" msgstr "" +"每个Hibernate session的基本操作 - 包括 persist(), merge(), " +"saveOrUpdate(), delete(), lock(), refresh(), evict(), replicate() " +"- 都有对应的级联风格(cascade style)。 这些级联风格(cascade style)风格分别命名" +"为 create, merge, save-update, delete, lock, refresh, evict, " +"replicate。 如果你希望一个操作被顺着关联关系级联传播,你必须在映射" +"文件中指出这一点。例如:" -#: index.docbook:921 +#. Tag: programlisting +#: session_api.xml:921 +#, no-c-format msgid "]]>" msgstr "" -#: index.docbook:923 +#. Tag: para +#: session_api.xml:923 +#, no-c-format msgid "Cascade styles my be combined:" -msgstr "" +msgstr "级联风格(cascade style)是可组合的:" -#: index.docbook:927 -msgid "]]>" -msgstr "" - -#: index.docbook:929 -msgid "You may even use cascade=\"all\" to specify that all operations should be cascaded along the association. The default cascade=\"none\" specifies that no operations are to be cascaded." -msgstr "" - -#: index.docbook:935 -msgid "A special cascade style, delete-orphan, applies only to one-to-many associations, and indicates that the delete() operation should be applied to any child object that is removed from the association." -msgstr "" - -#: index.docbook:942 -msgid "Recommendations:" -msgstr "" - -#: index.docbook:948 -msgid "It doesn't usually make sense to enable cascade on a <many-to-one> or <many-to-many> association. Cascade is often useful for <one-to-one> and <one-to-many> associations." -msgstr "" - -#: index.docbook:956 -msgid "If the child object's lifespan is bounded by the lifespan of the parent object, make it a life cycle object by specifying cascade=\"all,delete-orphan\"." -msgstr "" - -#: index.docbook:963 -msgid "Otherwise, you might not need cascade at all. But if you think that you will often be working with the parent and children together in the same transaction, and you want to save yourself some typing, consider using cascade=\"persist,merge,save-update\"." -msgstr "" - -#: index.docbook:971 -msgid "Mapping an association (either a single valued association, or a collection) with cascade=\"all\" marks the association as a parent/child style relationship where save/update/delete of the parent results in save/update/delete of the child or children." -msgstr "" - -#: index.docbook:977 -msgid "Futhermore, a mere reference to a child from a persistent parent will result in save/update of the child. This metaphor is incomplete, however. A child which becomes unreferenced by its parent is not automatically deleted, except in the case of a <one-to-many> association mapped with cascade=\"delete-orphan\". The precise semantics of cascading operations for a parent/child relationship are as follows:" -msgstr "" - -#: index.docbook:988 -msgid "If a parent is passed to persist(), all children are passed to persist()" -msgstr "" - -#: index.docbook:994 -msgid "If a parent is passed to merge(), all children are passed to merge()" -msgstr "" - -#: index.docbook:1000 -msgid "If a parent is passed to save(), update() or saveOrUpdate(), all children are passed to saveOrUpdate()" -msgstr "" - -#: index.docbook:1006 -msgid "If a transient or detached child becomes referenced by a persistent parent, it is passed to saveOrUpdate()" -msgstr "" - -#: index.docbook:1012 -msgid "If a parent is deleted, all children are passed to delete()" -msgstr "" - -#: index.docbook:1017 -msgid "If a child is dereferenced by a persistent parent, nothing special happens - the application should explicitly delete the child if necessary - unless cascade=\"delete-orphan\", in which case the \"orphaned\" child is deleted." -msgstr "" - -#: index.docbook:1026 -msgid "Finally, note that cascading of operations can be applied to an object graph at call time or at flush time. All operations, if enabled, are cascaded to associated entities reachable when the operation is executed. However, save-upate and delete-orphan are transitive for all associated entities reachable during flush of the Session." -msgstr "" - -#: index.docbook:1038 -msgid "Using metadata" -msgstr "" - -#: index.docbook:1040 -msgid "Hibernate requires a very rich meta-level model of all entity and value types. From time to time, this model is very useful to the application itself. For example, the application might use Hibernate's metadata to implement a \"smart\" deep-copy algorithm that understands which objects should be copied (eg. mutable value types) and which should not (eg. immutable value types and, possibly, associated entities)." -msgstr "" - -#: index.docbook:1047 -msgid "Hibernate exposes metadata via the ClassMetadata and CollectionMetadata interfaces and the Type hierarchy. Instances of the metadata interfaces may be obtained from the SessionFactory." -msgstr "" - -#: index.docbook:1054 +#. Tag: programlisting +#: session_api.xml:927 +#, no-c-format msgid "" - "" +"]]>" msgstr "" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" +#. Tag: para +#: session_api.xml:929 +#, no-c-format +msgid "" +"You may even use cascade=\"all\" to specify that " +"all operations should be cascaded along the " +"association. The default cascade=\"none\" specifies that " +"no operations are to be cascaded." +msgstr "" +"你可以使用cascade=\"all\"来指定全部操" +"作都顺着关联关系级联(cascaded)。 默认值是cascade=\"none\",即任何操作都不会被级联(cascaded)。" -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" +#. Tag: para +#: session_api.xml:935 +#, no-c-format +msgid "" +"A special cascade style, delete-orphan, applies only to " +"one-to-many associations, and indicates that the delete() " +"operation should be applied to any child object that is removed from the " +"association." +msgstr "" +"注意有一个特殊的级联风格(cascade style) delete-orphan,只" +"应用于one-to-many关联,表明delete()操作 应该被应用于所有从" +"关联中删除的对象。" +#. Tag: para +#: session_api.xml:942 +#, no-c-format +msgid "Recommendations:" +msgstr "建议:" + +#. Tag: para +#: session_api.xml:948 +#, no-c-format +msgid "" +"It doesn't usually make sense to enable cascade on a <many-to-" +"one> or <many-to-many> association. " +"Cascade is often useful for <one-to-one> and " +"<one-to-many> associations." +msgstr "" +"通常在<many-to-one><many-to-many>关系中应用级联(cascade)没什么意义。 级联(cascade)通常在 <" +"one-to-one><one-to-many>关系中比较有" +"用。" + +#. Tag: para +#: session_api.xml:956 +#, no-c-format +msgid "" +"If the child object's lifespan is bounded by the lifespan of the parent " +"object, make it a life cycle object by specifying " +"cascade=\"all,delete-orphan\"." +msgstr "" +"如果子对象的寿命限定在父亲对象的寿命之内,可通过指定cascade=\"all," +"delete-orphan\"将其变为自动生命周期管理的对象(life cycle " +"object)。" + +#. Tag: para +#: session_api.xml:963 +#, no-c-format +msgid "" +"Otherwise, you might not need cascade at all. But if you think that you will " +"often be working with the parent and children together in the same " +"transaction, and you want to save yourself some typing, consider using " +"cascade=\"persist,merge,save-update\"." +msgstr "" +"其他情况,你可根本不需要级联(cascade)。但是如果你认为你会经常在某个事务中同时" +"用到父对象与子对象,并且你希望少打点儿字,可以考虑使用cascade=" +"\"persist,merge,save-update\"。" + +#. Tag: para +#: session_api.xml:971 +#, no-c-format +msgid "" +"Mapping an association (either a single valued association, or a collection) " +"with cascade=\"all\" marks the association as a " +"parent/child style relationship where save/update/" +"delete of the parent results in save/update/delete of the child or children." +msgstr "" +"可以使用cascade=\"all\"将一个关联关系(无论是对值对象的关" +"联,或者对一个集合的关联)标记为父/子关系的关联。 这样对" +"父对象进行save/update/delete操作就会导致子对象也进行save/update/delete操作。" + +#. Tag: para +#: session_api.xml:977 +#, no-c-format +msgid "" +"Futhermore, a mere reference to a child from a persistent parent will result " +"in save/update of the child. This metaphor is incomplete, however. A child " +"which becomes unreferenced by its parent is not " +"automatically deleted, except in the case of a <one-to-many> association mapped with cascade=\"delete-orphan\". The precise semantics of cascading operations for a parent/child " +"relationship are as follows:" +msgstr "" +"此外,一个持久的父对象对子对象的浅引用(mere reference)会导致子对象被同步save/" +"update。 不过,这个隐喻(metaphor)的说法并不完整。除非关联是<one-" +"to-many>关联并且被标记为cascade=\"delete-orphan\", 否则父对象失去对某个子对象的引用不会导致该子" +"对象被自动删除。 父子关系的级联(cascading)操作准确语义如下:" + +#. Tag: para +#: session_api.xml:988 +#, no-c-format +msgid "" +"If a parent is passed to persist(), all children are " +"passed to persist()" +msgstr "" +"如果父对象被persist(),那么所有子对象也会被" +"persist()" + +#. Tag: para +#: session_api.xml:994 +#, no-c-format +msgid "" +"If a parent is passed to merge(), all children are passed " +"to merge()" +msgstr "" +"如果父对象被merge(),那么所有子对象也会被merge()" +"" + +#. Tag: para +#: session_api.xml:1000 +#, no-c-format +msgid "" +"If a parent is passed to save(), update() or saveOrUpdate(), all children are passed to " +"saveOrUpdate()" +msgstr "" +"如果父对象被save()update()或 " +"saveOrUpdate(),那么所有子对象则会被saveOrUpdate" +"()" + +#. Tag: para +#: session_api.xml:1006 +#, no-c-format +msgid "" +"If a transient or detached child becomes referenced by a persistent parent, " +"it is passed to saveOrUpdate()" +msgstr "" +"如果某个持久的父对象引用了瞬时(transient)或者脱管(detached)的子对象,那么子对" +"象将会被saveOrUpdate()" + +#. Tag: para +#: session_api.xml:1012 +#, no-c-format +msgid "" +"If a parent is deleted, all children are passed to delete()" +msgstr "如果父对象被删除,那么所有子对象也会被delete()" + +#. Tag: para +#: session_api.xml:1017 +#, no-c-format +msgid "" +"If a child is dereferenced by a persistent parent, nothing special " +"happens - the application should explicitly delete the child if " +"necessary - unless cascade=\"delete-orphan\", in which " +"case the \"orphaned\" child is deleted." +msgstr "" +"除非被标记为cascade=\"delete-orphan\"(删除“孤儿”模式,此" +"时不被任何一个父对象引用的子对象会被删除), 否则子对象失掉父对象对其的引用" +"时,什么事也不会发生。 如果有特殊需要,应用程序可通过显" +"式调用delete()删除子对象。" + +#. Tag: para +#: session_api.xml:1026 +#, no-c-format +msgid "" +"Finally, note that cascading of operations can be applied to an object graph " +"at call time or at flush time. All " +"operations, if enabled, are cascaded to associated entities reachable when " +"the operation is executed. However, save-upate and " +"delete-orphan are transitive for all associated entities " +"reachable during flush of the Session." +msgstr "" +"最后,注意操作的级联可能是在调用期(call time)或者" +"写入期(flush time)作用到对象图上的。所有的操作,如果允" +"许,都在操作被执行的时候级联到可触及的关联实体上。然而,save-upatedelete-orphan是在Session " +"flush的时候才作用到所有可触及的被关联对象上的。" + +#. Tag: title +#: session_api.xml:1038 +#, no-c-format +msgid "Using metadata" +msgstr "使用元数据" + +#. Tag: para +#: session_api.xml:1040 +#, no-c-format +msgid "" +"Hibernate requires a very rich meta-level model of all entity and value " +"types. From time to time, this model is very useful to the application " +"itself. For example, the application might use Hibernate's metadata to " +"implement a \"smart\" deep-copy algorithm that understands which objects " +"should be copied (eg. mutable value types) and which should not (eg. " +"immutable value types and, possibly, associated entities)." +msgstr "" +"Hibernate中有一个非常丰富的元级别(meta-level)的模型,含有所有的实体和值类型数" +"据的元数据。 有时这个模型对应用程序本身也会非常有用。 比如说,应用程序可能在" +"实现一种“智能”的深度拷贝算法时, 通过使用Hibernate的元数据来了解哪些对象应该" +"被拷贝(比如,可变的值类型数据), 那些不应该(不可变的值类型数据,也许还有某" +"些被关联的实体)。" + +#. Tag: para +#: session_api.xml:1047 +#, no-c-format +msgid "" +"Hibernate exposes metadata via the ClassMetadata and " +"CollectionMetadata interfaces and the Type hierarchy. Instances of the metadata interfaces may be obtained " +"from the SessionFactory." +msgstr "" +"Hibernate提供了ClassMetadata接口," +"CollectionMetadata接口和Type层次体系来" +"访问元数据。 可以通过SessionFactory获取元数据接口的实例。" + +#. Tag: programlisting +#: session_api.xml:1054 +#, no-c-format +msgid "" +"" +msgstr "" + +#~ msgid "UPDATE" +#~ msgstr "UPDATE" + +#~ msgid "DELETE" +#~ msgstr "DELETE" + +#~ msgid "state management" +#~ msgstr "状态管理(state management)" + +#~ msgid "statements" +#~ msgstr "语句(statements)" + +#~ msgid "Connection" +#~ msgstr "session.connection()" + +#~ msgid "session.connection()" +#~ msgstr "Connection" diff --git a/documentation/manual/translations/zh-CN/content/toolset_guide.po b/documentation/manual/translations/zh-CN/content/toolset_guide.po index 7f456a0828..42c6aef581 100644 --- a/documentation/manual/translations/zh-CN/content/toolset_guide.po +++ b/documentation/manual/translations/zh-CN/content/toolset_guide.po @@ -1,744 +1,1183 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: toolset_guide.xml:5 +#, no-c-format msgid "Toolset Guide" msgstr "工具箱指南" -#: index.docbook:7 -msgid "Roundtrip engineering with Hibernate is possible using a set of Eclipse plugins, commandline tools, as well as Ant tasks." -msgstr "可以通过一系列Eclipse插件、命令行工具和Ant任务来进行与Hibernate关联的转换。" +#. Tag: para +#: toolset_guide.xml:7 +#, no-c-format +msgid "" +"Roundtrip engineering with Hibernate is possible using a set of Eclipse " +"plugins, commandline tools, as well as Ant tasks." +msgstr "" +"可以通过一系列Eclipse插件、命令行工具和Ant任务来进行与Hibernate关联的转换。" -#: index.docbook:12 -msgid "The Hibernate Tools currently include plugins for the Eclipse IDE as well as Ant tasks for reverse engineering of existing databases:" -msgstr "除了Ant任务外,当前的Hibernate Tools也包含了Eclipse IDE的插件,用于与现存数据库的逆向工程。" +#. Tag: para +#: toolset_guide.xml:12 +#, no-c-format +msgid "" +"The Hibernate Tools currently include plugins for the " +"Eclipse IDE as well as Ant tasks for reverse engineering of existing " +"databases:" +msgstr "" +"除了Ant任务外,当前的Hibernate Tools也包含了Eclipse IDE" +"的插件,用于与现存数据库的逆向工程。" -#: index.docbook:18 -msgid "Mapping Editor: An editor for Hibernate XML mapping files, supporting auto-completion and syntax highlighting. It also supports semantic auto-completion for class names and property/field names, making it much more versatile than a normal XML editor." -msgstr "Mapping Editor: Hibernate XML映射文件的编辑器,支持自动完成和语法高亮。它也支持对类名和属性/字段名的语义自动完成,比通常的XML编辑器方便得多。" +#. Tag: para +#: toolset_guide.xml:18 +#, no-c-format +msgid "" +"Mapping Editor: An editor for Hibernate XML mapping " +"files, supporting auto-completion and syntax highlighting. It also supports " +"semantic auto-completion for class names and property/field names, making it " +"much more versatile than a normal XML editor." +msgstr "" +"Mapping Editor: Hibernate XML映射文件的编辑器,支持自动" +"完成和语法高亮。它也支持对类名和属性/字段名的语义自动完成,比通常的XML编辑器" +"方便得多。" -#: index.docbook:23 -msgid "Console: The console is a new view in Eclipse. In addition to a tree overview of your console configurations, you also get an interactive view of your persistent classes and their relationships. The console allows you to execute HQL queries against your database and browse the result directly in Eclipse." -msgstr "Console: Console是Eclipse的一个新视图。除了对你的console配置的树状概览,你还可以获得对你持久化类及其关联的交互式视图。Console允许你对数据库执行HQL查询,并直接在Eclipse中浏览结果。" +#. Tag: para +#: toolset_guide.xml:23 +#, no-c-format +msgid "" +"Console: The console is a new view in Eclipse. In " +"addition to a tree overview of your console configurations, you also get an " +"interactive view of your persistent classes and their relationships. The " +"console allows you to execute HQL queries against your database and browse " +"the result directly in Eclipse." +msgstr "" +"Console: Console是Eclipse的一个新视图。除了对你的console" +"配置的树状概览,你还可以获得对你持久化类及其关联的交互式视图。Console允许你对" +"数据库执行HQL查询,并直接在Eclipse中浏览结果。" -#: index.docbook:30 -msgid "Development Wizards: Several wizards are provided with the Hibernate Eclipse tools; you can use a wizard to quickly generate Hibernate configuration (cfg.xml) files, or you may even completely reverse engineer an existing database schema into POJO source files and Hibernate mapping files. The reverse engineering wizard supports customizable templates." -msgstr "Development Wizards: 在Hibernate Eclipse tools中还提供了几个向导;你可以用向导快速生成Hibernate 配置文件(cfg.xml),你甚至还可以同现存的数据库schema中反向工程出POJO源代码与Hibernate 映射文件。反向工程支持可定制的模版。" +#. Tag: para +#: toolset_guide.xml:30 +#, no-c-format +msgid "" +"Development Wizards: Several wizards are provided with " +"the Hibernate Eclipse tools; you can use a wizard to quickly generate " +"Hibernate configuration (cfg.xml) files, or you may even completely reverse " +"engineer an existing database schema into POJO source files and Hibernate " +"mapping files. The reverse engineering wizard supports customizable " +"templates." +msgstr "" +"Development Wizards: 在Hibernate Eclipse tools中还提供了" +"几个向导;你可以用向导快速生成Hibernate 配置文件(cfg.xml),你甚至还可以同现" +"存的数据库schema中反向工程出POJO源代码与Hibernate 映射文件。反向工程支持可定" +"制的模版。" -#: index.docbook:38 +#. Tag: emphasis +#: toolset_guide.xml:38 +#, no-c-format msgid "Ant Tasks:" msgstr "Ant Tasks:" -#: index.docbook:43 -msgid "Please refer to the Hibernate Tools package and it's documentation for more information." -msgstr "要得到更多信息,请查阅 Hibernate Tools 包及其文档。" +#. Tag: para +#: toolset_guide.xml:43 +#, no-c-format +msgid "" +"Please refer to the Hibernate Tools package and it's " +"documentation for more information." +msgstr "" +"要得到更多信息,请查阅 Hibernate Tools 包及其文档。" -#: index.docbook:48 -msgid "However, the Hibernate main package comes bundled with an integrated tool (it can even be used from \"inside\" Hibernate on-the-fly): SchemaExport aka hbm2ddl." -msgstr "同时,Hibernate主发行包还附带了一个集成的工具(它甚至可以在Hibernate“内部”快速运行)SchemaExport ,也就是 hbm2ddl。" +#. Tag: para +#: toolset_guide.xml:48 +#, no-c-format +msgid "" +"However, the Hibernate main package comes bundled with an integrated tool " +"(it can even be used from \"inside\" Hibernate on-the-fly): " +"SchemaExport aka hbm2ddl." +msgstr "" +"同时,Hibernate主发行包还附带了一个集成的工具(它甚至可以在Hibernate“内部”快" +"速运行)SchemaExport ,也就是 hbm2ddl。" -#: index.docbook:55 +#. Tag: title +#: toolset_guide.xml:55 +#, no-c-format msgid "Automatic schema generation" msgstr "Schema自动生成(Automatic schema generation)" -#: index.docbook:57 -msgid "DDL may be generated from your mapping files by a Hibernate utility. The generated schema includes referential integrity constraints (primary and foreign keys) for entity and collection tables. Tables and sequences are also created for mapped identifier generators." -msgstr "可以从你的映射文件使用一个Hibernate工具生成DDL。 生成的schema包含有对实体和集合类表的完整性引用约束(主键和外键)。涉及到的标示符生成器所需的表和sequence也会同时生成。" +#. Tag: para +#: toolset_guide.xml:57 +#, no-c-format +msgid "" +"DDL may be generated from your mapping files by a Hibernate utility. The " +"generated schema includes referential integrity constraints (primary and " +"foreign keys) for entity and collection tables. Tables and sequences are " +"also created for mapped identifier generators." +msgstr "" +"可以从你的映射文件使用一个Hibernate工具生成DDL。 生成的schema包含有对实体和集" +"合类表的完整性引用约束(主键和外键)。涉及到的标示符生成器所需的表和sequence" +"也会同时生成。" -#: index.docbook:64 -msgid "You must specify a SQL Dialect via the hibernate.dialect property when using this tool, as DDL is highly vendor specific." -msgstr "在使用这个工具的时候,你必须 通过hibernate.dialet属性指定一个SQL方言(Dialet),因为DDL是与供应商高度相关的。" +#. Tag: para +#: toolset_guide.xml:64 +#, no-c-format +msgid "" +"You must specify a SQL Dialect via " +"the hibernate.dialect property when using this tool, as " +"DDL is highly vendor specific." +msgstr "" +"在使用这个工具的时候,你必须 通过hibernate." +"dialet属性指定一个SQL方言(Dialet),因为DDL是与供" +"应商高度相关的。" -#: index.docbook:70 +#. Tag: para +#: toolset_guide.xml:70 +#, no-c-format msgid "First, customize your mapping files to improve the generated schema." msgstr "首先,要定制你的映射文件,来改善生成的schema。" -#: index.docbook:75 +#. Tag: title +#: toolset_guide.xml:75 +#, no-c-format msgid "Customizing the schema" msgstr "对schema定制化(Customizing the schema)" -#: index.docbook:77 -msgid "Many Hibernate mapping elements define optional attributes named length, precision and scale. You may set the length, precision and scale of a column with this attribute." -msgstr "很多Hibernate映射元素定义了可选的lengthprecision 或者 scale属性。你可以通过这个属性设置字段的长度、精度、小数点位数。" +#. Tag: para +#: toolset_guide.xml:77 +#, no-c-format +msgid "" +"Many Hibernate mapping elements define optional attributes named " +"length, precision and scale. You may set the length, precision and scale of a column with this " +"attribute." +msgstr "" +"很多Hibernate映射元素定义了可选的length、" +"precision 或者 scale属性。你可以通过这" +"个属性设置字段的长度、精度、小数点位数。" -#: index.docbook:84 +#. Tag: programlisting +#: toolset_guide.xml:84 +#, no-c-format msgid "]]>" -msgstr "]]>" +msgstr "" -#: index.docbook:85 +#. Tag: programlisting +#: toolset_guide.xml:85 +#, no-c-format msgid "]]>" -msgstr "]]>" - -#: index.docbook:87 -msgid "Some tags also accept a not-null attribute (for generating a NOT NULL constraint on table columns) and a unique attribute (for generating UNIQUE constraint on table columns)." -msgstr "有些tag还接受not-null属性(用来在表字段上生成NOT NULL约束)和unique属性(用来在表字段上生成UNIQUE约束)。" - -#: index.docbook:93 -msgid "]]>" -msgstr "]]>" - -#: index.docbook:95 -msgid "]]>" -msgstr "]]>" - -#: index.docbook:97 -msgid "A unique-key attribute may be used to group columns in a single unique key constraint. Currently, the specified value of the unique-key attribute is not used to name the constraint in the generated DDL, only to group the columns in the mapping file." -msgstr "unique-key属性可以对成组的字段指定一个唯一键约束(unique key constraint)。目前,unique-key属性指定的值在生成DDL时并不会被当作这个约束的名字,它们只是在用来在映射文件内部用作区分的。" - -#: index.docbook:105 -msgid "" - "\n" - "]]>" msgstr "" - "\n" - "]]>" -#: index.docbook:107 -msgid "An index attribute specifies the name of an index that will be created using the mapped column or columns. Multiple columns may be grouped into the same index, simply by specifying the same index name." -msgstr "index属性会用对应的字段(一个或多个)生成一个index,它指出了这个index的名字。如果多个字段对应的index名字相同,就会生成包含这些字段的index。" - -#: index.docbook:113 +#. Tag: para +#: toolset_guide.xml:87 +#, no-c-format msgid "" - "\n" - "]]>" +"Some tags also accept a not-null attribute (for " +"generating a NOT NULL constraint on table columns) and a " +"unique attribute (for generating UNIQUE constraint on table columns)." msgstr "" - "\n" - "]]>" +"有些tag还接受not-null属性(用来在表字段上生成NOT " +"NULL约束)和unique属性(用来在表字段上生成" +"UNIQUE约束)。" -#: index.docbook:115 -msgid "A foreign-key attribute may be used to override the name of any generated foreign key constraint." -msgstr "foreign-key属性可以用来覆盖任何生成的外键约束的名字。" - -#: index.docbook:120 -msgid "]]>" -msgstr "]]>" - -#: index.docbook:122 -msgid "Many mapping elements also accept a child <column> element. This is particularly useful for mapping multi-column types:" -msgstr "很多映射元素还接受<column>子元素。这在定义跨越多字段的类型时特别有用。" - -#: index.docbook:127 +#. Tag: programlisting +#: toolset_guide.xml:93 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - "]]>" +"]]>" msgstr "" - "\n" - " \n" - " \n" - " \n" - "]]>" -#: index.docbook:129 -msgid "The default attribute lets you specify a default value for a column (you should assign the same value to the mapped property before saving a new instance of the mapped class)." -msgstr "default属性为字段指定一个默认值 (在保存被映射的类的新实例之前,你应该将同样的值赋于对应的属性)。" - -#: index.docbook:135 +#. Tag: programlisting +#: toolset_guide.xml:95 +#, no-c-format msgid "" - "\n" - " \n" - "]]>" +"]]>" msgstr "" - "\n" - " \n" - "]]>" -#: index.docbook:137 +#. Tag: para +#: toolset_guide.xml:97 +#, no-c-format msgid "" - "\n" - " \n" - "]]>" +"A unique-key attribute may be used to group columns in a " +"single unique key constraint. Currently, the specified value of the " +"unique-key attribute is not used to " +"name the constraint in the generated DDL, only to group the columns in the " +"mapping file." msgstr "" - "\n" - " \n" - "]]>" +"unique-key属性可以对成组的字段指定一个唯一键约束(unique " +"key constraint)。目前,unique-key属性指定的值在生成DDL时" +"并不会被当作这个约束的名字,它们只是在用来在映射文件内部" +"用作区分的。" -#: index.docbook:139 -msgid "The sql-type attribute allows the user to override the default mapping of a Hibernate type to SQL datatype." -msgstr "sql-type属性允许用户覆盖默认的Hibernate类型到SQL数据类型的映射。" - -#: index.docbook:144 +#. Tag: programlisting +#: toolset_guide.xml:105 +#, no-c-format msgid "" - "\n" - " \n" - "]]>" +"\n" +"]]>" msgstr "" - "\n" - " \n" - "]]>" -#: index.docbook:146 -msgid "The check attribute allows you to specify a check constraint." +#. Tag: para +#: toolset_guide.xml:107 +#, no-c-format +msgid "" +"An index attribute specifies the name of an index that " +"will be created using the mapped column or columns. Multiple columns may be " +"grouped into the same index, simply by specifying the same index name." +msgstr "" +"index属性会用对应的字段(一个或多个)生成一个index,它指出" +"了这个index的名字。如果多个字段对应的index名字相同,就会生成包含这些字段的" +"index。" + +#. Tag: programlisting +#: toolset_guide.xml:113 +#, no-c-format +msgid "" +"\n" +"]]>" +msgstr "" + +#. Tag: para +#: toolset_guide.xml:115 +#, no-c-format +msgid "" +"A foreign-key attribute may be used to override the name " +"of any generated foreign key constraint." +msgstr "" +"foreign-key属性可以用来覆盖任何生成的外键约束的名字。" + +#. Tag: programlisting +#: toolset_guide.xml:120 +#, no-c-format +msgid "" +"]]>" +msgstr "" + +#. Tag: para +#: toolset_guide.xml:122 +#, no-c-format +msgid "" +"Many mapping elements also accept a child <column> " +"element. This is particularly useful for mapping multi-column types:" +msgstr "" +"很多映射元素还接受<column>子元素。这在定义跨越多字段" +"的类型时特别有用。" + +#. Tag: programlisting +#: toolset_guide.xml:127 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: toolset_guide.xml:129 +#, no-c-format +msgid "" +"The default attribute lets you specify a default value " +"for a column (you should assign the same value to the mapped property before " +"saving a new instance of the mapped class)." +msgstr "" +"default属性为字段指定一个默认值 (在保存被映射的类的新实例" +"之前,你应该将同样的值赋于对应的属性)。" + +#. Tag: programlisting +#: toolset_guide.xml:135 +#, no-c-format +msgid "" +"\n" +" \n" +"]]>" +msgstr "" + +#. Tag: programlisting +#: toolset_guide.xml:137 +#, no-c-format +msgid "" +"\n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: toolset_guide.xml:139 +#, no-c-format +msgid "" +"The sql-type attribute allows the user to override the " +"default mapping of a Hibernate type to SQL datatype." +msgstr "" +"sql-type属性允许用户覆盖默认的Hibernate类型到SQL数据类型的" +"映射。" + +#. Tag: programlisting +#: toolset_guide.xml:144 +#, no-c-format +msgid "" +"\n" +" \n" +"]]>" +msgstr "" + +#. Tag: para +#: toolset_guide.xml:146 +#, no-c-format +msgid "" +"The check attribute allows you to specify a check " +"constraint." msgstr "check属性允许用户指定一个约束检查。" -#: index.docbook:150 +#. Tag: programlisting +#: toolset_guide.xml:150 +#, no-c-format msgid "" - "\n" - " 10\"/>\n" - "]]>" +"\n" +" 10\"/>\n" +"]]>" msgstr "" - "\n" - " 10\"/>\n" - "]]>" -#: index.docbook:152 +#. Tag: programlisting +#: toolset_guide.xml:152 +#, no-c-format msgid "" - "\n" - " ...\n" - " \n" - "]]>" +"\n" +" ...\n" +" \n" +"]]>" msgstr "" - "\n" - " ...\n" - " \n" - "]]>" -#: index.docbook:156 +#. Tag: title +#: toolset_guide.xml:156 +#, no-c-format msgid "Summary" msgstr "Summary" -#: index.docbook:163 +#. Tag: entry +#: toolset_guide.xml:163 +#, no-c-format msgid "Attribute" msgstr "属性(Attribute)" -#: index.docbook:164 +#. Tag: entry +#: toolset_guide.xml:164 +#, no-c-format msgid "Values" msgstr "值(Values)" -#: index.docbook:165 +#. Tag: entry +#: toolset_guide.xml:165 +#, no-c-format msgid "Interpretation" msgstr "解释(Interpretation)" -#: index.docbook:170 +#. Tag: literal +#: toolset_guide.xml:170 +#, no-c-format msgid "length" msgstr "length" -#: index.docbook:171, index.docbook:176, index.docbook:181 +#. Tag: entry +#: toolset_guide.xml:171 toolset_guide.xml:176 toolset_guide.xml:181 +#, no-c-format msgid "number" -msgstr "数字" +msgstr "数字" -#: index.docbook:172 +#. Tag: entry +#: toolset_guide.xml:172 +#, no-c-format msgid "column length" msgstr "字段长度" -#: index.docbook:175 +#. Tag: literal +#: toolset_guide.xml:175 +#, no-c-format msgid "precision" msgstr "precision" -#: index.docbook:177 +#. Tag: entry +#: toolset_guide.xml:177 +#, no-c-format msgid "column decimal precision" msgstr "精度(decimal precision)" -#: index.docbook:180 +#. Tag: literal +#: toolset_guide.xml:180 +#, no-c-format msgid "scale" msgstr "scale" -#: index.docbook:182 +#. Tag: entry +#: toolset_guide.xml:182 +#, no-c-format msgid "column decimal scale" msgstr "小数点位数(decimal scale)" -#: index.docbook:185 +#. Tag: literal +#: toolset_guide.xml:185 +#, no-c-format msgid "not-null" msgstr "not-null" -#: index.docbook:186, index.docbook:191 +#. Tag: literal +#: toolset_guide.xml:186 toolset_guide.xml:191 +#, no-c-format msgid "true|false" msgstr "true|false" -#: index.docbook:187 +#. Tag: entry +#: toolset_guide.xml:187 +#, no-c-format msgid "specfies that the column should be non-nullable" msgstr "指明字段是否应该是非空的" -#: index.docbook:190 +#. Tag: literal +#: toolset_guide.xml:190 +#, no-c-format msgid "unique" msgstr "unique" -#: index.docbook:192 +#. Tag: entry +#: toolset_guide.xml:192 +#, no-c-format msgid "specifies that the column should have a unique constraint" msgstr "指明是否该字段具有惟一约束" -#: index.docbook:195 +#. Tag: literal +#: toolset_guide.xml:195 +#, no-c-format msgid "index" msgstr "index" -#: index.docbook:196 +#. Tag: literal +#: toolset_guide.xml:196 +#, no-c-format msgid "index_name" msgstr "index_name" -#: index.docbook:197 +#. Tag: entry +#: toolset_guide.xml:197 +#, no-c-format msgid "specifies the name of a (multi-column) index" msgstr "指明一个(多字段)的索引(index)的名字" -#: index.docbook:200 +#. Tag: literal +#: toolset_guide.xml:200 +#, no-c-format msgid "unique-key" msgstr "unique-key" -#: index.docbook:201 +#. Tag: literal +#: toolset_guide.xml:201 +#, no-c-format msgid "unique_key_name" msgstr "unique_key_name" -#: index.docbook:202 +#. Tag: entry +#: toolset_guide.xml:202 +#, no-c-format msgid "specifies the name of a multi-column unique constraint" msgstr "指明多字段惟一约束的名字(参见上面的说明)" -#: index.docbook:205 +#. Tag: literal +#: toolset_guide.xml:205 +#, no-c-format msgid "foreign-key" msgstr "foreign-key" -#: index.docbook:206 +#. Tag: literal +#: toolset_guide.xml:206 +#, no-c-format msgid "foreign_key_name" msgstr "foreign_key_name" -#: index.docbook:207 -msgid "specifies the name of the foreign key constraint generated for an association, for a <one-to-one>, <many-to-one>, <key>, or <many-to-many> mapping element. Note that inverse=\"true\" sides will not be considered by SchemaExport." -msgstr "specifies the name of the foreign key constraint generated for an association, for a <one-to-one>, <many-to-one>, <key>, or <many-to-many> mapping element. Note that inverse=\"true\" sides will not be considered by SchemaExport. 指明一个外键的名字,它是为关联生成的,或者<one-to-one><many-to-one>, <key>, 或者<many-to-many>映射元素。注意inverse=\"true\"SchemaExport时会被忽略。" +#. Tag: entry +#: toolset_guide.xml:207 +#, fuzzy, no-c-format +msgid "" +"specifies the name of the foreign key constraint generated for an " +"association, for a <one-to-one>, <many-" +"to-one>, <key>, or <many-" +"to-many> mapping element. Note that inverse=\"true\" sides will not be considered by SchemaExport." +msgstr "" +"指明一个外键的名字,它是为关联生成的,或者, , 或者映射元素。注意在" +"时会被忽略。" -#: index.docbook:217 +#. Tag: literal +#: toolset_guide.xml:217 +#, no-c-format msgid "sql-type" msgstr "sql-type" -#: index.docbook:218 +#. Tag: literal +#: toolset_guide.xml:218 +#, no-c-format msgid "SQL column type" msgstr "SQL 字段类型" -#: index.docbook:219 -msgid "overrides the default column type (attribute of <column> element only)" -msgstr "覆盖默认的字段类型(只能用于<column>属性)" +#. Tag: entry +#: toolset_guide.xml:219 +#, fuzzy, no-c-format +msgid "" +"overrides the default column type (attribute of <column> element only)" +msgstr "覆盖默认的字段类型(只能用于属性)" -#: index.docbook:225 +#. Tag: literal +#: toolset_guide.xml:225 +#, no-c-format msgid "default" msgstr "default" -#: index.docbook:226, index.docbook:233 +#. Tag: entry +#: toolset_guide.xml:226 toolset_guide.xml:233 +#, fuzzy, no-c-format msgid "SQL expression" -msgstr "SQL表达式" +msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"SQL表达式\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"SQL 表达式" -#: index.docbook:227 +#. Tag: entry +#: toolset_guide.xml:227 +#, no-c-format msgid "specify a default value for the column" msgstr "为字段指定默认值" -#: index.docbook:232 +#. Tag: literal +#: toolset_guide.xml:232 +#, no-c-format msgid "check" msgstr "check" -#: index.docbook:234 +#. Tag: entry +#: toolset_guide.xml:234 +#, no-c-format msgid "create an SQL check constraint on either column or table" msgstr "对字段或表加入SQL约束检查" -#: index.docbook:242 -msgid "The <comment> element allows you to specify comments for the generated schema." -msgstr "<comment>元素可以让你在生成的schema中加入注释。" - -#: index.docbook:247 +#. Tag: para +#: toolset_guide.xml:242 +#, no-c-format msgid "" - "\n" - " Current customers only\n" - " ...\n" - "]]>" +"The <comment> element allows you to specify " +"comments for the generated schema." msgstr "" - "\n" - " Current customers only\n" - " ...\n" - "]]>" +"<comment>元素可以让你在生成的schema中加入注释。" -#: index.docbook:249 +#. Tag: programlisting +#: toolset_guide.xml:247 +#, no-c-format msgid "" - "\n" - " \n" - " Balance in USD\n" - " \n" - "]]>" +"\n" +" Current customers only\n" +" ...\n" +"]]>" msgstr "" - "\n" - " \n" - " Balance in USD\n" - " \n" - "]]>" -#: index.docbook:251 -msgid "This results in a comment on table or comment on column statement in the generated DDL (where supported)." -msgstr "结果是在生成的DDL中包含comment on table 或者 comment on column语句(假若支持的话)。" +#. Tag: programlisting +#: toolset_guide.xml:249 +#, no-c-format +msgid "" +"\n" +" \n" +" Balance in USD\n" +" \n" +"]]>" +msgstr "" -#: index.docbook:260 +#. Tag: para +#: toolset_guide.xml:251 +#, no-c-format +msgid "" +"This results in a comment on table or comment on " +"column statement in the generated DDL (where supported)." +msgstr "" +"结果是在生成的DDL中包含comment on table 或者 " +"comment on column语句(假若支持的话)。" + +#. Tag: title +#: toolset_guide.xml:260 +#, no-c-format msgid "Running the tool" msgstr "运行该工具" -#: index.docbook:262 -msgid "The SchemaExport tool writes a DDL script to standard out and/or executes the DDL statements." -msgstr "SchemaExport工具把DDL脚本写到标准输出,同时/或者执行DDL语句。" +#. Tag: para +#: toolset_guide.xml:262 +#, no-c-format +msgid "" +"The SchemaExport tool writes a DDL script to standard out " +"and/or executes the DDL statements." +msgstr "" +"SchemaExport工具把DDL脚本写到标准输出,同时/或者执行DDL语" +"句。" -#: index.docbook:267 -msgid "java -cp hibernate_classpaths org.hibernate.tool.hbm2ddl.SchemaExport options mapping_files" -msgstr "java -cp hibernate_classpaths org.hibernate.tool.hbm2ddl.SchemaExport options mapping_files" +#. Tag: para +#: toolset_guide.xml:267 +#, no-c-format +msgid "" +"java -cp hibernate_classpaths " +"org.hibernate.tool.hbm2ddl.SchemaExport options " +"mapping_files" +msgstr "" -#: index.docbook:273 +#. Tag: title +#: toolset_guide.xml:273 +#, no-c-format msgid "SchemaExport Command Line Options" msgstr "SchemaExport命令行选项" -#: index.docbook:279, index.docbook:429, index.docbook:498 +#. Tag: entry +#: toolset_guide.xml:279 toolset_guide.xml:429 toolset_guide.xml:498 +#, no-c-format msgid "Option" -msgstr "选项" +msgstr "选项" -#: index.docbook:280, index.docbook:367, index.docbook:430, index.docbook:499 +#. Tag: entry +#: toolset_guide.xml:280 toolset_guide.xml:367 toolset_guide.xml:430 +#: toolset_guide.xml:499 +#, fuzzy, no-c-format msgid "Description" -msgstr "说明" +msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"说明\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"说明\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"说明\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"描述" -#: index.docbook:285, index.docbook:435 +#. Tag: literal +#: toolset_guide.xml:285 toolset_guide.xml:435 +#, no-c-format msgid "--quiet" msgstr "--quiet" -#: index.docbook:286, index.docbook:436 +#. Tag: entry +#: toolset_guide.xml:286 toolset_guide.xml:436 +#, no-c-format msgid "don't output the script to stdout" msgstr "不要把脚本输出到stdout" -#: index.docbook:289 +#. Tag: literal +#: toolset_guide.xml:289 +#, no-c-format msgid "--drop" msgstr "--drop" -#: index.docbook:290 +#. Tag: entry +#: toolset_guide.xml:290 +#, no-c-format msgid "only drop the tables" msgstr "只进行drop tables的步骤" -#: index.docbook:293 +#. Tag: literal +#: toolset_guide.xml:293 +#, no-c-format msgid "--create" msgstr "--create" -#: index.docbook:294 +#. Tag: entry +#: toolset_guide.xml:294 +#, no-c-format msgid "only create the tables" msgstr "只创建表" -#: index.docbook:297, index.docbook:439 +#. Tag: literal +#: toolset_guide.xml:297 toolset_guide.xml:439 +#, no-c-format msgid "--text" msgstr "--text" -#: index.docbook:298 +#. Tag: entry +#: toolset_guide.xml:298 +#, no-c-format msgid "don't export to the database" msgstr "不执行在数据库中运行的步骤" -#: index.docbook:301 +#. Tag: literal +#: toolset_guide.xml:301 +#, no-c-format msgid "--output=my_schema.ddl" msgstr "--output=my_schema.ddl" -#: index.docbook:302 +#. Tag: entry +#: toolset_guide.xml:302 +#, no-c-format msgid "output the ddl script to a file" msgstr "把输出的ddl脚本输出到一个文件" -#: index.docbook:305, index.docbook:443, index.docbook:504 +#. Tag: literal +#: toolset_guide.xml:305 toolset_guide.xml:443 toolset_guide.xml:504 +#, no-c-format msgid "--naming=eg.MyNamingStrategy" msgstr "--naming=eg.MyNamingStrategy" -#: index.docbook:306, index.docbook:444, index.docbook:505 +#. Tag: entry +#: toolset_guide.xml:306 toolset_guide.xml:444 toolset_guide.xml:505 +#, fuzzy, no-c-format msgid "select a NamingStrategy" -msgstr "选择一个命名策略(NamingStrategy)" +msgstr "在hibernate.properties文件中" -#: index.docbook:309, index.docbook:451, index.docbook:512 +#. Tag: literal +#: toolset_guide.xml:309 toolset_guide.xml:451 toolset_guide.xml:512 +#, no-c-format msgid "--config=hibernate.cfg.xml" msgstr "--config=hibernate.cfg.xml" -#: index.docbook:310 +#. Tag: entry +#: toolset_guide.xml:310 +#, no-c-format msgid "read Hibernate configuration from an XML file" msgstr "从XML文件读入Hibernate配置" -#: index.docbook:313, index.docbook:447, index.docbook:508 +#. Tag: literal +#: toolset_guide.xml:313 toolset_guide.xml:447 toolset_guide.xml:508 +#, no-c-format msgid "--properties=hibernate.properties" msgstr "--properties=hibernate.properties" -#: index.docbook:314, index.docbook:448, index.docbook:509 +#. Tag: entry +#: toolset_guide.xml:314 toolset_guide.xml:448 toolset_guide.xml:509 +#, fuzzy, no-c-format msgid "read database properties from a file" -msgstr "从文件读入数据库属性" +msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"从文件读入数据库属性\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"从指定文件读入数据库属性\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"从文件中读取数据库属性" -#: index.docbook:317 +#. Tag: literal +#: toolset_guide.xml:317 +#, no-c-format msgid "--format" msgstr "--format" -#: index.docbook:318 +#. Tag: entry +#: toolset_guide.xml:318 +#, no-c-format msgid "format the generated SQL nicely in the script" msgstr "把脚本中的SQL语句对齐和美化" -#: index.docbook:321 +#. Tag: literal +#: toolset_guide.xml:321 +#, no-c-format msgid "--delimiter=;" msgstr "--delimiter=;" -#: index.docbook:322 +#. Tag: entry +#: toolset_guide.xml:322 +#, no-c-format msgid "set an end of line delimiter for the script" msgstr "为脚本设置行结束符" -#: index.docbook:328 +#. Tag: para +#: toolset_guide.xml:328 +#, no-c-format msgid "You may even embed SchemaExport in your application:" msgstr "你甚至可以在你的应用程序中嵌入SchemaExport工具:" -#: index.docbook:332 +#. Tag: programlisting +#: toolset_guide.xml:332 +#, no-c-format msgid "" - "" +"" msgstr "" - "" -#: index.docbook:337 +#. Tag: title +#: toolset_guide.xml:337 +#, no-c-format msgid "Properties" msgstr "属性(Properties)" -#: index.docbook:339 +#. Tag: para +#: toolset_guide.xml:339 +#, no-c-format msgid "Database properties may be specified" msgstr "可以通过如下方式指定数据库属性:" -#: index.docbook:345 -msgid "as system properties with -D<property>" +#. Tag: para +#: toolset_guide.xml:345 +#, no-c-format +msgid "" +"as system properties with -D<property>" msgstr "通过-D<property>系统参数" -#: index.docbook:348 +#. Tag: para +#: toolset_guide.xml:348 +#, no-c-format msgid "in hibernate.properties" msgstr "在hibernate.properties文件中" -#: index.docbook:351 +#. Tag: para +#: toolset_guide.xml:351 +#, no-c-format msgid "in a named properties file with --properties" -msgstr "位于一个其它名字的properties文件中,然后用 --properties参数指定" +msgstr "" +"位于一个其它名字的properties文件中,然后用 --properties参数" +"指定" -#: index.docbook:355 +#. Tag: para +#: toolset_guide.xml:355 +#, no-c-format msgid "The needed properties are:" msgstr "所需的参数包括:" -#: index.docbook:360 +#. Tag: title +#: toolset_guide.xml:360 +#, no-c-format msgid "SchemaExport Connection Properties" msgstr "SchemaExport 连接属性" -#: index.docbook:366 +#. Tag: entry +#: toolset_guide.xml:366 +#, no-c-format msgid "Property Name" -msgstr "属性名" +msgstr "属性名" -#: index.docbook:372 +#. Tag: literal +#: toolset_guide.xml:372 +#, no-c-format msgid "hibernate.connection.driver_class" msgstr "hibernate.connection.driver_class" -#: index.docbook:373 +#. Tag: entry +#: toolset_guide.xml:373 +#, no-c-format msgid "jdbc driver class" msgstr "jdbc driver class" -#: index.docbook:376 +#. Tag: literal +#: toolset_guide.xml:376 +#, no-c-format msgid "hibernate.connection.url" msgstr "hibernate.connection.url" -#: index.docbook:377 +#. Tag: entry +#: toolset_guide.xml:377 +#, no-c-format msgid "jdbc url" msgstr "jdbc url" -#: index.docbook:380 +#. Tag: literal +#: toolset_guide.xml:380 +#, no-c-format msgid "hibernate.connection.username" msgstr "hibernate.connection.username" -#: index.docbook:381 +#. Tag: entry +#: toolset_guide.xml:381 +#, no-c-format msgid "database user" msgstr "database user" -#: index.docbook:384 +#. Tag: literal +#: toolset_guide.xml:384 +#, no-c-format msgid "hibernate.connection.password" msgstr "hibernate.connection.password" -#: index.docbook:385 +#. Tag: entry +#: toolset_guide.xml:385 +#, no-c-format msgid "user password" msgstr "user password" -#: index.docbook:388 +#. Tag: literal +#: toolset_guide.xml:388 +#, no-c-format msgid "hibernate.dialect" msgstr "hibernate.dialect" -#: index.docbook:389 +#. Tag: entry +#: toolset_guide.xml:389 +#, no-c-format msgid "dialect" msgstr "方言(dialect)" -#: index.docbook:398 +#. Tag: title +#: toolset_guide.xml:398 +#, no-c-format msgid "Using Ant" msgstr "使用Ant(Using Ant)" -#: index.docbook:400 -msgid "You can call SchemaExport from your Ant build script:" +#. Tag: para +#: toolset_guide.xml:400 +#, no-c-format +msgid "" +"You can call SchemaExport from your Ant build script:" msgstr "你可以在你的Ant build脚本中调用SchemaExport:" -#: index.docbook:404 +#. Tag: programlisting +#: toolset_guide.xml:404 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" -#: index.docbook:409 +#. Tag: title +#: toolset_guide.xml:409 +#, no-c-format msgid "Incremental schema updates" msgstr "对schema的增量更新(Incremental schema updates)" -#: index.docbook:411 -msgid "The SchemaUpdate tool will update an existing schema with \"incremental\" changes. Note that SchemaUpdate depends heavily upon the JDBC metadata API, so it will not work with all JDBC drivers." -msgstr "SchemaUpdate工具对已存在的schema采用\"增量\"方式进行更新。注意SchemaUpdate严重依赖于JDBC metadata API,所以它并非对所有JDBC驱动都有效。" +#. Tag: para +#: toolset_guide.xml:411 +#, no-c-format +msgid "" +"The SchemaUpdate tool will update an existing schema with " +"\"incremental\" changes. Note that SchemaUpdate depends " +"heavily upon the JDBC metadata API, so it will not work with all JDBC " +"drivers." +msgstr "" +"SchemaUpdate工具对已存在的schema采用\"增量\"方式进行更新。" +"注意SchemaUpdate严重依赖于JDBC metadata API,所以它并非对所" +"有JDBC驱动都有效。" -#: index.docbook:417 -msgid "java -cp hibernate_classpaths org.hibernate.tool.hbm2ddl.SchemaUpdate options mapping_files" -msgstr "java -cp hibernate_classpaths org.hibernate.tool.hbm2ddl.SchemaUpdate options mapping_files" +#. Tag: para +#: toolset_guide.xml:417 +#, no-c-format +msgid "" +"java -cp hibernate_classpaths " +"org.hibernate.tool.hbm2ddl.SchemaUpdate options " +"mapping_files" +msgstr "" -#: index.docbook:423 +#. Tag: title +#: toolset_guide.xml:423 +#, no-c-format msgid "SchemaUpdate Command Line Options" msgstr "SchemaUpdate命令行选项" -#: index.docbook:440 +#. Tag: entry +#: toolset_guide.xml:440 +#, no-c-format msgid "don't export the script to the database" msgstr "不把脚本输出到数据库" -#: index.docbook:452, index.docbook:513 +#. Tag: entry +#: toolset_guide.xml:452 toolset_guide.xml:513 +#, fuzzy, no-c-format msgid "specify a .cfg.xml file" -msgstr "指定一个 .cfg.xml文件" +msgstr "" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"指定一个 文件\n" +"#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +"指定一个文件" -#: index.docbook:458 +#. Tag: para +#: toolset_guide.xml:458 +#, no-c-format msgid "You may embed SchemaUpdate in your application:" msgstr "你可以在你的应用程序中嵌入SchemaUpdate工具:" -#: index.docbook:462 +#. Tag: programlisting +#: toolset_guide.xml:462 +#, no-c-format msgid "" - "" +"" msgstr "" - "" -#: index.docbook:467 +#. Tag: title +#: toolset_guide.xml:467 +#, no-c-format msgid "Using Ant for incremental schema updates" msgstr "用Ant来增量更新schema(Using Ant for incremental schema updates)" -#: index.docbook:469 +#. Tag: para +#: toolset_guide.xml:469 +#, no-c-format msgid "You can call SchemaUpdate from the Ant script:" msgstr "你可以在Ant脚本中调用SchemaUpdate:" -#: index.docbook:473 +#. Tag: programlisting +#: toolset_guide.xml:473 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" -#: index.docbook:478 +#. Tag: title +#: toolset_guide.xml:478 +#, no-c-format msgid "Schema validation" msgstr "Schema 校验" -#: index.docbook:480 -msgid "The SchemaValidator tool will validate that the existing database schema \"matches\" your mapping documents. Note that SchemaValidator depends heavily upon the JDBC metadata API, so it will not work with all JDBC drivers. This tool is extremely useful for testing." -msgstr "SchemaValidator工具会比较数据库现状是否与映射文档“匹配”。注意,SchemaValidator 严重依赖于JDBC的metadata API,因此不是对所有的JDBC驱动都适用。这一工具在测试的时候特别有用。" +#. Tag: para +#: toolset_guide.xml:480 +#, no-c-format +msgid "" +"The SchemaValidator tool will validate that the existing " +"database schema \"matches\" your mapping documents. Note that " +"SchemaValidator depends heavily upon the JDBC metadata " +"API, so it will not work with all JDBC drivers. This tool is extremely " +"useful for testing." +msgstr "" +"SchemaValidator工具会比较数据库现状是否与映射文档“匹配”。" +"注意,SchemaValidator 严重依赖于JDBC的metadata API,因此不" +"是对所有的JDBC驱动都适用。这一工具在测试的时候特别有用。" -#: index.docbook:486 -msgid "java -cp hibernate_classpaths org.hibernate.tool.hbm2ddl.SchemaValidator options mapping_files" -msgstr "java -cp hibernate_classpaths org.hibernate.tool.hbm2ddl.SchemaValidator options mapping_files" +#. Tag: para +#: toolset_guide.xml:486 +#, no-c-format +msgid "" +"java -cp hibernate_classpaths " +"org.hibernate.tool.hbm2ddl.SchemaValidator " +"options mapping_files" +msgstr "" -#: index.docbook:492 +#. Tag: title +#: toolset_guide.xml:492 +#, no-c-format msgid "SchemaValidator Command Line Options" msgstr "SchemaValidator命令行参数" -#: index.docbook:519 +#. Tag: para +#: toolset_guide.xml:519 +#, no-c-format msgid "You may embed SchemaValidator in your application:" msgstr "你可以在你的应用程序中嵌入SchemaValidator:" -#: index.docbook:523 +#. Tag: programlisting +#: toolset_guide.xml:523 +#, no-c-format msgid "" - "" +"" msgstr "" - "" -#: index.docbook:528 +#. Tag: title +#: toolset_guide.xml:528 +#, no-c-format msgid "Using Ant for schema validation" msgstr "使用Ant进行schema校验" -#: index.docbook:530 +#. Tag: para +#: toolset_guide.xml:530 +#, no-c-format msgid "You can call SchemaValidator from the Ant script:" msgstr "你可以在Ant脚本中调用SchemaValidator:" -#: index.docbook:534 +#. Tag: programlisting +#: toolset_guide.xml:534 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "]]>" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" +#~ msgid "<one-to-one>" +#~ msgstr "<one-to-one>" -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" +#~ msgid "<many-to-one>" +#~ msgstr "<many-to-one>" +#~ msgid "<key>" +#~ msgstr "<key>" + +#~ msgid "<many-to-many>" +#~ msgstr "<many-to-many>" + +#~ msgid "inverse=\"true\"" +#~ msgstr "inverse=\"true\"" + +#~ msgid "SchemaExport" +#~ msgstr "SchemaExport" + +#~ msgid "<column>" +#~ msgstr "<column>" + +#~ msgid "java -cp" +#~ msgstr "java -cp" + +#~ msgid "hibernate_classpaths" +#~ msgstr "hibernate_classpaths" + +#~ msgid "org.hibernate.tool.hbm2ddl.SchemaExport" +#~ msgstr "org.hibernate.tool.hbm2ddl.SchemaExport" + +#~ msgid "options mapping_files" +#~ msgstr "options mapping_files" + +#~ msgid "NamingStrategy" +#~ msgstr "NamingStrategy" + +#, fuzzy +#~ msgid "select a " +#~ msgstr "" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "选择一个命名策略()\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "选择一个命名策略 ()\n" +#~ "#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n" +#~ "选择一个命名策略 ()" + +#~ msgid "org.hibernate.tool.hbm2ddl.SchemaUpdate" +#~ msgstr "org.hibernate.tool.hbm2ddl.SchemaUpdate" + +#~ msgid ".cfg.xml" +#~ msgstr ".cfg.xml" + +#~ msgid "org.hibernate.tool.hbm2ddl.SchemaValidator" +#~ msgstr "org.hibernate.tool.hbm2ddl.SchemaValidator" diff --git a/documentation/manual/translations/zh-CN/content/transactions.po b/documentation/manual/translations/zh-CN/content/transactions.po index 48b8f57110..f3e8c10203 100644 --- a/documentation/manual/translations/zh-CN/content/transactions.po +++ b/documentation/manual/translations/zh-CN/content/transactions.po @@ -1,673 +1,1934 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: transactions.xml:5 +#, no-c-format msgid "Transactions And Concurrency" -msgstr "" +msgstr "事务和并发" -#: index.docbook:7 -msgid "The most important point about Hibernate and concurrency control is that it is very easy to understand. Hibernate directly uses JDBC connections and JTA resources without adding any additional locking behavior. We highly recommend you spend some time with the JDBC, ANSI, and transaction isolation specification of your database management system." +#. Tag: para +#: transactions.xml:7 +#, no-c-format +msgid "" +"The most important point about Hibernate and concurrency control is that it " +"is very easy to understand. Hibernate directly uses JDBC connections and JTA " +"resources without adding any additional locking behavior. We highly " +"recommend you spend some time with the JDBC, ANSI, and transaction isolation " +"specification of your database management system." msgstr "" +"Hibernate的事务和并发控制很容易掌握。Hibernate直接使用JDBC连接和JTA资源,不添" +"加任何附加锁定 行为。我们强烈推荐你花点时间了解JDBC编程,ANSI SQL查询语言和你" +"使用 的数据库系统的事务隔离规范。" -#: index.docbook:14 -msgid "Hibernate does not lock objects in memory. Your application can expect the behavior as defined by the isolation level of your database transactions. Note that thanks to the Session, which is also a transaction-scoped cache, Hibernate provides repeatable reads for lookup by identifier and entity queries (not reporting queries that return scalar values)." +#. Tag: para +#: transactions.xml:14 +#, no-c-format +msgid "" +"Hibernate does not lock objects in memory. Your application can expect the " +"behavior as defined by the isolation level of your database transactions. " +"Note that thanks to the Session, which is also a " +"transaction-scoped cache, Hibernate provides repeatable reads for lookup by " +"identifier and entity queries (not reporting queries that return scalar " +"values)." msgstr "" +"Hibernate不锁定内存中的对象。你的应用程序会按照你的数据库事务的隔离级别规定的" +"那样运作。幸亏有了Session,使得Hibernate通过标识符查找,和" +"实体查询(不是返回标量值的报表查询)提供了可重复的读取(Repeatable reads)功" +"能,Session同时也是事务范围内的缓存(cache)。" -#: index.docbook:22 -msgid "In addition to versioning for automatic optimistic concurrency control, Hibernate also offers a (minor) API for pessimistic locking of rows, using the SELECT FOR UPDATE syntax. Optimistic concurrency control and this API are discussed later in this chapter." +#. Tag: para +#: transactions.xml:22 +#, no-c-format +msgid "" +"In addition to versioning for automatic optimistic concurrency control, " +"Hibernate also offers a (minor) API for pessimistic locking of rows, using " +"the SELECT FOR UPDATE syntax. Optimistic concurrency " +"control and this API are discussed later in this chapter." msgstr "" +"除了对自动乐观并发控制提供版本管理,针对行级悲观锁定,Hibernate也提供了辅助的" +"(较小的)API,它使用了 SELECT FOR UPDATE的SQL语法。本章后" +"面会讨论乐观并发控制和这个API。" -#: index.docbook:29 -msgid "We start the discussion of concurrency control in Hibernate with the granularity of Configuration, SessionFactory, and Session, as well as database transactions and long conversations." +#. Tag: para +#: transactions.xml:29 +#, no-c-format +msgid "" +"We start the discussion of concurrency control in Hibernate with the " +"granularity of Configuration, SessionFactory, and Session, as well as database transactions " +"and long conversations." msgstr "" +"我们从Configuration层、SessionFactory" +"层, 和 Session层开始讨论Hibernate的并行控制、数据库事务和" +"应用 程序的长事务。" -#: index.docbook:36 +#. Tag: title +#: transactions.xml:36 +#, no-c-format msgid "Session and transaction scopes" -msgstr "" +msgstr "Session和事务范围(transaction scope)" -#: index.docbook:38 -msgid "A SessionFactory is an expensive-to-create, threadsafe object intended to be shared by all application threads. It is created once, usually on application startup, from a Configuration instance." +#. Tag: para +#: transactions.xml:38 +#, no-c-format +msgid "" +"A SessionFactory is an expensive-to-create, threadsafe " +"object intended to be shared by all application threads. It is created once, " +"usually on application startup, from a Configuration " +"instance." msgstr "" +"SessionFactory对象的创建代价很昂贵,它是线程安全的对象,它" +"为所有的应用程序线程所共享。它只创建一次,通常是在应用程序启动的时候,由一个" +"Configuraion的实例来创建。" -#: index.docbook:44 -msgid "A Session is an inexpensive, non-threadsafe object that should be used once, for a single request, a conversation, single unit of work, and then discarded. A Session will not obtain a JDBC Connection (or a Datasource) unless it is needed, hence consume no resources until used." +#. Tag: para +#: transactions.xml:44 +#, no-c-format +msgid "" +"A Session is an inexpensive, non-threadsafe object that " +"should be used once, for a single request, a conversation, single unit of " +"work, and then discarded. A Session will not obtain a " +"JDBC Connection (or a Datasource) " +"unless it is needed, hence consume no resources until used." msgstr "" +"Session对象的创建代价比较小,是非线程安全的,对于单个请" +"求,单个会话、单个的 工作单元而言,它只被使用一次,然后就丢弃。只有在需要的时" +"候,一个Session对象 才会获取一个JDBC的" +"Connection(或一个Datasource) 对象,因" +"此假若不使用的时候它不消费任何资源。" -#: index.docbook:52 -msgid "To complete this picture you also have to think about database transactions. A database transaction has to be as short as possible, to reduce lock contention in the database. Long database transactions will prevent your application from scaling to highly concurrent load. Hence, it is almost never good design to hold a database transaction open during user think time, until the unit of work is complete." +#. Tag: para +#: transactions.xml:52 +#, no-c-format +msgid "" +"To complete this picture you also have to think about database transactions. " +"A database transaction has to be as short as possible, to reduce lock " +"contention in the database. Long database transactions will prevent your " +"application from scaling to highly concurrent load. Hence, it is almost " +"never good design to hold a database transaction open during user think " +"time, until the unit of work is complete." msgstr "" +"此外我们还要考虑数据库事务。数据库事务应该尽可能的短,降低数据库中的锁争用。 " +"数据库长事务会阻止你的应用程序扩展到高的并发负载。因此,假若在用户思考期间让" +"数据库事务开着,直到整个工作单元完成才关闭这个事务,这绝不是一个好的设计。" -#: index.docbook:61 -msgid "What is the scope of a unit of work? Can a single Hibernate Session span several database transactions or is this a one-to-one relationship of scopes? When should you open and close a Session and how do you demarcate the database transaction boundaries?" +#. Tag: para +#: transactions.xml:61 +#, no-c-format +msgid "" +"What is the scope of a unit of work? Can a single Hibernate " +"Session span several database transactions or is this a " +"one-to-one relationship of scopes? When should you open and close a " +"Session and how do you demarcate the database transaction " +"boundaries?" msgstr "" +"一个操作单元(Unit of work)的范围是多大?单个的Hibernate Session能跨越多个 数据库事务吗?还是一个Session的作用范围" +"对应一个数据库事务的范围?应该何时打开 Session,何时关闭" +"Session?,你又如何划分数据库事务的边界呢?" -#: index.docbook:69 +#. Tag: title +#: transactions.xml:69 +#, no-c-format msgid "Unit of work" -msgstr "" +msgstr "操作单元(Unit of work)" -#: index.docbook:71 -msgid "First, don't use the session-per-operation antipattern, that is, don't open and close a Session for every simple database call in a single thread! Of course, the same is true for database transactions. Database calls in an application are made using a planned sequence, they are grouped into atomic units of work. (Note that this also means that auto-commit after every single SQL statement is useless in an application, this mode is intended for ad-hoc SQL console work. Hibernate disables, or expects the application server to do so, auto-commit mode immediately.) Database transactions are never optional, all communication with a database has to occur inside a transaction, no matter if you read or write data. As explained, auto-commit behavior for reading data should be avoided, as many small transactions are unlikely to perform better than one clearly defined unit of work. The latter is also much more maintainable and extensible." +#. Tag: para +#: transactions.xml:71 +#, no-c-format +msgid "" +"First, don't use the session-per-operation antipattern, " +"that is, don't open and close a Session for every simple " +"database call in a single thread! Of course, the same is true for database " +"transactions. Database calls in an application are made using a planned " +"sequence, they are grouped into atomic units of work. (Note that this also " +"means that auto-commit after every single SQL statement is useless in an " +"application, this mode is intended for ad-hoc SQL console work. Hibernate " +"disables, or expects the application server to do so, auto-commit mode " +"immediately.) Database transactions are never optional, all communication " +"with a database has to occur inside a transaction, no matter if you read or " +"write data. As explained, auto-commit behavior for reading data should be " +"avoided, as many small transactions are unlikely to perform better than one " +"clearly defined unit of work. The latter is also much more maintainable and " +"extensible." msgstr "" +"首先,别用session-per-operation这种反模式了,也就是说," +"在单个线程中, 不要因为一次简单的数据库调用,就打开和关闭一次" +"Session!数据库事务也是如此。 应用程序中的数据库调用是按照" +"计划好的次序,分组为原子的操作单元。(注意,这也意味着,应用程 序中,在单个的" +"SQL语句发送之后,自动事务提交(auto-commit)模式失效了。这种模式专门为SQL控制台" +"操作设计的。 Hibernate禁止立即自动事务提交模式,或者期望应用服务器禁止立即自" +"动事务提交模式。)数据库事务绝不是可有可无的,任何与数据库之间的通讯都必须在" +"某个事务中进行,不管你是在读还是在写数据。对读数据而言,应该避免auto-commit行" +"为,因为很多小的事务比一个清晰定义的工作单元性能差。后者也更容易维护和扩展。" -#: index.docbook:87 -msgid "The most common pattern in a multi-user client/server application is session-per-request. In this model, a request from the client is send to the server (where the Hibernate persistence layer runs), a new Hibernate Session is opened, and all database operations are executed in this unit of work. Once the work has been completed (and the response for the client has been prepared), the session is flushed and closed. You would also use a single database transaction to serve the clients request, starting and committing it when you open and close the Session. The relationship between the two is one-to-one and this model is a perfect fit for many applications." +#. Tag: para +#: transactions.xml:87 +#, no-c-format +msgid "" +"The most common pattern in a multi-user client/server application is " +"session-per-request. In this model, a request from the " +"client is send to the server (where the Hibernate persistence layer runs), a " +"new Hibernate Session is opened, and all database " +"operations are executed in this unit of work. Once the work has been " +"completed (and the response for the client has been prepared), the session " +"is flushed and closed. You would also use a single database transaction to " +"serve the clients request, starting and committing it when you open and " +"close the Session. The relationship between the two is " +"one-to-one and this model is a perfect fit for many applications." msgstr "" +"在多用户的client/server应用程序中,最常用的模式是 每个请求一个会话" +"(session-per-request)。 在这种模式下,来自客户端的请求被发送到服务" +"器端(即Hibernate持久化层运行的地方),一 个新的Hibernate Session被打开,并且执行这个操作单元中所有的数据库操作。 一旦操作完成(同时对" +"客户端的响应也准备就绪),session被同步,然后关闭。你也可以使用单 个数据库事" +"务来处理客户端请求,在你打开Session之后启动事务,在你关闭 " +"Session之前提交事务。会话和请求之间的关系是一对一的关系," +"这种模式对 于大多数应用程序来说是很棒的。" -#: index.docbook:99 -msgid "The challenge lies in the implementation. Hibernate provides built-in management of the \"current session\" to simplify this pattern. All you have to do is start a transaction when a server request has to be processed, and end the transaction before the response is send to the client. You can do this in any way you like, common solutions are ServletFilter, AOP interceptor with a pointcut on the service methods, or a proxy/interception container. An EJB container is a standardized way to implement cross-cutting aspects such as transaction demarcation on EJB session beans, declaratively with CMT. If you decide to use programmatic transaction demarcation, prefer the Hibernate Transaction API shown later in this chapter, for ease of use and code portability." +#. Tag: para +#: transactions.xml:99 +#, no-c-format +msgid "" +"The challenge lies in the implementation. Hibernate provides built-in " +"management of the \"current session\" to simplify this pattern. All you have " +"to do is start a transaction when a server request has to be processed, and " +"end the transaction before the response is send to the client. You can do " +"this in any way you like, common solutions are ServletFilter, AOP interceptor with a pointcut on the service methods, or a proxy/" +"interception container. An EJB container is a standardized way to implement " +"cross-cutting aspects such as transaction demarcation on EJB session beans, " +"declaratively with CMT. If you decide to use programmatic transaction " +"demarcation, prefer the Hibernate Transaction API shown " +"later in this chapter, for ease of use and code portability." msgstr "" +"实现才是真正的挑战。Hibernate内置了对\"当前session(current session)\" 的管" +"理,用于简化此模式。你要做的一切就是在服务器端要处理请求的时候,开启事务,在" +"响应发送给客户之前结束事务。你可以用任何方式来完成这一操作,通常的方案有" +"ServletFilter,在service方法中进行pointcut的AOP拦截器,或" +"者proxy/interception容器。EJB容器是实现横切诸如EJB session bean上的事务分界," +"用CMT对事务进行声明等方面的标准手段。假若你决定使用编程式的事务分界,请参考本" +"章后面讲到的Hibernate Transaction API,这对易用性和代码可" +"移植性都有好处。" -#: index.docbook:112 -msgid "Your application code can access a \"current session\" to process the request by simply calling sessionFactory.getCurrentSession() anywhere and as often as needed. You will always get a Session scoped to the current database transaction. This has to be configured for either resource-local or JTA environments, see ." +#. Tag: para +#: transactions.xml:112 +#, no-c-format +msgid "" +"Your application code can access a \"current session\" to process the " +"request by simply calling sessionFactory.getCurrentSession() anywhere and as often as needed. You will always get a " +"Session scoped to the current database transaction. This " +"has to be configured for either resource-local or JTA environments, see " +"." msgstr "" +"在任何时间,任何地方,你的应用代码可以通过简单的调用sessionFactory." +"getCurrentSession()来访问\"当前session\",用于处理请求。你总是会得" +"到当前数据库事务范围内的Session。在使用本地资源或JTA环境" +"时,必须配置它,请参见。" -#: index.docbook:120 -msgid "Sometimes it is convenient to extend the scope of a Session and database transaction until the \"view has been rendered\". This is especially useful in servlet applications that utilize a separate rendering phase after the request has been processed. Extending the database transaction until view rendering is complete is easy to do if you implement your own interceptor. However, it is not easily doable if you rely on EJBs with container-managed transactions, as a transaction will be completed when an EJB method returns, before rendering of any view can start. See the Hibernate website and forum for tips and examples around this Open Session in View pattern." +#. Tag: para +#: transactions.xml:120 +#, no-c-format +msgid "" +"Sometimes it is convenient to extend the scope of a Session and database transaction until the \"view has been rendered\". This " +"is especially useful in servlet applications that utilize a separate " +"rendering phase after the request has been processed. Extending the database " +"transaction until view rendering is complete is easy to do if you implement " +"your own interceptor. However, it is not easily doable if you rely on EJBs " +"with container-managed transactions, as a transaction will be completed when " +"an EJB method returns, before rendering of any view can start. See the " +"Hibernate website and forum for tips and examples around this Open " +"Session in View pattern." msgstr "" +"有时,将Session和数据库事务的边界延伸到\"展示层被渲染后" +"\"会带来便利。有些serlvet应用程序在对请求进行处理后,有个单独的渲染期,这种延" +"伸对这种程序特别有用。假若你实现你自己的拦截器,把事务边界延伸到展示层渲染结" +"束后非常容易。然而,假若你依赖有容器管理事务的EJB,这就不太容易了,因为事务会" +"在EJB方法返回后结束,而那是在任何展示层渲染开始之前。请访问Hibernate网站和论" +"坛,你可以找到Open Session in View这一模式的提示和示例。" -#: index.docbook:135 +#. Tag: title +#: transactions.xml:135 +#, no-c-format msgid "Long conversations" -msgstr "" +msgstr "长对话" -#: index.docbook:137 -msgid "The session-per-request pattern is not the only useful concept you can use to design units of work. Many business processes require a whole series of interactions with the user interleaved with database accesses. In web and enterprise applications it is not acceptable for a database transaction to span a user interaction. Consider the following example:" +#. Tag: para +#: transactions.xml:137 +#, no-c-format +msgid "" +"The session-per-request pattern is not the only useful concept you can use " +"to design units of work. Many business processes require a whole series of " +"interactions with the user interleaved with database accesses. In web and " +"enterprise applications it is not acceptable for a database transaction to " +"span a user interaction. Consider the following example:" msgstr "" +"session-per-request模式不仅仅是一个可以用来设计操作单元的有用概念。很多业务处" +"理都需 要一系列完整的与用户之间的交互,而这些用户是指对数据库有交叉访问的用" +"户。在基于web的应用和企业 应用中,跨用户交互的数据库事务是无法接受的。考虑下" +"面的例子:" -#: index.docbook:147 -msgid "The first screen of a dialog opens, the data seen by the user has been loaded in a particular Session and database transaction. The user is free to modify the objects." +#. Tag: para +#: transactions.xml:147 +#, no-c-format +msgid "" +"The first screen of a dialog opens, the data seen by the user has been " +"loaded in a particular Session and database transaction. " +"The user is free to modify the objects." msgstr "" +"在界面的第一屏,打开对话框,用户所看到的数据是被一个特定的 Session 和数据 库事务载入(load)的。用户可以随意修改对话框中的数据对象。" -#: index.docbook:154 -msgid "The user clicks \"Save\" after 5 minutes and expects his modifications to be made persistent; he also expects that he was the only person editing this information and that no conflicting modification can occur." +#. Tag: para +#: transactions.xml:154 +#, no-c-format +msgid "" +"The user clicks \"Save\" after 5 minutes and expects his modifications to be " +"made persistent; he also expects that he was the only person editing this " +"information and that no conflicting modification can occur." msgstr "" +"5分钟后,用户点击“保存”,期望所做出的修改被持久化;同时他也期望自己是唯一修改" +"这个信息的人,不会出现 修改冲突。" -#: index.docbook:162 -msgid "We call this unit of work, from the point of view of the user, a long running conversation (or application transaction). There are many ways how you can implement this in your application." +#. Tag: para +#: transactions.xml:162 +#, no-c-format +msgid "" +"We call this unit of work, from the point of view of the user, a long " +"running conversation (or application " +"transaction). There are many ways how you can implement this in " +"your application." msgstr "" +"从用户的角度来看,我们把这个操作单元称为长时间运行的对话" +"(conversation),或者(or 应用事务,application " +"transaction)。 在你的应用程序中,可以有很多种方法来实现它。" -#: index.docbook:168 -msgid "A first naive implementation might keep the Session and database transaction open during user think time, with locks held in the database to prevent concurrent modification, and to guarantee isolation and atomicity. This is of course an anti-pattern, since lock contention would not allow the application to scale with the number of concurrent users." +#. Tag: para +#: transactions.xml:168 +#, no-c-format +msgid "" +"A first naive implementation might keep the Session and " +"database transaction open during user think time, with locks held in the " +"database to prevent concurrent modification, and to guarantee isolation and " +"atomicity. This is of course an anti-pattern, since lock contention would " +"not allow the application to scale with the number of concurrent users." msgstr "" +"头一个幼稚的做法是,在用户思考的过程中,保持Session和数据" +"库事务是打开的, 保持数据库锁定,以阻止并发修改,从而保证数据库事务隔离级别和" +"原子操作。这种方式当然是一个反模式, 因为锁争用会导致应用程序无法扩展并发用户" +"的数目。" -#: index.docbook:176 -msgid "Clearly, we have to use several database transactions to implement the converastion. In this case, maintaining isolation of business processes becomes the partial responsibility of the application tier. A single conversation usually spans several database transactions. It will be atomic if only one of these database transactions (the last one) stores the updated data, all others simply read data (e.g. in a wizard-style dialog spanning several request/response cycles). This is easier to implement than it might sound, especially if you use Hibernate's features:" +#. Tag: para +#: transactions.xml:176 +#, no-c-format +msgid "" +"Clearly, we have to use several database transactions to implement the " +"converastion. In this case, maintaining isolation of business processes " +"becomes the partial responsibility of the application tier. A single " +"conversation usually spans several database transactions. It will be atomic " +"if only one of these database transactions (the last one) stores the updated " +"data, all others simply read data (e.g. in a wizard-style dialog spanning " +"several request/response cycles). This is easier to implement than it might " +"sound, especially if you use Hibernate's features:" msgstr "" +"很明显,我们必须使用多个数据库事务来实现这个对话。在这个例子中,维护业务处理" +"的 事务隔离变成了应用程序层的部分责任。一个对话通常跨越多个数据库事务。如果仅" +"仅只有一 个数据库事务(最后的那个事务)保存更新过的数据,而所有其他事务只是单" +"纯的读取数据(例如在一 个跨越多个请求/响应周期的向导风格的对话框中),那么应" +"用程序事务将保证其原子性。这种方式比听 起来还要容易实现,特别是当你使用了" +"Hibernate的下述特性的时候:" -#: index.docbook:189 -msgid "Automatic Versioning - Hibernate can do automatic optimistic concurrency control for you, it can automatically detect if a concurrent modification occured during user think time. Usually we only check at the end of the conversation." +#. Tag: para +#: transactions.xml:189 +#, no-c-format +msgid "" +"Automatic Versioning - Hibernate can do automatic " +"optimistic concurrency control for you, it can automatically detect if a " +"concurrent modification occured during user think time. Usually we only " +"check at the end of the conversation." msgstr "" +"自动版本化 - Hibernate能够自动进行乐观并发控制 ,如果在" +"用户思考 的过程中发生并发修改,Hibernate能够自动检测到。一般我们只在对话结束" +"时才检查。" -#: index.docbook:197 -msgid "Detached Objects - If you decide to use the already discussed session-per-request pattern, all loaded instances will be in detached state during user think time. Hibernate allows you to reattach the objects and persist the modifications, the pattern is called session-per-request-with-detached-objects. Automatic versioning is used to isolate concurrent modifications." +#. Tag: para +#: transactions.xml:197 +#, no-c-format +msgid "" +"Detached Objects - If you decide to use the already " +"discussed session-per-request pattern, all loaded " +"instances will be in detached state during user think time. Hibernate allows " +"you to reattach the objects and persist the modifications, the pattern is " +"called session-per-request-with-detached-objects. " +"Automatic versioning is used to isolate concurrent modifications." msgstr "" +"脱管对象(Detached Objects)- 如果你决定采用前面已经讨论" +"过的 session-per-request模式,所有载入的实例在用户思考的" +"过程 中都处于与Session脱离的状态。Hibernate允许你把与Session脱离的对象重新关" +"联到Session 上,并且对修改进行持久化,这种模式被称为 session-per-" +"request-with-detached-objects。自动版本化被用来隔离并发修改。" -#: index.docbook:207 -msgid "Extended (or Long) Session - The Hibernate Session may be disconnected from the underlying JDBC connection after the database transaction has been committed, and reconnected when a new client request occurs. This pattern is known as session-per-conversation and makes even reattachment unnecessary. Automatic versioning is used to isolate concurrent modifications and the Session is usually not allowed to be flushed automatically, but explicitely." +#. Tag: para +#: transactions.xml:207 +#, no-c-format +msgid "" +"Extended (or Long) Session - The Hibernate " +"Session may be disconnected from the underlying JDBC " +"connection after the database transaction has been committed, and " +"reconnected when a new client request occurs. This pattern is known as " +"session-per-conversation and makes even reattachment " +"unnecessary. Automatic versioning is used to isolate concurrent " +"modifications and the Session is usually not allowed to " +"be flushed automatically, but explicitely." msgstr "" +"Extended (or Long) Session - Hibernate 的" +"Session 可以在数据库事务提交之后和底层的JDBC连接断开,当一" +"个新的客户端请求到来的时候,它又重新连接上底层的 JDBC连接。这种模式被称之为" +"session-per-conversation,这种情况可 能会造成不必要的" +"Session和JDBC连接的重新关联。自动版本化被用来隔离并发修改, Session通常不允许自动flush,而是明确flush。" -#: index.docbook:220 -msgid "Both session-per-request-with-detached-objects and session-per-conversation have advantages and disadvantages, we discuss them later in this chapter in the context of optimistic concurrency control." +#. Tag: para +#: transactions.xml:220 +#, no-c-format +msgid "" +"Both session-per-request-with-detached-objects and " +"session-per-conversation have advantages and " +"disadvantages, we discuss them later in this chapter in the context of " +"optimistic concurrency control." msgstr "" +"session-per-request-with-detached-objects 和 " +"session-per-conversation 各有优缺点,我们在本章后面乐观" +"并发 控制那部分再进行讨论。" -#: index.docbook:229 +#. Tag: title +#: transactions.xml:229 +#, no-c-format msgid "Considering object identity" -msgstr "" +msgstr "关注对象标识(Considering object identity)" -#: index.docbook:231 -msgid "An application may concurrently access the same persistent state in two different Sessions. However, an instance of a persistent class is never shared between two Session instances. Hence there are two different notions of identity:" +#. Tag: para +#: transactions.xml:231 +#, no-c-format +msgid "" +"An application may concurrently access the same persistent state in two " +"different Sessions. However, an instance of a persistent " +"class is never shared between two Session instances. " +"Hence there are two different notions of identity:" msgstr "" +"应用程序可能在两个不同的Session中并发访问同一持久化状态," +"但是, 一个持久化类的实例无法在两个 Session中共享。因此有" +"两种不同的标识语义:" -#: index.docbook:240 +#. Tag: term +#: transactions.xml:240 +#, no-c-format msgid "Database Identity" -msgstr "" +msgstr "数据库标识" -#: index.docbook:243 +#. Tag: literal +#: transactions.xml:243 +#, no-c-format msgid "foo.getId().equals( bar.getId() )" -msgstr "" +msgstr "foo.getId().equals( bar.getId() )" -#: index.docbook:248 +#. Tag: term +#: transactions.xml:248 +#, no-c-format msgid "JVM Identity" -msgstr "" +msgstr "JVM 标识" -#: index.docbook:251 +#. Tag: literal +#: transactions.xml:251 +#, no-c-format msgid "foo==bar" -msgstr "" +msgstr "foo==bar" -#: index.docbook:257 -msgid "Then for objects attached to a particular Session (i.e. in the scope of a Session) the two notions are equivalent, and JVM identity for database identity is guaranteed by Hibernate. However, while the application might concurrently access the \"same\" (persistent identity) business object in two different sessions, the two instances will actually be \"different\" (JVM identity). Conflicts are resolved using (automatic versioning) at flush/commit time, using an optimistic approach." +#. Tag: para +#: transactions.xml:257 +#, fuzzy, no-c-format +msgid "" +"Then for objects attached to a particular " +"Session (i.e. in the scope of a Session) the two notions are equivalent, and JVM identity for database " +"identity is guaranteed by Hibernate. However, while the application might " +"concurrently access the \"same\" (persistent identity) business object in " +"two different sessions, the two instances will actually be \"different" +"\" (JVM identity). Conflicts are resolved using (automatic versioning) at " +"flush/commit time, using an optimistic approach." msgstr "" +"对于那些关联到 特定Session (也就是在" +"单个Session的范围内)上的对象来说,这 两种标识的语义是等价" +"的,与数据库标识对应的JVM标识是由Hibernate来保 证的。不过,当应用程序在两个不" +"同的session中并发访问具有同一持久化标 识的业务对象实例的时候,这个业务对象的" +"两个实例事实上是不相同的(从 JVM识别来看)。这种冲突可以通过在同步和提交的时" +"候使用自动版本化和乐 观锁定方法来解决。" -#: index.docbook:266 -msgid "This approach leaves Hibernate and the database to worry about concurrency; it also provides the best scalability, since guaranteeing identity in single-threaded units of work only doesn't need expensive locking or other means of synchronization. The application never needs to synchronize on any business object, as long as it sticks to a single thread per Session. Within a Session the application may safely use == to compare objects." +#. Tag: para +#: transactions.xml:266 +#, no-c-format +msgid "" +"This approach leaves Hibernate and the database to worry about concurrency; " +"it also provides the best scalability, since guaranteeing identity in single-" +"threaded units of work only doesn't need expensive locking or other means of " +"synchronization. The application never needs to synchronize on any business " +"object, as long as it sticks to a single thread per Session. Within a Session the application may safely use " +"== to compare objects." msgstr "" +"这种方式把关于并发的头疼问题留给了Hibernate和数据库;由于在单个线程内,操作单" +"元中的对象识别不 需要代价昂贵的锁定或其他意义上的同步,因此它同时可以提供最好" +"的可伸缩性。只要在单个线程只持有一个 Session,应用程序就不" +"需要同步任何业务对象。在Session 的范围内,应用程序可以放心" +"的使用==进行对象比较。" -#: index.docbook:275 -msgid "However, an application that uses == outside of a Session, might see unexpected results. This might occur even in some unexpected places, for example, if you put two detached instances into the same Set. Both might have the same database identity (i.e. they represent the same row), but JVM identity is by definition not guaranteed for instances in detached state. The developer has to override the equals() and hashCode() methods in persistent classes and implement his own notion of object equality. There is one caveat: Never use the database identifier to implement equality, use a business key, a combination of unique, usually immutable, attributes. The database identifier will change if a transient object is made persistent. If the transient instance (usually together with detached instances) is held in a Set, changing the hashcode breaks the contract of the Set. Attributes for business keys don't have to be as stable as database primary keys, you only have to guarantee stability as long as the objects are in the same Set. See the Hibernate website for a more thorough discussion of this issue. Also note that this is not a Hibernate issue, but simply how Java object identity and equality has to be implemented." +#. Tag: para +#: transactions.xml:275 +#, no-c-format +msgid "" +"However, an application that uses == outside of a " +"Session, might see unexpected results. This might occur " +"even in some unexpected places, for example, if you put two detached " +"instances into the same Set. Both might have the same " +"database identity (i.e. they represent the same row), but JVM identity is by " +"definition not guaranteed for instances in detached state. The developer has " +"to override the equals() and hashCode() methods in persistent classes and implement his own notion of " +"object equality. There is one caveat: Never use the database identifier to " +"implement equality, use a business key, a combination of unique, usually " +"immutable, attributes. The database identifier will change if a transient " +"object is made persistent. If the transient instance (usually together with " +"detached instances) is held in a Set, changing the " +"hashcode breaks the contract of the Set. Attributes for " +"business keys don't have to be as stable as database primary keys, you only " +"have to guarantee stability as long as the objects are in the same " +"Set. See the Hibernate website for a more thorough " +"discussion of this issue. Also note that this is not a Hibernate issue, but " +"simply how Java object identity and equality has to be implemented." msgstr "" +"不过,应用程序在Session的外面使用==进行" +"对象比较可能会 导致无法预期的结果。在一些无法预料的场合,例如,如果你把两个脱" +"管对象实例放进同一个 Set的时候,就可能发生。这两个对象实例" +"可能有同一个数据库标识(也就是说, 他们代表了表的同一行数据),从JVM标识的定" +"义上来说,对脱管的对象而言,Hibernate无法保证他们 的的JVM标识一致。开发人员必" +"须覆盖持久化类的equals()方法和 hashCode() 方法,从而实现自定义的对象相等语义。警告:不要使用数据库标识 来实现" +"对象相等,应该使用业务键值,由唯一的,通常不变的属性组成。当一个瞬时对象被持" +"久化的时 候,它的数据库标识会发生改变。如果一个瞬时对象(通常也包括脱管对象实" +"例)被放入一 个Set,改变它的hashcode会导致与这个" +"Set的关系中断。虽 然业务键值的属性不象数据库主键那样稳定不" +"变,但是你只需要保证在同一个Set 中的对象属性的稳定性就足够" +"了。请到Hibernate网站去寻求这个问题更多的详细的讨论。请注意,这不是一 个有关" +"Hibernate的问题,而仅仅是一个关于Java对象标识和判等行为如何实现的问题。" -#: index.docbook:296 +#. Tag: title +#: transactions.xml:296 +#, no-c-format msgid "Common issues" -msgstr "" +msgstr "常见问题" -#: index.docbook:298 -msgid "Never use the anti-patterns session-per-user-session or session-per-application (of course, there are rare exceptions to this rule). Note that some of the following issues might also appear with the recommended patterns, make sure you understand the implications before making a design decision:" +#. Tag: para +#: transactions.xml:298 +#, no-c-format +msgid "" +"Never use the anti-patterns session-per-user-session or " +"session-per-application (of course, there are rare " +"exceptions to this rule). Note that some of the following issues might also " +"appear with the recommended patterns, make sure you understand the " +"implications before making a design decision:" msgstr "" +"决不要使用反模式session-per-user-session或者 " +"session-per-application(当然,这个规定几乎没有例外)。请注意, 下" +"述一些问题可能也会出现在我们推荐的模式中,在你作出某个设计决定之前,请务必理" +"解该模式的应用前提。" -#: index.docbook:307 -msgid "A Session is not thread-safe. Things which are supposed to work concurrently, like HTTP requests, session beans, or Swing workers, will cause race conditions if a Session instance would be shared. If you keep your Hibernate Session in your HttpSession (discussed later), you should consider synchronizing access to your Http session. Otherwise, a user that clicks reload fast enough may use the same Session in two concurrently running threads." +#. Tag: para +#: transactions.xml:307 +#, no-c-format +msgid "" +"A Session is not thread-safe. Things which are supposed " +"to work concurrently, like HTTP requests, session beans, or Swing workers, " +"will cause race conditions if a Session instance would be " +"shared. If you keep your Hibernate Session in your " +"HttpSession (discussed later), you should consider " +"synchronizing access to your Http session. Otherwise, a user that clicks " +"reload fast enough may use the same Session in two " +"concurrently running threads." msgstr "" +"Session 对象是非线程安全的。如果一个Session 实例允许共享的话,那些支持并发运行的东东,例如HTTP request,session " +"beans,或者是 Swing workers,将会导致出现资源争用(race condition)。如果在" +"HttpSession中有 Hibernate 的Session的话" +"(稍后讨论),你应该考虑同步访问你的Http session。 否则,只要用户足够快的点击" +"浏览器的“刷新”,就会导致两个并发运行线程使用同一个 Session。" -#: index.docbook:318 -msgid "An exception thrown by Hibernate means you have to rollback your database transaction and close the Session immediately (discussed later in more detail). If your Session is bound to the application, you have to stop the application. Rolling back the database transaction doesn't put your business objects back into the state they were at the start of the transaction. This means the database state and the business objects do get out of sync. Usually this is not a problem, because exceptions are not recoverable and you have to start over after rollback anyway." +#. Tag: para +#: transactions.xml:318 +#, no-c-format +msgid "" +"An exception thrown by Hibernate means you have to rollback your database " +"transaction and close the Session immediately (discussed " +"later in more detail). If your Session is bound to the " +"application, you have to stop the application. Rolling back the database " +"transaction doesn't put your business objects back into the state they were " +"at the start of the transaction. This means the database state and the " +"business objects do get out of sync. Usually this is not a problem, because " +"exceptions are not recoverable and you have to start over after rollback " +"anyway." msgstr "" +"一个由Hibernate抛出的异常意味着你必须立即回滚数据库事务,并立即关闭" +"Session (稍后会展开讨论)。如果你的Session绑定到一个应用程序上,你必 须停止该应用程序。回滚数据库事务并不会把你" +"的业务对象退回到事务启动时候的状态。这 意味着数据库状态和业务对象状态不同步。" +"通常情况下,这不是什么问题,因为异常是不可 恢复的,你必须在回滚之后重新开始执" +"行。" -#: index.docbook:330 -msgid "The Session caches every object that is in persistent state (watched and checked for dirty state by Hibernate). This means it grows endlessly until you get an OutOfMemoryException, if you keep it open for a long time or simply load too much data. One solution for this is to call clear() and evict() to manage the Session cache, but you most likely should consider a Stored Procedure if you need mass data operations. Some solutions are shown in . Keeping a Session open for the duration of a user session also means a high probability of stale data." +#. Tag: para +#: transactions.xml:330 +#, no-c-format +msgid "" +"The Session caches every object that is in persistent " +"state (watched and checked for dirty state by Hibernate). This means it " +"grows endlessly until you get an OutOfMemoryException, if you keep it open " +"for a long time or simply load too much data. One solution for this is to " +"call clear() and evict() to manage the " +"Session cache, but you most likely should consider a " +"Stored Procedure if you need mass data operations. Some solutions are shown " +"in . Keeping a Session open for " +"the duration of a user session also means a high probability of stale data." msgstr "" +"Session 缓存了处于持久化状态的每个对象(Hibernate会监视和" +"检查脏数据)。 这意味着,如果你让Session打开很长一段时间," +"或是仅仅载入了过多的数据, Session占用的内存会一直增长,直" +"到抛出OutOfMemoryException异常。这个 问题的一个解决方法是调用clear()" +"evict()来管理 Session的缓" +"存,但是如果你需要大批量数据操作的话,最好考虑 使用存储过程。在中有一些解决方案。在用户会话期间一直保持 Session打开也意味着出现脏数据的可能性很高。" -#: index.docbook:348 +#. Tag: title +#: transactions.xml:348 +#, no-c-format msgid "Database transaction demarcation" -msgstr "" +msgstr "数据库事务声明" -#: index.docbook:350 -msgid "Datatabase (or system) transaction boundaries are always necessary. No communication with the database can occur outside of a database transaction (this seems to confuse many developers who are used to the auto-commit mode). Always use clear transaction boundaries, even for read-only operations. Depending on your isolation level and database capabilities this might not be required but there is no downside if you always demarcate transactions explicitly. Certainly, a single database transaction is going to perform better than many small transactions, even for reading data." +#. Tag: para +#: transactions.xml:350 +#, no-c-format +msgid "" +"Datatabase (or system) transaction boundaries are always necessary. No " +"communication with the database can occur outside of a database transaction " +"(this seems to confuse many developers who are used to the auto-commit " +"mode). Always use clear transaction boundaries, even for read-only " +"operations. Depending on your isolation level and database capabilities this " +"might not be required but there is no downside if you always demarcate " +"transactions explicitly. Certainly, a single database transaction is going " +"to perform better than many small transactions, even for reading data." msgstr "" +"数据库(或者系统)事务的声明总是必须的。在数据库事务之外,就无法和数据库通讯" +"(这可能会让那些习惯于 自动提交事务模式的开发人员感到迷惑)。永远使用清晰的事" +"务声明,即使只读操作也是如此。进行 显式的事务声明并不总是需要的,这取决于你的" +"事务隔离级别和数据库的能力,但不管怎么说,声明事务总归有益无害。当然,一个单" +"独的数据库事务总是比很多琐碎的事务性能更好,即时对读数据而言也是一样。" -#: index.docbook:360 -msgid "A Hibernate application can run in non-managed (i.e. standalone, simple Web- or Swing applications) and managed J2EE environments. In a non-managed environment, Hibernate is usually responsible for its own database connection pool. The application developer has to manually set transaction boundaries, in other words, begin, commit, or rollback database transactions himself. A managed environment usually provides container-managed transactions (CMT), with the transaction assembly defined declaratively in deployment descriptors of EJB session beans, for example. Programmatic transaction demarcation is then no longer necessary." +#. Tag: para +#: transactions.xml:360 +#, no-c-format +msgid "" +"A Hibernate application can run in non-managed (i.e. standalone, simple Web- " +"or Swing applications) and managed J2EE environments. In a non-managed " +"environment, Hibernate is usually responsible for its own database " +"connection pool. The application developer has to manually set transaction " +"boundaries, in other words, begin, commit, or rollback database transactions " +"himself. A managed environment usually provides container-managed " +"transactions (CMT), with the transaction assembly defined declaratively in " +"deployment descriptors of EJB session beans, for example. Programmatic " +"transaction demarcation is then no longer necessary." msgstr "" +"一个Hibernate应用程序可以运行在非托管环境中(也就是独立运行的应用程序,简单" +"Web应用程序, 或者Swing图形桌面应用程序),也可以运行在托管的J2EE环境中。在一" +"个非托管环境中,Hibernate 通常自己负责管理数据库连接池。应用程序开发人员必须" +"手工设置事务声明,换句话说,就是手工启 动,提交,或者回滚数据库事务。一个托管" +"的环境通常提供了容器管理事务(CMT),例如事务装配通过可声 明的方式定义在EJB " +"session beans的部署描述符中。可编程式事务声明不再需要,即使是 " +"Session 的同步也可以自动完成。" -#: index.docbook:370 -msgid "However, it is often desirable to keep your persistence layer portable between non-managed resource-local environments, and systems that can rely on JTA but use BMT instead of CMT. In both cases you'd use programmatic transaction demaracation. Hibernate offers a wrapper API called Transaction that translates into the native transaction system of your deployment environment. This API is actually optional, but we strongly encourage its use unless you are in a CMT session bean." +#. Tag: para +#: transactions.xml:370 +#, no-c-format +msgid "" +"However, it is often desirable to keep your persistence layer portable " +"between non-managed resource-local environments, and systems that can rely " +"on JTA but use BMT instead of CMT. In both cases you'd use programmatic " +"transaction demaracation. Hibernate offers a wrapper API called " +"Transaction that translates into the native transaction " +"system of your deployment environment. This API is actually optional, but we " +"strongly encourage its use unless you are in a CMT session bean." msgstr "" +"让持久层具备可移植性是人们的理想,这种移植发生在非托管的本地资源环境,与依赖" +"JTA但是使用BMT而非CMT的系统之间。在两种情况下你都可以使用编程式的事务管理。" +"Hibernate提供了一套称为Transaction的封装API, 用来把你的部" +"署环境中的本地事务管理系统转换到Hibernate事务上。这个API是可选的,但是我们强" +"烈 推荐你使用,除非你用CMT session bean。" -#: index.docbook:379 -msgid "Usually, ending a Session involves four distinct phases:" -msgstr "" +#. Tag: para +#: transactions.xml:379 +#, no-c-format +msgid "" +"Usually, ending a Session involves four distinct phases:" +msgstr "通常情况下,结束 Session 包含了四个不同的阶段:" -#: index.docbook:385 +#. Tag: para +#: transactions.xml:385 +#, no-c-format msgid "flush the session" -msgstr "" +msgstr "同步session(flush,刷出到磁盘)" -#: index.docbook:390 +#. Tag: para +#: transactions.xml:390 +#, no-c-format msgid "commit the transaction" -msgstr "" +msgstr "提交事务" -#: index.docbook:395 +#. Tag: para +#: transactions.xml:395 +#, no-c-format msgid "close the session" -msgstr "" +msgstr "关闭session" -#: index.docbook:400 +#. Tag: para +#: transactions.xml:400 +#, no-c-format msgid "handle exceptions" -msgstr "" +msgstr "处理异常" -#: index.docbook:406 -msgid "Flushing the session has been discussed earlier, we'll now have a closer look at transaction demarcation and exception handling in both managed- and non-managed environments." +#. Tag: para +#: transactions.xml:406 +#, no-c-format +msgid "" +"Flushing the session has been discussed earlier, we'll now have a closer " +"look at transaction demarcation and exception handling in both managed- and " +"non-managed environments." msgstr "" +"session的同步(flush,刷出)前面已经讨论过了,我们现在进一步考察在托管和非托管" +"环境下的事务声明和异常处理。" -#: index.docbook:413 +#. Tag: title +#: transactions.xml:413 +#, no-c-format msgid "Non-managed environment" -msgstr "" +msgstr "非托管环境" -#: index.docbook:415 -msgid "If a Hibernate persistence layer runs in a non-managed environment, database connections are usually handled by simple (i.e. non-DataSource) connection pools from which Hibernate obtains connections as needed. The session/transaction handling idiom looks like this:" -msgstr "" - -#: index.docbook:422 +#. Tag: para +#: transactions.xml:415 +#, no-c-format msgid "" - "" +"If a Hibernate persistence layer runs in a non-managed environment, database " +"connections are usually handled by simple (i.e. non-DataSource) connection " +"pools from which Hibernate obtains connections as needed. The session/" +"transaction handling idiom looks like this:" msgstr "" +"如果Hibernat持久层运行在一个非托管环境中,数据库连接通常由Hibernate的简单(即" +"非DataSource)连接池机制 来处理。session/transaction处理方式如下所示:" -#: index.docbook:424 -msgid "You don't have to flush() the Session explicitly - the call to commit() automatically triggers the synchronization (depending upon the FlushMode for the session. A call to close() marks the end of a session. The main implication of close() is that the JDBC connection will be relinquished by the session. This Java code is portable and runs in both non-managed and JTA environments." -msgstr "" - -#: index.docbook:433 -msgid "A much more flexible solution is Hibernate's built-in \"current session\" context management, as described earlier:" -msgstr "" - -#: index.docbook:438 +#. Tag: programlisting +#: transactions.xml:422 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:440 -msgid "You will very likely never see these code snippets in a regular application; fatal (system) exceptions should always be caught at the \"top\". In other words, the code that executes Hibernate calls (in the persistence layer) and the code that handles RuntimeException (and usually can only clean up and exit) are in different layers. The current context management by Hibernate can significantly simplify this design, as all you need is access to a SessionFactory. Exception handling is discussed later in this chapter." +#. Tag: para +#: transactions.xml:424 +#, fuzzy, no-c-format +msgid "" +"You don't have to flush() the Session " +"explicitly - the call to commit() automatically triggers " +"the synchronization (depending upon the FlushMode for the session. A call to close() marks " +"the end of a session. The main implication of close() is " +"that the JDBC connection will be relinquished by the session. This Java code " +"is portable and runs in both non-managed and JTA environments." +msgstr "" +"你不需要显式flush()Session - 对" +"commit()的调用会自动触发session的同步(取决于session的" +"FlushMode)。调用 close" +"() 标志session的结束。close()方法重要的暗示是," +"session释放了JDBC连接。这段Java代码在非托管环境下和JTA环境" +"下都可以运行。" + +#. Tag: para +#: transactions.xml:433 +#, no-c-format +msgid "" +"A much more flexible solution is Hibernate's built-in \"current session\" " +"context management, as described earlier:" +msgstr "" +"更加灵活的方案是Hibernate内置的\"current session\"上下文管理,前文已经讲过:" + +#. Tag: programlisting +#: transactions.xml:438 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:450 -msgid "Note that you should select org.hibernate.transaction.JDBCTransactionFactory (which is the default), and for the second example \"thread\" as your hibernate.current_session_context_class." +#. Tag: para +#: transactions.xml:440 +#, no-c-format +msgid "" +"You will very likely never see these code snippets in a regular application; " +"fatal (system) exceptions should always be caught at the \"top\". In other " +"words, the code that executes Hibernate calls (in the persistence layer) and " +"the code that handles RuntimeException (and usually can " +"only clean up and exit) are in different layers. The current context " +"management by Hibernate can significantly simplify this design, as all you " +"need is access to a SessionFactory. Exception handling is " +"discussed later in this chapter." msgstr "" +"你很可能从未在一个通常的应用程序的业务代码中见过这样的代码片断:致命的(系" +"统)异常应该总是 在应用程序“顶层”被捕获。换句话说,执行Hibernate调用的代码" +"(在持久层)和处理 RuntimeException异常的代码(通常只能清" +"理和退出应用程序)应该在不同 的应用程序逻辑层。Hibernate的当前上下文管理可以" +"极大地简化这一设计,你所有的一切就是SessionFactory。 异常" +"处理将在本章稍后进行讨论。" -#: index.docbook:459 +#. Tag: para +#: transactions.xml:450 +#, no-c-format +msgid "" +"Note that you should select org.hibernate.transaction." +"JDBCTransactionFactory (which is the default), and for the second " +"example \"thread\" as your hibernate." +"current_session_context_class." +msgstr "" +"请注意,你应该选择 org.hibernate.transaction." +"JDBCTransactionFactory (这是默认选项),对第二个例子来说," +"hibernate.current_session_context_class应该是" +"\"thread\"" + +#. Tag: title +#: transactions.xml:459 +#, no-c-format msgid "Using JTA" -msgstr "" +msgstr "使用JTA" -#: index.docbook:461 -msgid "If your persistence layer runs in an application server (e.g. behind EJB session beans), every datasource connection obtained by Hibernate will automatically be part of the global JTA transaction. You can also install a standalone JTA implementation and use it without EJB. Hibernate offers two strategies for JTA integration." -msgstr "" - -#: index.docbook:468 -msgid "If you use bean-managed transactions (BMT) Hibernate will tell the application server to start and end a BMT transaction if you use the Transaction API. So, the transaction management code is identical to the non-managed environment." -msgstr "" - -#: index.docbook:474 +#. Tag: para +#: transactions.xml:461 +#, no-c-format msgid "" - "" +"If your persistence layer runs in an application server (e.g. behind EJB " +"session beans), every datasource connection obtained by Hibernate will " +"automatically be part of the global JTA transaction. You can also install a " +"standalone JTA implementation and use it without EJB. Hibernate offers two " +"strategies for JTA integration." msgstr "" +"如果你的持久层运行在一个应用服务器中(例如,在EJB session beans的后面)," +"Hibernate获取 的每个数据源连接将自动成为全局JTA事务的一部分。 你可以安装一个" +"独立的JTA实现,使用它而不使用EJB。Hibernate提供了两种策略进行JTA集成。" -#: index.docbook:476 -msgid "If you want to use a transaction-bound Session, that is, the getCurrentSession() functionality for easy context propagation, you will have to use the JTA UserTransaction API directly:" -msgstr "" - -#: index.docbook:482 +#. Tag: para +#: transactions.xml:468 +#, no-c-format msgid "" - "" +"If you use bean-managed transactions (BMT) Hibernate will tell the " +"application server to start and end a BMT transaction if you use the " +"Transaction API. So, the transaction management code is " +"identical to the non-managed environment." msgstr "" +"如果你使用bean管理事务(BMT),可以通过使用Hibernate的 Transaction API来告诉 应用服务器启动和结束BMT事务。因此,事务管理代码和在非托管" +"环境下是一样的。" -#: index.docbook:484 -msgid "With CMT, transaction demarcation is done in session bean deployment descriptors, not programatically, hence, the code is reduced to:" -msgstr "" - -#: index.docbook:489 +#. Tag: programlisting +#: transactions.xml:474 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:491 -msgid "In a CMT/EJB even rollback happens automatically, since an unhandled RuntimeException thrown by a session bean method tells the container to set the global transaction to rollback. This means you do not need to use the Hibernate Transaction API at all with BMT or CMT, and you get automatic propagation of the \"current\" Session bound to the transaction." +#. Tag: para +#: transactions.xml:476 +#, no-c-format +msgid "" +"If you want to use a transaction-bound Session, that is, " +"the getCurrentSession() functionality for easy context " +"propagation, you will have to use the JTA UserTransaction " +"API directly:" +msgstr "" +"如果你希望使用与事务绑定的Session,也就是使用" +"getCurrentSession()来简化上下文管理,你将不得不直接使用" +"JTA UserTransactionAPI。" + +#. Tag: programlisting +#: transactions.xml:482 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:499 -msgid "Note that you should choose org.hibernate.transaction.JTATransactionFactory if you use JTA directly (BMT), and org.hibernate.transaction.CMTTransactionFactory in a CMT session bean, when you configure Hibernate's transaction factory. Remember to also set hibernate.transaction.manager_lookup_class. Furthermore, make sure that your hibernate.current_session_context_class is either unset (backwards compatiblity), or set to \"jta\"." +#. Tag: para +#: transactions.xml:484 +#, no-c-format +msgid "" +"With CMT, transaction demarcation is done in session bean deployment " +"descriptors, not programatically, hence, the code is reduced to:" +msgstr "" +"在CMT方式下,事务声明是在session bean的部署描述符中,而不需要编程。 因此,代" +"码被简化为:" + +#. Tag: programlisting +#: transactions.xml:489 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:508 -msgid "The getCurrentSession() operation has one downside in a JTA environment. There is one caveat to the use of after_statement connection release mode, which is then used by default. Due to a silly limitation of the JTA spec, it is not possible for Hibernate to automatically clean up any unclosed ScrollableResults or Iterator instances returned by scroll() or iterate(). You must release the underlying database cursor by calling ScrollableResults.close() or Hibernate.close(Iterator) explicity from a finally block. (Of course, most applications can easily avoid using scroll() or iterate() at all from the JTA or CMT code.)" +#. Tag: para +#: transactions.xml:491 +#, no-c-format +msgid "" +"In a CMT/EJB even rollback happens automatically, since an unhandled " +"RuntimeException thrown by a session bean method tells " +"the container to set the global transaction to rollback. This " +"means you do not need to use the Hibernate Transaction " +"API at all with BMT or CMT, and you get automatic propagation of the " +"\"current\" Session bound to the transaction." msgstr "" +"在CMT/EJB中甚至会自动rollback,因为假若有未捕获的RuntimeException从session bean方法中抛出,这就会通知容器把全局事务回滚。这" +"就意味着,在BMT或者CMT中,你根本就不需要使用Hibernate Transaction API ,你自动得到了绑定到事务的“当前”Session。 " -#: index.docbook:524 +#. Tag: para +#: transactions.xml:499 +#, no-c-format +msgid "" +"Note that you should choose org.hibernate.transaction." +"JTATransactionFactory if you use JTA directly (BMT), and " +"org.hibernate.transaction.CMTTransactionFactory in a CMT " +"session bean, when you configure Hibernate's transaction factory. Remember " +"to also set hibernate.transaction.manager_lookup_class. " +"Furthermore, make sure that your hibernate." +"current_session_context_class is either unset (backwards " +"compatiblity), or set to \"jta\"." +msgstr "" +"注意,当你配置Hibernate的transaction factory的时候,在直接使用JTA的时候" +"(BMT),你应该选择org.hibernate.transaction.JTATransactionFactory,在CMT session bean中选择org.hibernate.transaction." +"CMTTransactionFactory。记得也要设置hibernate.transaction." +"manager_lookup_class。还有,确认你的hibernate." +"current_session_context_class未设置(为了向下兼容),或者设置为" +"\"jta\"。" + +#. Tag: para +#: transactions.xml:508 +#, no-c-format +msgid "" +"The getCurrentSession() operation has one downside in a " +"JTA environment. There is one caveat to the use of after_statement connection release mode, which is then used by default. Due to a " +"silly limitation of the JTA spec, it is not possible for Hibernate to " +"automatically clean up any unclosed ScrollableResults or " +"Iterator instances returned by scroll() or iterate(). You must " +"release the underlying database cursor by calling ScrollableResults." +"close() or Hibernate.close(Iterator) explicity " +"from a finally block. (Of course, most applications can " +"easily avoid using scroll() or iterate() at all from the JTA or CMT code.)" +msgstr "" +"getCurrentSession()在JTA环境中有一个弊端。对" +"after_statement连接释放方式有一个警告,这是被默认使用的。" +"因为JTA规范的一个很愚蠢的限制,Hibernate不可能自动清理任何未关闭的" +"ScrollableResults 或者Iterator,它们是" +"由scroll()iterate()产生的。你" +"must通过在finally块中,显式调用" +"ScrollableResults.close()或者Hibernate.close" +"(Iterator)方法来释放底层数据库游标。(当然,大部分程序完全可以很容易" +"的避免在JTA或CMT代码中出现scroll()iterate()。)" + +#. Tag: title +#: transactions.xml:524 +#, no-c-format msgid "Exception handling" -msgstr "" +msgstr "异常处理" -#: index.docbook:526 -msgid "If the Session throws an exception (including any SQLException), you should immediately rollback the database transaction, call Session.close() and discard the Session instance. Certain methods of Session will not leave the session in a consistent state. No exception thrown by Hibernate can be treated as recoverable. Ensure that the Session will be closed by calling close() in a finally block." +#. Tag: para +#: transactions.xml:526 +#, no-c-format +msgid "" +"If the Session throws an exception (including any " +"SQLException), you should immediately rollback the " +"database transaction, call Session.close() and discard " +"the Session instance. Certain methods of " +"Session will not leave the session " +"in a consistent state. No exception thrown by Hibernate can be treated as " +"recoverable. Ensure that the Session will be closed by " +"calling close() in a finally block." msgstr "" +"如果 Session 抛出异常 (包括任何SQLException), 你应该立即回滚数据库事务,调用 Session.close() ,丢弃该 Session实例。Session" +"的某些方法可能会导致session 处于不一致的状态。所有由Hibernate抛出的异常都视为" +"不可以恢复的。确保在 finally 代码块中调用close()" +"方法,以关闭掉 Session。" -#: index.docbook:537 -msgid "The HibernateException, which wraps most of the errors that can occur in a Hibernate persistence layer, is an unchecked exception (it wasn't in older versions of Hibernate). In our opinion, we shouldn't force the application developer to catch an unrecoverable exception at a low layer. In most systems, unchecked and fatal exceptions are handled in one of the first frames of the method call stack (i.e. in higher layers) and an error message is presented to the application user (or some other appropriate action is taken). Note that Hibernate might also throw other unchecked exceptions which are not a HibernateException. These are, again, not recoverable and appropriate action should be taken." +#. Tag: para +#: transactions.xml:537 +#, no-c-format +msgid "" +"The HibernateException, which wraps most of the errors " +"that can occur in a Hibernate persistence layer, is an unchecked exception " +"(it wasn't in older versions of Hibernate). In our opinion, we shouldn't " +"force the application developer to catch an unrecoverable exception at a low " +"layer. In most systems, unchecked and fatal exceptions are handled in one of " +"the first frames of the method call stack (i.e. in higher layers) and an " +"error message is presented to the application user (or some other " +"appropriate action is taken). Note that Hibernate might also throw other " +"unchecked exceptions which are not a HibernateException. " +"These are, again, not recoverable and appropriate action should be taken." msgstr "" +"HibernateException是一个非检查期异常(这不同于Hibernate老" +"的版本), 它封装了Hibernate持久层可能出现的大多数错误。我们的观点是,不应该" +"强迫应用程序开发人员 在底层捕获无法恢复的异常。在大多数软件系统中,非检查期异" +"常和致命异常都是在相应方法调用 的堆栈的顶层被处理的(也就是说,在软件上面的逻" +"辑层),并且提供一个错误信息给应用软件的用户 (或者采取其他某些相应的操作)。" +"请注意,Hibernate也有可能抛出其他并不属于 HibernateException的非检查期异常。这些异常同样也是无法恢复的,应该 采取某些相应的操作去" +"处理。" -#: index.docbook:549 -msgid "Hibernate wraps SQLExceptions thrown while interacting with the database in a JDBCException. In fact, Hibernate will attempt to convert the eexception into a more meningful subclass of JDBCException. The underlying SQLException is always available via JDBCException.getCause(). Hibernate converts the SQLException into an appropriate JDBCException subclass using the SQLExceptionConverter attached to the SessionFactory. By default, the SQLExceptionConverter is defined by the configured dialect; however, it is also possible to plug in a custom implementation (see the javadocs for the SQLExceptionConverterFactory class for details). The standard JDBCException subtypes are:" +#. Tag: para +#: transactions.xml:549 +#, no-c-format +msgid "" +"Hibernate wraps SQLExceptions thrown while interacting " +"with the database in a JDBCException. In fact, Hibernate " +"will attempt to convert the eexception into a more meningful subclass of " +"JDBCException. The underlying SQLException is always available via JDBCException.getCause(). Hibernate converts the SQLException into an " +"appropriate JDBCException subclass using the " +"SQLExceptionConverter attached to the " +"SessionFactory. By default, the " +"SQLExceptionConverter is defined by the configured " +"dialect; however, it is also possible to plug in a custom implementation " +"(see the javadocs for the SQLExceptionConverterFactory " +"class for details). The standard JDBCException subtypes " +"are:" msgstr "" +"在和数据库进行交互时,Hibernate把捕获的SQLException封装为" +"Hibernate的 JDBCException。事实上,Hibernate尝试把异常转换" +"为更有实际含义 的JDBCException异常的子类。底层的" +"SQLException可以 通过JDBCException.getCause()来得到。Hibernate通过使用关联到 SessionFactory上的" +"SQLExceptionConverter来 把SQLException" +"转换为一个对应的JDBCException 异常的子类。默认情况下," +"SQLExceptionConverter可以通过配置dialect 选项指定;此外," +"也可以使用用户自定义的实现类(参考javadocs " +"SQLExceptionConverterFactory类来了解详情)。标准的 " +"JDBCException子类型是:" -#: index.docbook:565 -msgid "JDBCConnectionException - indicates an error with the underlying JDBC communication." +#. Tag: para +#: transactions.xml:565 +#, no-c-format +msgid "" +"JDBCConnectionException - indicates an error with the " +"underlying JDBC communication." msgstr "" +"JDBCConnectionException - 指明底层的JDBC通讯出现错误" -#: index.docbook:571 -msgid "SQLGrammarException - indicates a grammar or syntax problem with the issued SQL." +#. Tag: para +#: transactions.xml:571 +#, no-c-format +msgid "" +"SQLGrammarException - indicates a grammar or syntax " +"problem with the issued SQL." msgstr "" +"SQLGrammarException - 指明发送的SQL语句的语法或者格式错误" -#: index.docbook:577 -msgid "ConstraintViolationException - indicates some form of integrity constraint violation." +#. Tag: para +#: transactions.xml:577 +#, no-c-format +msgid "" +"ConstraintViolationException - indicates some form of " +"integrity constraint violation." msgstr "" +"ConstraintViolationException - 指明某种类型的约束违例错误" -#: index.docbook:583 -msgid "LockAcquisitionException - indicates an error acquiring a lock level necessary to perform the requested operation." +#. Tag: para +#: transactions.xml:583 +#, no-c-format +msgid "" +"LockAcquisitionException - indicates an error acquiring a " +"lock level necessary to perform the requested operation." msgstr "" +"LockAcquisitionException - 指明了在执行请求操作时,获取 所" +"需的锁级别时出现的错误。" -#: index.docbook:589 -msgid "GenericJDBCException - a generic exception which did not fall into any of the other categories." -msgstr "" +#. Tag: para +#: transactions.xml:589 +#, no-c-format +msgid "" +"GenericJDBCException - a generic exception which did not " +"fall into any of the other categories." +msgstr "GenericJDBCException - 不属于任何其他种类的原生异常" -#: index.docbook:599 +#. Tag: title +#: transactions.xml:599 +#, no-c-format msgid "Transaction timeout" -msgstr "" +msgstr "事务超时" -#: index.docbook:601 -msgid "One extremely important feature provided by a managed environment like EJB that is never provided for non-managed code is transaction timeout. Transaction timeouts ensure that no misbehaving transaction can indefinitely tie up resources while returning no response to the user. Outside a managed (JTA) environment, Hibernate cannot fully provide this functionality. However, Hibernate can at least control data access operations, ensuring that database level deadlocks and queries with huge result sets are limited by a defined timeout. In a managed environment, Hibernate can delegate transaction timeout to JTA. This functioanlity is abstracted by the Hibernate Transaction object." -msgstr "" - -#: index.docbook:614 +#. Tag: para +#: transactions.xml:601 +#, no-c-format msgid "" - "" +"One extremely important feature provided by a managed environment like EJB " +"that is never provided for non-managed code is transaction timeout. " +"Transaction timeouts ensure that no misbehaving transaction can indefinitely " +"tie up resources while returning no response to the user. Outside a managed " +"(JTA) environment, Hibernate cannot fully provide this functionality. " +"However, Hibernate can at least control data access operations, ensuring " +"that database level deadlocks and queries with huge result sets are limited " +"by a defined timeout. In a managed environment, Hibernate can delegate " +"transaction timeout to JTA. This functioanlity is abstracted by the " +"Hibernate Transaction object." +msgstr "" +"EJB这样的托管环境有一项极为重要的特性,而它从未在非托管环境中提供过,那就是事" +"务超时。在出现错误的事务行为的时候,超时可以确保不会无限挂起资源、对用户没有" +"交代。在托管(JTA)环境之外,Hibernate无法完全提供这一功能。但是,Hiberante至少" +"可以控制数据访问,确保数据库级别的死锁,和返回巨大结果集的查询被限定在一个规" +"定的时间内。在托管环境中,Hibernate会把事务超时转交给JTA。这一功能通过" +"Hibernate Transaction对象进行抽象。" + +#. Tag: programlisting +#: transactions.xml:614 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:616 -msgid "Note that setTimeout() may not be called in a CMT bean, where transaction timeouts must be defined declaratively." +#. Tag: para +#: transactions.xml:616 +#, no-c-format +msgid "" +"Note that setTimeout() may not be called in a CMT bean, " +"where transaction timeouts must be defined declaratively." msgstr "" +"注意setTimeout()不应该在CMT bean中调用,此时事务超时值应该" +"是被声明式定义的。" -#: index.docbook:626 +#. Tag: title +#: transactions.xml:626 +#, no-c-format msgid "Optimistic concurrency control" -msgstr "" +msgstr "乐观并发控制(Optimistic concurrency control)" -#: index.docbook:628 -msgid "The only approach that is consistent with high concurrency and high scalability is optimistic concurrency control with versioning. Version checking uses version numbers, or timestamps, to detect conflicting updates (and to prevent lost updates). Hibernate provides for three possible approaches to writing application code that uses optimistic concurrency. The use cases we show are in the context of long conversations, but version checking also has the benefit of preventing lost updates in single database transactions." +#. Tag: para +#: transactions.xml:628 +#, no-c-format +msgid "" +"The only approach that is consistent with high concurrency and high " +"scalability is optimistic concurrency control with versioning. Version " +"checking uses version numbers, or timestamps, to detect conflicting updates " +"(and to prevent lost updates). Hibernate provides for three possible " +"approaches to writing application code that uses optimistic concurrency. The " +"use cases we show are in the context of long conversations, but version " +"checking also has the benefit of preventing lost updates in single database " +"transactions." msgstr "" +"唯一能够同时保持高并发和高可伸缩性的方法就是使用带版本化的乐观并发控制。版本" +"检查使用版本号、 或者时间戳来检测更新冲突(并且防止更新丢失)。Hibernate为使" +"用乐观并发控制的代码提供了三种可 能的方法,应用程序在编写这些代码时,可以采用" +"它们。我们已经在前面应用程序对话那部分展示了 乐观并发控制的应用场景,此外,在" +"单个数据库事务范围内,版本检查也提供了防止更新丢失的好处。" -#: index.docbook:639 +#. Tag: title +#: transactions.xml:639 +#, no-c-format msgid "Application version checking" -msgstr "" +msgstr "应用程序级别的版本检查(Application version checking)" -#: index.docbook:641 -msgid "In an implementation without much help from Hibernate, each interaction with the database occurs in a new Session and the developer is responsible for reloading all persistent instances from the database before manipulating them. This approach forces the application to carry out its own version checking to ensure conversation transaction isolation. This approach is the least efficient in terms of database access. It is the approach most similar to entity EJBs." -msgstr "" - -#: index.docbook:650 +#. Tag: para +#: transactions.xml:641 +#, no-c-format msgid "" - "" +"In an implementation without much help from Hibernate, each interaction with " +"the database occurs in a new Session and the developer is " +"responsible for reloading all persistent instances from the database before " +"manipulating them. This approach forces the application to carry out its own " +"version checking to ensure conversation transaction isolation. This approach " +"is the least efficient in terms of database access. It is the approach most " +"similar to entity EJBs." +msgstr "" +"未能充分利用Hibernate功能的实现代码中,每次和数据库交互都需要一个新的 " +"Session,而且开发人员必须在显示数据之前从数据库中重 新载入" +"所有的持久化对象实例。这种方式迫使应用程序自己实现版本检查来确保 对话事务的隔" +"离,从数据访问的角度来说是最低效的。这种使用方式和 entity EJB最相似。" + +#. Tag: programlisting +#: transactions.xml:650 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:652 -msgid "The version property is mapped using <version>, and Hibernate will automatically increment it during flush if the entity is dirty." +#. Tag: para +#: transactions.xml:652 +#, no-c-format +msgid "" +"The version property is mapped using <" +"version>, and Hibernate will automatically increment it during " +"flush if the entity is dirty." msgstr "" +"version 属性使用 <version>来映" +"射,如果对象 是脏数据,在同步的时候,Hibernate会自动增加版本号。" -#: index.docbook:658 -msgid "Of course, if you are operating in a low-data-concurrency environment and don't require version checking, you may use this approach and just skip the version check. In that case, last commit wins will be the default strategy for your long conversations. Keep in mind that this might confuse the users of the application, as they might experience lost updates without error messages or a chance to merge conflicting changes." +#. Tag: para +#: transactions.xml:658 +#, no-c-format +msgid "" +"Of course, if you are operating in a low-data-concurrency environment and " +"don't require version checking, you may use this approach and just skip the " +"version check. In that case, last commit wins will be " +"the default strategy for your long conversations. Keep in mind that this " +"might confuse the users of the application, as they might experience lost " +"updates without error messages or a chance to merge conflicting changes." msgstr "" +"当然,如果你的应用是在一个低数据并发环境下,并不需要版本检查的话,你照样可以" +"使用 这种方式,只不过跳过版本检查就是了。在这种情况下,最晚提交生效" +"last commit wins)就是你的长对话的默认处理" +"策略。 请记住这种策略可能会让应用软件的用户感到困惑,因为他们有可能会碰上更新" +"丢失掉却没 有出错信息,或者需要合并更改冲突的情况。" -#: index.docbook:667 -msgid "Clearly, manual version checking is only feasible in very trivial circumstances and not practical for most applications. Often not only single instances, but complete graphs of modified ojects have to be checked. Hibernate offers automatic version checking with either an extended Session or detached instances as the design paradigm." +#. Tag: para +#: transactions.xml:667 +#, no-c-format +msgid "" +"Clearly, manual version checking is only feasible in very trivial " +"circumstances and not practical for most applications. Often not only single " +"instances, but complete graphs of modified ojects have to be checked. " +"Hibernate offers automatic version checking with either an extended " +"Session or detached instances as the design paradigm." msgstr "" +"很明显,手工进行版本检查只适合于某些软件规模非常小的应用场景,对于大多数软件" +"应用场景 来说并不现实。通常情况下,不仅是单个对象实例需要进行版本检查,整个被" +"修改过的关 联对象图也都需要进行版本检查。作为标准设计范例,Hibernate使用扩展" +"周期的 Session的方式,或者脱管对象实例的方式来提供自动版本" +"检查。" -#: index.docbook:678 +#. Tag: title +#: transactions.xml:678 +#, no-c-format msgid "Extended session and automatic versioning" -msgstr "" +msgstr "扩展周期的session和自动版本化" -#: index.docbook:680 -msgid "A single Session instance and its persistent instances are used for the whole conversation, known as session-per-conversation. Hibernate checks instance versions at flush time, throwing an exception if concurrent modification is detected. It's up to the developer to catch and handle this exception (common options are the opportunity for the user to merge changes or to restart the business conversation with non-stale data)." -msgstr "" - -#: index.docbook:689 -msgid "The Session is disconnected from any underlying JDBC connection when waiting for user interaction. This approach is the most efficient in terms of database access. The application need not concern itself with version checking or with reattaching detached instances, nor does it have to reload instances in every database transaction." -msgstr "" - -#: index.docbook:697 +#. Tag: para +#: transactions.xml:680 +#, no-c-format msgid "" - "" +"A single Session instance and its persistent instances " +"are used for the whole conversation, known as session-per-" +"conversation. Hibernate checks instance versions at flush time, " +"throwing an exception if concurrent modification is detected. It's up to the " +"developer to catch and handle this exception (common options are the " +"opportunity for the user to merge changes or to restart the business " +"conversation with non-stale data)." +msgstr "" +"单个 Session实例和它所关联的所有持久化对象实例都被用于整" +"个 对话,这被称为session-per-conversation。Hibernate在同" +"步的时候进行对象实例的版本检查,如果检测到并发修 改则抛出异常。由开发人员来决" +"定是否需要捕获和处理这个异常(通常的抉择是给用户 提供一个合并更改,或者在无脏" +"数据情况下重新进行业务对话的机会)。" + +#. Tag: para +#: transactions.xml:689 +#, no-c-format +msgid "" +"The Session is disconnected from any underlying JDBC " +"connection when waiting for user interaction. This approach is the most " +"efficient in terms of database access. The application need not concern " +"itself with version checking or with reattaching detached instances, nor " +"does it have to reload instances in every database transaction." +msgstr "" +"在等待用户交互的时候, Session 断开底层的JDBC连接。这种方" +"式 以数据库访问的角度来说是最高效的方式。应用程序不需要关心版本检查或脱管对象" +"实例 的重新关联,在每个数据库事务中,应用程序也不需要载入读取对象实例。" + +#. Tag: programlisting +#: transactions.xml:697 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:698 -msgid "The foo object still knows which Session it was loaded in. Beginning a new database transaction on an old session obtains a new connection and resumes the session. Committing a database transaction disconnects a session from the JDBC connection and returns the connection to the pool. After reconnection, to force a version check on data you aren't updating, you may call Session.lock() with LockMode.READ on any objects that might have been updated by another transaction. You don't need to lock any data that you are updating. Usually you would set FlushMode.MANUAL on an extended Session, so that only the last database transaction cycle is allowed to actually persist all modifications made in this conversation. Hence, only this last database transaction would include the flush() operation, and then also close() the session to end the conversation." +#. Tag: para +#: transactions.xml:698 +#, no-c-format +msgid "" +"The foo object still knows which Session it was loaded in. Beginning a new database transaction on an old " +"session obtains a new connection and resumes the session. Committing a " +"database transaction disconnects a session from the JDBC connection and " +"returns the connection to the pool. After reconnection, to force a version " +"check on data you aren't updating, you may call Session.lock() with LockMode.READ on any objects that might " +"have been updated by another transaction. You don't need to lock any data " +"that you are updating. Usually you would set " +"FlushMode.MANUAL on an extended Session, so that only the last database transaction cycle is allowed to " +"actually persist all modifications made in this conversation. Hence, only " +"this last database transaction would include the flush() " +"operation, and then also close() the session to end the " +"conversation." msgstr "" +"foo对象知道它是在哪个Session中被装入" +"的。在一个旧session中开启一个新的数据库事务,会导致session获取一个新的连接," +"并恢复session的功能。将数据库事务提交,使得session从JDBC连接断开,并将此连接" +"交还给连接池。在重新连接之后,要强制对你没有更新的数据进行一次版本检查,你可" +"以对所有可能被其他事务修改过的对象,使用参数LockMode.READ" +"来调用Session.lock()。你不用lock任何你正在更新的数据。一般你会在扩展的Session上设置" +"FlushMode.MANUAL,因此只有最后一个数据库事务循环才会真正的" +"吧整个对话中发生的修改发送到数据库。因此,只有这最后一次数据库事务才会包含" +"flush()操作,然后在整个对话结束后,还要close()这个session。" -#: index.docbook:713 -msgid "This pattern is problematic if the Session is too big to be stored during user think time, e.g. an HttpSession should be kept as small as possible. As the Session is also the (mandatory) first-level cache and contains all loaded objects, we can probably use this strategy only for a few request/response cycles. You should use a Session only for a single conversation, as it will soon also have stale data." +#. Tag: para +#: transactions.xml:713 +#, no-c-format +msgid "" +"This pattern is problematic if the Session is too big to " +"be stored during user think time, e.g. an HttpSession " +"should be kept as small as possible. As the Session is " +"also the (mandatory) first-level cache and contains all loaded objects, we " +"can probably use this strategy only for a few request/response cycles. You " +"should use a Session only for a single conversation, as " +"it will soon also have stale data." msgstr "" +"如果在用户思考的过程中,Session因为太大了而不能保存,那么" +"这种模式是有 问题的。举例来说,一个HttpSession应该尽可能的" +"小。由于 Session是一级缓存,并且保持了所有被载入过的对象," +"因此 我们只应该在那些少量的request/response情况下使用这种策略。你应该只把一个" +"Session用于单个对话,因为它很快就会出现脏数据。" -#: index.docbook:723 -msgid "(Note that earlier Hibernate versions required explicit disconnection and reconnection of a Session. These methods are deprecated, as beginning and ending a transaction has the same effect.)" +#. Tag: para +#: transactions.xml:723 +#, no-c-format +msgid "" +"(Note that earlier Hibernate versions required explicit disconnection and " +"reconnection of a Session. These methods are deprecated, " +"as beginning and ending a transaction has the same effect.)" msgstr "" +"(注意,早期的Hibernate版本需要明确的对Session进行" +"disconnec和reconnect。这些方法现在已经过时了,打开事务和关闭事务会起到同样的" +"效果。)" -#: index.docbook:729 -msgid "Also note that you should keep the disconnected Session close to the persistence layer. In other words, use an EJB stateful session bean to hold the Session in a three-tier environment, and don't transfer it to the web layer (or even serialize it to a separate tier) to store it in the HttpSession." +#. Tag: para +#: transactions.xml:729 +#, no-c-format +msgid "" +"Also note that you should keep the disconnected Session " +"close to the persistence layer. In other words, use an EJB stateful session " +"bean to hold the Session in a three-tier environment, and " +"don't transfer it to the web layer (or even serialize it to a separate tier) " +"to store it in the HttpSession." msgstr "" +"此外,也请注意,你应该让与数据库连接断开的Session对持久层" +"保持 关闭状态。换句话说,在三层环境中,使用有状态的EJB session bean来持有" +"Session, 而不要把它传递到web层(甚至把它序列化到一个单独" +"的层),保存在HttpSession中。" -#: index.docbook:737 -msgid "The extended session pattern, or session-per-conversation, is more difficult to implement with automatic current session context management. You need to supply your own implementation of the CurrentSessionContext for this, see the Hibernate Wiki for examples." +#. Tag: para +#: transactions.xml:737 +#, no-c-format +msgid "" +"The extended session pattern, or session-per-conversation, is more difficult to implement with automatic current session " +"context management. You need to supply your own implementation of the " +"CurrentSessionContext for this, see the Hibernate Wiki " +"for examples." msgstr "" +"扩展session模式,或者被称为每次对话一个session(session-per-" +"conversation), 在与自动管理当前session上下文联用的时候会更困难。你" +"需要提供你自己的CurrentSessionContext实现。请参阅" +"Hibernate Wiki以获得示例。" -#: index.docbook:747 +#. Tag: title +#: transactions.xml:747 +#, no-c-format msgid "Detached objects and automatic versioning" -msgstr "" +msgstr "脱管对象(deatched object)和自动版本化" -#: index.docbook:749 -msgid "Each interaction with the persistent store occurs in a new Session. However, the same persistent instances are reused for each interaction with the database. The application manipulates the state of detached instances originally loaded in another Session and then reattaches them using Session.update(), Session.saveOrUpdate(), or Session.merge()." -msgstr "" - -#: index.docbook:757 +#. Tag: para +#: transactions.xml:749 +#, no-c-format msgid "" - "" +"Each interaction with the persistent store occurs in a new Session. However, the same persistent instances are reused for each " +"interaction with the database. The application manipulates the state of " +"detached instances originally loaded in another Session " +"and then reattaches them using Session.update(), " +"Session.saveOrUpdate(), or Session.merge()." +msgstr "" +"这种方式下,与持久化存储的每次交互都发生在一个新的Session" +"中。 然而,同一持久化对象实例可以在多次与数据库的交互中重用。应用程序操纵脱管" +"对象实例 的状态,这个脱管对象实例最初是在另一个Session 中" +"载入的,然后 调用 Session.update()Session." +"saveOrUpdate(), 或者 Session.merge() 来重新关联" +"该对象实例。" + +#. Tag: programlisting +#: transactions.xml:757 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:759 -msgid "Again, Hibernate will check instance versions during flush, throwing an exception if conflicting updates occured." +#. Tag: para +#: transactions.xml:759 +#, no-c-format +msgid "" +"Again, Hibernate will check instance versions during flush, throwing an " +"exception if conflicting updates occured." msgstr "" +"Hibernate会再一次在同步的时候检查对象实例的版本,如果发生更新冲突,就抛出异" +"常。" -#: index.docbook:764 -msgid "You may also call lock() instead of update() and use LockMode.READ (performing a version check, bypassing all caches) if you are sure that the object has not been modified." +#. Tag: para +#: transactions.xml:764 +#, no-c-format +msgid "" +"You may also call lock() instead of update() and use LockMode.READ (performing a version " +"check, bypassing all caches) if you are sure that the object has not been " +"modified." msgstr "" +"如果你确信对象没有被修改过,你也可以调用lock() 来设置 " +"LockMode.READ(绕过所有的缓存,执行版本检查),从而取 代 " +"update()操作。" -#: index.docbook:773 +#. Tag: title +#: transactions.xml:773 +#, no-c-format msgid "Customizing automatic versioning" -msgstr "" +msgstr "定制自动版本化行为" -#: index.docbook:775 -msgid "You may disable Hibernate's automatic version increment for particular properties and collections by setting the optimistic-lock mapping attribute to false. Hibernate will then no longer increment versions if the property is dirty." +#. Tag: para +#: transactions.xml:775 +#, no-c-format +msgid "" +"You may disable Hibernate's automatic version increment for particular " +"properties and collections by setting the optimistic-lock " +"mapping attribute to false. Hibernate will then no longer " +"increment versions if the property is dirty." msgstr "" +"对于特定的属性和集合,通过为它们设置映射属性optimistic-lock的值 为false,来禁止Hibernate的版本自动增加。这样" +"的话,如果该属性 脏数据,Hibernate将不再增加版本号。" -#: index.docbook:782 -msgid "Legacy database schemas are often static and can't be modified. Or, other applications might also access the same database and don't know how to handle version numbers or even timestamps. In both cases, versioning can't rely on a particular column in a table. To force a version check without a version or timestamp property mapping, with a comparison of the state of all fields in a row, turn on optimistic-lock=\"all\" in the <class> mapping. Note that this concepetually only works if Hibernate can compare the old and new state, i.e. if you use a single long Session and not session-per-request-with-detached-objects." +#. Tag: para +#: transactions.xml:782 +#, no-c-format +msgid "" +"Legacy database schemas are often static and can't be modified. Or, other " +"applications might also access the same database and don't know how to " +"handle version numbers or even timestamps. In both cases, versioning can't " +"rely on a particular column in a table. To force a version check without a " +"version or timestamp property mapping, with a comparison of the state of all " +"fields in a row, turn on optimistic-lock=\"all\" in the " +"<class> mapping. Note that this concepetually only " +"works if Hibernate can compare the old and new state, i.e. if you use a " +"single long Session and not session-per-request-with-" +"detached-objects." msgstr "" +"遗留系统的数据库Schema通常是静态的,不可修改的。或者,其他应用程序也可能访问" +"同一数据 库,根本无法得知如何处理版本号,甚至时间戳。在以上的所有场景中,实现" +"版本化不能依靠 数据库表的某个特定列。在<class>的映射" +"中设置 optimistic-lock=\"all\"可以在没有版本或者时间戳属性" +"映射的情况下实现 版本检查,此时Hibernate将比较一行记录的每个字段的状态。请注" +"意,只有当Hibernate能够比 较新旧状态的情况下,这种方式才能生效,也就是说, 你" +"必须使用单个长生命周期Session模式,而不能使用 session-per-" +"request-with-detached-objects模式。" -#: index.docbook:793 -msgid "Sometimes concurrent modification can be permitted as long as the changes that have been made don't overlap. If you set optimistic-lock=\"dirty\" when mapping the <class>, Hibernate will only compare dirty fields during flush." +#. Tag: para +#: transactions.xml:793 +#, no-c-format +msgid "" +"Sometimes concurrent modification can be permitted as long as the changes " +"that have been made don't overlap. If you set optimistic-lock=" +"\"dirty\" when mapping the <class>, " +"Hibernate will only compare dirty fields during flush." msgstr "" +"有些情况下,只要更改不发生交错,并发修改也是允许的。当你在<" +"class> 的映射中设置optimistic-lock=\"dirty\",Hibernate在同步的时候将只比较有脏 数据的字段。" -#: index.docbook:799 -msgid "In both cases, with dedicated version/timestamp columns or with full/dirty field comparison, Hibernate uses a single UPDATE statement (with an appropriate WHERE clause) per entity to execute the version check and update the information. If you use transitive persistence to cascade reattachment to associated entities, Hibernate might execute uneccessary updates. This is usually not a problem, but on update triggers in the database might be executed even when no changes have been made to detached instances. You can customize this behavior by setting select-before-update=\"true\" in the <class> mapping, forcing Hibernate to SELECT the instance to ensure that changes did actually occur, before updating the row." +#. Tag: para +#: transactions.xml:799 +#, no-c-format +msgid "" +"In both cases, with dedicated version/timestamp columns or with full/dirty " +"field comparison, Hibernate uses a single UPDATE " +"statement (with an appropriate WHERE clause) per entity " +"to execute the version check and update the information. If you use " +"transitive persistence to cascade reattachment to associated entities, " +"Hibernate might execute uneccessary updates. This is usually not a problem, " +"but on update triggers in the database might be " +"executed even when no changes have been made to detached instances. You can " +"customize this behavior by setting select-before-update=\"true\" in the <class> mapping, forcing Hibernate " +"to SELECT the instance to ensure that changes did " +"actually occur, before updating the row." msgstr "" +"在以上所有场景中,不管是专门设置一个版本/时间戳列,还是进行全部字段/脏数据字" +"段比较, Hibernate都会针对每个实体对象发送一条UPDATE(带有" +"相应的 WHERE语句 )的SQL语句来执行版本检查和数据更新。如果" +"你对关联实体 设置级联关系使用传播性持久化(transitive persistence),那么" +"Hibernate可能会执行不必 要的update语句。这通常不是个问题,但是数据库里面对" +"on update点火 的触发器可能在脱管对象没有任何更改的情况下" +"被触发。因此,你可以在 <class>的映射中,通过设置" +"select-before-update=\"true\" 来定制这一行为,强制" +"Hibernate SELECT这个对象实例,从而保证, 在更新记录之前," +"对象的确是被修改过。" -#: index.docbook:817 +#. Tag: title +#: transactions.xml:817 +#, no-c-format msgid "Pessimistic Locking" -msgstr "" +msgstr "悲观锁定(Pessimistic Locking)" -#: index.docbook:819 -msgid "It is not intended that users spend much time worring about locking strategies. Its usually enough to specify an isolation level for the JDBC connections and then simply let the database do all the work. However, advanced users may sometimes wish to obtain exclusive pessimistic locks, or re-obtain locks at the start of a new transaction." +#. Tag: para +#: transactions.xml:819 +#, no-c-format +msgid "" +"It is not intended that users spend much time worring about locking " +"strategies. Its usually enough to specify an isolation level for the JDBC " +"connections and then simply let the database do all the work. However, " +"advanced users may sometimes wish to obtain exclusive pessimistic locks, or " +"re-obtain locks at the start of a new transaction." msgstr "" +"用户其实并不需要花很多精力去担心锁定策略的问题。通常情况下,只要为JDBC连接指" +"定一下隔 离级别,然后让数据库去搞定一切就够了。然而,高级用户有时候希望进行一" +"个排它的悲观锁定, 或者在一个新的事务启动的时候,重新进行锁定。" -#: index.docbook:826 -msgid "Hibernate will always use the locking mechanism of the database, never lock objects in memory!" +#. Tag: para +#: transactions.xml:826 +#, no-c-format +msgid "" +"Hibernate will always use the locking mechanism of the database, never lock " +"objects in memory!" +msgstr "Hibernate总是使用数据库的锁定机制,从不在内存中锁定对象!" + +#. Tag: para +#: transactions.xml:831 +#, no-c-format +msgid "" +"The LockMode class defines the different lock levels that " +"may be acquired by Hibernate. A lock is obtained by the following mechanisms:" msgstr "" +"类LockMode 定义了Hibernate所需的不同的锁定级别。一个锁定 " +"可以通过以下的机制来设置:" -#: index.docbook:831 -msgid "The LockMode class defines the different lock levels that may be acquired by Hibernate. A lock is obtained by the following mechanisms:" +#. Tag: para +#: transactions.xml:838 +#, no-c-format +msgid "" +"LockMode.WRITE is acquired automatically when Hibernate " +"updates or inserts a row." msgstr "" +"当Hibernate更新或者插入一行记录的时候,锁定级别自动设置为LockMode." +"WRITE。" -#: index.docbook:838 -msgid "LockMode.WRITE is acquired automatically when Hibernate updates or inserts a row." +#. Tag: para +#: transactions.xml:844 +#, no-c-format +msgid "" +"LockMode.UPGRADE may be acquired upon explicit user " +"request using SELECT ... FOR UPDATE on databases which " +"support that syntax." msgstr "" +"当用户显式的使用数据库支持的SQL格式SELECT ... FOR UPDATE " +"发送SQL的时候,锁定级别设置为LockMode.UPGRADE" -#: index.docbook:844 -msgid "LockMode.UPGRADE may be acquired upon explicit user request using SELECT ... FOR UPDATE on databases which support that syntax." +#. Tag: para +#: transactions.xml:850 +#, no-c-format +msgid "" +"LockMode.UPGRADE_NOWAIT may be acquired upon explicit " +"user request using a SELECT ... FOR UPDATE NOWAIT under " +"Oracle." msgstr "" +"当用户显式的使用Oracle数据库的SQL语句SELECT ... FOR UPDATE NOWAIT 的时候,锁定级别设置LockMode.UPGRADE_NOWAIT" -#: index.docbook:850 -msgid "LockMode.UPGRADE_NOWAIT may be acquired upon explicit user request using a SELECT ... FOR UPDATE NOWAIT under Oracle." +#. Tag: para +#: transactions.xml:856 +#, no-c-format +msgid "" +"LockMode.READ is acquired automatically when Hibernate " +"reads data under Repeatable Read or Serializable isolation level. May be re-" +"acquired by explicit user request." msgstr "" +"当Hibernate在“可重复读”或者是“序列化”数据库隔离级别下读取数据的时候,锁定模" +"式 自动设置为LockMode.READ。这种模式也可以通过用户显式指定" +"进行设置。" -#: index.docbook:856 -msgid "LockMode.READ is acquired automatically when Hibernate reads data under Repeatable Read or Serializable isolation level. May be re-acquired by explicit user request." +#. Tag: para +#: transactions.xml:863 +#, no-c-format +msgid "" +"LockMode.NONE represents the absence of a lock. All " +"objects switch to this lock mode at the end of a Transaction. Objects associated with the session via a call to update()" +" or saveOrUpdate() also start out in this lock " +"mode." msgstr "" +"LockMode.NONE 代表无需锁定。在Transaction结束时, 所有的对象都切换到该模式上来。与session相关联的对象通过调用" +"update() 或者saveOrUpdate()脱离该模式。" -#: index.docbook:863 -msgid "LockMode.NONE represents the absence of a lock. All objects switch to this lock mode at the end of a Transaction. Objects associated with the session via a call to update() or saveOrUpdate() also start out in this lock mode." +#. Tag: para +#: transactions.xml:872 +#, no-c-format +msgid "" +"The \"explicit user request\" is expressed in one of the following ways:" +msgstr "\"显式的用户指定\"可以通过以下几种方式之一来表示:" + +#. Tag: para +#: transactions.xml:878 +#, no-c-format +msgid "" +"A call to Session.load(), specifying a LockMode." msgstr "" +"调用 Session.load()的时候指定锁定模式(LockMode)。" -#: index.docbook:872 -msgid "The \"explicit user request\" is expressed in one of the following ways:" -msgstr "" - -#: index.docbook:878 -msgid "A call to Session.load(), specifying a LockMode." -msgstr "" - -#: index.docbook:883 +#. Tag: para +#: transactions.xml:883 +#, no-c-format msgid "A call to Session.lock()." -msgstr "" +msgstr "调用Session.lock()。" -#: index.docbook:888 +#. Tag: para +#: transactions.xml:888 +#, no-c-format msgid "A call to Query.setLockMode()." -msgstr "" +msgstr "调用Query.setLockMode()。" -#: index.docbook:894 -msgid "If Session.load() is called with UPGRADE or UPGRADE_NOWAIT, and the requested object was not yet loaded by the session, the object is loaded using SELECT ... FOR UPDATE. If load() is called for an object that is already loaded with a less restrictive lock than the one requested, Hibernate calls lock() for that object." +#. Tag: para +#: transactions.xml:894 +#, no-c-format +msgid "" +"If Session.load() is called with UPGRADE or UPGRADE_NOWAIT, and the requested object was " +"not yet loaded by the session, the object is loaded using " +"SELECT ... FOR UPDATE. If load() is " +"called for an object that is already loaded with a less restrictive lock " +"than the one requested, Hibernate calls lock() for that " +"object." msgstr "" +"如果在UPGRADE或者UPGRADE_NOWAIT锁定模式" +"下调 用Session.load(),并且要读取的对象尚未被session载入" +"过,那么对象 通过SELECT ... FOR UPDATE这样的SQL语句被载" +"入。如果为一个对象调用 load()方法时,该对象已经在另一个较" +"少限制的锁定模式下被载入了,那 么Hibernate就对该对象调用lock() 方法。" -#: index.docbook:903 -msgid "Session.lock() performs a version number check if the specified lock mode is READ, UPGRADE or UPGRADE_NOWAIT. (In the case of UPGRADE or UPGRADE_NOWAIT, SELECT ... FOR UPDATE is used.)" +#. Tag: para +#: transactions.xml:903 +#, no-c-format +msgid "" +"Session.lock() performs a version number check if the " +"specified lock mode is READ, UPGRADE " +"or UPGRADE_NOWAIT. (In the case of UPGRADE or UPGRADE_NOWAIT, SELECT ... FOR " +"UPDATE is used.)" msgstr "" +"如果指定的锁定模式是READ, UPGRADE 或 " +"UPGRADE_NOWAIT,那么Session.lock()就 执" +"行版本号检查。(在UPGRADE 或者UPGRADE_NOWAIT 锁定模式下,执行SELECT ... FOR UPDATE这样的SQL语" +"句。)" -#: index.docbook:910 -msgid "If the database does not support the requested lock mode, Hibernate will use an appropriate alternate mode (instead of throwing an exception). This ensures that applications will be portable." +#. Tag: para +#: transactions.xml:910 +#, no-c-format +msgid "" +"If the database does not support the requested lock mode, Hibernate will use " +"an appropriate alternate mode (instead of throwing an exception). This " +"ensures that applications will be portable." msgstr "" +"如果数据库不支持用户设置的锁定模式,Hibernate将使用适当的替代模式(而不是扔出" +"异常)。 这一点可以确保应用程序的可移植性。" -#: index.docbook:919 +#. Tag: title +#: transactions.xml:919 +#, no-c-format msgid "Connection Release Modes" +msgstr "连接释放模式(Connection Release Modes)" + +#. Tag: para +#: transactions.xml:921 +#, no-c-format +msgid "" +"The legacy (2.x) behavior of Hibernate in regards to JDBC connection " +"management was that a Session would obtain a connection " +"when it was first needed and then hold unto that connection until the " +"session was closed. Hibernate 3.x introduced the notion of connection " +"release modes to tell a session how to handle its JDBC connections. Note " +"that the following discussion is pertinent only to connections provided " +"through a configured ConnectionProvider; user-supplied " +"connections are outside the breadth of this discussion. The different " +"release modes are identified by the enumerated values of org." +"hibernate.ConnectionReleaseMode:" msgstr "" +"Hibernate关于JDBC连接管理的旧(2.x)行为是,Session在第一次" +"需要的时候获取一个连接,在session关闭之前一直会持有这个连接。Hibernate引入了" +"连接释放的概念,来告诉session如何处理它的JDBC连接。注意,下面的讨论只适用于采" +"用配置ConnectionProvider来提供连接的情况,用户自己提供的连" +"接与这里的讨论无关。通过org.hibernate.ConnectionReleaseMode的不同枚举值来使用不用的释放模式:" -#: index.docbook:921 -msgid "The legacy (2.x) behavior of Hibernate in regards to JDBC connection management was that a Session would obtain a connection when it was first needed and then hold unto that connection until the session was closed. Hibernate 3.x introduced the notion of connection release modes to tell a session how to handle its JDBC connections. Note that the following discussion is pertinent only to connections provided through a configured ConnectionProvider; user-supplied connections are outside the breadth of this discussion. The different release modes are identified by the enumerated values of org.hibernate.ConnectionReleaseMode:" +#. Tag: para +#: transactions.xml:935 +#, no-c-format +msgid "" +"ON_CLOSE - is essentially the legacy behavior described " +"above. The Hibernate session obatins a connection when it first needs to " +"perform some JDBC access and holds unto that connection until the session is " +"closed." msgstr "" +"ON_CLOSE - 基本上就是上面提到的老式行为。Hibernate session" +"在第一次需要进行JDBC操作的时候获取连接,然后持有它,直到session关闭。" -#: index.docbook:935 -msgid "ON_CLOSE - is essentially the legacy behavior described above. The Hibernate session obatins a connection when it first needs to perform some JDBC access and holds unto that connection until the session is closed." +#. Tag: para +#: transactions.xml:942 +#, no-c-format +msgid "" +"AFTER_TRANSACTION - says to release connections after a " +"org.hibernate.Transaction has completed." msgstr "" +"AFTER_TRANSACTION - 在org.hibernate.Transaction结束后释放连接。" -#: index.docbook:942 -msgid "AFTER_TRANSACTION - says to release connections after a org.hibernate.Transaction has completed." +#. Tag: para +#: transactions.xml:948 +#, no-c-format +msgid "" +"AFTER_STATEMENT (also referred to as aggressive release) " +"- says to release connections after each and every statement execution. This " +"aggressive releasing is skipped if that statement leaves open resources " +"associated with the given session; currently the only situation where this " +"occurs is through the use of org.hibernate.ScrollableResults." msgstr "" +"AFTER_STATEMENT (也被称做积极释放) - 在每一条语句被执行后" +"就释放连接。但假若语句留下了与session相关的资源,那就不会被释放。目前唯一的这" +"种情形就是使用org.hibernate.ScrollableResults。" -#: index.docbook:948 -msgid "AFTER_STATEMENT (also referred to as aggressive release) - says to release connections after each and every statement execution. This aggressive releasing is skipped if that statement leaves open resources associated with the given session; currently the only situation where this occurs is through the use of org.hibernate.ScrollableResults." +#. Tag: para +#: transactions.xml:958 +#, no-c-format +msgid "" +"The configuration parameter hibernate.connection.release_mode is used to specify which release mode to use. The possible values:" msgstr "" +"hibernate.connection.release_mode配置参数用来指定使用哪一" +"种释放模式。可能的值有:" -#: index.docbook:958 -msgid "The configuration parameter hibernate.connection.release_mode is used to specify which release mode to use. The possible values:" +#. Tag: para +#: transactions.xml:965 +#, no-c-format +msgid "" +"auto (the default) - this choice delegates to the release " +"mode returned by the org.hibernate.transaction.TransactionFactory." +"getDefaultReleaseMode() method. For JTATransactionFactory, this " +"returns ConnectionReleaseMode.AFTER_STATEMENT; for JDBCTransactionFactory, " +"this returns ConnectionReleaseMode.AFTER_TRANSACTION. It is rarely a good " +"idea to change this default behavior as failures due to the value of this " +"setting tend to indicate bugs and/or invalid assumptions in user code." msgstr "" +"auto(默认) - 这一选择把释放模式委派给org." +"hibernate.transaction.TransactionFactory.getDefaultReleaseMode()方" +"法。对JTATransactionFactory来说,它会返回ConnectionReleaseMode." +"AFTER_STATEMENT;对JDBCTransactionFactory来说,则是ConnectionReleaseMode." +"AFTER_TRANSACTION。很少需要修改这一默认行为,因为假若设置不当,就会带来bug," +"或者给用户代码带来误导。" -#: index.docbook:965 -msgid "auto (the default) - this choice delegates to the release mode returned by the org.hibernate.transaction.TransactionFactory.getDefaultReleaseMode() method. For JTATransactionFactory, this returns ConnectionReleaseMode.AFTER_STATEMENT; for JDBCTransactionFactory, this returns ConnectionReleaseMode.AFTER_TRANSACTION. It is rarely a good idea to change this default behavior as failures due to the value of this setting tend to indicate bugs and/or invalid assumptions in user code." +#. Tag: para +#: transactions.xml:975 +#, no-c-format +msgid "" +"on_close - says to use ConnectionReleaseMode.ON_CLOSE. " +"This setting is left for backwards compatibility, but its use is highly " +"discouraged." msgstr "" +"on_close - 使用 ConnectionReleaseMode.ON_CLOSE. 这种方式是" +"为了向下兼容的,但是已经完全不被鼓励使用了。" -#: index.docbook:975 -msgid "on_close - says to use ConnectionReleaseMode.ON_CLOSE. This setting is left for backwards compatibility, but its use is highly discouraged." +#. Tag: para +#: transactions.xml:981 +#, no-c-format +msgid "" +"after_transaction - says to use ConnectionReleaseMode." +"AFTER_TRANSACTION. This setting should not be used in JTA environments. Also " +"note that with ConnectionReleaseMode.AFTER_TRANSACTION, if a session is " +"considered to be in auto-commit mode connections will be released as if the " +"release mode were AFTER_STATEMENT." msgstr "" +"after_transaction - 使用ConnectionReleaseMode." +"AFTER_TRANSACTION。这一设置不应该在JTA环境下使用。也要注意,使用" +"ConnectionReleaseMode.AFTER_TRANSACTION的时候,假若session 处于auto-commit状" +"态,连接会像AFTER_STATEMENT那样被释放。" -#: index.docbook:981 -msgid "after_transaction - says to use ConnectionReleaseMode.AFTER_TRANSACTION. This setting should not be used in JTA environments. Also note that with ConnectionReleaseMode.AFTER_TRANSACTION, if a session is considered to be in auto-commit mode connections will be released as if the release mode were AFTER_STATEMENT." +#. Tag: para +#: transactions.xml:989 +#, no-c-format +msgid "" +"after_statement - says to use ConnectionReleaseMode." +"AFTER_STATEMENT. Additionally, the configured ConnectionProvider is consulted to see if it supports this setting " +"(supportsAggressiveRelease()). If not, the release mode " +"is reset to ConnectionReleaseMode.AFTER_TRANSACTION. This setting is only " +"safe in environments where we can either re-acquire the same underlying JDBC " +"connection each time we make a call into ConnectionProvider." +"getConnection() or in auto-commit environments where it does not " +"matter whether we get back the same connection." msgstr "" - -#: index.docbook:989 -msgid "after_statement - says to use ConnectionReleaseMode.AFTER_STATEMENT. Additionally, the configured ConnectionProvider is consulted to see if it supports this setting (supportsAggressiveRelease()). If not, the release mode is reset to ConnectionReleaseMode.AFTER_TRANSACTION. This setting is only safe in environments where we can either re-acquire the same underlying JDBC connection each time we make a call into ConnectionProvider.getConnection() or in auto-commit environments where it does not matter whether we get back the same connection." -msgstr "" - -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +"after_statement - 使用ConnectionReleaseMode." +"AFTER_STATEMENT。除此之外,会查询配置的ConnectionProvider,是否它支持这一设置((supportsAggressiveRelease()))。假若不支持,释放模式会被设置为ConnectionReleaseMode." +"AFTER_TRANSACTION。只有在你每次调用ConnectionProvider.getConnection" +"()获取底层JDBC连接的时候,都可以确信获得同一个连接的时候,这一设置" +"才是安全的;或者在auto-commit环境中,你可以不管是否每次都获得同一个连接的时" +"候,这才是安全的。" diff --git a/documentation/manual/translations/zh-CN/content/tutorial.po b/documentation/manual/translations/zh-CN/content/tutorial.po index 5a06e25a7b..1d39c38b09 100644 --- a/documentation/manual/translations/zh-CN/content/tutorial.po +++ b/documentation/manual/translations/zh-CN/content/tutorial.po @@ -1,1315 +1,2662 @@ -#, 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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:7 +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Tag: title +#: tutorial.xml:7 +#, no-c-format msgid "Introduction to Hibernate" -msgstr "" +msgstr "Hibernate入门" -#: index.docbook:10 +#. Tag: title +#: tutorial.xml:10 +#, no-c-format msgid "Preface" -msgstr "" +msgstr "前言" -#: index.docbook:12 -msgid "This chapter is an introductory tutorial for new users of Hibernate. We start with a simple command line application using an in-memory database and develop it in easy to understand steps." +#. Tag: para +#: tutorial.xml:12 +#, no-c-format +msgid "" +"This chapter is an introductory tutorial for new users of Hibernate. We " +"start with a simple command line application using an in-memory database and " +"develop it in easy to understand steps." msgstr "" +"本章是面向Hibernate初学者的一个入门教程。我们从一个使用驻留内存式(in-memory)" +"数据库的简单命令行应用程序开始, 用易于理解的方式逐步开发。" -#: index.docbook:18 -msgid "This tutorial is intended for new users of Hibernate but requires Java and SQL knowledge. It is based on a tutorial by Michael Gloegl, the third-party libraries we name are for JDK 1.4 and 5.0. You might need others for JDK 1.3." +#. Tag: para +#: tutorial.xml:18 +#, no-c-format +msgid "" +"This tutorial is intended for new users of Hibernate but requires Java and " +"SQL knowledge. It is based on a tutorial by Michael Gloegl, the third-party " +"libraries we name are for JDK 1.4 and 5.0. You might need others for JDK 1.3." msgstr "" +"本章面向Hibernate初学者,但需要Java和SQL知识。它是在Michael Goegl所写的指南的" +"基础上完成的。在这里,我们称第三方库文件是指JDK 1.4和5.0。若使用JDK1.3,你可" +"能需要其它的库文件。" -#: index.docbook:24 -msgid "The source code for the tutorial is included in the distribution in the doc/reference/tutorial/ directory." +#. Tag: para +#: tutorial.xml:24 +#, no-c-format +msgid "" +"The source code for the tutorial is included in the distribution in the " +"doc/reference/tutorial/ directory." msgstr "" +"本章的源代码已包含在发布包中,位于doc/reference/tutorial/" +"目录下。" -#: index.docbook:32 +#. Tag: title +#: tutorial.xml:32 +#, no-c-format msgid "Part 1 - The first Hibernate Application" -msgstr "" +msgstr "第一部分 - 第一个Hibernate应用程序" -#: index.docbook:34 -msgid "First, we'll create a simple console-based Hibernate application. We use an Java database (HSQL DB), so we do not have to install any database server." -msgstr "" - -#: index.docbook:39 -msgid "Let's assume we need a small database application that can store events we want to attend, and information about the hosts of these events." -msgstr "" - -#: index.docbook:44 -msgid "The first thing we do, is set up our development directory and put all the Java libraries we need into it. Download the Hibernate distribution from the Hibernate website. Extract the package and place all required libraries found in /lib into into the /lib directory of your new development working directory. It should look like this:" -msgstr "" - -#: index.docbook:52 +#. Tag: para +#: tutorial.xml:34 +#, no-c-format msgid "" - "" +"First, we'll create a simple console-based Hibernate application. We use an " +"Java database (HSQL DB), so we do not have to install any database server." +msgstr "" +"首先我们将创建一个简单的基于控制台的(console-based)Hibernate应用程序。由于我" +"们使用Java数据库(HSQL DB),所以不必安装任何数据库服务器。" + +#. Tag: para +#: tutorial.xml:39 +#, no-c-format +msgid "" +"Let's assume we need a small database application that can store events we " +"want to attend, and information about the hosts of these events." +msgstr "" +"假设我们希望有一个小应用程序可以保存我们希望参加的活动(events)和这些活动主" +"办方的相关信息。 (译者注:在本教程的后面部分,我们将直接使用event而不是它的" +"中文翻译“活动”,以免混淆。)" + +#. Tag: para +#: tutorial.xml:44 +#, no-c-format +msgid "" +"The first thing we do, is set up our development directory and put all the " +"Java libraries we need into it. Download the Hibernate distribution from the " +"Hibernate website. Extract the package and place all required libraries " +"found in /lib into into the /lib " +"directory of your new development working directory. It should look like " +"this:" +msgstr "" +"我们所做的第一件事就是创建我们的开发目录,并且把所有需要用到的Java库文件放进" +"去。解压缩从Hibernate网站下载的Hibernate发布包,并把/lib目" +"录下所有需要的库文件拷到我们新建开发目录下的/lib目录下。看" +"起来就像这样:" + +#. Tag: programlisting +#: tutorial.xml:52 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:54 -msgid "This is the minimum set of required libraries (note that we also copied hibernate3.jar, the main archive) for Hibernate at the time of writing. The Hibernate release you are using might require more or less libraries. See the README.txt file in the lib/ directory of the Hibernate distribution for more information about required and optional third-party libraries. (Actually, Log4j is not required but preferred by many developers.)" +#. Tag: para +#: tutorial.xml:54 +#, no-c-format +msgid "" +"This is the minimum set of required libraries (note that we also copied " +"hibernate3.jar, the main archive) for Hibernate at the time of " +"writing. The Hibernate release you are using might require more " +"or less libraries. See the README.txt file in the " +"lib/ directory of the Hibernate distribution for more " +"information about required and optional third-party libraries. (Actually, " +"Log4j is not required but preferred by many developers.)" msgstr "" +"到编写本文时为止,这些是Hibernate运行所需要的最小库文件" +"集合(注意我们也拷贝了 Hibernate3.jar,这个是最主要的文件)。你正使用的" +"Hibernate版本可能需要比这更多或少一些的库文件。请参见发布包中的lib/" +"目录下的README.txt,以获取更多关于所需和可选的第" +"三方库文件信息(事实上,Log4j并不是必须的库文件,但被许多开发者所喜欢)。" -#: index.docbook:63 -msgid "Next we create a class that represents the event we want to store in database." -msgstr "" +#. Tag: para +#: tutorial.xml:63 +#, no-c-format +msgid "" +"Next we create a class that represents the event we want to store in " +"database." +msgstr "接下来我们创建一个类,用来代表那些我们希望储存在数据库里的event。" -#: index.docbook:68 +#. Tag: title +#: tutorial.xml:68 +#, no-c-format msgid "The first class" -msgstr "" +msgstr "第一个class" -#: index.docbook:70 -msgid "Our first persistent class is a simple JavaBean class with some properties:" -msgstr "" - -#: index.docbook:74 +#. Tag: para +#: tutorial.xml:70 +#, no-c-format msgid "" - "" -msgstr "" +"Our first persistent class is a simple JavaBean class with some properties:" +msgstr "我们的第一个持久化类是一个带有一些属性(property)的简单JavaBean类:" -#: index.docbook:76 -msgid "You can see that this class uses standard JavaBean naming conventions for property getter and setter methods, as well as private visibility for the fields. This is a recommended design - but not required. Hibernate can also access fields directly, the benefit of accessor methods is robustness for refactoring. The no-argument constructor is required to instantiate an object of this class through reflection." -msgstr "" - -#: index.docbook:84 -msgid "The id property holds a unique identifier value for a particular event. All persistent entity classes (there are less important dependent classes as well) will need such an identifier property if we want to use the full feature set of Hibernate. In fact, most applications (esp. web applications) need to distinguish objects by identifier, so you should consider this a feature rather than a limitation. However, we usually don't manipulate the identity of an object, hence the setter method should be private. Only Hibernate will assign identifiers when an object is saved. You can see that Hibernate can access public, private, and protected accessor methods, as well as (public, private, protected) fields directly. The choice is up to you and you can match it to fit your application design." -msgstr "" - -#: index.docbook:96 -msgid "The no-argument constructor is a requirement for all persistent classes; Hibernate has to create objects for you, using Java Reflection. The constructor can be private, however, package visibility is required for runtime proxy generation and efficient data retrieval without bytecode instrumentation." -msgstr "" - -#: index.docbook:103 -msgid "Place this Java source file in a directory called src in the development folder, and in its correct package. The directory should now look like this:" -msgstr "" - -#: index.docbook:108 +#. Tag: programlisting +#: tutorial.xml:74 +#, no-c-format msgid "" - "\n" - "+src\n" - " +events\n" - " Event.java]]>" +"" msgstr "" -#: index.docbook:110 +#. Tag: para +#: tutorial.xml:76 +#, no-c-format +msgid "" +"You can see that this class uses standard JavaBean naming conventions for " +"property getter and setter methods, as well as private visibility for the " +"fields. This is a recommended design - but not required. Hibernate can also " +"access fields directly, the benefit of accessor methods is robustness for " +"refactoring. The no-argument constructor is required to instantiate an " +"object of this class through reflection." +msgstr "" +"你可以看到这个类对属性的存取方法(getter and setter method)使用了标准" +"JavaBean命名约定,同时把类属性(field)的访问级别设成私有的(private)。这是" +"推荐的设计,但并不是必须的。Hibernate也可以直接访问这些field,而使用访问方法" +"(accessor method)的好处是提供了重构时的健壮性(robustness)。为了通过反射机" +"制(Reflection)来实例化这个类的对象,我们需要提供一个无参的构造器(no-" +"argument constructor)。" + +#. Tag: para +#: tutorial.xml:84 +#, no-c-format +msgid "" +"The id property holds a unique identifier value for a " +"particular event. All persistent entity classes (there are less important " +"dependent classes as well) will need such an identifier property if we want " +"to use the full feature set of Hibernate. In fact, most applications (esp. " +"web applications) need to distinguish objects by identifier, so you should " +"consider this a feature rather than a limitation. However, we usually don't " +"manipulate the identity of an object, hence the setter method should be " +"private. Only Hibernate will assign identifiers when an object is saved. You " +"can see that Hibernate can access public, private, and protected accessor " +"methods, as well as (public, private, protected) fields directly. The choice " +"is up to you and you can match it to fit your application design." +msgstr "" +"对一特定的event, id 属性持有唯一的标识符(identifier)的" +"值。如果我们希望使用Hibernate提供的所有特性,那么所有的持久化实体" +"(persistent entity)类(这里也包括一些次要依赖类)都需要一个这样的标识符属" +"性。而事实上,大多数应用程序(特别是web应用程序)都需要通过标识符来区别对象," +"所以你应该考虑使用标识符属性而不是把它当作一种限制。然而,我们通常不会操作对" +"象的标识(identity),因此它的setter方法的访问级别应该声明private。这样当对象" +"被保存的时候,只有Hibernate可以为它分配标识符值。你可看到Hibernate可以直接访" +"问public,private和protected的访问方法和field。所以选择哪种方式完全取决于你," +"你可以使你的选择与你的应用程序设计相吻合。" + +#. Tag: para +#: tutorial.xml:96 +#, no-c-format +msgid "" +"The no-argument constructor is a requirement for all persistent classes; " +"Hibernate has to create objects for you, using Java Reflection. The " +"constructor can be private, however, package visibility is required for " +"runtime proxy generation and efficient data retrieval without bytecode " +"instrumentation." +msgstr "" +"所有的持久化类(persistent classes)都要求有无参的构造器,因为Hibernate必须使" +"用Java反射机制来为你创建对象。构造器(constructor)的访问级别可以是private," +"然而当生成运行时代理(runtime proxy)的时候则要求使用至少是package 级别的访问" +"控制,这样在没有字节码指令(bytecode instrumentation)的情况下,从持久化类里" +"获取数据会更有效率。" + +#. Tag: para +#: tutorial.xml:103 +#, no-c-format +msgid "" +"Place this Java source file in a directory called src in " +"the development folder, and in its correct package. The directory should now " +"look like this:" +msgstr "" +"把这个Java源代码文件放到开发目录下的src目录里,注意包位置" +"要正确。 现在这个目录看起来应该像这样:" + +#. Tag: programlisting +#: tutorial.xml:108 +#, no-c-format +msgid "" +"\n" +"+src\n" +" +events\n" +" Event.java]]>" +msgstr "" + +#. Tag: para +#: tutorial.xml:110 +#, no-c-format msgid "In the next step, we tell Hibernate about this persistent class." -msgstr "" +msgstr "下一步,我们把这个持久化类的信息告诉Hibernate。" -#: index.docbook:117 +#. Tag: title +#: tutorial.xml:117 +#, no-c-format msgid "The mapping file" -msgstr "" +msgstr "映射文件" -#: index.docbook:119 -msgid "Hibernate needs to know how to load and store objects of the persistent class. This is where the Hibernate mapping file comes into play. The mapping file tells Hibernate what table in the database it has to access, and what columns in that table it should use." +#. Tag: para +#: tutorial.xml:119 +#, no-c-format +msgid "" +"Hibernate needs to know how to load and store objects of the persistent " +"class. This is where the Hibernate mapping file comes into play. The mapping " +"file tells Hibernate what table in the database it has to access, and what " +"columns in that table it should use." msgstr "" +"Hibernate需要知道怎样去加载(load)和存储(store)持久化类的对象。这正是" +"Hibernate映射文件发挥作用的地方。映射文件告诉Hibernate它,应该访问数据库" +"(database)里面的哪个表(table)及应该使用表里面的哪些字段(column)。" -#: index.docbook:126 +#. Tag: para +#: tutorial.xml:126 +#, no-c-format msgid "The basic structure of a mapping file looks like this:" -msgstr "" +msgstr "一个映射文件的基本结构看起来像这样:" -#: index.docbook:130 +#. Tag: programlisting +#: tutorial.xml:130 +#, no-c-format msgid "" - "\n" - "\n" - "\n" - "\n" - "[...]\n" - "]]>" +"\n" +"\n" +"\n" +"\n" +"[...]\n" +"]]>" msgstr "" -#: index.docbook:132 -msgid "Note that the Hibernate DTD is very sophisticated. You can use it for auto-completion of XML mapping elements and attributes in your editor or IDE. You also should open up the DTD file in your text editor - it's the easiest way to get an overview of all elements and attributes and to see the defaults, as well as some comments. Note that Hibernate will not load the DTD file from the web, but first look it up from the classpath of the application. The DTD file is included in hibernate3.jar as well as in the src/ directory of the Hibernate distribution." -msgstr "" - -#: index.docbook:143 -msgid "We will omit the DTD declaration in future examples to shorten the code. It is of course not optional." -msgstr "" - -#: index.docbook:148 -msgid "Between the two hibernate-mapping tags, include a class element. All persistent entity classes (again, there might be dependent classes later on, which are not first-class entities) need such a mapping, to a table in the SQL database:" -msgstr "" - -#: index.docbook:155 +#. Tag: para +#: tutorial.xml:132 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - "\n" - " \n" - "\n" - "]]>" +"Note that the Hibernate DTD is very sophisticated. You can use it for auto-" +"completion of XML mapping elements and attributes in your editor or IDE. You " +"also should open up the DTD file in your text editor - it's the easiest way " +"to get an overview of all elements and attributes and to see the defaults, " +"as well as some comments. Note that Hibernate will not load the DTD file " +"from the web, but first look it up from the classpath of the application. " +"The DTD file is included in hibernate3.jar as well as in " +"the src/ directory of the Hibernate distribution." msgstr "" +"注意Hibernate的DTD是非常复杂的。你的编辑器或者IDE里使用它来自动完成那些用来映" +"射的XML元素(element)和属性(attribute)。你也可以在文本编辑器里打开DTD-这" +"是最简单的方式来概览所有的元素和attribute,并查看它们的缺省值以及注释。注意" +"Hibernate不会从web加载DTD文件,但它会首先在应用程序的classpath中查找。DTD文件" +"已包括在hibernate3.jar里,同时也在Hibernate发布包的" +"src/目录下。" -#: index.docbook:157 -msgid "So far we told Hibernate how to persist and load object of class Event to the table EVENTS, each instance represented by a row in that table. Now we continue with a mapping of the unique identifier property to the tables primary key. In addition, as we don't want to care about handling this identifier, we configure Hibernate's identifier generation strategy for a surrogate primary key column:" -msgstr "" - -#: index.docbook:165 +#. Tag: para +#: tutorial.xml:143 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"We will omit the DTD declaration in future examples to shorten the code. It " +"is of course not optional." msgstr "" +"为缩短代码长度,在以后的例子里我们会省略DTD的声明。当然,在实际的应用程序中," +"DTD声明是必须的。" -#: index.docbook:167 -msgid "The id element is the declaration of the identifer property, name=\"id\" declares the name of the Java property - Hibernate will use the getter and setter methods to access the property. The column attribute tells Hibernate which column of the EVENTS table we use for this primary key. The nested generator element specifies the identifier generation strategy, in this case we used native, which picks the best strategy depending on the configured database (dialect). Hibernate supports database generated, globally unique, as well as application assigned identifiers (or any strategy you have written an extension for)." -msgstr "" - -#: index.docbook:180 -msgid "Finally we include declarations for the persistent properties of the class in the mapping file. By default, no properties of the class are considered persistent:" -msgstr "" - -#: index.docbook:186 +#. Tag: para +#: tutorial.xml:148 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"Between the two hibernate-mapping tags, include a " +"class element. All persistent entity classes (again, " +"there might be dependent classes later on, which are not first-class " +"entities) need such a mapping, to a table in the SQL database:" msgstr "" +"在hibernate-mapping标签(tag)之间, 含有一个" +"class元素。所有的持久化实体类(再次声明,或许接下来会有依" +"赖类,就是那些次要的实体)都需要一个这样的映射,来把类对象映射到SQL数据库里的" +"表。" -#: index.docbook:188 -msgid "Just as with the id element, the name attribute of the property element tells Hibernate which getter and setter methods to use. So, in this case, Hibernate will look for getDate()/setDate(), as well as getTitle()/setTitle()." -msgstr "" - -#: index.docbook:195 -msgid "Why does the date property mapping include the column attribute, but the title doesn't? Without the column attribute Hibernate by default uses the property name as the column name. This works fine for title. However, date is a reserved keyword in most database, so we better map it to a different name." -msgstr "" - -#: index.docbook:204 -msgid "The next interesting thing is that the title mapping also lacks a type attribute. The types we declare and use in the mapping files are not, as you might expect, Java data types. They are also not SQL database types. These types are so called Hibernate mapping types, converters which can translate from Java to SQL data types and vice versa. Again, Hibernate will try to determine the correct conversion and mapping type itself if the type attribute is not present in the mapping. In some cases this automatic detection (using Reflection on the Java class) might not have the default you expect or need. This is the case with the date property. Hibernate can't know if the property (which is of java.util.Date) should map to a SQL date, timestamp, or time column. We preserve full date and time information by mapping the property with a timestamp converter." -msgstr "" - -#: index.docbook:220 -msgid "This mapping file should be saved as Event.hbm.xml, right in the directory next to the Event Java class source file. The naming of mapping files can be arbitrary, however the hbm.xml suffix is a convention in the Hibernate developer community. The directory structure should now look like this:" -msgstr "" - -#: index.docbook:228 +#. Tag: programlisting +#: tutorial.xml:155 +#, no-c-format msgid "" - "\n" - "+src\n" - " +events\n" - " Event.java\n" - " Event.hbm.xml]]>" +"\n" +"\n" +" \n" +"\n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:230 +#. Tag: para +#: tutorial.xml:157 +#, no-c-format +msgid "" +"So far we told Hibernate how to persist and load object of class " +"Event to the table EVENTS, each " +"instance represented by a row in that table. Now we continue with a mapping " +"of the unique identifier property to the tables primary key. In addition, as " +"we don't want to care about handling this identifier, we configure " +"Hibernate's identifier generation strategy for a surrogate primary key " +"column:" +msgstr "" +"到目前为止,我们告诉了Hibernate怎样把Events类的对象持久化" +"到数据库的EVENTS表里,以及怎样从EVENTS" +"表加载到Events类的对象。每个实例对应着数据库表中的一行。现" +"在我们将继续讨论有关唯一标识符属性到数据库表的映射。另外,由于我们不关心怎样" +"处理这个标识符,我们就配置由Hibernate的标识符生成策略来产生代理主键字段。" + +#. Tag: programlisting +#: tutorial.xml:165 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" +msgstr "" + +#. Tag: para +#: tutorial.xml:167 +#, no-c-format +msgid "" +"The id element is the declaration of the identifer " +"property, name=\"id\" declares the name of the Java " +"property - Hibernate will use the getter and setter methods to access the " +"property. The column attribute tells Hibernate which column of the " +"EVENTS table we use for this primary key. The nested " +"generator element specifies the identifier generation " +"strategy, in this case we used native, which picks the " +"best strategy depending on the configured database (dialect). Hibernate " +"supports database generated, globally unique, as well as application " +"assigned identifiers (or any strategy you have written an extension for)." +msgstr "" +"id元素是标识符属性的声明,name=\"id\" " +"声明了Java属性的名字 - Hibernate会使用getId()和" +"setId()来访问它。 column属性则告诉" +"Hibernate, 我们使用EVENTS表的哪个字段作为主键。嵌套的" +"generator元素指定了标识符生成策略,在这里我们指定" +"native,它根据已配置的数据库(方言)自动选择最佳的标识符生" +"成策略。Hibernate支持由数据库生成,全局唯一性(globally unique)和应用程序指" +"定(或者你自己为任何已有策略所写的扩展)这些策略来生成标识符。" + +#. Tag: para +#: tutorial.xml:180 +#, no-c-format +msgid "" +"Finally we include declarations for the persistent properties of the class " +"in the mapping file. By default, no properties of the class are considered " +"persistent:" +msgstr "" +"最后我们在映射文件里面包含需要持久化属性的声明。默认情况下,类里面的属性都被" +"视为非持久化的:" + +#. Tag: programlisting +#: tutorial.xml:186 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" +msgstr "" + +#. Tag: para +#: tutorial.xml:188 +#, no-c-format +msgid "" +"Just as with the id element, the name " +"attribute of the property element tells Hibernate which " +"getter and setter methods to use. So, in this case, Hibernate will look for " +"getDate()/setDate(), as well as getTitle()/" +"setTitle()." +msgstr "" +"和id元素一样,property元素的" +"name属性告诉Hibernate使用哪个getter和setter方法。在此例" +"中,Hibernate会寻找getDate()/setDate(), 以及" +"getTitle()/setTitle()。" + +#. Tag: para +#: tutorial.xml:195 +#, no-c-format +msgid "" +"Why does the date property mapping include the " +"column attribute, but the title " +"doesn't? Without the column attribute Hibernate by " +"default uses the property name as the column name. This works fine for " +"title. However, date is a reserved " +"keyword in most database, so we better map it to a different name." +msgstr "" +"为什么date属性的映射含有column " +"attribute,而title却没有?当没有设定column attribute 的时候,Hibernate缺省地使用JavaBean的属性名作为字段名。对" +"于title,这样工作得很好。然而,date在多" +"数的数据库里,是一个保留关键字,所以我们最好把它映射成一个不同的名字。" + +#. Tag: para +#: tutorial.xml:204 +#, no-c-format +msgid "" +"The next interesting thing is that the title mapping also " +"lacks a type attribute. The types we declare and use in " +"the mapping files are not, as you might expect, Java data types. They are " +"also not SQL database types. These types are so called Hibernate " +"mapping types, converters which can translate from Java to SQL " +"data types and vice versa. Again, Hibernate will try to determine the " +"correct conversion and mapping type itself if the type " +"attribute is not present in the mapping. In some cases this automatic " +"detection (using Reflection on the Java class) might not have the default " +"you expect or need. This is the case with the date " +"property. Hibernate can't know if the property (which is of java." +"util.Date) should map to a SQL date, " +"timestamp, or time column. We preserve " +"full date and time information by mapping the property with a " +"timestamp converter." +msgstr "" +"另一有趣的事情是title属性缺少一个type " +"attribute。我们在映射文件里声明并使用的类型,却不是我们期望的那样,是Java数据" +"类型,同时也不是SQL数据库的数据类型。这些类型就是所谓的Hibernate 映射类型" +"(mapping types),它们能把Java数据类型转换到SQL数据类" +"型,反之亦然。再次重申,如果在映射文件中没有设置type属性的" +"话,Hibernate会自己试着去确定正确的转换类型和它的映射类型。在某些情况下这个自" +"动检测机制(在Java 类上使用反射机制)不会产生你所期待或需要的缺省值。" +"date属性就是个很好的例子,Hibernate无法知道这个属性" +"(java.util.Date类型的)应该被映射成:SQL date,或timestamp,还是time 字段。" +"在此例中,把这个属性映射成timestamp 转换器,这样我们预留了" +"日期和时间的全部信息。" + +#. Tag: para +#: tutorial.xml:220 +#, no-c-format +msgid "" +"This mapping file should be saved as Event.hbm.xml, right " +"in the directory next to the Event Java class source " +"file. The naming of mapping files can be arbitrary, however the hbm." +"xml suffix is a convention in the Hibernate developer community. " +"The directory structure should now look like this:" +msgstr "" +"应该把这个映射文件保存为Event.hbm.xml,且就在" +"EventJava类的源文件目录下。映射文件可随意地命名,但" +"hbm.xml的后缀已成为Hibernate开发者社区的约定。现在目录结构" +"看起来应该像这样:" + +#. Tag: programlisting +#: tutorial.xml:228 +#, no-c-format +msgid "" +"\n" +"+src\n" +" +events\n" +" Event.java\n" +" Event.hbm.xml]]>" +msgstr "" + +#. Tag: para +#: tutorial.xml:230 +#, no-c-format msgid "We continue with the main configuration of Hibernate." -msgstr "" +msgstr "我们继续进行Hibernate的主要配置。" -#: index.docbook:237 +#. Tag: title +#: tutorial.xml:237 +#, no-c-format msgid "Hibernate configuration" -msgstr "" +msgstr "Hibernate配置" -#: index.docbook:239 -msgid "We now have a persistent class and its mapping file in place. It is time to configure Hibernate. Before we do this, we will need a database. HSQL DB, a java-based SQL DBMS, can be downloaded from the HSQL DB website(http://hsqldb.org/). Actually, you only need the hsqldb.jar from this download. Place this file in the lib/ directory of the development folder." -msgstr "" - -#: index.docbook:247 -msgid "Create a directory called data in the root of the development directory - this is where HSQL DB will store its data files. Now start the database by running java -classpath ../lib/hsqldb.jar org.hsqldb.Server in this data directory. You can see it start up and bind to a TCP/IP socket, this is where our application will connect later. If you want to start with a fresh database during this tutorial, shutdown HSQL DB (press CTRL + C in the window), delete all files in the data/ directory, and start HSQL DB again." -msgstr "" - -#: index.docbook:257 -msgid "Hibernate is the layer in your application which connects to this database, so it needs connection information. The connections are made through a JDBC connection pool, which we also have to configure. The Hibernate distribution contains several open source JDBC connection pooling tools, but will use the Hibernate built-in connection pool for this tutorial. Note that you have to copy the required library into your classpath and use different connection pooling settings if you want to use a production-quality third party JDBC pooling software." -msgstr "" - -#: index.docbook:267 -msgid "For Hibernate's configuration, we can use a simple hibernate.properties file, a slightly more sophisticated hibernate.cfg.xml file, or even complete programmatic setup. Most users prefer the XML configuration file:" -msgstr "" - -#: index.docbook:273 +#. Tag: para +#: tutorial.xml:239 +#, no-c-format msgid "" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - "\n" - " \n" - " org.hsqldb.jdbcDriver\n" - " jdbc:hsqldb:hsql://localhost\n" - " sa\n" - " \n" - "\n" - " \n" - " 1\n" - "\n" - " \n" - " org.hibernate.dialect.HSQLDialect\n" - "\n" - " \n" - " thread\n" - "\n" - " \n" - " org.hibernate.cache.NoCacheProvider\n" - "\n" - " \n" - " true\n" - "\n" - " \n" - " create\n" - "\n" - " \n" - "\n" - " \n" - "\n" - "]]>" +"We now have a persistent class and its mapping file in place. It is time to " +"configure Hibernate. Before we do this, we will need a database. HSQL DB, a " +"java-based SQL DBMS, can be downloaded from the HSQL DB website(http://" +"hsqldb.org/). Actually, you only need the hsqldb.jar from " +"this download. Place this file in the lib/ directory of " +"the development folder." +msgstr "" +"现在我们已经有了一个持久化类和它的映射文件,该是配置Hibernate的时候了。在此之" +"前,我们需要一个数据库。 HSQL DB是种基于Java 的SQL数据库管理系统(DBMS),可" +"以从HSQL DB的网站上下载。实际上,你只需下载的包中的hsqldb.jar文件,并把这个文件放在开发文件夹的lib/目录下即可。" + +#. Tag: para +#: tutorial.xml:247 +#, no-c-format +msgid "" +"Create a directory called data in the root of the " +"development directory - this is where HSQL DB will store its data files. Now " +"start the database by running java -classpath ../lib/hsqldb.jar org." +"hsqldb.Server in this data directory. You can see it start up and " +"bind to a TCP/IP socket, this is where our application will connect later. " +"If you want to start with a fresh database during this tutorial, shutdown " +"HSQL DB (press CTRL + C in the window), delete all files " +"in the data/ directory, and start HSQL DB again." +msgstr "" +"在开发的根目录下创建一个data目录 - 这是HSQL DB存储数据文" +"件的地方。此时在data目录中运行java -classpath ../lib/hsqldb.jar org." +"hsqldb.Server就可启动数据库。你可以在log中看到它的启动,及绑定到" +"TCP/IP套结字,这正是我们的应用程序稍后会连接的地方。如果你希望在本例中运行一" +"个全新的数据库,就在窗口中按下CTRL + C来关闭HSQL数据库,并" +"删除data/目录下的所有文件,再重新启动HSQL数据库。" + +#. Tag: para +#: tutorial.xml:257 +#, no-c-format +msgid "" +"Hibernate is the layer in your application which connects to this database, " +"so it needs connection information. The connections are made through a JDBC " +"connection pool, which we also have to configure. The Hibernate distribution " +"contains several open source JDBC connection pooling tools, but will use the " +"Hibernate built-in connection pool for this tutorial. Note that you have to " +"copy the required library into your classpath and use different connection " +"pooling settings if you want to use a production-quality third party JDBC " +"pooling software." +msgstr "" +"Hibernate是你的应用程序里连接数据库的那层,所以它需要连接用的信息。连接" +"(connection)是通过一个也由我们配置的JDBC连接池(connection pool)来完成的。" +"Hibernate的发布包里包含了许多开源的(open source)连接池,但在我们例子中使用" +"Hibernate内置的连接池。注意,如果你希望使用一个产品级(production-quality)的第" +"三方连接池软件,你必须拷贝所需的库文件到你的classpath下,并使用不同的连接池设" +"置。" + +#. Tag: para +#: tutorial.xml:267 +#, no-c-format +msgid "" +"For Hibernate's configuration, we can use a simple hibernate." +"properties file, a slightly more sophisticated hibernate." +"cfg.xml file, or even complete programmatic setup. Most users " +"prefer the XML configuration file:" +msgstr "" +"为了保存Hibernate的配置,我们可以使用一个简单的hibernate." +"properties文件,或者一个稍微复杂的hibernate.cfg.xml,甚至可以完全使用程序来配置Hibernate。多数用户更喜欢使用XML配置文" +"件:" + +#. Tag: programlisting +#: tutorial.xml:273 +#, no-c-format +msgid "" +"\n" +"\n" +"\n" +"\n" +"\n" +" \n" +"\n" +" \n" +" org.hsqldb.jdbcDriver\n" +" jdbc:hsqldb:hsql://localhost\n" +" sa\n" +" \n" +"\n" +" \n" +" 1\n" +"\n" +" \n" +" org.hibernate.dialect.HSQLDialect\n" +"\n" +" \n" +" thread\n" +"\n" +" \n" +" org.hibernate.cache." +"NoCacheProvider\n" +"\n" +" \n" +" true\n" +"\n" +" \n" +" create\n" +"\n" +" \n" +"\n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:275 -msgid "Note that this XML configuration uses a different DTD. We configure Hibernate's SessionFactory - a global factory responsible for a particular database. If you have several databases, use several <session-factory> configurations, usually in several configuration files (for easier startup)." +#. Tag: para +#: tutorial.xml:275 +#, no-c-format +msgid "" +"Note that this XML configuration uses a different DTD. We configure " +"Hibernate's SessionFactory - a global factory responsible " +"for a particular database. If you have several databases, use several " +"<session-factory> configurations, usually in " +"several configuration files (for easier startup)." msgstr "" +"注意这个XML配置使用了一个不同的DTD。在这里,我们配置了Hibernate的" +"SessionFactory-一个关联于特定数据库全局的工厂" +"(factory)。如果你要使用多个数据库,就要用多个的<session-" +"factory>,通常把它们放在多个配置文件中(为了更容易启动)。" -#: index.docbook:283 -msgid "The first four property elements contain the necessary configuration for the JDBC connection. The dialect property element specifies the particular SQL variant Hibernate generates. Hibernate's automatic session management for persistence contexts will come in handy as you will soon see. The hbm2ddl.auto option turns on automatic generation of database schemas - directly into the database. This can of course also be turned off (by removing the config option) or redirected to a file with the help of the SchemaExport Ant task. Finally, we add the mapping file(s) for persistent classes to the configuration." +#. Tag: para +#: tutorial.xml:283 +#, no-c-format +msgid "" +"The first four property elements contain the necessary " +"configuration for the JDBC connection. The dialect property element specifies the particular SQL variant Hibernate generates. " +"Hibernate's automatic session management for persistence contexts will come " +"in handy as you will soon see. The hbm2ddl.auto option " +"turns on automatic generation of database schemas - directly into the " +"database. This can of course also be turned off (by removing the config " +"option) or redirected to a file with the help of the SchemaExport Ant task. Finally, we add the mapping file(s) for persistent " +"classes to the configuration." msgstr "" +"最开始的4个property元素包含必要的JDBC连接信息。方言" +"(dialect)的property元素指明Hibernate 生成的特定SQL变量。" +"你很快会看到,Hibernate对持久化上下文的自动session管理就会派上用场。 打开" +"hbm2ddl.auto选项将自动生成数据库模式(schema)- 直接加入" +"数据库中。当然这个选项也可以被关闭(通过去除这个配置选项)或者通过Ant任务" +"SchemaExport的帮助来把数据库schema重定向到文件中。最后,在" +"配置中为持久化类加入映射文件。" -#: index.docbook:296 -msgid "Copy this file into the source directory, so it will end up in the root of the classpath. Hibernate automatically looks for a file called hibernate.cfg.xml in the root of the classpath, on startup." +#. Tag: para +#: tutorial.xml:296 +#, no-c-format +msgid "" +"Copy this file into the source directory, so it will end up in the root of " +"the classpath. Hibernate automatically looks for a file called " +"hibernate.cfg.xml in the root of the classpath, on " +"startup." msgstr "" +"把这个文件拷贝到源代码目录下面,这样它就位于classpath的根目录的最后。" +"Hibernate在启动时会自动在classpath的根目录查找名为hibernate.cfg." +"xml的配置文件。" -#: index.docbook:305 +#. Tag: title +#: tutorial.xml:305 +#, no-c-format msgid "Building with Ant" -msgstr "" +msgstr "用Ant构建" -#: index.docbook:307 -msgid "We'll now build the tutorial with Ant. You will need to have Ant installed - get it from the Ant download page. How to install Ant will not be covered here. Please refer to the Ant manual. After you have installed Ant, we can start to create the buildfile. It will be called build.xml and placed directly in the development directory." +#. Tag: para +#: tutorial.xml:307 +#, no-c-format +msgid "" +"We'll now build the tutorial with Ant. You will need to have Ant installed - " +"get it from the Ant " +"download page. How to install Ant will not be covered here. Please " +"refer to the Ant " +"manual. After you have installed Ant, we can start to create the " +"buildfile. It will be called build.xml and placed " +"directly in the development directory." msgstr "" +"现在我们用Ant来构建应用程序。你必须先安装Ant-可以从Ant 下载页面得到它。怎样安装Ant就不在这" +"里介绍了,请参考Ant 用" +"户手册。当你安装完了Ant,就可以开始创建build.xml文" +"件,把它直接放在开发目录下面。" -#: index.docbook:316 +#. Tag: para +#: tutorial.xml:316 +#, no-c-format msgid "A basic build file looks like this:" -msgstr "" +msgstr "一个简单的build文件看起来像这样:" -#: index.docbook:320 +#. Tag: programlisting +#: tutorial.xml:320 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"\n" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:322 -msgid "This will tell Ant to add all files in the lib directory ending with .jar to the classpath used for compilation. It will also copy all non-Java source files to the target directory, e.g. configuration and Hibernate mapping files. If you now run Ant, you should get this output:" -msgstr "" - -#: index.docbook:329 +#. Tag: para +#: tutorial.xml:322 +#, no-c-format msgid "" - "ant\n" - "Buildfile: build.xml\n" - "\n" - "copy-resources:\n" - " [copy] Copying 2 files to C:\\hibernateTutorial\\bin\n" - "\n" - "compile:\n" - " [javac] Compiling 1 source file to C:\\hibernateTutorial\\bin\n" - "\n" - "BUILD SUCCESSFUL\n" - "Total time: 1 second ]]>" +"This will tell Ant to add all files in the lib directory ending with " +".jar to the classpath used for compilation. It will also " +"copy all non-Java source files to the target directory, e.g. configuration " +"and Hibernate mapping files. If you now run Ant, you should get this output:" +msgstr "" +"这将告诉Ant把所有在lib目录下以.jar结尾的文件拷贝到" +"classpath中以供编译之用。它也把所有的非Java源代码文件,例如配置和Hibernate映" +"射文件,拷贝到目标目录。如果你现在运行Ant,会得到以下输出:" + +#. Tag: programlisting +#: tutorial.xml:329 +#, no-c-format +msgid "" +"ant\n" +"Buildfile: build.xml\n" +"\n" +"copy-resources:\n" +" [copy] Copying 2 files to C:\\hibernateTutorial\\bin\n" +"\n" +"compile:\n" +" [javac] Compiling 1 source file to C:\\hibernateTutorial\\bin\n" +"\n" +"BUILD SUCCESSFUL\n" +"Total time: 1 second ]]>" msgstr "" -#: index.docbook:334 +#. Tag: title +#: tutorial.xml:334 +#, no-c-format msgid "Startup and helpers" -msgstr "" +msgstr "启动和辅助类" -#: index.docbook:336 -msgid "It's time to load and store some Event objects, but first we have to complete the setup with some infrastructure code. We have to startup Hibernate. This startup includes building a global SessionFactory object and to store it somewhere for easy access in application code. A SessionFactory can open up new Session's. A Session represents a single-threaded unit of work, the SessionFactory is a thread-safe global object, instantiated once." -msgstr "" - -#: index.docbook:346 -msgid "We'll create a HibernateUtil helper class which takes care of startup and makes accessing a SessionFactory convenient. Let's have a look at the implementation:" -msgstr "" - -#: index.docbook:352 +#. Tag: para +#: tutorial.xml:336 +#, no-c-format msgid "" - "" +"It's time to load and store some Event objects, but first " +"we have to complete the setup with some infrastructure code. We have to " +"startup Hibernate. This startup includes building a global " +"SessionFactory object and to store it somewhere for easy " +"access in application code. A SessionFactory can open up " +"new Session's. A Session represents a " +"single-threaded unit of work, the SessionFactory is a " +"thread-safe global object, instantiated once." msgstr "" +"是时候来加载和储存一些Event对象了,但首先我们得编写一些基" +"础的代码以完成设置。我们必须启动Hibernate,此过程包括创建一个全局的" +"SessoinFactory,并把它储存在应用程序代码容易访问的地方。" +"SessionFactory可以创建并打开新的Session。一个Session代表一个单线程的单元操作," +"SessionFactory则是个线程安全的全局对象,只需要被实例化一" +"次。" -#: index.docbook:354 -msgid "This class does not only produce the global SessionFactory in its static initializer (called once by the JVM when the class is loaded), but also hides the fact that it uses a static singleton. It might as well lookup the SessionFactory from JNDI in an application server." -msgstr "" - -#: index.docbook:361 -msgid "If you give the SessionFactory a name in your configuration file, Hibernate will in fact try to bind it to JNDI after it has been built. To avoid this code completely you could also use JMX deployment and let the JMX-capable container instantiate and bind a HibernateService to JNDI. These advanced options are discussed in the Hibernate reference documentation." -msgstr "" - -#: index.docbook:370 -msgid "Place HibernateUtil.java in the development source directory, in a package next to events:" -msgstr "" - -#: index.docbook:375 +#. Tag: para +#: tutorial.xml:346 +#, no-c-format msgid "" - "\n" - "+src\n" - " +events\n" - " Event.java\n" - " Event.hbm.xml\n" - " +util\n" - " HibernateUtil.java\n" - " hibernate.cfg.xml\n" - "+data\n" - "build.xml]]>" +"We'll create a HibernateUtil helper class which takes " +"care of startup and makes accessing a SessionFactory " +"convenient. Let's have a look at the implementation:" +msgstr "" +"我们将创建一个HibernateUtil辅助类(helper class)来负责启" +"动Hibernate和更方便地操作SessionFactory。让我们来看一下它" +"的实现:" + +#. Tag: programlisting +#: tutorial.xml:352 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:377 -msgid "This should again compile without problems. We finally need to configure a logging system - Hibernate uses commons logging and leaves you the choice between Log4j and JDK 1.4 logging. Most developers prefer Log4j: copy log4j.properties from the Hibernate distribution (it's in the etc/ directory) to your src directory, next to hibernate.cfg.xml. Have a look at the example configuration and change the settings if you like to have more verbose output. By default, only Hibernate startup message are shown on stdout." +#. Tag: para +#: tutorial.xml:354 +#, no-c-format +msgid "" +"This class does not only produce the global SessionFactory in its static initializer (called once by the JVM when the class is " +"loaded), but also hides the fact that it uses a static singleton. It might " +"as well lookup the SessionFactory from JNDI in an " +"application server." +msgstr "" +"这个类不但在它的静态初始化过程(仅当加载这个类的时候被JVM执行一次)中产生全局" +"的SessionFactory,而且隐藏了它使用了静态singleton的事实。" +"它也可能在应用程序服务器中的JNDI查找SessionFactory。" + +#. Tag: para +#: tutorial.xml:361 +#, no-c-format +msgid "" +"If you give the SessionFactory a name in your " +"configuration file, Hibernate will in fact try to bind it to JNDI after it " +"has been built. To avoid this code completely you could also use JMX " +"deployment and let the JMX-capable container instantiate and bind a " +"HibernateService to JNDI. These advanced options are " +"discussed in the Hibernate reference documentation." +msgstr "" +"如果你在配置文件中给SessionFactory一个名字,在" +"SessionFactory创建后,Hibernate会试着把它绑定到JNDI。要完" +"全避免这样的代码,你也可以使用JMX部署,让具有JMX能力的容器来实例化" +"HibernateService并把它绑定到JNDI。这些高级可选项在后面的章" +"节中会讨论到。" + +#. Tag: para +#: tutorial.xml:370 +#, no-c-format +msgid "" +"Place HibernateUtil.java in the development source " +"directory, in a package next to events:" +msgstr "" +"把HibernateUtil.java放在开发目录的源代码路径下,与放" +"events的包并列:" + +#. Tag: programlisting +#: tutorial.xml:375 +#, no-c-format +msgid "" +"\n" +"+src\n" +" +events\n" +" Event.java\n" +" Event.hbm.xml\n" +" +util\n" +" HibernateUtil.java\n" +" hibernate.cfg.xml\n" +"+data\n" +"build.xml]]>" msgstr "" -#: index.docbook:387 -msgid "The tutorial infrastructure is complete - and we are ready to do some real work with Hibernate." +#. Tag: para +#: tutorial.xml:377 +#, no-c-format +msgid "" +"This should again compile without problems. We finally need to configure a " +"logging system - Hibernate uses commons logging and leaves you the choice " +"between Log4j and JDK 1.4 logging. Most developers prefer Log4j: copy " +"log4j.properties from the Hibernate distribution (it's in " +"the etc/ directory) to your src " +"directory, next to hibernate.cfg.xml. Have a look at the " +"example configuration and change the settings if you like to have more " +"verbose output. By default, only Hibernate startup message are shown on " +"stdout." msgstr "" +"再次编译这个应用程序应该不会有问题。最后我们需要配置一个日志(logging)系统 " +"- Hibernate使用通用日志接口,允许你在Log4j和JDK 1.4 日志之间进行选择。多数开" +"发者更喜欢Log4j:从Hibernate的发布包中(它在etc/目录下)拷" +"贝log4j.properties到你的src目录,与" +"hibernate.cfg.xml.放在一起。看一下配置示例,如果你希望看到" +"更加详细的输出信息,你可以修改配置。默认情况下,只有Hibernate的启动信息才会显" +"示在标准输出上。" -#: index.docbook:395 +#. Tag: para +#: tutorial.xml:387 +#, no-c-format +msgid "" +"The tutorial infrastructure is complete - and we are ready to do some real " +"work with Hibernate." +msgstr "示例的基本框架完成了 - 现在我们可以用Hibernate来做些真正的工作。" + +#. Tag: title +#: tutorial.xml:395 +#, no-c-format msgid "Loading and storing objects" -msgstr "" +msgstr "加载并存储对象" -#: index.docbook:397 -msgid "Finally, we can use Hibernate to load and store objects. We write an EventManager class with a main() method:" -msgstr "" - -#: index.docbook:402 +#. Tag: para +#: tutorial.xml:397 +#, no-c-format msgid "" - "" +"Finally, we can use Hibernate to load and store objects. We write an " +"EventManager class with a main() " +"method:" msgstr "" +"我们终于可以使用Hibernate来加载和存储对象了,编写一个带有main()方法的EventManager类:" -#: index.docbook:404 -msgid "We create a new Event object, and hand it over to Hibernate. Hibernate now takes care of the SQL and executes INSERTs on the database. Let's have a look at the Session and Transaction-handling code before we run this." -msgstr "" - -#: index.docbook:411 -msgid "A Session is a single unit of work. For now we'll keep things simple and assume a one-to-one granularity between a Hibernate Session and a database transaction. To shield our code from the actual underlying transaction system (in this case plain JDBC, but it could also run with JTA) we use the Transaction API that is available on the Hibernate Session." -msgstr "" - -#: index.docbook:419 -msgid "What does sessionFactory.getCurrentSession() do? First, you can call it as many times and anywhere you like, once you get hold of your SessionFactory (easy thanks to HibernateUtil). The getCurrentSession() method always returns the \"current\" unit of work. Remember that we switched the configuration option for this mechanism to \"thread\" in hibernate.cfg.xml? Hence, the current unit of work is bound to the current Java thread that executes our application. However, this is not the full picture, you also have to consider scope, when a unit of work begins and when it ends." -msgstr "" - -#: index.docbook:430 -msgid "A Session begins when it is first needed, when the first call to getCurrentSession() is made. It is then bound by Hibernate to the current thread. When the transaction ends, either through commit or rollback, Hibernate automatically unbinds the Session from the thread and closes it for you. If you call getCurrentSession() again, you get a new Session and can start a new unit of work. This thread-bound programming model is the most popular way of using Hibernate, as it allows flexible layering of your code (transaction demarcation code can be separated from data access code, we'll do this later in this tutorial)." -msgstr "" - -#: index.docbook:441 -msgid "Related to the unit of work scope, should the Hibernate Session be used to execute one or several database operations? The above example uses one Session for one operation. This is pure coincidence, the example is just not complex enough to show any other approach. The scope of a Hibernate Session is flexible but you should never design your application to use a new Hibernate Session for every database operation. So even if you see it a few more times in the following (very trivial) examples, consider session-per-operation an anti-pattern. A real (web) application is shown later in this tutorial." -msgstr "" - -#: index.docbook:452 -msgid "Have a look at for more information about transaction handling and demarcation. We also skipped any error handling and rollback in the previous example." -msgstr "" - -#: index.docbook:458 -msgid "To run this first routine we have to add a callable target to the Ant build file:" -msgstr "" - -#: index.docbook:462 +#. Tag: programlisting +#: tutorial.xml:402 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - "]]>" +"" msgstr "" -#: index.docbook:464 -msgid "The value of the action argument is set on the command line when calling the target:" +#. Tag: para +#: tutorial.xml:404 +#, no-c-format +msgid "" +"We create a new Event object, and hand it over to " +"Hibernate. Hibernate now takes care of the SQL and executes INSERTs on the database. Let's have a look at the Session and Transaction-handling code before we run this." +msgstr "" +"我们创建了个新的Event对象并把它传递给Hibernate。现在" +"Hibernate负责与SQL打交道,并把INSERT命令传给数据库。在运行" +"之前,让我们看一下处理SessionTransaction的代码。" + +#. Tag: para +#: tutorial.xml:411 +#, no-c-format +msgid "" +"A Session is a single unit of work. For now we'll keep " +"things simple and assume a one-to-one granularity between a Hibernate " +"Session and a database transaction. To shield our code " +"from the actual underlying transaction system (in this case plain JDBC, but " +"it could also run with JTA) we use the Transaction API " +"that is available on the Hibernate Session." +msgstr "" +"一个Session就是个单一的工作单元。我们暂时让事情简单一些," +"并假设HibernateSession和数据库事务是一一对应的。为了让我们" +"的代码从底层的事务系统中脱离出来(此例中是JDBC,但也可能是JTA),我们使用" +"Hibernate Session中的Transaction API。" + +#. Tag: para +#: tutorial.xml:419 +#, no-c-format +msgid "" +"What does sessionFactory.getCurrentSession() do? First, " +"you can call it as many times and anywhere you like, once you get hold of " +"your SessionFactory (easy thanks to " +"HibernateUtil). The getCurrentSession() method always returns the \"current\" unit of work. Remember that " +"we switched the configuration option for this mechanism to \"thread\" in " +"hibernate.cfg.xml? Hence, the current unit of work is " +"bound to the current Java thread that executes our application. However, " +"this is not the full picture, you also have to consider scope, when a unit " +"of work begins and when it ends." +msgstr "" +"sessionFactory.getCurrentSession()是干什么的呢?首先,只要" +"你持有SessionFactory(幸亏我们有HibernateUtil,可以随时获得),大可在任何时候、任何地点调用这个方法。" +"getCurrentSession()方法总会返回“当前的”工作单元。记得我们" +"在hibernate.cfg.xml中把这一配置选项调整为\"thread\"了吗?" +"因此,因此,当前工作单元被绑定到当前执行我们应用程序的Java线程。但是,这并非" +"是完全准确的,你还得考虑工作单元的生命周期范围 (scope),它何时开始,又何时结束." + +#. Tag: para +#: tutorial.xml:430 +#, no-c-format +msgid "" +"A Session begins when it is first needed, when the first " +"call to getCurrentSession() is made. It is then bound by " +"Hibernate to the current thread. When the transaction ends, either through " +"commit or rollback, Hibernate automatically unbinds the Session from the thread and closes it for you. If you call " +"getCurrentSession() again, you get a new " +"Session and can start a new unit of work. This " +"thread-bound programming model is the most popular way " +"of using Hibernate, as it allows flexible layering of your code (transaction " +"demarcation code can be separated from data access code, we'll do this later " +"in this tutorial)." +msgstr "" +"Session在第一次被使用的时候,即第一次调用" +"getCurrentSession()的时候,其生命周期就开始。然后它被" +"Hibernate绑定到当前线程。当事务结束的时候,不管是提交还是回滚,Hibernate会自" +"动把Session从当前线程剥离,并且关闭它。假若你再次调用" +"getCurrentSession(),你会得到一个新的Session,并且开始一个新的工作单元。这种线程绑定(thread-bound)的编程模型(model)是使用Hibernate的最广泛的方式,因为它支持对你的代" +"码灵活分层(事务划分可以和你的数据访问代码分离开来,在本教程的后面部分就会这么" +"做)。" + +#. Tag: para +#: tutorial.xml:441 +#, no-c-format +msgid "" +"Related to the unit of work scope, should the Hibernate Session be used to execute one or several database operations? The above " +"example uses one Session for one operation. This is pure " +"coincidence, the example is just not complex enough to show any other " +"approach. The scope of a Hibernate Session is flexible " +"but you should never design your application to use a new Hibernate " +"Session for every database " +"operation. So even if you see it a few more times in the following (very " +"trivial) examples, consider session-per-operation an " +"anti-pattern. A real (web) application is shown later in this tutorial." +msgstr "" +"和工作单元的生命周期这个话题相关,Hibernate Session是否被" +"应该用来执行多次数据库操作?上面的例子对每一次操作使用了一个" +"Session,这完全是巧合,这个例子不是很复杂,无法展示其他方" +"式。Hibernate Session的生命周期可以很灵活,但是你绝不要把" +"你的应用程序设计成为每一次数据库操作都用一个新的" +"Hibernate Session。因此就算下面的例子(它们都很简单)中你" +"可以看到这种用法,记住每次操作一个session是一个反模式。" +"在本教程的后面会展示一个真正的(web)程序。" + +#. Tag: para +#: tutorial.xml:452 +#, no-c-format +msgid "" +"Have a look at for more information about " +"transaction handling and demarcation. We also skipped any error handling and " +"rollback in the previous example." +msgstr "" +"关于事务处理及事务边界界定的详细信息,请参看。在上面的例子中,我们也忽略了所有的错误与回滚的处理。" + +#. Tag: para +#: tutorial.xml:458 +#, no-c-format +msgid "" +"To run this first routine we have to add a callable target to the Ant build " +"file:" +msgstr "" +"为第一次运行我们的程序,我们得在Ant的build文件中增加一个可以调用得到的" +"target。" + +#. Tag: programlisting +#: tutorial.xml:462 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:469 +#. Tag: para +#: tutorial.xml:464 +#, no-c-format +msgid "" +"The value of the action argument is set on the command " +"line when calling the target:" +msgstr "" +"action参数(argument)的值是通过命令行调用这个target的时候" +"设置的:" + +#. Tag: programlisting +#: tutorial.xml:469 +#, no-c-format msgid "ant run -Daction=store]]>" msgstr "" -#: index.docbook:471 -msgid "You should see, after compilation, Hibernate starting up and, depending on your configuration, lots of log output. At the end you will find the following line:" -msgstr "" - -#: index.docbook:476 -msgid "" -msgstr "" - -#: index.docbook:478 -msgid "This is the INSERT executed by Hibernate, the question marks represent JDBC bind parameters. To see the values bound as arguments, or to reduce the verbosity of the log, check your log4j.properties." -msgstr "" - -#: index.docbook:484 -msgid "Now we'd like to list stored events as well, so we add an option to the main method:" -msgstr "" - -#: index.docbook:488 +#. Tag: para +#: tutorial.xml:471 +#, no-c-format msgid "" - "" +"You should see, after compilation, Hibernate starting up and, depending on " +"your configuration, lots of log output. At the end you will find the " +"following line:" +msgstr "" +"你应该会看到,编译以后,Hibernate根据你的配置启动,并产生一大堆的输出日志。在" +"日志最后你会看到下面这行:" + +#. Tag: programlisting +#: tutorial.xml:476 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:490 +#. Tag: para +#: tutorial.xml:478 +#, no-c-format +msgid "" +"This is the INSERT executed by Hibernate, the question " +"marks represent JDBC bind parameters. To see the values bound as arguments, " +"or to reduce the verbosity of the log, check your log4j.properties." +msgstr "" +"这是Hibernate执行的INSERT命令,问号代表JDBC的绑定参数。如" +"果想要看到绑定参数的值或者减少日志的长度,就要调整你在log4j." +"properties文件里的设置。" + +#. Tag: para +#: tutorial.xml:484 +#, no-c-format +msgid "" +"Now we'd like to list stored events as well, so we add an option to the main " +"method:" +msgstr "" +"我们想要列出所有已经被存储的events,就要增加一个条件分支选项到main方法中去。" + +#. Tag: programlisting +#: tutorial.xml:488 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: tutorial.xml:490 +#, no-c-format msgid "We also add a new listEvents() method:" -msgstr "" +msgstr "我们也增加一个新的listEvents()方法:" -#: index.docbook:494 +#. Tag: programlisting +#: tutorial.xml:494 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:496 -msgid "What we do here is use an HQL (Hibernate Query Language) query to load all existing Event objects from the database. Hibernate will generate the appropriate SQL, send it to the database and populate Event objects with the data. You can create more complex queries with HQL, of course." +#. Tag: para +#: tutorial.xml:496 +#, no-c-format +msgid "" +"What we do here is use an HQL (Hibernate Query Language) query to load all " +"existing Event objects from the database. Hibernate will " +"generate the appropriate SQL, send it to the database and populate " +"Event objects with the data. You can create more complex " +"queries with HQL, of course." msgstr "" +"我们在这里是用一个HQL(Hibernate Query Language-Hibernate查询语言)查询语句" +"来从数据库中加载所有存在的Event对象。Hibernate会生成适当的" +"SQL,把它发送到数据库,并操作从查询得到数据的Event对象。当" +"然,你可以使用HQL来创建更加复杂的查询。" -#: index.docbook:503 +#. Tag: para +#: tutorial.xml:503 +#, no-c-format msgid "Now, to execute and test all of this, follow these steps:" -msgstr "" +msgstr "现在,根据以下步骤来执行并测试以上各项:" -#: index.docbook:509 -msgid "Run ant run -Daction=store to store something into the database and, of course, to generate the database schema before through hbm2ddl." +#. Tag: para +#: tutorial.xml:509 +#, no-c-format +msgid "" +"Run ant run -Daction=store to store something into the " +"database and, of course, to generate the database schema before through " +"hbm2ddl." msgstr "" +"运行ant run -Daction=store来保存一些内容到数据库。当然,先" +"得用hbm2ddl来生成数据库schema。" -#: index.docbook:515 -msgid "Now disable hbm2ddl by commenting out the property in your hibernate.cfg.xml file. Usually you only leave it turned on in continous unit testing, but another run of hbm2ddl would drop everything you have stored - the create configuration setting actually translates into \"drop all tables from the schema, then re-create all tables, when the SessionFactory is build\"." +#. Tag: para +#: tutorial.xml:515 +#, no-c-format +msgid "" +"Now disable hbm2ddl by commenting out the property in your " +"hibernate.cfg.xml file. Usually you only leave it turned " +"on in continous unit testing, but another run of hbm2ddl would " +"drop everything you have stored - the create configuration setting actually translates into \"drop all tables " +"from the schema, then re-create all tables, when the SessionFactory is build" +"\"." msgstr "" +"现在把hibernate.cfg.xml文件中hbm2ddl属性注释掉,这样我们就" +"取消了在启动时用hbm2ddl来生成数据库schema。通常只有在不断重复进行单元测试的时" +"候才需要打开它,但再次运行hbm2ddl会把你保存的一切都删掉(drop)——create配置的真实含义是:“在创建SessionFactory" +"的时候,从schema 中drop 掉所有的表,再重新创建它们”。" -#: index.docbook:525 -msgid "If you now call Ant with -Daction=list, you should see the events you have stored so far. You can of course also call the store action a few times more." +#. Tag: para +#: tutorial.xml:525 +#, no-c-format +msgid "" +"If you now call Ant with -Daction=list, you should see " +"the events you have stored so far. You can of course also call the " +"store action a few times more." msgstr "" +"如果你现在使用命令行参数-Daction=list运行Ant,你会看到那些" +"至今为止我们所储存的events。当然,你也可以多调用几次store" +"以保存更多的envents。" -#: index.docbook:531 -msgid "Note: Most new Hibernate users fail at this point and we see questions about Table not found error messages regularly. However, if you follow the steps outlined above you will not have this problem, as hbm2ddl creates the database schema on the first run, and subsequent application restarts will use this schema. If you change the mapping and/or database schema, you have to re-enable hbm2ddl once again." +#. Tag: para +#: tutorial.xml:531 +#, no-c-format +msgid "" +"Note: Most new Hibernate users fail at this point and we see questions about " +"Table not found error messages regularly. However, if " +"you follow the steps outlined above you will not have this problem, as " +"hbm2ddl creates the database schema on the first run, and subsequent " +"application restarts will use this schema. If you change the mapping and/or " +"database schema, you have to re-enable hbm2ddl once again." msgstr "" +"注意,很多Hibernate新手在这一步会失败,我们不时看到关于Table not " +"found错误信息的提问。但是,只要你根据上面描述的步骤来执行,就不会" +"有这个问题,因为hbm2ddl会在第一次运行的时候创建数据库schema,后继的应用程序重" +"起后还能继续使用这个schema。假若你修改了映射,或者修改了数据库schema,你必须" +"把hbm2ddl重新打开一次。" -#: index.docbook:544 +#. Tag: title +#: tutorial.xml:544 +#, no-c-format msgid "Part 2 - Mapping associations" -msgstr "" +msgstr "第二部分 - 关联映射" -#: index.docbook:546 -msgid "We mapped a persistent entity class to a table. Let's build on this and add some class associations. First we'll add people to our application, and store a list of events they participate in." +#. Tag: para +#: tutorial.xml:546 +#, no-c-format +msgid "" +"We mapped a persistent entity class to a table. Let's build on this and add " +"some class associations. First we'll add people to our application, and " +"store a list of events they participate in." msgstr "" +"我们已经映射了一个持久化实体类到表上。让我们在这个基础上增加一些类之间的关" +"联。首先我们往应用程序里增加人(people)的概念,并存储他们所参与的一个Event列" +"表。(译者注:与Event一样,我们在后面将直接使用person来表示“人”而不是它的中文" +"翻译)" -#: index.docbook:552 +#. Tag: title +#: tutorial.xml:552 +#, no-c-format msgid "Mapping the Person class" -msgstr "" +msgstr "映射Person类" -#: index.docbook:554 +#. Tag: para +#: tutorial.xml:554 +#, no-c-format msgid "The first cut of the Person class is simple:" -msgstr "" +msgstr "最初简单的Person类:" -#: index.docbook:558 +#. Tag: programlisting +#: tutorial.xml:558 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:560 -msgid "Create a new mapping file called Person.hbm.xml (don't forget the DTD reference at the top):" -msgstr "" - -#: index.docbook:565 +#. Tag: para +#: tutorial.xml:560 +#, no-c-format msgid "" - "\n" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"Create a new mapping file called Person.hbm.xml (don't " +"forget the DTD reference at the top):" +msgstr "" +"创建一个名为Person.hbm.xml的新映射文件(别忘了最上面的DTD" +"引用):" + +#. Tag: programlisting +#: tutorial.xml:565 +#, no-c-format +msgid "" +"\n" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:567 +#. Tag: para +#: tutorial.xml:567 +#, no-c-format msgid "Finally, add the new mapping to Hibernate's configuration:" -msgstr "" +msgstr "最后,把新的映射加入到Hibernate的配置中:" -#: index.docbook:571 +#. Tag: programlisting +#: tutorial.xml:571 +#, no-c-format msgid "" - "\n" - "]]>" +"\n" +"]]>" msgstr "" -#: index.docbook:573 -msgid "We'll now create an association between these two entities. Obviously, persons can participate in events, and events have participants. The design questions we have to deal with are: directionality, multiplicity, and collection behavior." +#. Tag: para +#: tutorial.xml:573 +#, no-c-format +msgid "" +"We'll now create an association between these two entities. Obviously, " +"persons can participate in events, and events have participants. The design " +"questions we have to deal with are: directionality, multiplicity, and " +"collection behavior." msgstr "" +"现在我们在这两个实体之间创建一个关联。显然,persons可以参与一系列events,而" +"events也有不同的参加者(persons)。我们需要处理的设计问题是关联方向" +"(directionality),阶数(multiplicity)和集合(collection)的行为。" -#: index.docbook:583 +#. Tag: title +#: tutorial.xml:583 +#, no-c-format msgid "A unidirectional Set-based association" -msgstr "" +msgstr "单向Set-based的关联" -#: index.docbook:585 -msgid "We'll add a collection of events to the Person class. That way we can easily navigate to the events for a particular person, without executing an explicit query - by calling aPerson.getEvents(). We use a Java collection, a Set, because the collection will not contain duplicate elements and the ordering is not relevant for us." -msgstr "" - -#: index.docbook:592 -msgid "We need a unidirectional, many-valued associations, implemented with a Set. Let's write the code for this in the Java classes and then map it:" -msgstr "" - -#: index.docbook:597 +#. Tag: para +#: tutorial.xml:585 +#, no-c-format msgid "" - "" +"We'll add a collection of events to the Person class. " +"That way we can easily navigate to the events for a particular person, " +"without executing an explicit query - by calling aPerson.getEvents()" +". We use a Java collection, a Set, because the " +"collection will not contain duplicate elements and the ordering is not " +"relevant for us." msgstr "" +"我们将向Person类增加一连串的events。那样,通过调用" +"aPerson.getEvents(),就可以轻松地导航到特定person所参与的" +"events,而不用去执行一个显式的查询。我们使用Java的集合类(collection):" +"Set,因为set 不包含重复的元素及与我们无关的排序。" -#: index.docbook:599 -msgid "Before we map this association, think about the other side. Clearly, we could just keep this unidirectional. Or, we could create another collection on the Event, if we want to be able to navigate it bi-directional, i.e. anEvent.getParticipants(). This is not necessary, from a functional perspective. You could always execute an explicit query to retrieve the participants for a particular event. This is a design choice left to you, but what is clear from this discussion is the multiplicity of the association: \"many\" valued on both sides, we call this a many-to-many association. Hence, we use Hibernate's many-to-many mapping:" -msgstr "" - -#: index.docbook:610 +#. Tag: para +#: tutorial.xml:592 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - "]]>" +"We need a unidirectional, many-valued associations, implemented with a " +"Set. Let's write the code for this in the Java classes " +"and then map it:" +msgstr "" +"我们需要用set 实现一个单向多值关联。让我们在Java类里为这个关联编码,接着映射" +"它:" + +#. Tag: programlisting +#: tutorial.xml:597 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:612 -msgid "Hibernate supports all kinds of collection mappings, a <set> being most common. For a many-to-many association (or n:m entity relationship), an association table is needed. Each row in this table represents a link between a person and an event. The table name is configured with the table attribute of the set element. The identifier column name in the association, for the person's side, is defined with the <key> element, the column name for the event's side with the column attribute of the <many-to-many>. You also have to tell Hibernate the class of the objects in your collection (correct: the class on the other side of the collection of references)." +#. Tag: para +#: tutorial.xml:599 +#, no-c-format +msgid "" +"Before we map this association, think about the other side. Clearly, we " +"could just keep this unidirectional. Or, we could create another collection " +"on the Event, if we want to be able to navigate it bi-" +"directional, i.e. anEvent.getParticipants(). This is not " +"necessary, from a functional perspective. You could always execute an " +"explicit query to retrieve the participants for a particular event. This is " +"a design choice left to you, but what is clear from this discussion is the " +"multiplicity of the association: \"many\" valued on both sides, we call this " +"a many-to-many association. Hence, we use Hibernate's " +"many-to-many mapping:" +msgstr "" +"在映射这个关联之前,先考虑一下此关联的另外一端。很显然,我们可以保持这个关联" +"是单向的。或者,我们可以在Event里创建另外一个集合,如果希" +"望能够双向地导航,如:anEvent.getParticipants()。从功能的" +"角度来说,这并不是必须的。因为你总可以显式地执行一个查询,以获得某个特定event" +"的所有参与者。这是个在设计时需要做出的选择,完全由你来决定,但此讨论中关于关" +"联的阶数是清楚的:即两端都是“多”值的,我们把它叫做多对多(many-to-" +"many)关联。因而,我们使用Hibernate的多对多映射:" + +#. Tag: programlisting +#: tutorial.xml:610 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +"]]>" msgstr "" -#: index.docbook:624 +#. Tag: para +#: tutorial.xml:612 +#, no-c-format +msgid "" +"Hibernate supports all kinds of collection mappings, a <set> being most common. For a many-to-many association (or n:" +"m entity relationship), an association table is needed. Each row " +"in this table represents a link between a person and an event. The table " +"name is configured with the table attribute of the " +"set element. The identifier column name in the " +"association, for the person's side, is defined with the <key>" +" element, the column name for the event's side with the " +"column attribute of the <many-to-many>. You also have to tell Hibernate the class of the objects in your " +"collection (correct: the class on the other side of the collection of " +"references)." +msgstr "" +"Hibernate支持各种各样的集合映射,<set>使用的最为普" +"遍。对于多对多关联(或叫n:m实体关系), 需要一个关联表" +"(association table)。里面的每一行代表从person到event的" +"一个关联。表名是由set元素的table属性配" +"置的。关联里面的标识符字段名,对于person的一端,是由<key>元素定义,而event一端的字段名是由<many-to-many>元素的column属性定义。你也必须告诉Hibernate集合中" +"对象的类(也就是位于这个集合所代表的关联另外一端的类)。" + +#. Tag: para +#: tutorial.xml:624 +#, no-c-format msgid "The database schema for this mapping is therefore:" -msgstr "" +msgstr "因而这个映射的数据库schema是:" -#: index.docbook:628 +#. Tag: programlisting +#: tutorial.xml:628 +#, no-c-format msgid "" - " | *EVENT_ID | | |\n" - " | EVENT_DATE | | *PERSON_ID | <--> | *PERSON_ID |\n" - " | TITLE | |__________________| | AGE |\n" - " |_____________| | FIRSTNAME |\n" - " | LASTNAME |\n" - " |_____________|\n" - " ]]>" +" | *EVENT_ID | | |\n" +" | EVENT_DATE | | *PERSON_ID | <--> | *PERSON_ID |\n" +" | TITLE | |__________________| | AGE |\n" +" |_____________| | FIRSTNAME |\n" +" | LASTNAME |\n" +" |_____________|\n" +" ]]>" msgstr "" -#: index.docbook:633 +#. Tag: title +#: tutorial.xml:633 +#, no-c-format msgid "Working the association" -msgstr "" +msgstr "使关联工作" -#: index.docbook:635 -msgid "Let's bring some people and events together in a new method in EventManager:" -msgstr "" - -#: index.docbook:639 +#. Tag: para +#: tutorial.xml:635 +#, no-c-format msgid "" - "" +"Let's bring some people and events together in a new method in " +"EventManager:" msgstr "" +"我们把一些people和events 一起放到EventManager的新方法中:" -#: index.docbook:641 -msgid "After loading a Person and an Event, simply modify the collection using the normal collection methods. As you can see, there is no explicit call to update() or save(), Hibernate automatically detects that the collection has been modified and needs to be updated. This is called automatic dirty checking, and you can also try it by modifying the name or the date property of any of your objects. As long as they are in persistent state, that is, bound to a particular Hibernate Session (i.e. they have been just loaded or saved in a unit of work), Hibernate monitors any changes and executes SQL in a write-behind fashion. The process of synchronizing the memory state with the database, usually only at the end of a unit of work, is called flushing. In our code, the unit of work ends with a commit (or rollback) of the database transaction - as defined by the thread configuration option for the CurrentSessionContext class." -msgstr "" - -#: index.docbook:656 -msgid "You might of course load person and event in different units of work. Or you modify an object outside of a Session, when it is not in persistent state (if it was persistent before, we call this state detached). You can even modify a collection when it is detached:" -msgstr "" - -#: index.docbook:663 +#. Tag: programlisting +#: tutorial.xml:639 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:665 -msgid "The call to update makes a detached object persistent again, you could say it binds it to a new unit of work, so any modifications you made to it while detached can be saved to the database. This includes any modifications (additions/deletions) you made to a collection of that entity object." -msgstr "" - -#: index.docbook:672 -msgid "Well, this is not much use in our current situation, but it's an important concept you can design into your own application. For now, complete this exercise by adding a new action to the EventManager's main method and call it from the command line. If you need the identifiers of a person and an event - the save() method returns it (you might have to modify some of the previous methods to return that identifier):" -msgstr "" - -#: index.docbook:680 +#. Tag: para +#: tutorial.xml:641 +#, no-c-format msgid "" - "" +"After loading a Person and an Event, " +"simply modify the collection using the normal collection methods. As you can " +"see, there is no explicit call to update() or " +"save(), Hibernate automatically detects that the " +"collection has been modified and needs to be updated. This is called " +"automatic dirty checking, and you can also try it by " +"modifying the name or the date property of any of your objects. As long as " +"they are in persistent state, that is, bound to a " +"particular Hibernate Session (i.e. they have been just " +"loaded or saved in a unit of work), Hibernate monitors any changes and " +"executes SQL in a write-behind fashion. The process of synchronizing the " +"memory state with the database, usually only at the end of a unit of work, " +"is called flushing. In our code, the unit of work ends " +"with a commit (or rollback) of the database transaction - as defined by the " +"thread configuration option for the " +"CurrentSessionContext class." +msgstr "" +"在加载一PersonEvent后,使用普通的集合" +"方法就可容易地修改我们定义的集合。如你所见,没有显式的update()save(),Hibernate会自动检测到集合已经被修改并需" +"要更新回数据库。这叫做自动脏检查(automatic dirty checking),你也可以尝试修改任何对象的name或者date属性,只要他们处于" +"持久化状态,也就是被绑定到某个Hibernate 的" +"Session上(如:他们刚刚在一个单元操作被加载或者保存)," +"Hibernate监视任何改变并在后台隐式写的方式执行SQL。同步内存状态和数据库的过" +"程,通常只在单元操作结束的时候发生,称此过程为清理缓存(flushing)" +"。在我们的代码中,工作单元由数据库事务的提交(或者回滚)来结束——这" +"是由CurrentSessionContext类的thread配置" +"选项定义的。" + +#. Tag: para +#: tutorial.xml:656 +#, no-c-format +msgid "" +"You might of course load person and event in different units of work. Or you " +"modify an object outside of a Session, when it is not in " +"persistent state (if it was persistent before, we call this state " +"detached). You can even modify a collection when it is " +"detached:" +msgstr "" +"当然,你也可以在不同的单元操作里面加载person和event。或在Session以外修改不是处在持久化(persistent)状态下的对象(如果该对象以前曾经" +"被持久化,那么我们称这个状态为脱管(detached))。你甚至" +"可以在一个集合被脱管时修改它:" + +#. Tag: programlisting +#: tutorial.xml:663 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:682 -msgid "This was an example of an association between two equally important classes, two entities. As mentioned earlier, there are other classes and types in a typical model, usually \"less important\". Some you have already seen, like an int or a String. We call these classes value types, and their instances depend on a particular entity. Instances of these types don't have their own identity, nor are they shared between entities (two persons don't reference the same firstname object, even if they have the same first name). Of course, value types can not only be found in the JDK (in fact, in a Hibernate application all JDK classes are considered value types), but you can also write dependent classes yourself, Address or MonetaryAmount, for example." +#. Tag: para +#: tutorial.xml:665 +#, no-c-format +msgid "" +"The call to update makes a detached object persistent " +"again, you could say it binds it to a new unit of work, so any modifications " +"you made to it while detached can be saved to the database. This includes " +"any modifications (additions/deletions) you made to a collection of that " +"entity object." +msgstr "" +"对update的调用使一个脱管对象重新持久化,你可以说它被绑定到" +"一个新的单元操作上,所以在脱管状态下对它所做的任何修改都会被保存到数据库里。" +"这也包括你对这个实体对象的集合所作的任何改动(增加/删除)。" + +#. Tag: para +#: tutorial.xml:672 +#, no-c-format +msgid "" +"Well, this is not much use in our current situation, but it's an important " +"concept you can design into your own application. For now, complete this " +"exercise by adding a new action to the EventManager's " +"main method and call it from the command line. If you need the identifiers " +"of a person and an event - the save() method returns it " +"(you might have to modify some of the previous methods to return that " +"identifier):" +msgstr "" +"这对我们当前的情形不是很有用,但它是非常重要的概念,你可以把它融入到你自己的" +"应用程序设计中。在EventManager的main方法中添加一个新的动" +"作,并从命令行运行它来完成我们所做的练习。如果你需要person及event的标识符 — " +"那就用save()方法返回它(你可能需要修改前面的一些方法来返回" +"那个标识符):" + +#. Tag: programlisting +#: tutorial.xml:680 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:695 -msgid "You can also design a collection of value types. This is conceptually very different from a collection of references to other entities, but looks almost the same in Java." +#. Tag: para +#: tutorial.xml:682 +#, no-c-format +msgid "" +"This was an example of an association between two equally important classes, " +"two entities. As mentioned earlier, there are other classes and types in a " +"typical model, usually \"less important\". Some you have already seen, like " +"an int or a String. We call these " +"classes value types, and their instances " +"depend on a particular entity. Instances of these types " +"don't have their own identity, nor are they shared between entities (two " +"persons don't reference the same firstname object, even " +"if they have the same first name). Of course, value types can not only be " +"found in the JDK (in fact, in a Hibernate application all JDK classes are " +"considered value types), but you can also write dependent classes yourself, " +"Address or MonetaryAmount, for example." msgstr "" +"上面是个关于两个同等重要的实体类间关联的例子。像前面所提到的那样,在特定的模" +"型中也存在其它的类和类型,这些类和类型通常是“次要的”。你已看到过其中的一些," +"像intString。我们称这些类为" +"值类型(value type),它们的实例依赖(depend)在某个特定的实体上。这些类型的实例没有它们自己的标识(identity),也" +"不能在实体间被共享(比如,两个person不能引用同一个firstname对象,即使他们有相同的first name)。当然,值类型并不仅仅在JDK中存在" +"(事实上,在一个Hibernate应用程序中,所有的JDK类都被视为值类型),而且你也可" +"以编写你自己的依赖类,例如Address," +"MonetaryAmount。" -#: index.docbook:703 +#. Tag: para +#: tutorial.xml:695 +#, no-c-format +msgid "" +"You can also design a collection of value types. This is conceptually very " +"different from a collection of references to other entities, but looks " +"almost the same in Java." +msgstr "" +"你也可以设计一个值类型的集合,这在概念上与引用其它实体的集合有很大的不同,但" +"是在Java里面看起来几乎是一样的。" + +#. Tag: title +#: tutorial.xml:703 +#, no-c-format msgid "Collection of values" -msgstr "" +msgstr "值类型的集合" -#: index.docbook:705 -msgid "We add a collection of value typed objects to the Person entity. We want to store email addresses, so the type we use is String, and the collection is again a Set:" -msgstr "" - -#: index.docbook:710 +#. Tag: para +#: tutorial.xml:705 +#, no-c-format msgid "" - "" +"We add a collection of value typed objects to the Person " +"entity. We want to store email addresses, so the type we use is " +"String, and the collection is again a Set:" +msgstr "" +"我们把一个值类型对象的集合加入Person实体中。我们希望保存" +"email地址,所以使用String类型,而且这次的集合类型又是" +"Set:" + +#. Tag: programlisting +#: tutorial.xml:710 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:712 +#. Tag: para +#: tutorial.xml:712 +#, no-c-format msgid "The mapping of this Set:" -msgstr "" +msgstr "这个Set的映射" -#: index.docbook:716 +#. Tag: programlisting +#: tutorial.xml:716 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:718 -msgid "The difference compared with the earlier mapping is the element part, which tells Hibernate that the collection does not contain references to another entity, but a collection of elements of type String (the lowercase name tells you it's a Hibernate mapping type/converter). Once again, the table attribute of the set element determines the table name for the collection. The key element defines the foreign-key column name in the collection table. The column attribute in the element element defines the column name where the String values will actually be stored." +#. Tag: para +#: tutorial.xml:718 +#, no-c-format +msgid "" +"The difference compared with the earlier mapping is the element part, which tells Hibernate that the collection does not contain " +"references to another entity, but a collection of elements of type " +"String (the lowercase name tells you it's a Hibernate " +"mapping type/converter). Once again, the table attribute " +"of the set element determines the table name for the " +"collection. The key element defines the foreign-key " +"column name in the collection table. The column attribute " +"in the element element defines the column name where the " +"String values will actually be stored." msgstr "" +"比较这次和此前映射的差别,主要在于element部分,这次并没有" +"包含对其它实体引用的集合,而是元素类型为String的集合(在映" +"射中使用小写的名字”string“是向你表明它是一个Hibernate的映射类型或者类型转换" +"器)。和之前一样,set元素的table属性决" +"定了用于集合的表名。key元素定义了在集合表中外键的字段名。" +"element元素的column属性定义用于实际保存" +"String值的字段名。" -#: index.docbook:728 +#. Tag: para +#: tutorial.xml:728 +#, no-c-format msgid "Have a look at the updated schema:" -msgstr "" +msgstr "看一下修改后的数据库schema。" -#: index.docbook:732 +#. Tag: programlisting +#: tutorial.xml:732 +#, no-c-format msgid "" - " | *EVENT_ID | | | |___________________|\n" - " | EVENT_DATE | | *PERSON_ID | <--> | *PERSON_ID | <--> | *PERSON_ID |\n" - " | TITLE | |__________________| | AGE | | *EMAIL_ADDR |\n" - " |_____________| | FIRSTNAME | |___________________|\n" - " | LASTNAME |\n" - " |_____________|\n" - " ]]>" +" | *EVENT_ID | | | |" +"___________________|\n" +" | EVENT_DATE | | *PERSON_ID | <--> | *PERSON_ID | <--> | " +"*PERSON_ID |\n" +" | TITLE | |__________________| | AGE | | " +"*EMAIL_ADDR |\n" +" |_____________| | FIRSTNAME | |" +"___________________|\n" +" | LASTNAME |\n" +" |_____________|\n" +" ]]>" msgstr "" -#: index.docbook:734 -msgid "You can see that the primary key of the collection table is in fact a composite key, using both columns. This also implies that there can't be duplicate email addresses per person, which is exactly the semantics we need for a set in Java." -msgstr "" - -#: index.docbook:740 -msgid "You can now try and add elements to this collection, just like we did before by linking persons and events. It's the same code in Java:" -msgstr "" - -#: index.docbook:745 +#. Tag: para +#: tutorial.xml:734 +#, no-c-format msgid "" - "" +"You can see that the primary key of the collection table is in fact a " +"composite key, using both columns. This also implies that there can't be " +"duplicate email addresses per person, which is exactly the semantics we need " +"for a set in Java." +msgstr "" +"你可以看到集合表的主键实际上是个复合主键,同时使用了2个字段。这也暗示了对于同" +"一个person不能有重复的email地址,这正是Java里面使用Set时候所需要的语义(Set里" +"元素不能重复)。" + +#. Tag: para +#: tutorial.xml:740 +#, no-c-format +msgid "" +"You can now try and add elements to this collection, just like we did before " +"by linking persons and events. It's the same code in Java:" +msgstr "" +"你现在可以试着把元素加入到这个集合,就像我们在之前关联person和event的那样。其" +"实现的Java代码是相同的:" + +#. Tag: programlisting +#: tutorial.xml:745 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:747 -msgid "This time we didnt' use a fetch query to initialize the collection. Hence, the call to its getter method will trigger an additional select to initialize it, so we can add an element to it. Monitor the SQL log and try to optimize this with an eager fetch." +#. Tag: para +#: tutorial.xml:747 +#, no-c-format +msgid "" +"This time we didnt' use a fetch query to initialize the " +"collection. Hence, the call to its getter method will trigger an additional " +"select to initialize it, so we can add an element to it. Monitor the SQL log " +"and try to optimize this with an eager fetch." msgstr "" +"这次我们没有使用fetch查询来初始化集合。因此,调用其" +"getter方法会触发另一附加的select来初始化集合,这样我们才能把元素添加进去。检" +"查SQL log,试着通过预先抓取来优化它。" -#: index.docbook:757 +#. Tag: title +#: tutorial.xml:757 +#, no-c-format msgid "Bi-directional associations" -msgstr "" +msgstr "双向关联" -#: index.docbook:759 -msgid "Next we are going to map a bi-directional association - making the association between person and event work from both sides in Java. Of course, the database schema doesn't change, we still have many-to-many multiplicity. A relational database is more flexible than a network programming language, so it doesn't need anything like a navigation direction - data can be viewed and retrieved in any possible way." -msgstr "" - -#: index.docbook:767 -msgid "First, add a collection of participants to the Event Event class:" -msgstr "" - -#: index.docbook:771 +#. Tag: para +#: tutorial.xml:759 +#, no-c-format msgid "" - "" +"Next we are going to map a bi-directional association - making the " +"association between person and event work from both sides in Java. Of " +"course, the database schema doesn't change, we still have many-to-many " +"multiplicity. A relational database is more flexible than a network " +"programming language, so it doesn't need anything like a navigation " +"direction - data can be viewed and retrieved in any possible way." msgstr "" +"接下来我们将映射双向关联(bi-directional association)- 在Java里让person和" +"event可以从关联的任何一端访问另一端。当然,数据库schema没有改变,我们仍然需要" +"多对多的阶数。一个关系型数据库要比网络编程语言 更加灵活,所以它并不需要任何像" +"导航方向(navigation direction)的东西 - 数据可以用任何可能的方式进行查看和" +"获取。" -#: index.docbook:773 -msgid "Now map this side of the association too, in Event.hbm.xml." -msgstr "" - -#: index.docbook:777 +#. Tag: para +#: tutorial.xml:767 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - "]]>" +"First, add a collection of participants to the Event " +"Event class:" +msgstr "首先,把一个参与者(person)的集合加入Event类中:" + +#. Tag: programlisting +#: tutorial.xml:771 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:779 -msgid "As you see, these are normal set mappings in both mapping documents. Notice that the column names in key and many-to-many are swapped in both mapping documents. The most important addition here is the inverse=\"true\" attribute in the set element of the Event's collection mapping." +#. Tag: para +#: tutorial.xml:773 +#, no-c-format +msgid "" +"Now map this side of the association too, in Event.hbm.xml." +msgstr "在Event.hbm.xml里面也映射这个关联。" + +#. Tag: programlisting +#: tutorial.xml:777 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:787 -msgid "What this means is that Hibernate should take the other side - the Person class - when it needs to find out information about the link between the two. This will be a lot easier to understand once you see how the bi-directional link between our two entities is created ." +#. Tag: para +#: tutorial.xml:779 +#, no-c-format +msgid "" +"As you see, these are normal set mappings in both mapping " +"documents. Notice that the column names in key and " +"many-to-many are swapped in both mapping documents. The " +"most important addition here is the inverse=\"true\" " +"attribute in the set element of the Event's collection mapping." msgstr "" +"如你所见,两个映射文件里都有普通的set映射。注意在两个映射" +"文件中,互换了keymany-to-many的字段" +"名。这里最重要的是Event映射文件里增加了set元素的inverse=\"true\"属性。" -#: index.docbook:796 +#. Tag: para +#: tutorial.xml:787 +#, no-c-format +msgid "" +"What this means is that Hibernate should take the other side - the " +"Person class - when it needs to find out information " +"about the link between the two. This will be a lot easier to understand once " +"you see how the bi-directional link between our two entities is created ." +msgstr "" +"这意味着在需要的时候,Hibernate能在关联的另一端 - Person" +"类得到两个实体间关联的信息。这将会极大地帮助你理解双向关联是如何在两个实体间" +"被创建的。" + +#. Tag: title +#: tutorial.xml:796 +#, no-c-format msgid "Working bi-directional links" -msgstr "" +msgstr "使双向连起来" -#: index.docbook:798 -msgid "First, keep in mind that Hibernate does not affect normal Java semantics. How did we create a link between a Person and an Event in the unidirectional example? We added an instance of Event to the collection of event references, of an instance of Person. So, obviously, if we want to make this link working bi-directional, we have to do the same on the other side - adding a Person reference to the collection in an Event. This \"setting the link on both sides\" is absolutely necessary and you should never forget doing it." -msgstr "" - -#: index.docbook:808 -msgid "Many developers program defensive and create link management methods to correctly set both sides, e.g. in Person:" -msgstr "" - -#: index.docbook:813 +#. Tag: para +#: tutorial.xml:798 +#, no-c-format msgid "" - "" +"First, keep in mind that Hibernate does not affect normal Java semantics. " +"How did we create a link between a Person and an " +"Event in the unidirectional example? We added an instance " +"of Event to the collection of event references, of an " +"instance of Person. So, obviously, if we want to make " +"this link working bi-directional, we have to do the same on the other side - " +"adding a Person reference to the collection in an " +"Event. This \"setting the link on both sides\" is " +"absolutely necessary and you should never forget doing it." +msgstr "" +"首先请记住,Hibernate并不影响通常的Java语义。 在单向关联的例子中,我们是怎样" +"在PersonEvent之间创建联系的?我们把" +"Event实例添加到Person实例内的event引用" +"集合里。因此很显然,如果我们要让这个关联可以双向地工作,我们需要在另外一端做" +"同样的事情 - 把Person实例加入Event类内" +"的Person引用集合。这“在关联的两端设置联系”是完全必要的而且你都得这么做。" + +#. Tag: para +#: tutorial.xml:808 +#, no-c-format +msgid "" +"Many developers program defensive and create link management methods to " +"correctly set both sides, e.g. in Person:" +msgstr "" +"许多开发人员防御式地编程,创建管理关联的方法来保证正确的设置了关联的两端,比" +"如在Person里:" + +#. Tag: programlisting +#: tutorial.xml:813 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:815 -msgid "Notice that the get and set methods for the collection are now protected - this allows classes in the same package and subclasses to still access the methods, but prevents everybody else from messing with the collections directly (well, almost). You should probably do the same with the collection on the other side." +#. Tag: para +#: tutorial.xml:815 +#, no-c-format +msgid "" +"Notice that the get and set methods for the collection are now protected - " +"this allows classes in the same package and subclasses to still access the " +"methods, but prevents everybody else from messing with the collections " +"directly (well, almost). You should probably do the same with the collection " +"on the other side." msgstr "" +"注意现在对于集合的get和set方法的访问级别是protected - 这允许在位于同一个包" +"(package)中的类以及继承自这个类的子类可以访问这些方法,但禁止其他任何人的直" +"接访问,避免了集合内容的混乱。你应尽可能地在另一端也把集合的访问级别设成" +"protected。" -#: index.docbook:822 -msgid "What about the inverse mapping attribute? For you, and for Java, a bi-directional link is simply a matter of setting the references on both sides correctly. Hibernate however doesn't have enough information to correctly arrange SQL INSERT and UPDATE statements (to avoid constraint violations), and needs some help to handle bi-directional associations properly. Making one side of the association inverse tells Hibernate to basically ignore it, to consider it a mirror of the other side. That's all that is necessary for Hibernate to work out all of the issues when transformation a directional navigation model to a SQL database schema. The rules you have to remember are straightforward: All bi-directional associations need one side as inverse. In a one-to-many association it has to be the many-side, in many-to-many association you can pick either side, there is no difference." +#. Tag: para +#: tutorial.xml:822 +#, no-c-format +msgid "" +"What about the inverse mapping attribute? For you, and " +"for Java, a bi-directional link is simply a matter of setting the references " +"on both sides correctly. Hibernate however doesn't have enough information " +"to correctly arrange SQL INSERT and UPDATE statements (to avoid constraint violations), and needs some help to " +"handle bi-directional associations properly. Making one side of the " +"association inverse tells Hibernate to basically ignore " +"it, to consider it a mirror of the other side. That's " +"all that is necessary for Hibernate to work out all of the issues when " +"transformation a directional navigation model to a SQL database schema. The " +"rules you have to remember are straightforward: All bi-directional " +"associations need one side as inverse. In a one-to-many " +"association it has to be the many-side, in many-to-many association you can " +"pick either side, there is no difference." msgstr "" +"inverse映射属性究竟表示什么呢?对于你和Java来说,一个双向" +"关联仅仅是在两端简单地正确设置引用。然而,Hibernate并没有足够的信息去正确地执" +"行INSERTUPDATE语句(以避免违反数据库" +"约束),所以它需要一些帮助来正确的处理双向关联。把关联的一端设置为" +"inverse将告诉Hibernate忽略关联的这一端,把这端看成是另外一" +"端的一个镜象(mirror)。这就是所需的全部信息,Hibernate" +"利用这些信息来处理把一个有向导航模型转移到数据库schema时的所有问题。你只需要" +"记住这个直观的规则:所有的双向关联需要有一端被设置为inverse。在一对多关联中它必须是代表多(many)的那端。而在多对多(many-to-" +"many)关联中,你可以任意选取一端,因为两端之间并没有差别。" -#: index.docbook:837 +#. Tag: para +#: tutorial.xml:837 +#, no-c-format msgid "Let's turn this into a small web application." -msgstr "" +msgstr "让我们把进入一个小型的web应用程序。" -#: index.docbook:844 +#. Tag: title +#: tutorial.xml:844 +#, no-c-format msgid "Part 3 - The EventManager web application" -msgstr "" +msgstr "第三部分 - EventManager web应用程序" -#: index.docbook:846 -msgid "A Hibernate web application uses Session and Transaction almost like a standalone application. However, some common patterns are useful. We now write an EventManagerServlet. This servlet can list all events stored in the database, and it provides an HTML form to enter new events." +#. Tag: para +#: tutorial.xml:846 +#, no-c-format +msgid "" +"A Hibernate web application uses Session and " +"Transaction almost like a standalone application. " +"However, some common patterns are useful. We now write an " +"EventManagerServlet. This servlet can list all events " +"stored in the database, and it provides an HTML form to enter new events." msgstr "" +"Hibernate web应用程序使用SessionTransaction的方式几乎和独立应用程序是一样的。但是,有一些常见的模式(pattern)非" +"常有用。现在我们编写一个EventManagerServlet。这个servlet可" +"以列出数据库中保存的所有的events,还提供一个HTML表单来增加新的events。" -#: index.docbook:854 +#. Tag: title +#: tutorial.xml:854 +#, no-c-format msgid "Writing the basic servlet" -msgstr "" +msgstr "编写基本的servlet" -#: index.docbook:856 -msgid "Create a new class in your source directory, in the events package:" -msgstr "" - -#: index.docbook:861 +#. Tag: para +#: tutorial.xml:856 +#, no-c-format msgid "" - "" -msgstr "" +"Create a new class in your source directory, in the events package:" +msgstr "在你的源代码目录的events包中创建一个新的类:" -#: index.docbook:863 -msgid "The servlet handles HTTP GET requests only, hence, the method we implement is doGet():" -msgstr "" - -#: index.docbook:868 +#. Tag: programlisting +#: tutorial.xml:861 +#, no-c-format msgid "" - "" +"" msgstr "" -#: index.docbook:870 -msgid "The pattern we are applying here is called session-per-request. When a request hits the servlet, a new Hibernate Session is opened through the first call to getCurrentSession() on the SessionFactory. Then a database transaction is started—all data access as to occur inside a transaction, no matter if data is read or written (we don't use the auto-commit mode in applications)." +#. Tag: para +#: tutorial.xml:863 +#, no-c-format +msgid "" +"The servlet handles HTTP GET requests only, hence, the " +"method we implement is doGet():" +msgstr "" +"我们后面会用到dateFormatter 的工具, 它把Date对象转换为字符串。只要一个formatter作为servlet的成员就可以了。" + +#. Tag: programlisting +#: tutorial.xml:868 +#, no-c-format +msgid "" +"" msgstr "" -#: index.docbook:879 -msgid "Do not use a new Hibernate Session for every database operation. Use one Hibernate Session that is scoped to the whole request. Use getCurrentSession(), so that it is automatically bound to the current Java thread." +#. Tag: para +#: tutorial.xml:870 +#, fuzzy, no-c-format +msgid "" +"The pattern we are applying here is called session-per-request. When a request hits the servlet, a new Hibernate " +"Session is opened through the first call to " +"getCurrentSession() on the SessionFactory. Then a database transaction is started—all data access as to " +"occur inside a transaction, no matter if data is read or written (we don't " +"use the auto-commit mode in applications)." msgstr "" +"这个servlet只处理 HTTP GET 请求,因此,我们要实现的是" +"doGet()方法:" -#: index.docbook:886 -msgid "Next, the possible actions of the request are processed and the response HTML is rendered. We'll get to that part soon." +#. Tag: para +#: tutorial.xml:879 +#, no-c-format +msgid "" +"Do not use a new Hibernate Session " +"for every database operation. Use one Hibernate Session " +"that is scoped to the whole request. Use getCurrentSession(), so that it is automatically bound to the current Java thread." msgstr "" +"我们称这里应用的模式为每次请求一个session(session-per-request)。当有请求到达这个servlet的时候,通过对SessionFactory的第一次调用,打开一个新的Hibernate Session。然后" +"启动一个数据库事务—所有的数据访问都是在事务中进行,不管是读还是写(我们" +"在应用程序中不使用auto-commit模式)。" -#: index.docbook:891 -msgid "Finally, the unit of work ends when processing and rendering is complete. If any problem occured during processing or rendering, an exception will be thrown and the database transaction rolled back. This completes the session-per-request pattern. Instead of the transaction demarcation code in every servlet you could also write a servlet filter. See the Hibernate website and Wiki for more information about this pattern, called Open Session in View—you'll need it as soon as you consider rendering your view in JSP, not in a servlet." +#. Tag: para +#: tutorial.xml:886 +#, no-c-format +msgid "" +"Next, the possible actions of the request are processed and the response " +"HTML is rendered. We'll get to that part soon." msgstr "" +"不要为每次数据库操作都使用一个新的Hibernate " +"Session。将Hibernate Session的范围设置" +"为整个请求。要用getCurrentSession(),这样它自动会绑定到当" +"前Java线程。" -#: index.docbook:905 +#. Tag: para +#: tutorial.xml:891 +#, fuzzy, no-c-format +msgid "" +"Finally, the unit of work ends when processing and rendering is complete. If " +"any problem occured during processing or rendering, an exception will be " +"thrown and the database transaction rolled back. This completes the " +"session-per-request pattern. Instead of the transaction " +"demarcation code in every servlet you could also write a servlet filter. See " +"the Hibernate website and Wiki for more information about this pattern, " +"called Open Session in View—you'll need it as " +"soon as you consider rendering your view in JSP, not in a servlet." +msgstr "" +"下一步,对请求的可能动作进行处理,渲染出反馈的HTML。我们很快就会涉及到那部" +"分。" + +#. Tag: title +#: tutorial.xml:905 +#, no-c-format msgid "Processing and rendering" msgstr "" +"最后,当处理与渲染都结束的时候,这个工作单元就结束了。假若在处理或渲染的时候" +"有任何错误发生,会抛出一个异常,回滚数据库事务。这样,session-per-" +"request模式就完成了。为了避免在每个servlet中都编写事务边界界定的代" +"码,可以考虑写一个servlet 过滤器(filter)来更好地解决。关于这一模式的更多信" +"息,请参阅Hibernate网站和Wiki,这一模式叫做Open Session in View—只要你考虑用JSP来渲染你的视图(view),而不是在servlet中,你" +"就会很快用到它。" -#: index.docbook:907 -msgid "Let's implement the processing of the request and rendering of the page." -msgstr "" - -#: index.docbook:911 +#. Tag: para +#: tutorial.xml:907 +#, no-c-format msgid "" - "Event Manager\");\n" - "\n" - "// Handle actions\n" - "if ( \"store\".equals(request.getParameter(\"action\")) ) {\n" - "\n" - " String eventTitle = request.getParameter(\"eventTitle\");\n" - " String eventDate = request.getParameter(\"eventDate\");\n" - "\n" - " if ( \"\".equals(eventTitle) || \"\".equals(eventDate) ) {\n" - " out.println(\"Please enter event title and date.\");\n" - " } else {\n" - " createAndStoreEvent(eventTitle, dateFormatter.parse(eventDate));\n" - " out.println(\"Added event.\");\n" - " }\n" - "}\n" - "\n" - "// Print page\n" - "printEventForm(out);\n" - "listEvents(out, dateFormatter);\n" - "\n" - "// Write HTML footer\n" - "out.println(\"\");\n" - "out.flush();\n" - "out.close();]]>" -msgstr "" +"Let's implement the processing of the request and rendering of the page." +msgstr "处理与渲染" -#: index.docbook:913 -msgid "Granted, this coding style with a mix of Java and HTML would not scale in a more complex application—keep in mind that we are only illustrating basic Hibernate concepts in this tutorial. The code prints an HTML header and a footer. Inside this page, an HTML form for event entry and a list of all events in the database are printed. The first method is trivial and only outputs HTML:" -msgstr "" - -#: index.docbook:922 +#. Tag: programlisting +#: tutorial.xml:911 +#, no-c-format msgid "" - "Add new event:\");\n" - " out.println(\"
\");\n" - " out.println(\"Title:
\");\n" - " out.println(\"Date (e.g. 24.12.2009):
\");\n" - " out.println(\"\");\n" - " out.println(\"
\");\n" - "}]]>" +"Event Manager\");\n" +"\n" +"// Handle actions\n" +"if ( \"store\".equals(request.getParameter(\"action\")) ) {\n" +"\n" +" String eventTitle = request.getParameter(\"eventTitle\");\n" +" String eventDate = request.getParameter(\"eventDate\");\n" +"\n" +" if ( \"\".equals(eventTitle) || \"\".equals(eventDate) ) {\n" +" out.println(\"Please enter event title and date.\");\n" +" } else {\n" +" createAndStoreEvent(eventTitle, dateFormatter.parse(eventDate));\n" +" out.println(\"Added event.\");\n" +" }\n" +"}\n" +"\n" +"// Print page\n" +"printEventForm(out);\n" +"listEvents(out, dateFormatter);\n" +"\n" +"// Write HTML footer\n" +"out.println(\"\");\n" +"out.flush();\n" +"out.close();]]>" msgstr "" -#: index.docbook:924 -msgid "The listEvents() method uses the Hibernate Session bound to the current thread to execute a query:" -msgstr "" - -#: index.docbook:930 +#. Tag: para +#: tutorial.xml:913 +#, fuzzy, no-c-format msgid "" - " 0) {\n" - " out.println(\"

Events in database:

\");\n" - " out.println(\"\");\n" - " out.println(\"\");\n" - " out.println(\"\");\n" - " out.println(\"\");\n" - " out.println(\"\");\n" - " for (Iterator it = result.iterator(); it.hasNext();) {\n" - " Event event = (Event) it.next();\n" - " out.println(\"\");\n" - " out.println(\"\");\n" - " out.println(\"\");\n" - " out.println(\"\");\n" - " }\n" - " out.println(\"
Event titleEvent date
\" + event.getTitle() + \"\" + dateFormatter.format(event.getDate()) + \"
\");\n" - " }\n" - "}]]>" -msgstr "" +"Granted, this coding style with a mix of Java and HTML would not scale in a " +"more complex application—keep in mind that we are only illustrating " +"basic Hibernate concepts in this tutorial. The code prints an HTML header " +"and a footer. Inside this page, an HTML form for event entry and a list of " +"all events in the database are printed. The first method is trivial and only " +"outputs HTML:" +msgstr "我们来实现处理请求以及渲染页面的工作。" -#: index.docbook:932 -msgid "Finally, the store action is dispatched to the createAndStoreEvent() method, which also uses the Session of the current thread:" -msgstr "" - -#: index.docbook:938 +#. Tag: programlisting +#: tutorial.xml:922 +#, no-c-format msgid "" - "" +"Add new event:\");\n" +" out.println(\"
\");\n" +" out.println(\"Title:
\");\n" +" out.println(\"Date (e.g. 24.12.2009):
\");\n" +" out.println(\"\");\n" +" out.println(\"
\");\n" +"}]]>" msgstr "" -#: index.docbook:940 -msgid "That's it, the servlet is complete. A request to the servlet will be processed in a single Session and Transaction. As earlier in the standalone application, Hibernate can automatically bind these ojects to the current thread of execution. This gives you the freedom to layer your code and access the SessionFactory in any way you like. Usually you'd use a more sophisticated design and move the data access code into data access objects (the DAO pattern). See the Hibernate Wiki for more examples." +#. Tag: para +#: tutorial.xml:924 +#, no-c-format +msgid "" +"The listEvents() method uses the Hibernate " +"Session bound to the current thread to execute a query:" +msgstr "" +"listEvents()方法使用绑定到当前线程的Hibernate " +"Session来执行查询:" + +#. Tag: programlisting +#: tutorial.xml:930 +#, no-c-format +msgid "" +" 0) {\n" +" out.println(\"

Events in database:

\");\n" +" out.println(\"\");\n" +" out.println(\"\");\n" +" out.println(\"\");\n" +" out.println(\"\");\n" +" out.println(\"\");\n" +" for (Iterator it = result.iterator(); it.hasNext();) {\n" +" Event event = (Event) it.next();\n" +" out.println(\"\");\n" +" out.println(\"\");\n" +" out.println(\"\");\n" +" out.println(\"\");\n" +" }\n" +" out.println(\"
Event titleEvent date
\" + event.getTitle() + \"\" + dateFormatter.format(event.getDate()) + " +"\"
\");\n" +" }\n" +"}]]>" msgstr "" -#: index.docbook:954 +#. Tag: para +#: tutorial.xml:932 +#, no-c-format +msgid "" +"Finally, the store action is dispatched to the " +"createAndStoreEvent() method, which also uses the " +"Session of the current thread:" +msgstr "" +"最后,store动作会被导向到createAndStoreEvent()方法,它也使用当前线程的Session:" + +#. Tag: programlisting +#: tutorial.xml:938 +#, no-c-format +msgid "" +"" +msgstr "" + +#. Tag: para +#: tutorial.xml:940 +#, no-c-format +msgid "" +"That's it, the servlet is complete. A request to the servlet will be " +"processed in a single Session and Transaction. As earlier in the standalone application, Hibernate can " +"automatically bind these ojects to the current thread of execution. This " +"gives you the freedom to layer your code and access the " +"SessionFactory in any way you like. Usually you'd use a " +"more sophisticated design and move the data access code into data access " +"objects (the DAO pattern). See the Hibernate Wiki for more examples." +msgstr "" +"大功告成,这个servlet写完了。Hibernate会在单一的Session 和" +"Transaction中处理到达的servlet请求。如同在前面的独立应用程" +"序中那样,Hibernate可以自动的把这些对象绑定到当前运行的线程中。这给了你用任何" +"你喜欢的方式来对代码分层及访问SessionFactory的自由。通常," +"你会用更加完备的设计,把数据访问代码转移到数据访问对象中(DAO模式)。请参见" +"Hibernate Wiki,那里有更多的例子。" + +#. Tag: title +#: tutorial.xml:954 +#, no-c-format msgid "Deploying and testing" -msgstr "" +msgstr "部署与测试" -#: index.docbook:956 -msgid "To deploy this application you have to create a web archive, a WAR. Add the following Ant target to your build.xml:" -msgstr "" - -#: index.docbook:961 +#. Tag: para +#: tutorial.xml:956 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " \n" - " \n" - "\n" - " \n" - " \n" - "]]>" +"To deploy this application you have to create a web archive, a WAR. Add the " +"following Ant target to your build.xml:" msgstr "" +"要发布这个程序,你得把它打成web发布包:WAR文件。把下面的脚本加入到你的" +"build.xml中:" -#: index.docbook:963 -msgid "This target creates a file called hibernate-tutorial.war in your project directory. It packages all libraries and the web.xml descriptor, which is expected in the base directory of your project:" -msgstr "" - -#: index.docbook:969 +#. Tag: programlisting +#: tutorial.xml:961 +#, no-c-format msgid "" - "\n" - "\n" - "\n" - " \n" - " Event Manager\n" - " events.EventManagerServlet\n" - " \n" - "\n" - " \n" - " Event Manager\n" - " /eventmanager\n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +"\n" +" \n" +" \n" +"]]>" msgstr "" -#: index.docbook:971 -msgid "Before you compile and deploy the web application, note that an additional library is required: jsdk.jar. This is the Java servlet development kit, if you don't have this library already, get it from the Sun website and copy it to your library directory. However, it will be only used for compliation and excluded from the WAR package." +#. Tag: para +#: tutorial.xml:963 +#, no-c-format +msgid "" +"This target creates a file called hibernate-tutorial.war " +"in your project directory. It packages all libraries and the web." +"xml descriptor, which is expected in the base directory of your " +"project:" +msgstr "" +"这段代码在你的开发目录中创建一个hibernate-tutorial.war的文" +"件。它把所有的类库和web.xml描述文件都打包进去,web.xml 文" +"件应该位于你的开发根目录中:" + +#. Tag: programlisting +#: tutorial.xml:969 +#, no-c-format +msgid "" +"\n" +"\n" +"\n" +" \n" +" Event Manager\n" +" events.EventManagerServlet\n" +" \n" +"\n" +" \n" +" Event Manager\n" +" /eventmanager\n" +" \n" +"]]>" msgstr "" -#: index.docbook:979 -msgid "To build and deploy call ant war in your project directory and copy the hibernate-tutorial.war file into your Tomcat webapp directory. If you don't have Tomcat installed, download it and follow the installation instructions. You don't have to change any Tomcat configuration to deploy this application though." +#. Tag: para +#: tutorial.xml:971 +#, no-c-format +msgid "" +"Before you compile and deploy the web application, note that an additional " +"library is required: jsdk.jar. This is the Java servlet " +"development kit, if you don't have this library already, get it from the Sun " +"website and copy it to your library directory. However, it will be only used " +"for compliation and excluded from the WAR package." msgstr "" +"请注意在你编译和部署web应用程之前,需要一个附加的类库:jsdk.jar。这是Java Servlet开发包,假若你还没有,可以从Sun网站上下载,把它copy" +"到你的lib目录。但是,它仅仅是在编译时需要,不会被打入WAR包。" -#: index.docbook:987 -msgid "Once deployed and Tomcat is running, access the application at http://localhost:8080/hibernate-tutorial/eventmanager. Make sure you watch the Tomcat log to see Hibernate initialize when the first request hits your servlet (the static initializer in HibernateUtil is called) and to get the detailed output if any exceptions occurs." +#. Tag: para +#: tutorial.xml:979 +#, no-c-format +msgid "" +"To build and deploy call ant war in your project " +"directory and copy the hibernate-tutorial.war file into " +"your Tomcat webapp directory. If you don't have Tomcat " +"installed, download it and follow the installation instructions. You don't " +"have to change any Tomcat configuration to deploy this application though." msgstr "" +"在你的开发目录中,调用ant war来构建、打包,然后把" +"hibernate-tutorial.war文件拷贝到你的tomcat的" +"webapps目录下。假若你还没安装Tomcat,就去下载一个,按照指" +"南来安装。对此应用的发布,你不需要修改任何Tomcat的配置。" -#: index.docbook:1000 +#. Tag: para +#: tutorial.xml:987 +#, no-c-format +msgid "" +"Once deployed and Tomcat is running, access the application at " +"http://localhost:8080/hibernate-tutorial/eventmanager. " +"Make sure you watch the Tomcat log to see Hibernate initialize when the " +"first request hits your servlet (the static initializer in " +"HibernateUtil is called) and to get the detailed output " +"if any exceptions occurs." +msgstr "" +"在部署完,启动Tomcat之后,通过http://localhost:8080/hibernate-" +"tutorial/eventmanager进行访问你的应用,在第一次servlet 请求发生时," +"请在Tomcat log中确认你看到Hibernate被初始化了(HibernateUtil的静态初始化器被调用),假若有任何异常抛出,也可以看到详细的输出。" + +#. Tag: title +#: tutorial.xml:1000 +#, no-c-format msgid "Summary" +msgstr "总结" + +#. Tag: para +#: tutorial.xml:1002 +#, no-c-format +msgid "" +"This tutorial covered the basics of writing a simple standalone Hibernate " +"application and a small web application." msgstr "" +"本章覆盖了如何编写一个简单独立的Hibernate命令行应用程序及小型的Hibernate web" +"应用程序的基本要素。" -#: index.docbook:1002 -msgid "This tutorial covered the basics of writing a simple standalone Hibernate application and a small web application." +#. Tag: para +#: tutorial.xml:1007 +#, no-c-format +msgid "" +"If you already feel confident with Hibernate, continue browsing through the " +"reference documentation table of contents for topics you find interesting - " +"most asked are transactional processing (), " +"fetch performance (), or the usage of the API " +"() and the query features ()." msgstr "" +"如果你已经对Hibernate感到自信,通过开发指南目录,继续浏览你感兴趣的内容-那些" +"会被问到的问题大多是事务处理 (),抓取" +"(fetch)的效率 (),或者API的使用 ()和查询的特性()。" -#: index.docbook:1007 -msgid "If you already feel confident with Hibernate, continue browsing through the reference documentation table of contents for topics you find interesting - most asked are transactional processing (), fetch performance (), or the usage of the API () and the query features ()." -msgstr "" - -#: index.docbook:1015 -msgid "Don't forget to check the Hibernate website for more (specialized) tutorials." -msgstr "" - -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +#. Tag: para +#: tutorial.xml:1015 +#, no-c-format +msgid "" +"Don't forget to check the Hibernate website for more (specialized) tutorials." +msgstr "别忘了去Hibernate的网站查看更多(有针对性的)示例。" diff --git a/documentation/manual/translations/zh-CN/content/xml.po b/documentation/manual/translations/zh-CN/content/xml.po index d08103aa27..dd2124a4a9 100644 --- a/documentation/manual/translations/zh-CN/content/xml.po +++ b/documentation/manual/translations/zh-CN/content/xml.po @@ -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 \n" -"Content-Type: text/plain; charset=utf-8\n" -#: index.docbook:5 +"Language-Team: LANGUAGE \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: persist(), saveOrUpdate(), merge(), delete(), replicate() (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: persist" +"(), saveOrUpdate(), merge(), delete(), replicate() (merging is not " +"yet supported)." msgstr "" +"Hibernate支持采用dom4j作为操作XML树的API。你可以写一些查询从数据库中检索出 " +"dom4j树,随后你对这颗树做的任何修改都将自动同步回数据库。你甚至可以用dom4j解" +"析 一篇XML文档,然后使用Hibernate的任一基本操作将它写入数据库: " +"persist(), saveOrUpdate(), merge(), delete(), replicate() " +"(合并操作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 "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +"]]>" 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 "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - "]]>" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +"]]>" 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 Maps). 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 Maps). The property names " +"are purely logical constructs that may be referred to in HQL queries." msgstr "" +"这个映射使得你既可以把数据作为一棵dom4j树那样访问,又可以作为由属性键值对" +"(java Maps) 组成的图那样访问。属性名字纯粹是逻辑上的结构," +"你可以在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 node 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 node attribute must be one of the following:" +#. Tag: para +#: xml.xml:75 +#, no-c-format +msgid "" +"Many Hibernate mapping elements accept the node " +"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 node attribute must be one of the following:" msgstr "" +"许多Hibernate映射元素具有node属性。这使你可以指定用来保存 " +"属性或实体数据的XML属性或元素。node属性必须是下列格式之" +"一:" -#: index.docbook:84 +#. Tag: para +#: xml.xml:84 +#, no-c-format msgid "\"element-name\" - map to the named XML element" -msgstr "" +msgstr "\"element-name\" - 映射为指定的XML元素" -#: index.docbook:87 +#. Tag: para +#: xml.xml:87 +#, no-c-format msgid "\"@attribute-name\" - map to the named XML attribute" -msgstr "" +msgstr "\"@attribute-name\" - 映射为指定的XML属性" -#: index.docbook:90 +#. Tag: para +#: xml.xml:90 +#, no-c-format msgid "\".\" - map to the parent element" -msgstr "" +msgstr "\".\" - 映射为父元素" -#: index.docbook:93 -msgid "\"element-name/@attribute-name\" - map to the named attribute of the named element" -msgstr "" - -#: index.docbook:100 -msgid "For collections and single valued associations, there is an additional embed-xml attribute. If embed-xml=\"true\", 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 embed-xml=\"false\", 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 embed-xml=\"true\" 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 "" - "\n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " \n" - " ...\n" - " \n" - "]]>" +"\"element-name/@attribute-name\" - map to the named " +"attribute of the named element" +msgstr "" +"\"element-name/@attribute-name\" - 映射为指定元素的指定属" +"性" + +#. Tag: para +#: xml.xml:100 +#, no-c-format +msgid "" +"For collections and single valued associations, there is an additional " +"embed-xml attribute. If embed-xml=\"true\", 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 embed-xml=\"false\", " +"then only the referenced identifier value will appear in the XML for single " +"point associations and collections will simply not appear at all." +msgstr "" +"对于集合和单值的关联,有一个额外的embed-xml属性可用。 这个" +"属性的缺省值是真(embed-xml=\"true\")。如果embed-" +"xml=\"true\", 则对应于被关联实体或值类型的集合的XML树将直接嵌入拥" +"有这些关联的实体的XML树中。 否则,如果embed-xml=\"false\",那么对于单值的关联,仅被引用的实体的标识符出现在 XML树中(被引用实体" +"本身不出现),而集合则根本不出现。" + +#. Tag: para +#: xml.xml:110 +#, no-c-format +msgid "" +"You should be careful not to leave embed-xml=\"true\" for " +"too many associations, since XML does not deal well with circularity!" +msgstr "" +"你应该小心,不要让太多关联的embed-xml属性为真(embed-xml=\"true\"),因为XML不能很好地处理 循环引用!" + +#. Tag: programlisting +#: xml.xml:115 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" ...\n" +" \n" +"]]>" 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 "" +"" msgstr "" -#: index.docbook:122 -msgid "" -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 "" - "\n" - " 987632567\n" - " 985612323\n" - " \n" - " Gavin\n" - " A\n" - " King\n" - " \n" - " ...\n" - "]]>" +"\n" +" 987632567\n" +" 985612323\n" +" \n" +" Gavin\n" +" A\n" +" King\n" +" \n" +" ...\n" +"]]>" msgstr "" -#: index.docbook:130 -msgid "If you set embed-xml=\"true\" on the <one-to-many> mapping, the data might look more like this:" -msgstr "" - -#: index.docbook:135 +#. Tag: para +#: xml.xml:130 +#, no-c-format msgid "" - "\n" - " \n" - " \n" - " 100.29\n" - " \n" - " \n" - " \n" - " -2370.34\n" - " \n" - " \n" - " Gavin\n" - " A\n" - " King\n" - " \n" - " ...\n" - "]]>" +"If you set embed-xml=\"true\" on the <one-to-" +"many> mapping, the data might look more like this:" +msgstr "" +"如果你把一对多映射<one-to-many>的embed-xml属性置为真" +"(embed-xml=\"true\"), 则数据看上去就像这样:" + +#. Tag: programlisting +#: xml.xml:135 +#, no-c-format +msgid "" +"\n" +" \n" +" \n" +" 100.29\n" +" \n" +" \n" +" \n" +" -2370.34\n" +" \n" +" \n" +" Gavin\n" +" A\n" +" King\n" +" \n" +" ...\n" +"]]>" 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 "" - "" +"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 "" - "" +"" msgstr "" -#: index.docbook:152 -msgid "It is extremely useful to combine this feature with Hibernate's replicate() operation to implement XML-based data import/export." +#. Tag: programlisting +#: xml.xml:150 +#, no-c-format +msgid "" +"" msgstr "" -msgid "ROLES_OF_TRANSLATORS" -msgstr "" - -msgid "CREDIT_FOR_TRANSLATORS" -msgstr "" - +#. Tag: para +#: xml.xml:152 +#, no-c-format +msgid "" +"It is extremely useful to combine this feature with Hibernate's " +"replicate() operation to implement XML-based data import/" +"export." +msgstr "" +"将这一特色与Hibernate的replicate()操作结合起来对于实现的基" +"于XML的数据导入/导出将非常有用."