From 7ea9c8fe763665a73ddcdcdae3e944c0d7030212 Mon Sep 17 00:00:00 2001 From: xhuang Date: Tue, 16 Mar 2010 01:42:26 +0000 Subject: [PATCH] update git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19003 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../docbook/zh-CN/content/best_practices.po | 262 +-- .../zh-CN/content/example_parentchild.po | 294 +--- .../zh-CN/content/persistent_classes.po | 510 ++---- .../main/docbook/zh-CN/content/portability.po | 243 +-- .../src/main/docbook/zh-CN/content/preface.po | 159 +- .../docbook/zh-CN/content/query_criteria.po | 251 +-- .../main/docbook/zh-CN/content/query_hql.po | 966 +++-------- .../main/docbook/zh-CN/content/query_sql.po | 589 ++----- .../main/docbook/zh-CN/content/session_api.po | 1212 +++----------- .../docbook/zh-CN/content/toolset_guide.po | 339 +--- .../docbook/zh-CN/content/transactions.po | 1433 +++-------------- .../main/docbook/zh-CN/content/tutorial.po | 1384 +++------------- .../src/main/docbook/zh-CN/content/xml.po | 149 +- .../zh-CN/fallback_content/Conventions.po | 86 +- .../zh-CN/fallback_content/Feedback.po | 11 +- .../zh-CN/fallback_content/Legal_Notice.po | 8 +- 16 files changed, 1480 insertions(+), 6416 deletions(-) diff --git a/documentation/manual/src/main/docbook/zh-CN/content/best_practices.po b/documentation/manual/src/main/docbook/zh-CN/content/best_practices.po index 141a146d14..44087311f5 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/best_practices.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/best_practices.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Collection_Mapping\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-02-11T05:38:15\n" -"PO-Revision-Date: 2009-11-06 10:05+1000\n" +"PO-Revision-Date: 2010-03-16 10:01+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,24 +21,13 @@ msgstr "最佳实践(Best Practices)" #. Tag: term #, no-c-format -msgid "" -"Write fine-grained classes and map them using <component>:" -msgstr "" -"设计细颗粒度的持久类并且使用 <component> 来实现映" -"射:" +msgid "Write fine-grained classes and map them using <component>:" +msgstr "设计细颗粒度的持久类并且使用 <component> 来实现映射:" #. Tag: para #, no-c-format -msgid "" -"Use an Address class to encapsulate street, suburb, state, " -"postcode. This encourages code reuse and simplifies " -"refactoring." -msgstr "" -"使用一个 Address 持久类来封装 street," -"suburbstatepostcode。 这将有利于代码重用和简化代码重构(refactoring)的工作。" +msgid "Use an Address class to encapsulate street, suburb, state, postcode. This encourages code reuse and simplifies refactoring." +msgstr "使用一个 Address 持久类来封装 streetsuburbstatepostcode。 这将有利于代码重用和简化代码重构(refactoring)的工作。" #. Tag: term #, no-c-format @@ -47,13 +36,8 @@ msgstr "对持久类声明标识符属性(identifier properties):" #. Tag: para #, no-c-format -msgid "" -"Hibernate makes identifier properties optional. There are a range of reasons " -"why you should use them. We recommend that identifiers be 'synthetic', that " -"is, generated with no business meaning." -msgstr "" -"Hibernate 中标识符属性是可选的,不过有很多原因来说明你应该使用标识符属性。我" -"们建议标识符应该是“人造”的(自动生成,不涉及业务含义)。 " +msgid "Hibernate makes identifier properties optional. There are a range of reasons why you should use them. We recommend that identifiers be 'synthetic', that is, generated with no business meaning." +msgstr "Hibernate 中标识符属性是可选的,不过有很多原因来说明你应该使用标识符属性。我们建议标识符应该是“人造”的(自动生成,不涉及业务含义)。 " #. Tag: term #, no-c-format @@ -62,15 +46,8 @@ msgstr "使用自然键(natural keys)标识:" #. Tag: para #, 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(),在其中" -"用组成自然键的属性进行比较。" +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(),在其中用组成自然键的属性进行比较。" #. Tag: term #, no-c-format @@ -79,14 +56,8 @@ msgstr "为每个持久类写一个映射文件:" #. Tag: para #, no-c-format -msgid "" -"Do not use a single monolithic mapping document. Map com.eg.Foo in the file com/eg/Foo.hbm.xml. This makes " -"sense, particularly in a team environment." -msgstr "" -"不要把所有的持久类映射都写到一个大文件中。把 com.eg.Foo 映" -"射到 com/eg/Foo.hbm.xml 中。在团队开发环境中,这一点尤其重" -"要。" +msgid "Do not use a single monolithic mapping document. Map com.eg.Foo in the file com/eg/Foo.hbm.xml. This makes sense, particularly in a team environment." +msgstr "不要把所有的持久类映射都写到一个大文件中。把 com.eg.Foo 映射到 com/eg/Foo.hbm.xml 中。在团队开发环境中,这一点尤其重要。" #. Tag: term #, no-c-format @@ -105,13 +76,8 @@ msgstr "考虑把查询字符串放在程序外面:" #. Tag: para #, no-c-format -msgid "" -"This is recommended if your queries call non-ANSI-standard SQL functions. " -"Externalizing the query strings to mapping files will make the application " -"more portable." -msgstr "" -"如果你的查询中调用了非 ANSI 标准的 SQL 函数,那么这条实践经验对你适用。把查询" -"字符串放在映射文件中可以让程序具有更好的可移植性。 " +msgid "This is recommended if your queries call non-ANSI-standard SQL functions. Externalizing the query strings to mapping files will make the application more portable." +msgstr "如果你的查询中调用了非 ANSI 标准的 SQL 函数,那么这条实践经验对你适用。把查询字符串放在映射文件中可以让程序具有更好的可移植性。 " #. Tag: term #, no-c-format @@ -120,13 +86,8 @@ msgstr "使用绑定变量" #. Tag: para #, no-c-format -msgid "" -"As in JDBC, always replace non-constant values by \"?\". Do not use string " -"manipulation to bind a non-constant value in a query. You should also " -"consider using named parameters in queries." -msgstr "" -"就像在 JDBC 编程中一样,应该总是用占位符 \"?\" 来替换非常量值,不要在查询中用" -"字符串值来构造非常量值。你也应该考虑在查询中使用命名参数。" +msgid "As in JDBC, always replace non-constant values by \"?\". Do not use string manipulation to bind a non-constant value in a query. You should also consider using named parameters in queries." +msgstr "就像在 JDBC 编程中一样,应该总是用占位符 \"?\" 来替换非常量值,不要在查询中用字符串值来构造非常量值。你也应该考虑在查询中使用命名参数。" #. Tag: term #, no-c-format @@ -135,15 +96,8 @@ msgstr "不要自己来管理 JDBC 连接:" #. Tag: para #, no-c-format -msgid "" -"Hibernate allows the application to manage JDBC connections, but his " -"approach should be considered a last-resort. If you cannot use the built-in " -"connection providers, consider providing your own implementation of " -"org.hibernate.connection.ConnectionProvider." -msgstr "" -"Hibernate 允许应用程序自己来管理 JDBC 连接,但是应该作为最后没有办法的办法。" -"如果你不能使用 Hibernate 内建的 connections providers,那么考虑实现自己来实" -"现 org.hibernate.connection.ConnectionProvider。" +msgid "Hibernate allows the application to manage JDBC connections, but his approach should be considered a last-resort. If you cannot use the built-in connection providers, consider providing your own implementation of org.hibernate.connection.ConnectionProvider." +msgstr "Hibernate 允许应用程序自己来管理 JDBC 连接,但是应该作为最后没有办法的办法。如果你不能使用 Hibernate 内建的 connections providers,那么考虑实现自己来实现 org.hibernate.connection.ConnectionProvider。" #. Tag: term #, no-c-format @@ -152,17 +106,8 @@ msgstr "考虑使用用户自定义类型(custom type):" #. Tag: para #, no-c-format -msgid "" -"Suppose you have a Java type from a library that needs to be persisted but " -"does not 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 之间" -"的相互转换。 " +msgid "Suppose you have a Java type from a library that needs to be persisted but does not 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 之间的相互转换。 " #. Tag: term #, no-c-format @@ -170,22 +115,9 @@ msgid "Use hand-coded JDBC in bottlenecks:" msgstr "在性能瓶颈的地方使用硬编码的 JDBC:" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"In performance-critical areas of the system, some kinds of operations might " -"benefit from direct JDBC. Do not assume, however, that JDBC is necessarily " -"faster. Please wait until you know something is a " -"bottleneck. If you need to use direct JDBC, you can open a Hibernate " -"Session, wrap your JDBC operation as a org." -"hibernate.jdbc.Work object and using that JDBC connection. This " -"way you can still use the same transaction strategy and underlying " -"connection provider." -msgstr "" -"在系统中对性能要求很严格的一些部分,某些操作也许直接使用 JDBC 会更好。但是请" -"先确认这的确是一个瓶颈,并且不要想当然认为 JDBC 一定会更" -"快。如果确实需要直接使用 JDBC,那么最好打开一个 Hibernate Session 然后从 Session 获得 connection,按照这种办法你仍" -"然可以使用同样的 transaction 策略和底层的 connection provider。 " +#, no-c-format +msgid "In performance-critical areas of the system, some kinds of operations might benefit from direct JDBC. Do not assume, however, that JDBC is necessarily faster. Please wait until you know something is a bottleneck. If you need to use direct JDBC, you can open a Hibernate Session, wrap your JDBC operation as a org.hibernate.jdbc.Work object and using that JDBC connection. This way you can still use the same transaction strategy and underlying connection provider." +msgstr "在系统中对性能要求很严格的一些部分,某些操作也许直接使用 JDBC 会更好。但是请先确认这的确是一个瓶颈,并且不要想当然认为 JDBC 一定会更快。如果确实需要直接使用 JDBC,那么最好打开一个 Hibernate Session 然后将 JDBC 操作包裹为 org.hibernate.jdbc.Work 并使用 JDBC 连接。按照这种办法你仍然可以使用同样的 transaction 策略和底层的 connection provider。 " #. Tag: term #, no-c-format @@ -194,16 +126,8 @@ msgstr "理解 Session 冲刷(flushing):" #. Tag: para #, no-c-format -msgid "" -"Sometimes the Session synchronizes its persistent state with the database. " -"Performance will be affected if this process occurs too often. You can " -"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 中改变查询和其它操作的顺序。 " +msgid "Sometimes the Session synchronizes its persistent state with the database. Performance will be affected if this process occurs too often. You can 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 中改变查询和其它操作的顺序。 " #. Tag: term #, no-c-format @@ -212,17 +136,8 @@ msgstr "在三层结构中,考虑使用脱管对象(detached object):" #. Tag: para #, no-c-format -msgid "" -"When using a servlet/session bean architecture, you can 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() 来与数据库同步。 " +msgid "When using a servlet/session bean architecture, you can 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() 来与数据库同步。 " #. Tag: term #, no-c-format @@ -231,27 +146,8 @@ msgstr "在两层结构中,考虑使用长持久上下文(long persistence c #. Tag: para #, no-c-format -msgid "" -"Database Transactions have to be as short as possible for best scalability. " -"However, it is often necessary 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 appropriate alternative in a two " -"tiered architecture, is to maintain a single open persistence contact " -"session for the whole life cycle of the application transaction. Then 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)中,否则你的数据可能会过期失效。" +msgid "Database Transactions have to be as short as possible for best scalability. However, it is often necessary 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 appropriate alternative in a two tiered architecture, is to maintain a single open persistence contact session for the whole life cycle of the application transaction. Then 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)中,否则你的数据可能会过期失效。" #. Tag: term #, no-c-format @@ -260,20 +156,8 @@ msgstr "不要把异常看成可恢复的:" #. Tag: para #, 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 do not do this, Hibernate cannot " -"guarantee that in-memory state accurately represents the persistent state. " -"For example, 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() 或者进行一次查询。" +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 do not do this, Hibernate cannot guarantee that in-memory state accurately represents the persistent state. For example, 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() 或者进行一次查询。" #. Tag: term #, no-c-format @@ -282,55 +166,18 @@ msgstr "对于关联优先考虑 lazy fetching:" #. Tag: para #, 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 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。 " +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 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。 " #. Tag: term #, 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)策略来避免再次抓取数据带来的问题:" +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)策略来避免再次抓取数据带来的问题:" #. Tag: para #, 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. Unless you are prepared to hold the persistence context (the " -"session) open across the view rendering process, 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. 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 的限制,这是实" -"现安全的事务化数据访问的基本需求。" +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. Unless you are prepared to hold the persistence context (the session) open across the view rendering process, 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. 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 的限制,这是实现安全的事务化数据访问的基本需求。" #. Tag: term #, no-c-format @@ -339,19 +186,8 @@ msgstr "考虑把 Hibernate 代码从业务逻辑代码中抽象出来:" #. Tag: para #, 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, " -"however, 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 张表的应用程序并不适合。" +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, however, 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 张表的应用程序并不适合。" #. Tag: term #, no-c-format @@ -360,17 +196,8 @@ msgstr "不要用怪异的连接映射:" #. Tag: para #, no-c-format -msgid "" -"Practical test cases for 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, most associations are one-to-many and many-" -"to-one. For this reason, you should proceed cautiously when using any other " -"association style." -msgstr "" -"多对多连接用得好的例子实际上相当少见。大多数时候你在“连接表”中需要保存额外的" -"信息。这种情况下,用两个指向中介类的一对多的连接比较好。实际上,我们认为绝大" -"多数的连接是一对多和多对一的。i因此,你应该谨慎使用其它连接风格。" +msgid "Practical test cases for 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, most associations are one-to-many and many-to-one. For this reason, you should proceed cautiously when using any other association style." +msgstr "多对多连接用得好的例子实际上相当少见。大多数时候你在“连接表”中需要保存额外的信息。这种情况下,用两个指向中介类的一对多的连接比较好。实际上,我们认为绝大多数的连接是一对多和多对一的。i因此,你应该谨慎使用其它连接风格。" #. Tag: term #, no-c-format @@ -379,9 +206,6 @@ msgstr "偏爱双向关联:" #. Tag: para #, 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 "" -"单向关联更加难于查询。在大型应用中,几乎所有的关联必须在查询中可以双向导航。" +msgid "Unidirectional associations are more difficult to query. In a large application, almost all associations must be navigable in both directions in queries." +msgstr "单向关联更加难于查询。在大型应用中,几乎所有的关联必须在查询中可以双向导航。" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/example_parentchild.po b/documentation/manual/src/main/docbook/zh-CN/content/example_parentchild.po index 4e3b4f3ac1..3cb29c123e 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/example_parentchild.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/example_parentchild.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Collection_Mapping\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-02-10T07:25:35\n" -"PO-Revision-Date: 2009-11-27 13:54+1000\n" +"PO-Revision-Date: 2010-03-16 10:04+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,31 +21,8 @@ msgstr "示例:父子关系(Parent/Child)" #. Tag: para #, no-c-format -msgid "" -"One of the first things that new users want to do with Hibernate is to model " -"a parent/child type relationship. There are two different approaches to " -"this. 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>. The 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." -msgstr "" -"刚刚接触 Hibernate 的人大多是从父子关系(parent / child type relationship)的" -"建模入手的。父子关系的建模有两种方法。由于种种原因,最方便的方法是把 " -"ParentChild 都建模成实体类,并创建" -"一个从 Parent 指向 Child 的 <one-to-" -"many> 关联,对新手来说尤其如此。还有一种方法,就是将 Child 声明为一个 <composite-element>(组合元" -"素)。 事实上在 Hibernate 中 one to many 关联的默认语义远没有 composite " -"element 贴近 parent / child 关系的通常语义。下面我们会阐述如何使用" -"带有级联的双向一对多关联(idirectional one to many association with " -"cascades)去建立有效、优美的 parent / child 关系。" +msgid "One of the first things that new users want to do with Hibernate is to model a parent/child type relationship. There are two different approaches to this. 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>. The 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." +msgstr "刚刚接触 Hibernate 的人大多是从父子关系(parent / child type relationship)的建模入手的。父子关系的建模有两种方法。由于种种原因,最方便的方法是把 ParentChild 都建模成实体类,并创建一个从 Parent 指向 Child 的 <one-to-many> 关联,对新手来说尤其如此。还有一种方法,就是将 Child 声明为一个 <composite-element>(组合元素)。 事实上在 Hibernate 中 one to many 关联的默认语义远没有 composite element 贴近 parent / child 关系的通常语义。下面我们会阐述如何使用带有级联的双向一对多关联(idirectional one to many association with cascades)去建立有效、优美的 parent / child 关系。" #. Tag: title #, no-c-format @@ -54,62 +31,28 @@ msgstr "关于 collections 需要注意的一点" #. Tag: para #, no-c-format -msgid "" -"Hibernate collections are considered to be a logical part of their owning " -"entity and not of the contained entities. Be aware that this is a critical " -"distinction that has the following consequences:" -msgstr "" -"Hibernate collections 被当作其所属实体而不是其包含实体的一个逻辑部分。这非常" -"重要,它主要体现为以下几点:" +msgid "Hibernate collections are considered to be a logical part of their owning entity and not of the contained entities. Be aware that this is a critical distinction that has the following consequences:" +msgstr "Hibernate collections 被当作其所属实体而不是其包含实体的一个逻辑部分。这非常重要,它主要体现为以下几点:" #. Tag: para #, no-c-format -msgid "" -"When you remove/add an object from/to a collection, the version number of " -"the collection owner is incremented." -msgstr "" -"当删除或增加 collection 中对象的时候,collection 所属者的版本值会递增。 " +msgid "When you remove/add an object from/to a collection, the version number of the collection owner is incremented." +msgstr "当删除或增加 collection 中对象的时候,collection 所属者的版本值会递增。 " #. Tag: para #, no-c-format -msgid "" -"If an object that was removed from a collection is an instance of a value " -"type (e.g. 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 的实例将会使之立即被持久" -"化。 " +msgid "If an object that was removed from a collection is an instance of a value type (e.g. 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 的实例将会使之立即被持久化。 " #. Tag: para #, no-c-format -msgid "" -"Conversely, 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 behavior 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 增加一个实体不会使之被持久" -"化。 " +msgid "Conversely, 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 behavior 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 增加一个实体不会使之被持久化。 " #. Tag: para #, no-c-format -msgid "" -"Adding an entity to a collection, by default, merely creates a link between " -"the two entities. Removing the entity will remove the link. This is " -"appropriate for all sorts of cases. However, it is not appropriate in the " -"case of a parent/child relationship. In this case, the life of the child is " -"bound to the life cycle of the parent." -msgstr "" -"实际上,向 Collection 增加一个实体的缺省动作只是在两个实体之间创建一个连接而" -"已,同样移除的时候也只是删除连接。这种处理对于所有的情况都是合适的。对于父子" -"关系则是完全不适合的,在这种关系下,子对象的生存绑定于父对象的生存周期。 " +msgid "Adding an entity to a collection, by default, merely creates a link between the two entities. Removing the entity will remove the link. This is appropriate for all sorts of cases. However, it is not appropriate in the case of a parent/child relationship. In this case, the life of the child is bound to the life cycle of the parent." +msgstr "实际上,向 Collection 增加一个实体的缺省动作只是在两个实体之间创建一个连接而已,同样移除的时候也只是删除连接。这种处理对于所有的情况都是合适的。对于父子关系则是完全不适合的,在这种关系下,子对象的生存绑定于父对象的生存周期。 " #. Tag: title #, no-c-format @@ -118,11 +61,8 @@ msgstr "双向的一对多关系(Bidirectional one-to-many)" #. Tag: para #, no-c-format -msgid "" -"Suppose we start with a simple <one-to-many> " -"association from Parent to Child." -msgstr "" -"假设我们要实现一个简单的从 Parent 到 Child 的 <one-to-many> 关联。" +msgid "Suppose we start with a simple <one-to-many> association from Parent to Child." +msgstr "假设我们要实现一个简单的从 Parent 到 Child 的 <one-to-many> 关联。" #. Tag: para #, no-c-format @@ -136,31 +76,18 @@ msgstr "Hibernate 会产生两条 SQL 语句:" #. Tag: para #, no-c-format -msgid "" -"an INSERT to create the record for c" -msgstr "" -"一条 INSERT 语句,为 c 创建一条记录" +msgid "an INSERT to create the record for c" +msgstr "一条 INSERT 语句,为 c 创建一条记录" #. Tag: para #, no-c-format -msgid "" -"an UPDATE to create the link from p to " -"c" -msgstr "" -"一条 UPDATE 语句,创建从 p 到 " -"c 的连接" +msgid "an UPDATE to create the link from p to c" +msgstr "一条 UPDATE 语句,创建从 pc 的连接" #. Tag: para #, no-c-format -msgid "" -"This is not only inefficient, but also violates any NOT NULL constraint on the parent_id column. You can fix " -"the nullability constraint violation by specifying not-null=\"true" -"\" in the collection mapping:" -msgstr "" -"这样做不仅效率低,而且违反了 parent_id 列 " -"parent_id 非空的限制。我们可以通过在集合类映射上指定 " -"not-null=\"true\" 来解决违反非空约束的问题:" +msgid "This is not only inefficient, but also violates any NOT NULL constraint on the parent_id column. You can fix the nullability constraint violation by specifying not-null=\"true\" in the collection mapping:" +msgstr "这样做不仅效率低,而且违反了 parent_idparent_id 非空的限制。我们可以通过在集合类映射上指定 not-null=\"true\" 来解决违反非空约束的问题:" #. Tag: para #, no-c-format @@ -169,35 +96,18 @@ msgstr "然而,这并非是推荐的解决方法。" #. Tag: para #, no-c-format -msgid "" -"The underlying cause of this behavior 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. The " -"solution is to make the link part of the Child mapping." -msgstr "" -"这种现象的根本原因是从 pc 的连接" -"(外键 parent_id)没有被当作 Child 对象状态的一部分,因而" -"没有在 INSERT 语句中被创建。因此解决的办法就是把这个连接添" -"加到 Child 的映射中。" +msgid "The underlying cause of this behavior 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. The solution is to make the link part of the Child mapping." +msgstr "这种现象的根本原因是从 pc 的连接(外键 parent_id)没有被当作 Child 对象状态的一部分,因而没有在 INSERT 语句中被创建。因此解决的办法就是把这个连接添加到 Child 的映射中。" #. Tag: para #, no-c-format -msgid "" -"You also need to add the parent property to the " -"Child class." -msgstr "" -"你还需要为类 Child 添加 parent 属性。" +msgid "You also need to add the parent property to the Child class." +msgstr "你还需要为类 Child 添加 parent 属性。" #. Tag: para #, 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 to do this:" -msgstr "" -"现在实体 Child 在管理连接的状态,为了使 collection 不更新" -"连接,我们使用 inverse 属性:" +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 to do this:" +msgstr "现在实体 Child 在管理连接的状态,为了使 collection 不更新连接,我们使用 inverse 属性:" #. Tag: para #, no-c-format @@ -211,12 +121,8 @@ msgstr "现在,只会有一条 INSERT 语句被执行。" #. Tag: para #, no-c-format -msgid "" -"You could also create an addChild() method of " -"Parent." -msgstr "" -"为了让事情变得井井有条,可以为 Parent 加一个 " -"addChild() 方法。" +msgid "You could also create an addChild() method of Parent." +msgstr "为了让事情变得井井有条,可以为 Parent 加一个 addChild() 方法。" #. Tag: para #, no-c-format @@ -230,12 +136,8 @@ msgstr "级联生命周期(Cascading lifecycle) " #. Tag: para #, no-c-format -msgid "" -"You can address the frustrations of the explicit call to save() by using cascades." -msgstr "" -"需要显式调用 save() 仍然很麻烦,我们可以用级联来解决这个问" -"题。 " +msgid "You can address the frustrations of the explicit call to save() by using cascades." +msgstr "需要显式调用 save() 仍然很麻烦,我们可以用级联来解决这个问题。 " #. Tag: para #, no-c-format @@ -244,13 +146,8 @@ msgstr "这样上面的代码可以简化为: " #. Tag: para #, no-c-format -msgid "" -"Similarly, we do not 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 及其所有子对象对应的数据库记录。 " +msgid "Similarly, we do not 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: para #, no-c-format @@ -259,41 +156,18 @@ msgstr "然而,这段代码:" #. Tag: para #, no-c-format -msgid "" -"will not remove c from the database. In this case, it " -"will only remove the link to p and cause a NOT " -"NULL constraint violation. You need to explicitly delete()" -" the Child." -msgstr "" -"不会从数据库删除c;它只会删除与 p 之间" -"的连接(并且会导致违反 NOT NULL 约束,在这个例子中)。你需" -"要显式调用 delete() 来删除 Child。 " +msgid "will not remove c from the database. In this case, it will only remove the link to p and cause a NOT NULL constraint violation. You need to explicitly delete() the Child." +msgstr "不会从数据库删除c;它只会删除与 p 之间的连接(并且会导致违反 NOT NULL 约束,在这个例子中)。你需要显式调用 delete() 来删除 Child。 " #. Tag: para #, no-c-format -msgid "" -"In our case, a Child cannot exist without its parent. So " -"if we remove a Child from the collection, we do want it " -"to be deleted. To do this, we must use cascade=\"all-delete-orphan" -"\"." -msgstr "" -"在我们的例子中,如果没有父对象,子对象就不应该存在,如果将子对象从 " -"collection 中移除,实际上我们是想删除它。要实现这种要求,就必须使用 " -"cascade=\"all-delete-orphan\"。 " +msgid "In our case, a Child cannot exist without its parent. So if we remove a Child from the collection, we do want it to be deleted. To do this, we must use cascade=\"all-delete-orphan\"." +msgstr "在我们的例子中,如果没有父对象,子对象就不应该存在,如果将子对象从 collection 中移除,实际上我们是想删除它。要实现这种要求,就必须使用 cascade=\"all-delete-orphan\"。 " #. Tag: para #, no-c-format -msgid "" -"Even though the collection mapping specifies inverse=\"true\", cascades are still processed by iterating the collection elements. " -"If you need 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() 是不够的。 " +msgid "Even though the collection mapping specifies inverse=\"true\", cascades are still processed by iterating the collection elements. If you need 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 #, no-c-format @@ -301,57 +175,19 @@ msgid "Cascades and unsaved-value" msgstr "级联与未保存值(unsaved-value)" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"Suppose we loaded up a Parent in one Session, made some changes in a UI action and wanted to persist these " -"changes in a new session by calling update(). The " -"Parent will contain a collection of children and, since " -"the cascading update is enabled, Hibernate needs to know which children are " -"newly instantiated and which represent existing rows in the database. We " -"will also assume that both Parent and Child have generated 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 对象是新实" -"例化的,哪些代表数据库中已经存在的记录。我们假设 Parent " -"和 Child 对象的标识属性都是自动生成的,类型为 " -"java.lang.Long。Hibernate 会使用标识属性的值,和 version " -"或 timestamp 属性,来判断哪些子对象是新的。(参见 在 Hibernate3 中,显式指定 " -"unsaved-value 不再是必须的了。" +#, no-c-format +msgid "Suppose we loaded up a Parent in one Session, made some changes in a UI action and wanted to persist these changes in a new session by calling update(). The Parent will contain a collection of children and, since the cascading update is enabled, Hibernate needs to know which children are newly instantiated and which represent existing rows in the database. We will also assume that both Parent and Child have generated 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 对象的标识属性都是自动生成的,类型为 Long。Hibernate 会使用标识属性的值,和 version 或 timestamp 属性,来判断哪些子对象是新的。(参见 在 Hibernate3 中,显式指定 unsaved-value 不再是必须的了。 " #. Tag: para #, no-c-format -msgid "" -"The following code will update parent and child and insert newChild:" -msgstr "" -"下面的代码会更新 parentchild 对象," -"并且插入 newChild 对象。 " +msgid "The following code will update parent and child and insert newChild:" +msgstr "下面的代码会更新 parentchild 对象,并且插入 newChild 对象。 " #. Tag: para #, no-c-format -msgid "" -"This may be suitable for the case of a generated identifier, but what about " -"assigned identifiers and composite identifiers? This is more difficult, " -"since Hibernate cannot 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 属" -"性,或者查询第二级缓存,或者最坏的情况,查询数据库,来确认是否此行存在。 " +msgid "This may be suitable for the case of a generated identifier, but what about assigned identifiers and composite identifiers? This is more difficult, since Hibernate cannot 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 属性,或者查询第二级缓存,或者最坏的情况,查询数据库,来确认是否此行存在。 " #. Tag: title #, no-c-format @@ -360,28 +196,13 @@ msgstr "结论" #. Tag: para #, no-c-format -msgid "" -"The sections we have just covered can be a bit confusing. However, in " -"practice, it all works out nicely. Most Hibernate applications use the " -"parent/child pattern in many places." -msgstr "" -"这里有不少东西需要融会贯通,可能会让新手感到迷惑。但是在实践中它们都工作地非" -"常好。大部分 Hibernate 应用程序都会经常用到父子对象模式。 " +msgid "The sections we have just covered can be a bit confusing. However, in practice, it all works out nicely. Most Hibernate applications use the parent/child pattern in many places." +msgstr "这里有不少东西需要融会贯通,可能会让新手感到迷惑。但是在实践中它们都工作地非常好。大部分 Hibernate 应用程序都会经常用到父子对象模式。 " #. Tag: para #, 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 with composite element classes: " -"composite elements cannot own collections and they should not be the child " -"of any entity other than the unique parent." -msgstr "" -"在第一段中我们曾经提到另一个方案。上面的这些问题都不会出现在 <" -"composite-element> 映射中,它准确地表达了父子关系的语义。很不幸" -"复合元素还有两个重大限制:复合元素不能拥有 collections,并且,除了用于惟一的" -"父对象外,它们不能再作为其它任何实体的子对象。 " +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 with composite element classes: composite elements cannot own collections and they should not be the child of any entity other than the unique parent." +msgstr "在第一段中我们曾经提到另一个方案。上面的这些问题都不会出现在 <composite-element> 映射中,它准确地表达了父子关系的语义。很不幸复合元素还有两个重大限制:复合元素不能拥有 collections,并且,除了用于惟一的父对象外,它们不能再作为其它任何实体的子对象。 " #~ msgid "" #~ "\n" @@ -393,7 +214,6 @@ msgstr "" #~ " \n" #~ " \n" #~ "]]>" - #~ msgid "" #~ "" - #~ msgid "" #~ "\n" #~ " \n" @@ -417,14 +236,12 @@ msgstr "" #~ " \n" #~ " \n" #~ "]]>" - #~ msgid "" #~ "]]>" #~ msgstr "" #~ "]]>" - #~ msgid "" #~ "\n" #~ " \n" @@ -435,7 +252,6 @@ msgstr "" #~ " \n" #~ " \n" #~ "]]>" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "\n" #~ " \n" @@ -485,7 +298,6 @@ msgstr "" #~ " \n" #~ " \n" #~ "]]>" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "\n" @@ -544,7 +352,6 @@ msgstr "" #~ " \n" #~ " \n" #~ "]]>" - #~ msgid "" #~ "" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/persistent_classes.po b/documentation/manual/src/main/docbook/zh-CN/content/persistent_classes.po index c58d1029ea..809cb58b93 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/persistent_classes.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/persistent_classes.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: persistent_classes\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-02-11T05:38:15\n" -"PO-Revision-Date: 2009-12-07 09:36+1000\n" +"PO-Revision-Date: 2010-03-16 10:00+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -22,30 +22,13 @@ msgstr "持久化类(Persistent Classes)" #. Tag: para #, 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. For example, an instance can instead be transient " -"or detached." -msgstr "" -"在应用程序中,用来实现业务问题实体的(如,在电子商务应用程序中的 Customer 和 " -"Order)类就是持久化类。不能认为所有的持久化类的实例都是持久的状态 - 一个实例" -"的状态也可能是瞬时的或脱管的。" +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. For example, an instance can instead be transient or detached." +msgstr "在应用程序中,用来实现业务问题实体的(如,在电子商务应用程序中的 Customer 和 Order)类就是持久化类。不能认为所有的持久化类的实例都是持久的状态 - 一个实例的状态也可能是瞬时的或脱管的。" #. Tag: para #, 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 can express a domain model " -"in other ways (using trees of Map instances, for example)." -msgstr "" -"如果这些持久化类遵循一些简单的规则,Hibernate 能够工作得更好,这些规则也被称" -"作简单传统 Java 对象(POJO:Plain Old Java Object)编程模型。但是这些规则并不" -"是必需的。 实际上,Hibernate3 对于你的持久化类几乎不做任何设想。你可以用其他" -"的方法来表达领域模型:比如,使用 Map 实例的树型结构。" +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 can express a domain model in other ways (using trees of Map instances, for example)." +msgstr "如果这些持久化类遵循一些简单的规则,Hibernate 能够工作得更好,这些规则也被称作简单传统 Java 对象(POJO:Plain Old Java Object)编程模型。但是这些规则并不是必需的。 实际上,Hibernate3 对于你的持久化类几乎不做任何设想。你可以用其他的方法来表达领域模型:比如,使用 Map 实例的树型结构。" #. Tag: title #, no-c-format @@ -54,16 +37,12 @@ msgstr "一个简单的 POJO 例子" #. Tag: para #, no-c-format -msgid "" -"Most Java applications require a persistent class representing felines. For " -"example:" +msgid "Most Java applications require a persistent class representing felines. For example:" msgstr "大多数 Java 程序需要用一个持久化类来表示猫科动物。例如:" #. Tag: para #, no-c-format -msgid "" -"The four main rules of persistent classes are explored in more detail in the " -"following sections." +msgid "The four main rules of persistent classes are explored in more detail in the following sections." msgstr "在后续的章节里我们将介绍持久性类的 4 个主要规则的更多细节。" #. Tag: title @@ -73,19 +52,8 @@ msgstr "实现一个默认的(即无参数的)构造方法(constructor)" #. Tag: para #, no-c-format -msgid "" -"Cat has a no-argument constructor. All persistent classes " -"must have a default constructor (which can be non-public) so that Hibernate " -"can instantiate them using Constructor.newInstance(). It " -"is recommended that you have a default constructor with at least " -"package visibility for runtime proxy generation in " -"Hibernate." -msgstr "" -"Cat 有一个无参数的构造方法。所有的持久化类都必须有一个默认" -"的构造方法(可以不是 public 的),这样的话 Hibernate 就可以使用 " -"Constructor.newInstance()来实例化它们。 我们强烈建议,在 " -"Hibernate 中,为了运行期代理的生成,构造方法至少是包(package)内可见的。" +msgid "Cat has a no-argument constructor. All persistent classes must have a default constructor (which can be non-public) so that Hibernate can instantiate them using Constructor.newInstance(). It is recommended that you have a default constructor with at least package visibility for runtime proxy generation in Hibernate." +msgstr "Cat 有一个无参数的构造方法。所有的持久化类都必须有一个默认的构造方法(可以不是 public 的),这样的话 Hibernate 就可以使用 Constructor.newInstance()来实例化它们。 我们强烈建议,在 Hibernate 中,为了运行期代理的生成,构造方法至少是包(package)内可见的。" #. Tag: title #, no-c-format @@ -94,65 +62,38 @@ msgstr "提供一个标识属性(identifier property)(可选)" #. Tag: para #, 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 use a user-defined class with properties of these " -"types (see the section on composite identifiers later in the chapter.)" -msgstr "" -"Cat 有一个属性叫做 id。这个属性映射数据" -"库表的主 键字段。这个属性可以叫任何名字,其类型可以是任何的原始类型、原始类型" -"的包装类型、 java.lang.String 或者是 java.util." -"Date。(如果你的遗留数据库表有联合主键,你甚至可以用一个用户自定义" -"的类,该类拥有这些类型的属性。参见后面的关于联合标识符的章节。)" +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 use a user-defined class with properties of these types (see the section on composite identifiers later in the chapter.)" +msgstr "Cat 有一个属性叫做 id。这个属性映射数据库表的主 键字段。这个属性可以叫任何名字,其类型可以是任何的原始类型、原始类型的包装类型、 java.lang.String 或者是 java.util.Date。(如果你的遗留数据库表有联合主键,你甚至可以用一个用户自定义的类,该类拥有这些类型的属性。参见后面的关于联合标识符的章节。)" #. Tag: para #, 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 内部来追踪对象的识别。 但是我" -"们并不推荐这样做。" +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 内部来追踪对象的识别。 但是我们并不推荐这样做。" #. Tag: para #, no-c-format -msgid "" -"In fact, some functionality is available only to classes that declare an " -"identifier property:" +msgid "In fact, some functionality is available only to classes that declare an identifier property:" msgstr "实际上,一些功能只对那些声明了标识符属性的类起作用: " #. Tag: para -#, fuzzy, no-c-format -msgid "" -"Transitive reattachment for detached objects (cascade update or cascade " -"merge) - see " -msgstr "" -"托管对象的传播性再连接(级联更新或级联合并) — 参阅 " - -#. Tag: para -#, fuzzy, no-c-format -msgid "Session.saveOrUpdate()" -msgstr "Session.saveOrUpdate()" - -#. Tag: para -#, fuzzy, no-c-format -msgid "Session.merge()" -msgstr "Session.merge()" +#, no-c-format +msgid "Transitive reattachment for detached objects (cascade update or cascade merge) - see " +msgstr "托管对象的传播性再连接(级联更新或级联合并)- 参阅 " #. Tag: para #, no-c-format -msgid "" -"We recommend that you declare consistently-named identifier properties on " -"persistent classes and that you use a nullable (i.e., non-primitive) type." -msgstr "" -"我们建议你对持久化类声明命名一致的标识属性。我们还建议你使用一个可以为空(也" -"就是说,不是原始类型)的类型。 " +msgid "Session.saveOrUpdate()" +msgstr "Session.saveOrUpdate() " + +#. Tag: para +#, no-c-format +msgid "Session.merge()" +msgstr "Session.merge() " + +#. Tag: para +#, no-c-format +msgid "We recommend that you declare consistently-named identifier properties on persistent classes and that you use a nullable (i.e., non-primitive) type." +msgstr "我们建议你对持久化类声明命名一致的标识属性。我们还建议你使用一个可以为空(也就是说,不是原始类型)的类型。 " #. Tag: title #, no-c-format @@ -161,72 +102,33 @@ msgstr "使用非final的类(可选)" #. Tag: para #, 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 的接" -"口。" +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 的接口。" #. Tag: para #, no-c-format -msgid "" -"You can persist final classes that do not implement an " -"interface with Hibernate. You will not, however, be able to use proxies for " -"lazy association fetching which will ultimately limit your options for " -"performance tuning." -msgstr "" -"你可以用 Hibernate 持久化一个没有实现任何接口的 final 类," -"但是你不能使用代理来延迟关联加载,这会限制你进行性能优化的选择。 " +msgid "You can persist final classes that do not implement an interface with Hibernate. You will not, however, be able to use proxies for lazy association fetching which will ultimately limit your options for performance tuning." +msgstr "你可以用 Hibernate 持久化一个没有实现任何接口的 final 类,但是你不能使用代理来延迟关联加载,这会限制你进行性能优化的选择。 " #. Tag: para #, 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\" 来明确地禁用代理。 " +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\" 来明确地禁用代理。 " #. Tag: title #, no-c-format msgid "Declare accessors and mutators for persistent fields (optional)" -msgstr "" -"为持久化字段声明访问器(accessors)和是否可变的标志(mutators)(可选)" +msgstr "为持久化字段声明访问器(accessors)和是否可变的标志(mutators)(可选)" #. Tag: para #, no-c-format -msgid "" -"Cat declares accessor methods for all its persistent " -"fields. Many other ORM tools directly persist instance variables. 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. If " -"required, you can switch to direct field access for particular properties." -msgstr "" -"Cat 为它的所有持久化字段声明了访问方法。很多其他 ORM 工具" -"直接对实例变量进行持久化。我们相信,在关系数据库 schema 和类的内部数据结构之" -"间引入间接层(原文为\"非直接\",indirection)会好一些。默认情况下 Hibernate " -"持久化 JavaBeans 风格的属性,认可 getFoo," -"isFoosetFoo 这种形式的方法名。如果" -"需要,你可以对某些特定属性实行直接字段访问。 " +msgid "Cat declares accessor methods for all its persistent fields. Many other ORM tools directly persist instance variables. 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. If required, you can switch to direct field access for particular properties." +msgstr "Cat 为它的所有持久化字段声明了访问方法。很多其他 ORM 工具直接对实例变量进行持久化。我们相信,在关系数据库 schema 和类的内部数据结构之间引入间接层(原文为\"非直接\",indirection)会好一些。默认情况下 Hibernate 持久化 JavaBeans 风格的属性,认可 getFooisFoosetFoo 这种形式的方法名。如果需要,你可以对某些特定属性实行直接字段访问。 " #. Tag: para #, 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 可以持久化一个" -"有 defaultprotected 或 " -"private 的 get/set 方法对的属性进行持久化。" +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 方法对的属性进行持久化。" #. Tag: title #, no-c-format @@ -235,38 +137,23 @@ msgstr "实现继承(Inheritance)" #. Tag: para #, no-c-format -msgid "" -"A subclass must also observe the first and second rules. It inherits its " -"identifier property from the superclass, Cat. For example:" -msgstr "" -"子类也必须遵守第一条和第二条规则。它从超类 Cat 继承了标识" -"属性。例如:" +msgid "A subclass must also observe the first and second rules. It inherits its identifier property from the superclass, Cat. For example:" +msgstr "子类也必须遵守第一条和第二条规则。它从超类 Cat 继承了标识属性。例如:" #. Tag: title #, no-c-format -msgid "" -"Implementing equals() and hashCode()" -msgstr "" -"实现 equals()hashCode() 方法:" +msgid "Implementing equals() and hashCode()" +msgstr "实现 equals()hashCode() 方法:" #. Tag: para #, no-c-format -msgid "" -"You have to override the equals() and hashCode()" -" methods if you:" -msgstr "" -"如果你有如下需求,你必须重载 equals()hashCode" -"() 方法: " +msgid "You have to override the equals() and hashCode() methods if you:" +msgstr "如果你有如下需求,你必须重载 equals()hashCode() 方法: " #. Tag: para #, 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 中(当表示多值关联时,推荐这么" -"做),而且" +msgid "intend to put instances of persistent classes in a Set (the recommended way to represent many-valued associations); and" +msgstr "想把持久类的实例放入 Set 中(当表示多值关联时,推荐这么做),而且" #. Tag: para #, no-c-format @@ -275,73 +162,23 @@ msgstr "想重用脱管实例" #. Tag: para #, no-c-format -msgid "" -"Hibernate guarantees equivalence of persistent identity (database row) and " -"Java identity only inside a particular session scope. When you mix instances " -"retrieved in different sessions, you must implement equals() and hashCode() if you wish to have meaningful " -"semantics for Sets." -msgstr "" -"Hibernate 保证,仅在特定会话范围内,持久化标识(数据库的行)和 Java 标识是等" -"价的。因此,一旦我们混合了从不同会话中获取的实例,如果希望 Set 有明确的语义,就必须实现 equals() 和 " -"hashCode()。 " +msgid "Hibernate guarantees equivalence of persistent identity (database row) and Java identity only inside a particular session scope. When you mix instances retrieved in different sessions, you must implement equals() and hashCode() if you wish to have meaningful semantics for Sets." +msgstr "Hibernate 保证,仅在特定会话范围内,持久化标识(数据库的行)和 Java 标识是等价的。因此,一旦我们混合了从不同会话中获取的实例,如果希望 Set 有明确的语义,就必须实现 equals()hashCode()。 " #. Tag: para #, 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, " -"because they are equal. If both are added to a Set, you " -"will only have one element in the Set). Unfortunately, " -"you cannot 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. 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 对象等价的语义问题。 " +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, because they are equal. If both are added to a Set, you will only have one element in the Set). Unfortunately, you cannot 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. 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 #, no-c-format -msgid "" -"It is recommended that you implement equals() and " -"hashCode() using Business key equality. Business key equality means that the equals() " -"method compares only the properties that form the business key. It is a key " -"that would identify our instance in the real world (a natural candidate key):" -msgstr "" -"我们建议使用业务键值相等(Business key equality)来实现 " -"equals()hashCode()。业务键值相等的" -"意思是,equals() 方法仅仅比较形成业务键的属性,它能在现实" -"世界里标识我们的实例(是一个自然的候选码)。" +msgid "It is recommended that you implement equals() and hashCode() using Business key equality. Business key equality means that the equals() method compares only the properties that form the business key. It is a key that would identify our instance in the real world (a natural candidate key):" +msgstr "我们建议使用业务键值相等(Business key equality)来实现 equals()hashCode()。业务键值相等的意思是,equals() 方法仅仅比较形成业务键的属性,它能在现实世界里标识我们的实例(是一个自然的候选码)。" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"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 "" -"注意,业务键不必像数据库的主键那样固定不变(参见 )。对业务键而言,不可变或唯一的属性是不错" -"的选择。 " +#, no-c-format +msgid "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 "注意,业务键不必像数据库的主键那样固定不变(参见 )。对业务键而言,不可变或唯一的属性是不错的选择。" #. Tag: title #, no-c-format @@ -354,117 +191,54 @@ msgid "Note" msgstr "注意" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"The following features are currently considered experimental and " -"may change in the near future." -msgstr "" -"注意,以下特性在当前处于试验阶段,将来可能会有变化。" +#, no-c-format +msgid "The following features are currently considered experimental and may change in the near future." +msgstr "注意,以下特性在当前处于试验阶段,将来可能会有变化。 " #. Tag: para #, no-c-format -msgid "" -"Persistent entities do not 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 " -"do not write persistent classes, only mapping files." -msgstr "" -"运行期的持久化实体没有必要一定表示为像 POJO 类或 JavaBean 对象那样的形式。" -"Hibernate 也支持动态模型 (在运行期使用 Map 的 " -"Map)和象 DOM4J 的树模型那样的实体表示。使用这种方法,你不" -"用写持久化类,只写映射文件就行了。 " - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"By default, Hibernate works in normal POJO mode. You can 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,设置一个默认的实体表示模式。(参见 ) " +msgid "Persistent entities do not 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 do not write persistent classes, only mapping files." +msgstr "运行期的持久化实体没有必要一定表示为像 POJO 类或 JavaBean 对象那样的形式。Hibernate 也支持动态模型 (在运行期使用 MapMap)和象 DOM4J 的树模型那样的实体表示。使用这种方法,你不用写持久化类,只写映射文件就行了。 " #. Tag: para #, no-c-format -msgid "" -"The following examples demonstrate 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 来代替一个类名(或作为一种附属)。 " +msgid "By default, Hibernate works in normal POJO mode. You can 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 #, no-c-format -msgid "" -"Even though associations are declared using target class names, the target " -"type of associations can also be a dynamic entity instead of a POJO." -msgstr "" -"注意,虽然是用目标类名来声明关联的,但是关联的目标类型除了是 POJO 之外,也可" -"以是一个动态的实体。 " +msgid "The following examples demonstrate 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: para #, no-c-format -msgid "" -"After setting the default entity mode to dynamic-map for " -"the SessionFactory, you can, at runtime, work with " -"Maps of Maps:" -msgstr "" -"在使用 dynamic-mapSessionFactory 设" -"置了默认的实体模式之后,可以在运行期使用 Map 的 " -"Map:" +msgid "Even though associations are declared using target class names, the target type of associations can also be a dynamic entity instead of a POJO." +msgstr "注意,虽然是用目标类名来声明关联的,但是关联的目标类型除了是 POJO 之外,也可以是一个动态的实体。 " #. Tag: para #, no-c-format -msgid "" -"One of the main advantages of dynamic mapping is quick turnaround time for " -"prototyping, without the need for entity class implementation. However, you " -"lose compile-time type checking and will likely deal with many exceptions at " -"runtime. As a result of 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 能容易的规格化和合理化,并允许稍后在此之上添加合" -"适的领域模型实现。 " +msgid "After setting the default entity mode to dynamic-map for the SessionFactory, you can, at runtime, work with Maps of Maps:" +msgstr "在使用 dynamic-mapSessionFactory 设置了默认的实体模式之后,可以在运行期使用 MapMap:" #. Tag: para #, no-c-format -msgid "" -"Entity representation modes can also be set on a per Session basis:" +msgid "One of the main advantages of dynamic mapping is quick turnaround time for prototyping, without the need for entity class implementation. However, you lose compile-time type checking and will likely deal with many exceptions at runtime. As a result of 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 +#, no-c-format +msgid "Entity representation modes can also be set on a per Session basis:" msgstr "实体表示模式也能在每个 Session 的基础上设置:" #. Tag: para #, 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 do not have to call 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(),同样的,把事务和连接的处理交给原来的工作单元。 " +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 do not have to call 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 -#, fuzzy, no-c-format -msgid "" -"More information about the XML representation capabilities can be found in " -"." -msgstr "关于 XML 表示能力的更多信息可以在 中找到。 " +#, no-c-format +msgid "More information about the XML representation capabilities can be found in ." +msgstr "关于 XML 表示能力的更多信息可以在 中找到。" #. Tag: title #, no-c-format @@ -473,61 +247,18 @@ msgstr "元组片断映射(Tuplizers)" #. Tag: para #, no-c-format -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 that 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 corresponding tuplizer knows how create the POJO " -"through its constructor. It also knows how to access the POJO properties " -"using the defined property accessors." -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 则是针对组件" -"的。 " +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 that 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 corresponding tuplizer knows how create the POJO through its constructor. It also knows how to access the POJO properties using the defined property accessors." +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 #, no-c-format -msgid "" -"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 "" -"有两种高层类型的 Tuplizer,分别由 org.hibernate.tuple.entity." -"EntityTuplizerorg.hibernate.tuple.component." -"ComponentTuplizer 接口代表。EntityTuplizer 负责" -"管理和实体相关的上述合约,而ComponentTuplizer 则负责组件。" +msgid "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 "有两种高层类型的 Tuplizer,分别由 org.hibernate.tuple.entity.EntityTuplizerorg.hibernate.tuple.component.ComponentTuplizer 接口代表。EntityTuplizer 负责管理和实体相关的上述合约,而ComponentTuplizer 则负责组件。" #. Tag: para #, no-c-format -msgid "" -"Users can 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. Tuplizer 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 例子: " +msgid "Users can 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. Tuplizer 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: title #, no-c-format @@ -536,60 +267,23 @@ msgstr "EntityNameResolvers" #. Tag: para #, no-c-format -msgid "" -"The org.hibernate.EntityNameResolver " -"interface is a contract for resolving the entity name of a given entity " -"instance. The interface defines a single method " -"resolveEntityName which is passed the entity " -"instance and is expected to return the appropriate entity name (null is " -"allowed and would indicate that the resolver does not know how to resolve " -"the entity name of the given entity instance). Generally speaking, an " -"org.hibernate.EntityNameResolver is going to " -"be most useful in the case of dynamic models. One example might be using " -"proxied interfaces as your domain model. The hibernate test suite has an " -"example of this exact style of usage under the org.hibernate.test." -"dynamicentity.tuplizer2. Here is some of the code from that " -"package for illustration." -msgstr "" -"org.hibernate.EntityNameResolver 接口是一个解" -"析给定实体实例的实体名称的合约。这个接口定义了一个单一的方法 " -"resolveEntityName,它传递实体实例并预期返回合适的实" -"体名称(null 指明解析器不知道如何解析给定实体实例的实体名称)。一般说来," -"org.hibernate.EntityNameResolver 在动态模型里" -"最为有用。其中的例子是把代理接口用作你的域模型。Hibernate Test Suite 在 " -"org.hibernate.test.dynamicentity.tuplizer2 下有具有完全相" -"同风格的例子。下面是该包里的一些代码:" +msgid "The org.hibernate.EntityNameResolver interface is a contract for resolving the entity name of a given entity instance. The interface defines a single method resolveEntityName which is passed the entity instance and is expected to return the appropriate entity name (null is allowed and would indicate that the resolver does not know how to resolve the entity name of the given entity instance). Generally speaking, an org.hibernate.EntityNameResolver is going to be most useful in the case of dynamic models. One example might be using proxied interfaces as your domain model. The hibernate test suite has an example of this exact style of usage under the org.hibernate.test.dynamicentity.tuplizer2. Here is some of the code from that package for illustration." +msgstr "org.hibernate.EntityNameResolver 接口是一个解析给定实体实例的实体名称的合约。这个接口定义了一个单一的方法 resolveEntityName,它传递实体实例并预期返回合适的实体名称(null 指明解析器不知道如何解析给定实体实例的实体名称)。一般说来,org.hibernate.EntityNameResolver 在动态模型里最为有用。其中的例子是把代理接口用作你的域模型。Hibernate Test Suite 在 org.hibernate.test.dynamicentity.tuplizer2 下有具有完全相同风格的例子。下面是该包里的一些代码:" #. Tag: para #, no-c-format -msgid "" -"In order to register an org.hibernate.EntityNameResolver users must either:" -msgstr "" -"为了注册 org.hibernate.EntityNameResolver,用" -"户必须:" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"Implement a custom Tuplizer, implementing the getEntityNameResolvers " -"method." -msgstr "" -"实现自定义的 并实现 " -"getEntityNameResolvers 方法。 " +msgid "In order to register an org.hibernate.EntityNameResolver users must either:" +msgstr "为了注册 org.hibernate.EntityNameResolver,用户必须:" #. Tag: para #, no-c-format -msgid "" -"Register it with the org.hibernate.impl.SessionFactoryImpl (which is the implementation class for org." -"hibernate.SessionFactory) using the " -"registerEntityNameResolver method." -msgstr "" -"用 registerEntityNameResolver 方法注册到 " -"org.hibernate.impl.SessionFactoryImpl(它是 " -"org.hibernate.SessionFactory 的实现类)。" +msgid "Implement a custom Tuplizer, implementing the getEntityNameResolvers method." +msgstr "实现自定义的 Tuplizer 并实现 getEntityNameResolvers 方法。" + +#. Tag: para +#, no-c-format +msgid "Register it with the org.hibernate.impl.SessionFactoryImpl (which is the implementation class for org.hibernate.SessionFactory) using the registerEntityNameResolver method." +msgstr "用 registerEntityNameResolver 方法注册到 org.hibernate.impl.SessionFactoryImpl(它是 org.hibernate.SessionFactory 的实现类)。" #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "\n" #~ "\n" @@ -894,7 +585,6 @@ msgstr "" #~ " \n" #~ " \n" #~ "]]>" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "\n" #~ " \n" @@ -1043,7 +731,6 @@ msgstr "" #~ " }\n" #~ " }\n" #~ "}]]>" - #~ msgid "" #~ "/**\n" #~ " * A very trivial JDK Proxy InvocationHandler implementation where we " @@ -1302,3 +989,4 @@ msgstr "" #~ "\n" #~ " ...\n" #~ "}" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/portability.po b/documentation/manual/src/main/docbook/zh-CN/content/portability.po index 7d76b379af..642830ef90 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/portability.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/portability.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Collection_Mapping\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-03-12T00:03:47\n" -"PO-Revision-Date: 2010-01-11 10:57+1000\n" +"PO-Revision-Date: 2010-03-16 10:10+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -26,21 +26,8 @@ msgstr "移植性基础" #. Tag: para #, no-c-format -msgid "" -"One of the selling points of Hibernate (and really Object/Relational Mapping " -"as a whole) is the notion of database portability. This could mean an " -"internal IT user migrating from one database vendor to another, or it could " -"mean a framework or deployable application consuming Hibernate to " -"simultaneously target multiple database products by their users. Regardless " -"of the exact scenario, the basic idea is that you want Hibernate to help you " -"run against any number of databases without changes to your code, and " -"ideally without any changes to the mapping metadata." -msgstr "" -"Hibernate(实际上是整个 Object/Relational Mapping)的一个卖点是数据库的移植" -"性。这意味着内部的 IT 用户可以改变数据库供应商,或者可部署的应用程序/框架使" -"用 Hibernate 来同时使用多个数据库产品。不考虑具体的应用情景,这里的基本概念" -"是 Hibernate 可帮助你运行多种数据库而无需修改你的代码,理想情况下甚至不用修改" -"映射元数据。" +msgid "One of the selling points of Hibernate (and really Object/Relational Mapping as a whole) is the notion of database portability. This could mean an internal IT user migrating from one database vendor to another, or it could mean a framework or deployable application consuming Hibernate to simultaneously target multiple database products by their users. Regardless of the exact scenario, the basic idea is that you want Hibernate to help you run against any number of databases without changes to your code, and ideally without any changes to the mapping metadata." +msgstr "Hibernate(实际上是整个 Object/Relational Mapping)的一个卖点是数据库的移植性。这意味着内部的 IT 用户可以改变数据库供应商,或者可部署的应用程序/框架使用 Hibernate 来同时使用多个数据库产品。不考虑具体的应用情景,这里的基本概念是 Hibernate 可帮助你运行多种数据库而无需修改你的代码,理想情况下甚至不用修改映射元数据。" #. Tag: title #, no-c-format @@ -49,21 +36,8 @@ msgstr "Dialect" #. Tag: para #, no-c-format -msgid "" -"The first line of portability for Hibernate is the dialect, which is a " -"specialization of the org.hibernate.dialect.Dialect " -"contract. A dialect encapsulates all the differences in how Hibernate must " -"communicate with a particular database to accomplish some task like getting " -"a sequence value or structuring a SELECT query. Hibernate bundles a wide " -"range of dialects for many of the most popular databases. If you find that " -"your particular database is not among them, it is not terribly difficult to " -"write your own." -msgstr "" -"Hibernate 的移植性的首要问题是方言(dialect),也就是 org." -"hibernate.dialect.Dialect 合约的具体实例。方言封装了 Hibernate 和" -"特定数据库通讯以完成某些任务如获取序列值或构建 SELECT 查询等的所有差异。" -"Hibernate 捆绑了用于许多最常用的数据库的方言。如果你发现自己使用的数据库不在" -"其中,编写自定义的方言也不是很困难的事情。" +msgid "The first line of portability for Hibernate is the dialect, which is a specialization of the org.hibernate.dialect.Dialect contract. A dialect encapsulates all the differences in how Hibernate must communicate with a particular database to accomplish some task like getting a sequence value or structuring a SELECT query. Hibernate bundles a wide range of dialects for many of the most popular databases. If you find that your particular database is not among them, it is not terribly difficult to write your own." +msgstr "Hibernate 的移植性的首要问题是方言(dialect),也就是 org.hibernate.dialect.Dialect 合约的具体实例。方言封装了 Hibernate 和特定数据库通讯以完成某些任务如获取序列值或构建 SELECT 查询等的所有差异。Hibernate 捆绑了用于许多最常用的数据库的方言。如果你发现自己使用的数据库不在其中,编写自定义的方言也不是很困难的事情。" #. Tag: title #, no-c-format @@ -72,82 +46,23 @@ msgstr "方言的使用" #. Tag: para #, no-c-format -msgid "" -"Originally, Hibernate would always require that users specify which dialect " -"to use. In the case of users looking to simultaneously target multiple " -"databases with their build that was problematic. Generally this required " -"their users to configure the Hibernate dialect or defining their own method " -"of setting that value." -msgstr "" -"最开始,Hibernate 总是要求用户指定所使用的方言(dialect)。在用户希望同时使用" -"多个数据库时就会出现问题。通常这要求用户配置 Hibernate 方言或者定义自己设置这" -"个值的方法。" +msgid "Originally, Hibernate would always require that users specify which dialect to use. In the case of users looking to simultaneously target multiple databases with their build that was problematic. Generally this required their users to configure the Hibernate dialect or defining their own method of setting that value." +msgstr "最开始,Hibernate 总是要求用户指定所使用的方言(dialect)。在用户希望同时使用多个数据库时就会出现问题。通常这要求用户配置 Hibernate 方言或者定义自己设置这个值的方法。" #. Tag: para #, no-c-format -msgid "" -"Starting with version 3.2, Hibernate introduced the notion of automatically " -"detecting the dialect to use based on the java.sql." -"DatabaseMetaData obtained from a java.sql." -"Connection to that database. This was much better, expect " -"that this resolution was limited to databases Hibernate know about ahead of " -"time and was in no way configurable or overrideable." -msgstr "" -"从版本 3.2 开始,Hibernate 引入了方言的自动检测,它基于从该数据库的 " -"java.sql.Connection 上获得的 " -"java.sql.DatabaseMetaData。这是一个更好的方" -"案,但它局限于 Hibernate 已知的数据库且无法进行配置和覆盖。" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"Starting with version 3.3, Hibernate has a fare more powerful way to " -"automatically determine which dialect to should be used by relying on a " -"series of delegates which implement the org.hibernate.dialect." -"resolver.DialectResolver which defines only a single method:" -"public Dialect resolveDialect(DatabaseMetaData " -"metaData) throws JDBCConnectionException. The basic " -"contract here is that if the resolver 'understands' the given database " -"metadata then it returns the corresponding Dialect; if not it returns null " -"and the process continues to the next resolver. The signature also " -"identifies org.hibernate.exception.JDBCConnectionException as possibly being thrown. A JDBCConnectionException here is " -"interpreted to imply a \"non transient\" (aka non-recoverable) connection " -"problem and is used to indicate an immediate stop to resolution attempts. " -"All other exceptions result in a warning and continuing on to the next " -"resolver." -msgstr "" -"从版本 3.3 开始,Hibernate 有了更为强大的自动决定应该使用哪个方言的方法,这根" -"据一系列实现 org.hibernate.dialect.resolver.DialectResolver 接口的代理,它们只定义一个方法:public " -"Dialect resolveDialect(DatabaseMetaData metaData) throws " -"JDBCConnectionException。这里的基本合约是如果解析者" -"(resolver)“理解”给点数据库的元数据并返回对应的方言;否则返回 null 并使用下" -"一个解析者。这个签名也指定可能抛出的异常 org.hibernate." -"exception.JDBCConnectionException。这里的 " -"JDBCConnectionException 被认为是“非瞬时的”(也就是不可恢复的)连接问题且指示" -"立即终止解析。所有其他的异常都导致警告发出并使用下一个解析者。\"" +msgid "Starting with version 3.2, Hibernate introduced the notion of automatically detecting the dialect to use based on the java.sql.DatabaseMetaData obtained from a java.sql.Connection to that database. This was much better, expect that this resolution was limited to databases Hibernate know about ahead of time and was in no way configurable or overrideable." +msgstr "从版本 3.2 开始,Hibernate 引入了方言的自动检测,它基于从该数据库的 java.sql.Connection 上获得的 java.sql.DatabaseMetaData。这是一个更好的方案,但它局限于 Hibernate 已知的数据库且无法进行配置和覆盖。" #. Tag: para #, no-c-format -msgid "" -"The cool part about these resolvers is that users can also register their " -"own custom resolvers which will be processed ahead of the built-in Hibernate " -"ones. This might be useful in a number of different situations: it allows " -"easy integration for auto-detection of dialects beyond those shipped with " -"HIbernate itself; it allows you to specify to use a custom dialect when a " -"particular database is recognized; etc. To register one or more resolvers, " -"simply specify them (seperated by commas, tabs or spaces) using the " -"'hibernate.dialect_resolvers' configuration setting (see the " -"DIALECT_RESOLVERS constant on org.hibernate." -"cfg.Environment)." -msgstr "" -"这些解析者最棒的功能是用户也可以注册自定义的解析者,它们将在内置的解析者之前" -"被调用。在许多情况下这可能很有用:它可以轻易地集成内置方言之外的方言的自动检" -"测;它让你可以使用自定义的方言等。要注册一个或多个解析者,只要用 'hibernate." -"dialect_resolvers' 配置设置指定它们(由逗号、制表符或空格隔开)就可以了(请参" -"考 org.hibernate.cfg.Environment 上的 " -"DIALECT_RESOLVERS)。" +msgid "Starting with version 3.3, Hibernate has a fare more powerful way to automatically determine which dialect to should be used by relying on a series of delegates which implement the org.hibernate.dialect.resolver.DialectResolver which defines only a single method:public Dialect resolveDialect(DatabaseMetaData metaData) throws JDBCConnectionException. The basic contract here is that if the resolver 'understands' the given database metadata then it returns the corresponding Dialect; if not it returns null and the process continues to the next resolver. The signature also identifies org.hibernate.exception.JDBCConnectionException as possibly being thrown. A JDBCConnectionException here is interpreted to imply a \"non transient\" (aka non-recoverable) connection problem and is used to indicate an immediate stop to resolution attempts. All other exceptions result in a warning and continuing on to the next resolver." +msgstr "从版本 3.3 开始,Hibernate 有了更为强大的自动决定应该使用哪个方言的方法,这根据一系列实现 org.hibernate.dialect.resolver.DialectResolver 接口的代理,它们只定义一个方法:public Dialect resolveDialect(DatabaseMetaData metaData) throws JDBCConnectionException。这里的基本合约是如果解析者(resolver)“理解”给点数据库的元数据并返回对应的方言;否则返回 null 并使用下一个解析者。这个签名也指定可能抛出的异常 org.hibernate.exception.JDBCConnectionException。这里的 JDBCConnectionException 被认为是“非瞬时的”(也就是不可恢复的)连接问题且指示立即终止解析。所有其他的异常都导致警告发出并使用下一个解析者。\"" + +#. Tag: para +#, no-c-format +msgid "The cool part about these resolvers is that users can also register their own custom resolvers which will be processed ahead of the built-in Hibernate ones. This might be useful in a number of different situations: it allows easy integration for auto-detection of dialects beyond those shipped with HIbernate itself; it allows you to specify to use a custom dialect when a particular database is recognized; etc. To register one or more resolvers, simply specify them (seperated by commas, tabs or spaces) using the 'hibernate.dialect_resolvers' configuration setting (see the DIALECT_RESOLVERS constant on org.hibernate.cfg.Environment)." +msgstr "这些解析者最棒的功能是用户也可以注册自定义的解析者,它们将在内置的解析者之前被调用。在许多情况下这可能很有用:它可以轻易地集成内置方言之外的方言的自动检测;它让你可以使用自定义的方言等。要注册一个或多个解析者,只要用 'hibernate.dialect_resolvers' 配置设置指定它们(由逗号、制表符或空格隔开)就可以了(请参考 org.hibernate.cfg.Environment 上的 DIALECT_RESOLVERS)。" #. Tag: title #, no-c-format @@ -155,91 +70,44 @@ msgid "Identifier generation" msgstr "标识符的生成" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"When considering portability between databases, another important decision " -"is selecting the identifier generation stratagy you want to use. Originally " -"Hibernate provided the native generator for this " -"purpose, which was intended to select between a sequence, identity, or table " -"strategy depending on the capability of the underlying database. However, an " -"insidious implication of this approach comes about when targtetting some " -"databases which support identity generation and some " -"which do not. identity generation relies on the SQL " -"definition of an IDENTITY (or auto-increment) column to manage the " -"identifier value; it is what is known as a post-insert generation strategy " -"becauase the insert must actually happen before we can know the identifier " -"value. Because Hibernate relies on this identifier value to uniquely " -"reference entities within a persistence context it must then issue the " -"insert immediately when the users requests the entitiy be associated with " -"the session (like via save() e.g.) regardless of current transactional " -"semantics." -msgstr "" -"当考虑数据库的移植性时,另外一个重要的考量是选择标识符生成策略。Hibernate 原" -"先提供的 native 生成器的目的是根据底层数据库的能力在 " -"sequenceidentity 或 " -"table 策略间进行选择。然而,这个方法一个潜在的问题是有些" -"数据库支持标识符(identity)生成而有些则不支持。" -"标识符(identity) 生成依赖于管理标识符值的 IDENTITY" -"(或 auto-increment)字段的 SQL 定义。它也成为 post-insert 生成策略,因为 " -"insert 必须在知道标识符值后才能实际发生。因为 Hibernate 依赖于这个标识符值来" -"唯一地引用持久性上下文里的实体,当用户请求和会话相关联的实体时,它必须立即执" -"行 insert 语句而不管当前的事务性语义。底层的问题是应用程序的语义在这些情况下" -"自身也会发生改变。" +#, no-c-format +msgid "When considering portability between databases, another important decision is selecting the identifier generation stratagy you want to use. Originally Hibernate provided the native generator for this purpose, which was intended to select between a sequence, identity, or table strategy depending on the capability of the underlying database. However, an insidious implication of this approach comes about when targtetting some databases which support identity generation and some which do not. identity generation relies on the SQL definition of an IDENTITY (or auto-increment) column to manage the identifier value; it is what is known as a post-insert generation strategy becauase the insert must actually happen before we can know the identifier value. Because Hibernate relies on this identifier value to uniquely reference entities within a persistence context it must then issue the insert immediately when the users requests the entitiy be associated with the session (like via save() e.g.) regardless of current transactional semantics." +msgstr "当考虑数据库的移植性时,另外一个重要的考量是选择标识符生成策略。Hibernate 原先提供的 native 生成器的目的是根据底层数据库的能力在 sequenceidentitytable 策略间进行选择。然而,这个方法一个潜在的问题是有些数据库支持标识符(identity)生成而有些则不支持。标识符(identity) 生成依赖于管理标识符值的 IDENTITY(或 auto-increment)字段的 SQL 定义。它也成为 post-insert 生成策略,因为 insert 必须在知道标识符值后才能实际发生。因为 Hibernate 依赖于这个标识符值来唯一地引用持久性上下文里的实体,当用户请求和会话相关联的实体时(如通过 save()),它必须立即执行 insert 语句而不管当前的事务性语义。" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"Hibernate was changed slightly once the implication of this was better " -"understood so that the insert is delayed in cases where that is feasible." -msgstr "Hibernate 已经进行了改进,所以在可行时这种插入会被延迟。" +#, no-c-format +msgid "Hibernate was changed slightly once the implication of this was better understood so that the insert is delayed in cases where that is feasible." +msgstr "Hibernate 已经进行了轻微改进,所以在可行时这种插入会被延迟。" #. Tag: note #, no-c-format -msgid "" -"The underlying issue is that the actual semanctics of the application itself " -"changes in these cases." -msgstr "" +msgid "The underlying issue is that the actual semanctics of the application itself changes in these cases." +msgstr "底层的问题是这些例子里应用程序自身的实际模式的改变。" #. Tag: para #, no-c-format -msgid "" -"Starting with version 3.2.3, Hibernate comes with a set of enhanced identifier generators " -"targetting portability in a much different way." -msgstr "" -"从 3.2.3 版本开始,Hibernate 带有一套 enhanced 标识符生成器,它以很不同的方式实现移植性。" +msgid "Starting with version 3.2.3, Hibernate comes with a set of enhanced identifier generators targetting portability in a much different way." +msgstr "从 3.2.3 版本开始,Hibernate 带有一套 enhanced 标识符生成器,它以很不同的方式实现移植性。" #. Tag: para #, no-c-format -msgid "" -"There are specifically 2 bundled enhancedgenerators:" +msgid "There are specifically 2 bundled enhancedgenerators:" msgstr "特别是两个捆绑的 enhanced 生成器:" #. Tag: para -#, fuzzy, no-c-format +#, no-c-format msgid "org.hibernate.id.enhanced.SequenceStyleGenerator" -msgstr "" -"org.hibernate.id.enhanced.SequenceStyleGenerator" +msgstr "org.hibernate.id.enhanced.SequenceStyleGenerator" #. Tag: para -#, fuzzy, no-c-format +#, no-c-format msgid "org.hibernate.id.enhanced.TableGenerator" msgstr "org.hibernate.id.enhanced.TableGenerator" #. Tag: note #, no-c-format -msgid "" -"The idea behind these generators is to port the actual semantics of the " -"identifer value generation to the different databases. For example, the " -"org.hibernate.id.enhanced.SequenceStyleGenerator " -"mimics the behavior of a sequence on databases which do not support " -"sequences by using a table." -msgstr "" -"这些生成器背后的概念是把标识符值生成的实际情景移植到不同的数据库里。例如," -"org.hibernate.id.enhanced.SequenceStyleGenerator 通过" -"使用表来模拟不支持序列(sequences)的数据库上的序列行为。" +msgid "The idea behind these generators is to port the actual semantics of the identifer value generation to the different databases. For example, the org.hibernate.id.enhanced.SequenceStyleGenerator mimics the behavior of a sequence on databases which do not support sequences by using a table." +msgstr "这些生成器背后的概念是把标识符值生成的实际情景移植到不同的数据库里。例如,org.hibernate.id.enhanced.SequenceStyleGenerator 通过使用表来模拟不支持序列(sequences)的数据库上的序列行为。" #. Tag: title #, no-c-format @@ -248,47 +116,23 @@ msgstr "数据库函数" #. Tag: para #, no-c-format -msgid "" -"This is an area in Hibernate in need of improvement. In terms of portability " -"concerns, this function handling currently works pretty well from HQL; " -"however, it is quite lacking in all other aspects." -msgstr "" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"SQL functions can be referenced in many ways by users. However, not all " -"databases support the same set of functions. Hibernate, provides a means of " -"mapping a logical function name to a delegate which " -"knows how to render that particular function, perhaps even using a totally " -"different physical function call." -msgstr "" -"用户可以以多种方式引用 SQL 函数。然而,不是所有的数据库都支持相同的函数集。" -"Hibernate 提供了一种映射逻辑函数名到代理的方法,这个代理" -"知道如何解析特定的函数,甚至可能使用完全不同的物理函数调用。" +msgid "This is an area in Hibernate in need of improvement. In terms of portability concerns, this function handling currently works pretty well from HQL; however, it is quite lacking in all other aspects." +msgstr "这是 Hibernate 需要提高的一个领域。从可移植性来说,这个功能可以很好地处理 HQL 的内容,但在其他方面就有所欠缺。" #. Tag: para #, no-c-format -msgid "" -"Technically this function registration is handled through the org." -"hibernate.dialect.function.SQLFunctionRegistry class which is " -"intended to allow users to provide custom function definitions without " -"having to provide a custom dialect. This specific behavior is not fully " -"completed as of yet." -msgstr "" -"从技术上来讲,这个函数注册是通过 org.hibernate.dialect.function." -"SQLFunctionRegistry 类进行处理的,它的目的是允许用户提供自定义的" -"函数定义而无需提供自定义的方言。这种特殊的行为目前还未全部开发完毕。" +msgid "SQL functions can be referenced in many ways by users. However, not all databases support the same set of functions. Hibernate, provides a means of mapping a logical function name to a delegate which knows how to render that particular function, perhaps even using a totally different physical function call." +msgstr "用户可以以多种方式引用 SQL 函数。然而,不是所有的数据库都支持相同的函数集。Hibernate 提供了一种映射逻辑函数名到代理的方法,这个代理知道如何解析特定的函数,甚至可能使用完全不同的物理函数调用。 " #. Tag: para #, no-c-format -msgid "" -"It is sort of implemented such that users can programatically register " -"functions with the org.hibernate.cfg.Configuration " -"and those functions will be recognized for HQL." -msgstr "" -"其中一些功能已经实现,如用户可以在程序里用 org.hibernate.cfg." -"Configuration 注册函数且这些函数可被 HQL 识别。" +msgid "Technically this function registration is handled through the org.hibernate.dialect.function.SQLFunctionRegistry class which is intended to allow users to provide custom function definitions without having to provide a custom dialect. This specific behavior is not fully completed as of yet." +msgstr "从技术上来讲,这个函数注册是通过 org.hibernate.dialect.function.SQLFunctionRegistry 类进行处理的,它的目的是允许用户提供自定义的函数定义而无需提供自定义的方言。这种特殊的行为目前还未全部开发完毕。" + +#. Tag: para +#, no-c-format +msgid "It is sort of implemented such that users can programatically register functions with the org.hibernate.cfg.Configuration and those functions will be recognized for HQL." +msgstr "其中一些功能已经实现,如用户可以在程序里用 org.hibernate.cfg.Configuration 注册函数且这些函数可被 HQL 识别。" #. Tag: title #, no-c-format @@ -304,3 +148,4 @@ msgstr "本节内容仍未完成..." #~ "This is a new area in Hibernate and as such it is not as mature as the " #~ "overall Hibernate experience." #~ msgstr "这是 Hibernate 的一个新的领域,暂时还不如 Hibernate 总体那么成熟。" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/preface.po b/documentation/manual/src/main/docbook/zh-CN/content/preface.po index 2858f26acd..10fe77cfde 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/preface.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/preface.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Collection_Mapping\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-02-11T05:38:15\n" -"PO-Revision-Date: 2010-01-11 10:44+1000\n" +"PO-Revision-Date: 2010-03-16 10:12+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -20,108 +20,44 @@ msgid "Preface" msgstr "前言" #. Tag: para -#, fuzzy, 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 的关系模型数据结构中去。" +#, 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 的关系模型数据结构中去。 " #. Tag: para #, 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. It can also significantly reduce development " -"time otherwise spent with manual data handling in SQL and JDBC." -msgstr "" -"Hibernate 不仅管理 Java 类到数据库表的映射(包括 Java 数据类型到 SQL 数据类型" -"的映射),还提供数据查询和获取数据的方法,可以大幅度减少开发时对人工使用 SQL " -"和 JDBC 处理数据的时间。 " +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. It can also significantly reduce development time otherwise spent with manual data handling in SQL and JDBC." +msgstr "Hibernate 不仅管理 Java 类到数据库表的映射(包括 Java 数据类型到 SQL 数据类型的映射),还提供数据查询和获取数据的方法,可以大幅度减少开发时对人工使用 SQL 和 JDBC 处理数据的时间。 " #. Tag: para #, no-c-format -msgid "" -"Hibernate's 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 代码,而且帮助你结" -"果集从表格式的表示形式转换到一系列的对象中去。 " +msgid "Hibernate's 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 #, no-c-format -msgid "" -"If you are new to Hibernate and Object/Relational Mapping or even Java, " -"please follow these steps:" -msgstr "" -"如果你对 Hibernate 和对象/关系型数据库映射还是个新手,甚至对 Java 也不熟悉," -"请按照下面的步骤来学习。" - -#. Tag: para -#, fuzzy, 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/ 目" -"录下找到。 " - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"Read to understand the environments where " -"Hibernate can be used." -msgstr "" -"阅读 来理解 Hibernate 可以使用的环境。 " +msgid "If you are new to Hibernate and Object/Relational Mapping or even Java, please follow these steps:" +msgstr "如果你对 Hibernate 和对象/关系型数据库映射还是个新手,甚至对 Java 也不熟悉,请按照下面的步骤来学习。" #. Tag: para #, no-c-format -msgid "" -"View 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/ 目录并修改一下 " -"etc/hibernate.properties,指定数据库的信息。然后进入命令" -"行,切换到发行包的目录,输入 ant eg(使用 Ant),或者在 " -"Windows 系统下使用 build eg。 " +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 -#, fuzzy, no-c-format -msgid "" -"Use this reference documentation as your primary source of information. " -"Consider reading if you need " -"more help with application design, or if you prefer a step-by-step tutorial. " -"Also visit and download " -"the example application from ." -msgstr "" -"把这份文档作为你学习的主要信息来源。如果你需要应用程序设计方面的帮助或者你希" -"望有一个按部就班的指南,你可以考虑阅读 Hibernate in Action(http://www.manning.com/bauer)。你也可以访问http://caveatemptor." -"hibernate.org 并下载 Hibernate 的示例程序。 " +#, no-c-format +msgid "Read to understand the environments where Hibernate can be used." +msgstr "阅读 来理解 Hibernate 可以使用的环境。" + +#. Tag: para +#, no-c-format +msgid "View 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/ 目录并修改一下 etc/hibernate.properties,指定数据库的信息。然后进入命令行,切换到发行包的目录,输入 ant eg(使用 Ant),或者在 Windows 系统下使用 build eg。 " + +#. Tag: para +#, no-c-format +msgid "Use this reference documentation as your primary source of information. Consider reading if you need more help with application design, or if you prefer a step-by-step tutorial. Also visit and download the example application from ." +msgstr "把这份文档作为你学习的主要信息来源。如果你需要应用程序设计方面的帮助或者你希望有一个按部就班的指南,你可以考虑阅读 。你也可以访问 并从 下载示例程序。" #. Tag: para #, no-c-format @@ -129,53 +65,27 @@ msgid "FAQs are answered on the Hibernate website." msgstr "在 Hibernate 网站上可以找到问题和解答(FAQ)。" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"Links to third party demos, examples, and tutorials are maintained on the " -"Hibernate website." -msgstr "在 Hibernate 网站上还有第三方的演示、示例和教程的链接。" +#, no-c-format +msgid "Links to third party demos, examples, and tutorials are maintained on the Hibernate website." +msgstr "在 Hibernate 网站上还有第三方的演示、示例和教程的链接。 " #. Tag: para #, 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 网站的社区是讨论关于设计模式以及很多整合方案(Tomcat、JBoss AS、" -"Struts、EJB 等)的好地方。" +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 网站的社区是讨论关于设计模式以及很多整合方案(Tomcat、JBoss AS、Struts、EJB 等)的好地方。" #. Tag: para #, no-c-format -msgid "" -"If you have questions, use the user forum linked on the Hibernate website. " -"We also provide a JIRA issue tracking 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 有兴趣,请" -"加入开发者的邮件列表。如果你对翻译本文档感兴趣,请通过开发者的邮件列表来联系" -"我们。 " +msgid "If you have questions, use the user forum linked on the Hibernate website. We also provide a JIRA issue tracking 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 有兴趣,请加入开发者的邮件列表。如果你对翻译本文档感兴趣,请通过开发者的邮件列表来联系我们。 " #. Tag: para #, 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 是一个专业的开源项目,也是 " -"JBoss 企业级中间件系统(JBoss Enterprise Middleware System,JEMS)里的一个核" -"心组件。 " +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 是一个专业的开源项目,也是 JBoss 企业级中间件系统(JBoss Enterprise Middleware System,JEMS)里的一个核心组件。 " #~ msgid "Feedback" #~ msgstr "反馈" - #~ msgid "" #~ "Use Hibernate JIRA to report errors or request enhacements to this " @@ -183,3 +93,4 @@ msgstr "" #~ msgstr "" #~ "用 Hibernate JIRA 来报告错误或改进本文档。" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/query_criteria.po b/documentation/manual/src/main/docbook/zh-CN/content/query_criteria.po index 3d9eb7c236..277b094fc6 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/query_criteria.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/query_criteria.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Collection_Mapping\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-02-11T05:38:15\n" -"PO-Revision-Date: 2009-12-07 20:31+1000\n" +"PO-Revision-Date: 2010-03-16 09:53+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -31,13 +31,8 @@ msgstr "创建一个 Criteria 实例" #. Tag: para #, 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 实例的工厂。" +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: title #, no-c-format @@ -46,15 +41,8 @@ msgstr "限制结果集内容" #. Tag: para #, 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 类型的工厂方法。" +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: para #, no-c-format @@ -63,30 +51,18 @@ msgstr "约束可以按逻辑分组。 " #. Tag: para #, no-c-format -msgid "" -"There are a range of built-in criterion types (Restrictions subclasses). One of the most useful allows you to specify SQL " -"directly." -msgstr "" -"Hibernate 提供了相当多的内置 criterion 类型(Restrictions " -"子类),但是尤其有用的是可以允许你直接使用 SQL。 " +msgid "There are a range of built-in criterion types (Restrictions subclasses). One of the most useful allows you to specify SQL directly." +msgstr "Hibernate 提供了相当多的内置 criterion 类型(Restrictions 子类),但是尤其有用的是可以允许你直接使用 SQL。 " #. Tag: para #, no-c-format -msgid "" -"The {alias} placeholder with be replaced by the row alias " -"of the queried entity." +msgid "The {alias} placeholder with be replaced by the row alias of the queried entity." msgstr "{alias} 占位符应当被替换为被查询实体的列别名。" #. Tag: para #, no-c-format -msgid "" -"You can also obtain a criterion from a Property instance. " -"You can create a Property by calling Property." -"forName():" -msgstr "" -"Property 实例是获得一个条件的另外一种途径。你可以通过调用 " -"Property.forName() 创建一个 Property:" +msgid "You can also obtain a criterion from a Property instance. You can create a Property by calling Property.forName():" +msgstr "Property 实例是获得一个条件的另外一种途径。你可以通过调用 Property.forName() 创建一个 Property:" #. Tag: title #, no-c-format @@ -95,12 +71,8 @@ msgstr "结果集排序" #. Tag: para #, no-c-format -msgid "" -"You can order the results using org.hibernate.criterion.Order." -msgstr "" -"你可以使用 org.hibernate.criterion.Order 来为查询结果排" -"序。 " +msgid "You can order the results using org.hibernate.criterion.Order." +msgstr "你可以使用 org.hibernate.criterion.Order 来为查询结果排序。 " #. Tag: title #, no-c-format @@ -109,85 +81,53 @@ msgstr "关联" #. Tag: para #, no-c-format -msgid "" -"By navigating associations using createCriteria() you can " -"specify constraints upon related entities:" -msgstr "" -"通过使用 createCriteria() 对关联进行导航,你可以指定相关实" -"体的约束。" +msgid "By navigating associations using createCriteria() you can specify constraints upon related entities:" +msgstr "通过使用 createCriteria() 对关联进行导航,你可以指定相关实体的约束。" #. Tag: para #, no-c-format -msgid "" -"The second createCriteria() returns a new instance of " -"Criteria that refers to the elements of the " -"kittens collection." -msgstr "" -"注意第二个 createCriteria() 返回一个新的 " -"Criteria 实例,该实例引用 kittens 集合" -"中的元素。 " +msgid "The second createCriteria() returns a new instance of Criteria that refers to the elements of the kittens collection." +msgstr "注意第二个 createCriteria() 返回一个新的 Criteria 实例,该实例引用 kittens 集合中的元素。 " #. Tag: para #, no-c-format -msgid "" -"There is also an alternate form that is useful in certain circumstances:" +msgid "There is also an alternate form that is useful in certain circumstances:" msgstr "接下来,替换形态在某些情况下也是很有用的。 " #. Tag: para #, no-c-format -msgid "" -"(createAlias() does not create a new instance of " -"Criteria.)" -msgstr "" -"(createAlias() 并不创建一个新的 Criteria 实例。)" +msgid "(createAlias() does not create a new instance of Criteria.)" +msgstr "(createAlias() 并不创建一个新的 Criteria 实例。)" #. Tag: para #, no-c-format -msgid "" -"The kittens collections held by the Cat instances " -"returned by the previous two queries are not pre-" -"filtered by the criteria. If you want to retrieve just the kittens that " -"match the criteria, you must use a ResultTransformer." -msgstr "" -"Cat 实例所保存的之前两次查询所返回的 kittens 集合是 " -"没有被条件预过滤的。如果你希望只获得符合条件的 kittens," -"你必须使用 ResultTransformer。 " +msgid "The kittens collections held by the Cat instances returned by the previous two queries are not pre-filtered by the criteria. If you want to retrieve just the kittens that match the criteria, you must use a ResultTransformer." +msgstr "Cat 实例所保存的之前两次查询所返回的 kittens 集合是 没有被条件预过滤的。如果你希望只获得符合条件的 kittens,你必须使用 ResultTransformer。 " #. Tag: para #, no-c-format msgid "Additionally you may manipulate the result set using a left outer join:" -msgstr "" +msgstr "此外,你可以用一个 left outer join 来操纵结果集:" #. Tag: para #, no-c-format -msgid "" -"This will return all of the Cats with a mate whose name " -"starts with \"good\" ordered by their mate's age, and all cats who do not " -"have a mate. This is useful when there is a need to order or limit in the " -"database prior to returning complex/large result sets, and removes many " -"instances where multiple queries would have to be performed and the results " -"unioned by java in memory." -msgstr "" +msgid "This will return all of the Cats with a mate whose name starts with \"good\" ordered by their mate's age, and all cats who do not have a mate. This is useful when there is a need to order or limit in the database prior to returning complex/large result sets, and removes many instances where multiple queries would have to be performed and the results unioned by java in memory." +msgstr "这将返回配偶的名字以 \"good\" 起始的所有 Cat,并根据其配偶的年龄进行排序。当需要在返回复杂/大型结果集前进行排序或限制、在多个查询必须执行且结果通过 Java 在内存里组合从而删除许多实例时,这很有用。" #. Tag: para #, no-c-format -msgid "" -"Without this feature, first all of the cats without a mate would need to be " -"loaded in one query." -msgstr "" +msgid "Without this feature, first all of the cats without a mate would need to be loaded in one query." +msgstr "如果没有这个功能,那么没有配偶的猫就需要在一次查询里进行加载。" #. Tag: para #, no-c-format -msgid "" -"A second query would need to retreive the cats with mates who's name started " -"with \"good\" sorted by the mates age." -msgstr "" +msgid "A second query would need to retreive the cats with mates who's name started with \"good\" sorted by the mates age." +msgstr "第二个查询将需要获取配偶名以 \"good\" 起始并按照配偶年龄排序的猫。" #. Tag: para #, no-c-format msgid "Thirdly, in memory; the lists would need to be joined manually." -msgstr "" +msgstr "第三点,列表需要在内存中进行手工联合。" #. Tag: title #, no-c-format @@ -196,22 +136,13 @@ msgstr "动态关联抓取" #. Tag: para #, no-c-format -msgid "" -"You can specify association fetching semantics at runtime using " -"setFetchMode()." -msgstr "" -"你可以使用 setFetchMode() 在运行时定义动态关联抓取的语" -"义。 " +msgid "You can specify association fetching semantics at runtime using setFetchMode()." +msgstr "你可以使用 setFetchMode() 在运行时定义动态关联抓取的语义。 " #. Tag: para -#, fuzzy, no-c-format -msgid "" -"This query will fetch both mate and kittens by outer join. See for " -"more information." -msgstr "" -"这个查询可以通过外连接抓取 matekittens。查看 可以获得更多信息。" +#, no-c-format +msgid "This query will fetch both mate and kittens by outer join. See for more information." +msgstr "这个查询可以通过外连接抓取 matekittens。查看 可以获得更多信息。 " #. Tag: title #, no-c-format @@ -220,18 +151,12 @@ msgstr "查询示例" #. Tag: para #, 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 类允许你通过一个给定实例构" -"建一个条件查询。" +msgid "The class org.hibernate.criterion.Example allows you to construct a query criterion from a given instance." +msgstr "org.hibernate.criterion.Example 类允许你通过一个给定实例构建一个条件查询。" #. Tag: para #, no-c-format -msgid "" -"Version properties, identifiers and associations are ignored. By default, " -"null valued properties are excluded." +msgid "Version properties, identifiers and associations are ignored. By default, null valued properties are excluded." msgstr "版本属性、标识符和关联被忽略。默认情况下值为 null 的属性将被排除。" #. Tag: para @@ -251,53 +176,27 @@ msgstr "投影(Projections)、聚合(aggregation)和分组(grouping) #. Tag: para #, no-c-format -msgid "" -"The class org.hibernate.criterion.Projections is a " -"factory for Projection instances. You can apply a " -"projection to a query by calling setProjection()." -msgstr "" -"org.hibernate.criterion.Projections 是 " -"Projection 的实例工厂。我们通过调用 setProjection" -"() 应用投影到一个查询。 " +msgid "The class org.hibernate.criterion.Projections is a factory for Projection instances. You can apply a projection to a query by calling setProjection()." +msgstr "org.hibernate.criterion.ProjectionsProjection 的实例工厂。我们通过调用 setProjection() 应用投影到一个查询。 " #. Tag: para #, 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 子句中。" +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 子句中。" #. Tag: para #, no-c-format -msgid "" -"An alias can be assigned to a projection so that the projected value can be " -"referred to in restrictions or orderings. Here are two different ways to do " -"this:" -msgstr "" -"你可以选择把一个别名指派给一个投影,这样可以使投影值被约束或排序所引用。下面" -"是两种不同的实现方式: " +msgid "An alias can be assigned to a projection so that the projected value can be referred to in restrictions or orderings. Here are two different ways to do this:" +msgstr "你可以选择把一个别名指派给一个投影,这样可以使投影值被约束或排序所引用。下面是两种不同的实现方式: " #. Tag: para #, 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 实例中。简而言之,当你" -"添加一个投影到一个投影列表中时你可以为它指定一个别名:" +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: para #, no-c-format -msgid "" -"You can also use Property.forName() to express " -"projections:" +msgid "You can also use Property.forName() to express projections:" msgstr "你也可以使用 Property.forName() 来表示投影:" #. Tag: title @@ -307,24 +206,13 @@ msgstr "离线(detached)查询和子查询" #. Tag: para #, no-c-format -msgid "" -"The DetachedCriteria class allows you to create a query " -"outside the scope of a session and then execute it using an arbitrary " -"Session." -msgstr "" -"DetachedCriteria 类使你在一个 session 范围之外创建一个查" -"询,并且可以使用任意的 Session 来执行它。 " +msgid "The DetachedCriteria class allows you to create a query outside the scope of a session and then execute it using an arbitrary Session." +msgstr "DetachedCriteria 类使你在一个 session 范围之外创建一个查询,并且可以使用任意的 Session 来执行它。 " #. Tag: para #, no-c-format -msgid "" -"A DetachedCriteria can also be used to express a " -"subquery. Criterion instances involving subqueries can be obtained via " -"Subqueries or Property." -msgstr "" -"DetachedCriteria 也可以用以表示子查询。条件实例包含子查询" -"可以通过 Subqueries 或者 Property 获" -"得。 " +msgid "A DetachedCriteria can also be used to express a subquery. Criterion instances involving subqueries can be obtained via Subqueries or Property." +msgstr "DetachedCriteria 也可以用以表示子查询。条件实例包含子查询可以通过 Subqueries 或者 Property 获得。 " #. Tag: para #, no-c-format @@ -338,45 +226,23 @@ msgstr "根据自然标识查询(Queries by natural identifier)" #. Tag: para #, no-c-format -msgid "" -"For most queries, including criteria queries, the query cache is not " -"efficient because query cache invalidation occurs too frequently. However, " -"there is a special kind of query where you 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 对这种用例提" -"供了特别规约。 " +msgid "For most queries, including criteria queries, the query cache is not efficient because query cache invalidation occurs too frequently. However, there is a special kind of query where you 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 #, no-c-format -msgid "" -"First, map the natural key of your entity using <natural-id> and enable use of the second-level cache." -msgstr "" -"首先,你应该对你的 entity 使用 <natural-id> 来映射自" -"然键,然后打开第二级缓存。 " +msgid "First, map the natural key of your entity using <natural-id> and enable use of the second-level cache." +msgstr "首先,你应该对你的 entity 使用 <natural-id> 来映射自然键,然后打开第二级缓存。 " #. Tag: para #, no-c-format -msgid "" -"This functionality is not intended for use with entities with " -"mutable natural keys." -msgstr "" -"注意,此功能对具有mutable自然键的 entity 并不适用。 " +msgid "This functionality is not intended for use with entities with mutable natural keys." +msgstr "注意,此功能对具有mutable自然键的 entity 并不适用。 " #. Tag: para #, no-c-format -msgid "" -"Once you have enabled the Hibernate query cache, the Restrictions." -"naturalId() allows you to make use of the more efficient cache " -"algorithm." -msgstr "" -"现在,我们可以用 Restrictions.naturalId() 来使用更加高效的" -"缓存算法。 " +msgid "Once you have enabled the Hibernate query cache, the Restrictions.naturalId() allows you to make use of the more efficient cache algorithm." +msgstr "现在,我们可以用 Restrictions.naturalId() 来使用更加高效的缓存算法。 " #, fuzzy #~ msgid "" @@ -884,3 +750,4 @@ msgstr "" #~ " .set(\"org\", \"hb\") \n" #~ " ).setCacheable(true)\n" #~ " .uniqueResult();" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/query_hql.po b/documentation/manual/src/main/docbook/zh-CN/content/query_hql.po index dec867f46a..4d2ce16934 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/query_hql.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/query_hql.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Collection_Mapping\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-02-11T05:38:15\n" -"PO-Revision-Date: 2009-12-07 21:13+1000\n" +"PO-Revision-Date: 2010-03-16 10:03+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,14 +21,8 @@ msgstr "HQL: Hibernate 查询语言" #. Tag: para #, no-c-format -msgid "" -"Hibernate uses a powerful query language (HQL) that is similar in appearance " -"to SQL. Compared with SQL, however, HQL is fully object-oriented and " -"understands notions like inheritance, polymorphism and association." -msgstr "" -"Hibernate 配备了一种非常强大的查询语言,这种语言看上去很像 SQL。但是不要被语" -"法结构上的相似所迷惑,HQL 是非常有意识的被设计为完全面向对象的查询,它可以理" -"解如继承、多态和关联之类的概念。 " +msgid "Hibernate uses a powerful query language (HQL) that is similar in appearance to SQL. Compared with SQL, however, HQL is fully object-oriented and understands notions like inheritance, polymorphism and association." +msgstr "Hibernate 配备了一种非常强大的查询语言,这种语言看上去很像 SQL。但是不要被语法结构上的相似所迷惑,HQL 是非常有意识的被设计为完全面向对象的查询,它可以理解如继承、多态和关联之类的概念。 " #. Tag: title #, no-c-format @@ -37,29 +31,13 @@ msgstr "大小写敏感性问题" #. Tag: para #, no-c-format -msgid "" -"With the exception of names of Java classes and properties, queries are case-" -"insensitive. 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。 " +msgid "With the exception of names of Java classes and properties, queries are case-insensitive. 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。 " #. Tag: para #, no-c-format -msgid "" -"This manual uses lowercase HQL keywords. Some users find queries with " -"uppercase keywords more readable, but this convention is unsuitable for " -"queries embedded in Java code." -msgstr "" -"本手册中的 HQL 关键字将使用小写字母。很多用户发现使用完全大写的关键字会使查询" -"语句的可读性更强,但我们发现,当把查询语句嵌入到 Java 语句中的时候使用大写关" -"键字比较难看。" +msgid "This manual uses lowercase HQL keywords. Some users find queries with uppercase keywords more readable, but this convention is unsuitable for queries embedded in Java code." +msgstr "本手册中的 HQL 关键字将使用小写字母。很多用户发现使用完全大写的关键字会使查询语句的可读性更强,但我们发现,当把查询语句嵌入到 Java 语句中的时候使用大写关键字比较难看。" #. Tag: title #, no-c-format @@ -73,52 +51,28 @@ msgstr "Hibernate 中最简单的查询语句的形式如下:" #. Tag: para #, no-c-format -msgid "" -"This returns all instances of the class eg.Cat. You do " -"not usually need to qualify the class name, since auto-import is the default. For example:" -msgstr "" -"该子句简单的返回 eg.Cat 类的所有实例。通常我们不需要使用类" -"的全限定名,因为 auto-import(自动引入)是缺省的情况。所" -"以我们几乎只使用如下的简单写法: " +msgid "This returns all instances of the class eg.Cat. You do not usually need to qualify the class name, since auto-import is the default. For example:" +msgstr "该子句简单的返回 eg.Cat 类的所有实例。通常我们不需要使用类的全限定名,因为 auto-import(自动引入)是缺省的情况。所以我们几乎只使用如下的简单写法: " #. Tag: para #, no-c-format -msgid "" -"In order to refer to the Cat in other parts of the query, " -"you will need to assign an alias. For example:" -msgstr "" -"为了在这个查询的其他部分里引用 Cat,你将需要分配一个" -"别名。例如:" +msgid "In order to refer to the Cat in other parts of the query, you will need to assign an alias. For example:" +msgstr "为了在这个查询的其他部分里引用 Cat,你将需要分配一个别名。例如:" #. Tag: para #, no-c-format -msgid "" -"This query assigns the alias cat to Cat instances, so you can use that alias later in the query. The " -"as keyword is optional. You could also write:" -msgstr "" -"这个语句把别名 cat 指定给类Cat 的实例," -"这样我们就可以在随后的查询中使用此别名了。关键字 as 是可选" -"的,我们也可以这样写: " +msgid "This query assigns the alias cat to Cat instances, so you can use that alias later in the query. The as keyword is optional. You could also write:" +msgstr "这个语句把别名 cat 指定给类Cat 的实例,这样我们就可以在随后的查询中使用此别名了。关键字 as 是可选的,我们也可以这样写: " #. Tag: para #, no-c-format -msgid "" -"Multiple classes can appear, resulting in a cartesian product or \"cross\" " -"join." -msgstr "" -"子句中可以同时出现多个类,其查询结果是产生一个笛卡儿积或产生跨表的连接。 " +msgid "Multiple classes can appear, resulting in a cartesian product or \"cross\" join." +msgstr "子句中可以同时出现多个类,其查询结果是产生一个笛卡儿积或产生跨表的连接。 " #. Tag: para #, no-c-format -msgid "" -"It is good practice to name query aliases using an initial lowercase as this " -"is consistent with Java naming standards for local variables (e.g. " -"domesticCat)." -msgstr "" -"查询语句中别名的开头部分小写被认为是实践中的好习惯,这样做与 Java 变量的命名" -"标准保持了一致(比如,domesticCat)。 " +msgid "It is good practice to name query aliases using an initial lowercase as this is consistent with Java naming standards for local variables (e.g. domesticCat)." +msgstr "查询语句中别名的开头部分小写被认为是实践中的好习惯,这样做与 Java 变量的命名标准保持了一致(比如,domesticCat)。 " #. Tag: title #, no-c-format @@ -127,12 +81,8 @@ msgstr "关联(Association)与连接(Join)" #. Tag: para #, no-c-format -msgid "" -"You can also assign aliases to associated entities or to elements of a " -"collection of values using a join. For example:" -msgstr "" -"我们也可以为相关联的实体甚至是对一个集合中的全部元素指定一个别名,这时要使用" -"关键字 join。 " +msgid "You can also assign aliases to associated entities or to elements of a collection of values using a join. For example:" +msgstr "我们也可以为相关联的实体甚至是对一个集合中的全部元素指定一个别名,这时要使用关键字 join。 " #. Tag: para #, no-c-format @@ -161,91 +111,33 @@ msgstr "full join(全连接,并不常用)" #. Tag: para #, no-c-format -msgid "" -"The inner join, left outer join and " -"right outer join constructs may be abbreviated." -msgstr "" -"语句 inner joinleft outer join 以及 " -"right outer join 可以简写。" +msgid "The inner join, left outer join and right outer join constructs may be abbreviated." +msgstr "语句 inner joinleft outer join 以及 right outer join 可以简写。" #. Tag: para #, no-c-format -msgid "" -"You may supply extra join conditions using the HQL with " -"keyword." -msgstr "" -"通过 HQL 的 with 关键字,你可以提供额外的 join 条件。" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"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)。查看 以获得等多的信" -"息。" +msgid "You may supply extra join conditions using the HQL with keyword." +msgstr "通过 HQL 的 with 关键字,你可以提供额外的 join 条件。" #. Tag: para #, 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). The associated objects are also not returned directly " -"in the query results. Instead, they may be accessed via the parent object. " -"The only reason you might need an alias is if you are recursively join " -"fetching a further collection:" -msgstr "" -"一个 fetch 连接通常不需要被指定别名,因为相关联的对象不应当被用在 " -"where 子句(或其它任何子句)中。同时,相关联的对象并不在查" -"询的结果中直接返回,但可以通过他们的父对象来访问到他们。 " +msgid "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: para #, no-c-format -msgid "" -"The fetch construct cannot be used in queries called " -"using iterate() (though scroll() can " -"be used). Fetch should 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 would expect. Fetch should also not be used " -"together with impromptu 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 " -"can produce unexpected results for bag mappings, so user discretion is " -"advised when formulating 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 fetch 与 " -"right join fetch 是没有意义的。 " +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). The associated objects are also not returned directly in the query results. Instead, they may be accessed via the parent object. The only reason you might need an alias is if you are recursively join fetching a further collection:" +msgstr "一个 fetch 连接通常不需要被指定别名,因为相关联的对象不应当被用在 where 子句(或其它任何子句)中。同时,相关联的对象并不在查询的结果中直接返回,但可以通过他们的父对象来访问到他们。 " #. Tag: para #, 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 in the first query immediately using fetch all " -"properties." -msgstr "" -"如果你使用属性级别的延迟获取(lazy fetching)(这是通过重新编写字节码实现" -"的),可以使用 fetch all properties 来强制 Hibernate 立即" -"取得那些原本需要延迟加载的属性(在第一个查询中)。 " +msgid "The fetch construct cannot be used in queries called using iterate() (though scroll() can be used). Fetch should 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 would expect. Fetch should also not be used together with impromptu 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 can produce unexpected results for bag mappings, so user discretion is advised when formulating 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 +#, 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 in the first query immediately using fetch all properties." +msgstr "如果你使用属性级别的延迟获取(lazy fetching)(这是通过重新编写字节码实现的),可以使用 fetch all properties 来强制 Hibernate 立即取得那些原本需要延迟加载的属性(在第一个查询中)。 " #. Tag: title #, no-c-format @@ -254,35 +146,18 @@ msgstr "join 语法的形式" #. Tag: para #, no-c-format -msgid "" -"HQL supports two forms of association joining: implicit " -"and explicit." -msgstr "" -"HQL 支持两种关联 join 的形式:implicit(隐式) 与 " -"explicit(显式)。" +msgid "HQL supports two forms of association joining: implicit and explicit." +msgstr "HQL 支持两种关联 join 的形式:implicit(隐式)explicit(显式)。" #. Tag: para #, no-c-format -msgid "" -"The queries shown in the previous section all use the explicit form, that is, where the join keyword is explicitly used in the " -"from clause. This is the recommended form." -msgstr "" -"上一节中给出的查询都是使用 explicit(显式)形式的,其中 " -"form 子句中明确给出了 join 关键字。这是建议使用的方式。 " +msgid "The queries shown in the previous section all use the explicit form, that is, where the join keyword is explicitly used in the from clause. This is the recommended form." +msgstr "上一节中给出的查询都是使用 explicit(显式)形式的,其中 form 子句中明确给出了 join 关键字。这是建议使用的方式。 " #. Tag: para #, 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 的方式出" -"现。" +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 的方式出现。" #. Tag: title #, no-c-format @@ -296,48 +171,23 @@ msgstr "通常有两种方法来引用实体的 identifier 属性: " #. Tag: para #, no-c-format -msgid "" -"The special property (lowercase) id may be used to " -"reference the identifier property of an entity provided that the " -"entity does not define a non-identifier property named id." -msgstr "" -"特殊属性(lowercase)id 可以用来引用实体的 identifier 属" -"性 假设这个实体没有定义用 non-identifier 属性命名的 id。 " +msgid "The special property (lowercase) id may be used to reference the identifier property of an entity provided that the entity does not define a non-identifier property named id." +msgstr "特殊属性(lowercase)id 可以用来引用实体的 identifier 属性 假设这个实体没有定义用 non-identifier 属性命名的 id。 " #. Tag: para #, no-c-format -msgid "" -"If the entity defines a named identifier property, you can use that property " -"name." +msgid "If the entity defines a named identifier property, you can use that property name." msgstr "如果这个实体定义了 identifier 属性,你可以使用属性名。 " #. Tag: para #, 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 reference the " -"identifier property." -msgstr "" -"对组合 identifier 属性的引用遵循相同的命名规则。如果实体有一个 non-" -"identifier 属性命名的 id,这个组合 identifier 属性只能用自己定义的名字来引" -"用;否则,特殊 id 属性可以用来引用 identifier 属性。 " +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 reference the identifier property." +msgstr "对组合 identifier 属性的引用遵循相同的命名规则。如果实体有一个 non-identifier 属性命名的 id,这个组合 identifier 属性只能用自己定义的名字来引用;否则,特殊 id 属性可以用来引用 identifier 属性。 " #. Tag: para #, no-c-format -msgid "" -"Please note that, starting in version 3.2.2, this has changed significantly. " -"In previous versions, id always " -"referred to the identifier property regardless of its actual name. A " -"ramification of that decision was that non-identifier properties named " -"id could never be referenced in Hibernate queries." -msgstr "" -"注意:从 3.2.2 版本开始,这已经改变了很多。在前面的版本里,不管实际的名字," -"id 总是指向 identifier 属性;而用 " -"non-identifier 属性命名的 id 就从来不在 Hibernate 查询里引" -"用。 " +msgid "Please note that, starting in version 3.2.2, this has changed significantly. In previous versions, id always referred to the identifier property regardless of its actual name. A ramification of that decision was that non-identifier properties named id could never be referenced in Hibernate queries." +msgstr "注意:从 3.2.2 版本开始,这已经改变了很多。在前面的版本里,不管实际的名字,id 总是指向 identifier 属性;而用 non-identifier 属性命名的 id 就从来不在 Hibernate 查询里引用。 " #. Tag: title #, no-c-format @@ -346,39 +196,23 @@ msgstr "select 子句" #. Tag: para #, no-c-format -msgid "" -"The select clause picks which objects and properties to " -"return in the query result set. Consider the following:" -msgstr "" -"select 子句选择将哪些对象与属性返回到查询结果集中。考虑如" -"下情况:" +msgid "The select clause picks which objects and properties to return in the query result set. Consider the following:" +msgstr "select 子句选择将哪些对象与属性返回到查询结果集中。考虑如下情况:" #. Tag: para #, no-c-format -msgid "" -"The query will select mates of other Cats. You can express this query more compactly as:" -msgstr "" -"该语句将选择其它 Catmate(其他猫的" -"配偶)。实际上,你可以更简洁的用以下的查询语句表达相同的含义: " +msgid "The query will select mates of other Cats. You can express this query more compactly as:" +msgstr "该语句将选择其它 Catmate(其他猫的配偶)。实际上,你可以更简洁的用以下的查询语句表达相同的含义: " #. Tag: para #, no-c-format -msgid "" -"Queries can return properties of any value type including properties of " -"component type:" -msgstr "" -"查询语句可以返回值为任何类型的属性,包括返回类型为某种组件(Component)的属" -"性: " +msgid "Queries can return properties of any value type including properties of component type:" +msgstr "查询语句可以返回值为任何类型的属性,包括返回类型为某种组件(Component)的属性: " #. Tag: para #, no-c-format -msgid "" -"Queries can return multiple objects and/or properties as an array of type " -"Object[]:" -msgstr "" -"查询语句可以返回多个对象和(或)属性,存放在 Object[] 队列" -"中, " +msgid "Queries can return multiple objects and/or properties as an array of type Object[]:" +msgstr "查询语句可以返回多个对象和(或)属性,存放在 Object[] 队列中, " #. Tag: para #, no-c-format @@ -387,33 +221,23 @@ msgstr "或存放在一个 List 对象中:" #. Tag: para #, no-c-format -msgid "" -"Or - assuming that the class Family has an appropriate " -"constructor - as an actual typesafe Java object:" -msgstr "" -"假设类 Family 有一个合适的构造函数 - 作为实际的类型安全的 " -"Java 对象:" +msgid "Or - assuming that the class Family has an appropriate constructor - as an actual typesafe Java object:" +msgstr "假设类 Family 有一个合适的构造函数 - 作为实际的类型安全的 Java 对象:" #. Tag: para #, no-c-format -msgid "" -"You can assign aliases to selected expressions using as:" +msgid "You can assign aliases to selected expressions using as:" msgstr "你可以使用关键字 as 给“被选择了的表达式”指派别名: " #. Tag: para #, no-c-format -msgid "" -"This is most useful when used together with select new map:" +msgid "This is most useful when used together with select new map:" msgstr "这种做法在与子句 select new map 一起使用时最有用:" #. Tag: para #, no-c-format -msgid "" -"This query returns a Map from aliases to selected values." -msgstr "" -"该查询返回了一个 Map 的对象,内容是别名与被选择的值组成的" -"名-值映射。" +msgid "This query returns a Map from aliases to selected values." +msgstr "该查询返回了一个 Map 的对象,内容是别名与被选择的值组成的名-值映射。" #. Tag: title #, no-c-format @@ -422,8 +246,7 @@ msgstr "聚集函数" #. Tag: para #, no-c-format -msgid "" -"HQL queries can even return the results of aggregate functions on properties:" +msgid "HQL queries can even return the results of aggregate functions on properties:" msgstr "HQL 查询甚至可以返回作用于属性之上的聚集函数的计算结果: " #. Tag: para @@ -432,9 +255,9 @@ msgid "The supported aggregate functions are:" msgstr "受支持的聚集函数如下: " #. Tag: para -#, fuzzy, no-c-format +#, no-c-format msgid "avg(...), sum(...), min(...), max(...)" -msgstr "avg(...), sum(...), min(...), max(...)" +msgstr "avg(...), sum(...), min(...), max(...) " #. Tag: para #, no-c-format @@ -442,25 +265,19 @@ msgid "count(*)" msgstr "count(*)" #. Tag: para -#, fuzzy, no-c-format +#, no-c-format msgid "count(...), count(distinct ...), count(all...)" msgstr "count(...), count(distinct ...), count(all...)" #. Tag: para #, no-c-format -msgid "" -"You can use arithmetic operators, concatenation, and recognized SQL " -"functions in the select clause:" +msgid "You can use arithmetic operators, concatenation, and recognized SQL functions in the select clause:" msgstr "你可以在选择子句中使用数学操作符、连接以及经过验证的 SQL 函数: " #. Tag: para #, no-c-format -msgid "" -"The distinct and all keywords can be " -"used and have the same semantics as in SQL." -msgstr "" -"关键字 distinctall 也可以使用,它们" -"具有与 SQL 相同的语义。 " +msgid "The distinct and all keywords can be used and have the same semantics as in SQL." +msgstr "关键字 distinctall 也可以使用,它们具有与 SQL 相同的语义。 " #. Tag: title #, no-c-format @@ -474,38 +291,18 @@ msgstr "一个如下的查询语句:" #. Tag: para #, no-c-format -msgid "" -"returns instances not only of Cat, but also of subclasses " -"like DomesticCat. Hibernate queries can 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 类或接口。查询会返回继承了" -"该类的所有持久化子类的实例或返回声明了该接口的所有持久化类的实例。下面的查询" -"语句返回所有的被持久化的对象: " +msgid "returns instances not only of Cat, but also of subclasses like DomesticCat. Hibernate queries can 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 类或接口。查询会返回继承了该类的所有持久化子类的实例或返回声明了该接口的所有持久化类的实例。下面的查询语句返回所有的被持久化的对象: " #. Tag: para #, no-c-format -msgid "" -"The interface Named might be implemented by various " -"persistent classes:" +msgid "The interface Named might be implemented by various persistent classes:" msgstr "接口 Named 可能被各种各样的持久化类声明:" #. Tag: para #, no-c-format -msgid "" -"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 cannot call these " -"queries using Query.scroll()." -msgstr "" -"注意,最后的两个查询将需要超过一个的 SQL SELECT。这表明 " -"order by 子句没有对整个结果集进行正确的排序。(这也说明你" -"不能对这样的查询使用 Query.scroll() 方法。)" +msgid "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 cannot call these queries using Query.scroll()." +msgstr "注意,最后的两个查询将需要超过一个的 SQL SELECT。这表明 order by 子句没有对整个结果集进行正确的排序。(这也说明你不能对这样的查询使用 Query.scroll() 方法。)" #. Tag: title #, no-c-format @@ -514,12 +311,8 @@ msgstr "where 子句" #. Tag: para #, no-c-format -msgid "" -"The where clause allows you to refine the list of " -"instances returned. If no alias exists, you can refer to properties by name:" -msgstr "" -"where 子句允许你将返回的实例列表的范围缩小。如果没有指定别" -"名,你可以使用属性名来直接引用属性: " +msgid "The where clause allows you to refine the list of instances returned. If no alias exists, you can refer to properties by name:" +msgstr "where 子句允许你将返回的实例列表的范围缩小。如果没有指定别名,你可以使用属性名来直接引用属性: " #. Tag: para #, no-c-format @@ -529,8 +322,7 @@ msgstr "如果指派了别名,需要使用完整的属性名:" #. Tag: para #, no-c-format msgid "This returns instances of Cat named 'Fritz'." -msgstr "" -"返回名为(属性 name 等于)'Fritz' 的 Cat 类的实例。 " +msgstr "返回名为(属性 name 等于)'Fritz' 的 Cat 类的实例。 " #. Tag: para #, no-c-format @@ -539,25 +331,13 @@ msgstr "下面的查询:" #. Tag: para #, no-c-format -msgid "" -"returns all instances of Foo with 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 the following:" -msgstr "" -"将返回所有满足下面条件的 Foo 类的实例: 存在如下的 " -"bar 的一个实例,其 date 属性等于 " -"FoostartDate 属性。复合路径表达式使" -"得 where 子句非常的强大,考虑如下情况: " +msgid "returns all instances of Foo with 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 the following:" +msgstr "将返回所有满足下面条件的 Foo 类的实例: 存在如下的 bar 的一个实例,其 date 属性等于 FoostartDate 属性。复合路径表达式使得 where 子句非常的强大,考虑如下情况: " #. Tag: para #, no-c-format -msgid "" -"This query translates to an SQL query with a table (inner) join. For example:" -msgstr "" -"该查询将被翻译成为一个含有表连接(内连接)的 SQL 查询。如果你打算写像这样的查" -"询语句:" +msgid "This query translates to an SQL query with a table (inner) join. For example:" +msgstr "该查询将被翻译成为一个含有表连接(内连接)的 SQL 查询。如果你打算写像这样的查询语句:" #. Tag: para #, no-c-format @@ -566,21 +346,13 @@ msgstr "在 SQL 中,你为达此目的将需要进行一个四表连接的查 #. Tag: para #, no-c-format -msgid "" -"The = operator can be used to compare not only " -"properties, but also instances:" -msgstr "" -"= 运算符不仅可以被用来比较属性的值,也可以用来比较实例: " +msgid "The = operator can be used to compare not only properties, but also instances:" +msgstr "= 运算符不仅可以被用来比较属性的值,也可以用来比较实例: " #. Tag: para -#, fuzzy, no-c-format -msgid "" -"The special property (lowercase) id can be used to " -"reference the unique identifier of an object. See for more information." -msgstr "" -"特殊属性(小写)id 可以用来表示一个对象的唯一的标识符。详" -"情请参考 。" +#, no-c-format +msgid "The special property (lowercase) id can be used to reference the unique identifier of an object. See for more information." +msgstr "特殊属性(小写)id 可以用来表示一个对象的唯一的标识符。详情请参考 。 " #. Tag: para #, no-c-format @@ -589,14 +361,8 @@ msgstr "第二个查询是有效的。此时不需要进行表连接。" #. Tag: para #, no-c-format -msgid "" -"Properties of composite identifiers can also be used. Consider the following " -"example where Person has composite identifiers consisting " -"of country and medicareNumber:" -msgstr "" -"同样也可以使用复合标识符。比如 Person 类有一个复合标识符," -"它由 country 属性与 medicareNumber 属性" -"组成:" +msgid "Properties of composite identifiers can also be used. Consider the following example where Person has composite identifiers consisting of country and medicareNumber:" +msgstr "同样也可以使用复合标识符。比如 Person 类有一个复合标识符,它由 country 属性与 medicareNumber 属性组成:" #. Tag: para #, no-c-format @@ -604,57 +370,29 @@ msgid "Once again, the second query does not require a table join." msgstr "第二个查询也不需要进行表连接。 " #. Tag: para -#, fuzzy, no-c-format -msgid "" -"See for more information " -"regarding referencing identifier properties)" -msgstr "" -"关于引用标识符属性的更多信息,请参考 。" +#, no-c-format +msgid "See for more information regarding referencing identifier properties)" +msgstr "关于引用标识符属性的更多信息,请参考 。 " #. Tag: para #, no-c-format -msgid "" -"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 类的" -"名字将被转换为该类的鉴别值。 " - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"You can also use components or composite user types, or properties of said " -"component types. See for more " -"information." -msgstr "" -"你也可以使用组件或者复合用户类型,以及组件类型的属性。详情请参考 。" +msgid "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 类的名字将被转换为该类的鉴别值。 " #. Tag: para #, no-c-format -msgid "" -"An \"any\" type has the special properties id and " -"class that allows you to express a join in the following " -"way (where AuditLog.item is a property mapped with " -"<any>):" -msgstr "" -"一个“任意”类型有两个特殊的属性 idclass,来允许我们按照下面的方式表达一个连接(AuditLog.item 是一个属性,该属性被映射为 <any>)。 " +msgid "You can also use components or composite user types, or properties of said component types. See for more information." +msgstr "你也可以使用组件或者复合用户类型,以及组件类型的属性。详情请参考 。 " #. Tag: para #, no-c-format -msgid "" -"The 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 将涉及到完全不同的数据库中的列。" +msgid "An \"any\" type has the special properties id and class that allows you to express a join in the following way (where AuditLog.item is a property mapped with <any>):" +msgstr "一个“任意”类型有两个特殊的属性 idclass,来允许我们按照下面的方式表达一个连接(AuditLog.item 是一个属性,该属性被映射为 <any>)。 " + +#. Tag: para +#, no-c-format +msgid "The log.item.class and payment.class would refer to the values of completely different database columns in the above query." +msgstr "注意,在上面的查询与句中,log.item.classpayment.class 将涉及到完全不同的数据库中的列。" #. Tag: title #, no-c-format @@ -663,12 +401,8 @@ msgstr "表达式" #. Tag: para #, no-c-format -msgid "" -"Expressions used in the where clause include the " -"following:" -msgstr "" -"在 where 子句中允许使用的表达式包括 大多数你可以在 SQL 使" -"用的表达式种类: " +msgid "Expressions used in the where clause include the following:" +msgstr "在 where 子句中允许使用的表达式包括 大多数你可以在 SQL 使用的表达式种类: " #. Tag: para #, no-c-format @@ -677,11 +411,8 @@ msgstr "数学运算符 +,-,*,/ " #. Tag: para #, no-c-format -msgid "" -"binary comparison operators: =, >=, <=, <>, !=, like" -msgstr "" -"二进制比较运算符 =, >=, <=, <>, !=, like " +msgid "binary comparison operators: =, >=, <=, <>, !=, like" +msgstr "二进制比较运算符 =, >=, <=, <>, !=, like " #. Tag: para #, no-c-format @@ -695,64 +426,33 @@ msgstr "括号 ( ),表示分组 " #. Tag: para #, 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" +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" #. Tag: para #, no-c-format -msgid "" -"\"Simple\" case, case ... when ... then ... else ... end, " -"and \"searched\" case, case when ... then ... else ... end" -msgstr "" -"\"Simple\" case, case ... when ... then ... else ... end, " -"and \"searched\" case, case when ... then ... else ... end" +msgid "\"Simple\" case, case ... when ... then ... else ... end, and \"searched\" case, case when ... then ... else ... end" +msgstr "\"Simple\" case, case ... when ... then ... else ... end, and \"searched\" case, case when ... then ... else ... end" #. Tag: para #, no-c-format -msgid "" -"string concatenation ...||... or concat(...,...)" -"" -msgstr "" -"字符串连接符 ...||... or concat(...,...)" +msgid "string concatenation ...||... or concat(...,...)" +msgstr "字符串连接符 ...||... or concat(...,...)" #. Tag: para #, no-c-format -msgid "" -"current_date(), current_time(), and " -"current_timestamp()" -msgstr "" -"current_date(), current_time(), and " -"current_timestamp()" +msgid "current_date(), current_time(), and current_timestamp()" +msgstr "current_date(), current_time(), and current_timestamp()" #. Tag: para #, no-c-format -msgid "" -"second(...), minute(...), hour" -"(...), day(...), month(...), " -"and year(...)" -msgstr "" -"second(...)minute(...)hour" -"(...)day(...)month(...) " -"和 year(...)" +msgid "second(...), minute(...), hour(...), day(...), month(...), and year(...)" +msgstr "second(...)minute(...)hour(...)day(...)month(...)year(...)" #. Tag: para #, 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()" +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()" #. Tag: para #, no-c-format @@ -761,53 +461,28 @@ msgstr "coalesce()nullif()" #. Tag: para #, no-c-format -msgid "" -"str() for converting numeric or temporal values to a " -"readable string" +msgid "str() for converting numeric or temporal values to a readable string" msgstr "str() 把数字或者时间值转换为可读的字符串" #. Tag: para #, 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() 被底层数据库支持" +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() 被底层数据库支持" #. Tag: para #, no-c-format -msgid "" -"the HQL index() function, that applies to aliases of a " -"joined indexed collection" +msgid "the HQL index() function, that applies to aliases of a joined indexed collection" msgstr "HQL index() 函数,作用于 join 的有序集合的别名。" #. Tag: para #, 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 that can be quantified using some, all, exists, any, in." -msgstr "" -"HQL 函数,把集合作为参数:size(), minelement(), maxelement(), " -"minindex(), maxindex(),还有特别的 elements() " -"和 indices 函数,可以与数量词加以限定:some, " -"all, exists, any, in。 " +msgid "HQL functions that take collection-valued path expressions: size(), minelement(), maxelement(), minindex(), maxindex(), along with the special elements() and indices functions that can be quantified using some, all, exists, any, in." +msgstr "HQL 函数,把集合作为参数:size(), minelement(), maxelement(), minindex(), maxindex(),还有特别的 elements()indices 函数,可以与数量词加以限定:some, all, exists, any, in。 " #. Tag: para #, no-c-format -msgid "" -"Any database-supported SQL scalar function like sign(), " -"trunc(), rtrim(), and sin()" -msgstr "" -"任何数据库支持的 SQL 标量函数,比如 sign(), trunc" -"(), rtrim(), sin() " +msgid "Any database-supported SQL scalar function like sign(), trunc(), rtrim(), and sin()" +msgstr "任何数据库支持的 SQL 标量函数,比如 sign(), trunc(), rtrim(), sin() " #. Tag: para #, no-c-format @@ -816,38 +491,23 @@ msgstr "JDBC 风格的参数传入 ?" #. Tag: para #, no-c-format -msgid "" -"named parameters :name, :start_date, " -"and :x1" -msgstr "" -"命名参数 :name:start_date:" -"x1 " +msgid "named parameters :name, :start_date, and :x1" +msgstr "命名参数 :name:start_date:x1 " #. Tag: para #, 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'" +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'" #. Tag: para #, no-c-format -msgid "" -"Java public static final constants eg.Color." -"TABBY" -msgstr "" -"Java public static final 类型的常量 eg.Color." -"TABBY" +msgid "Java public static final constants eg.Color.TABBY" +msgstr "Java public static final 类型的常量 eg.Color.TABBY" #. Tag: para #, no-c-format -msgid "" -"in and between can be used as follows:" -msgstr "" -"关键字 inbetween 可按如下方法使" -"用: " +msgid "in and between can be used as follows:" +msgstr "关键字 inbetween 可按如下方法使用: " #. Tag: para #, no-c-format @@ -856,106 +516,53 @@ msgstr "而且否定的格式也可以如下书写: " #. Tag: para #, no-c-format -msgid "" -"Similarly, is null and is not null can " -"be used to test for null values." -msgstr "" -"同样,子句 is nullis not null 可以" -"被用来测试空值(null)。 " +msgid "Similarly, is null and is not null can be used to test for null values." +msgstr "同样,子句 is nullis not null 可以被用来测试空值(null)。 " #. Tag: para #, no-c-format -msgid "" -"Booleans can be easily used in expressions by declaring HQL query " -"substitutions in Hibernate configuration:" -msgstr "" -"在 Hibernate 配置文件中声明 HQL“查询替代(query substitutions)”之后,布尔表" -"达式(Booleans)可以在其他表达式中轻松的使用: " +msgid "Booleans can be easily used in expressions by declaring HQL query substitutions in Hibernate configuration:" +msgstr "在 Hibernate 配置文件中声明 HQL“查询替代(query substitutions)”之后,布尔表达式(Booleans)可以在其他表达式中轻松的使用: " #. Tag: para #, 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:" +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 语句时,该设置表明将用字符 10 来取代关键字 truefalse:" #. Tag: para #, no-c-format -msgid "" -"You can test the size of a collection with the special property " -"size or the special size() function." -msgstr "" -"你可以用特殊属性 size,或是特殊函数 size() 测试一个集合的大小。 " +msgid "You can test the size of a collection with the special property size or the special size() function." +msgstr "你可以用特殊属性 size,或是特殊函数 size() 测试一个集合的大小。 " #. Tag: para #, no-c-format -msgid "" -"For indexed collections, you can refer to the minimum and maximum indices " -"using minindex and maxindex functions. " -"Similarly, you can refer to the minimum and maximum elements of a collection " -"of basic type using the minelement and " -"maxelement functions. For example:" -msgstr "" -"对于索引了(有序)的集合,你可以使用 minindex 与 " -"maxindex 函数来引用到最小与最大的索引序数。同理,你可以使" -"用 minelementmaxelement 函数来引用" -"到一个基本数据类型的集合中最小与最大的元素。例如:" +msgid "For indexed collections, you can refer to the minimum and maximum indices using minindex and maxindex functions. Similarly, you can refer to the minimum and maximum elements of a collection of basic type using the minelement and maxelement functions. For example:" +msgstr "对于索引了(有序)的集合,你可以使用 minindexmaxindex 函数来引用到最小与最大的索引序数。同理,你可以使用 minelementmaxelement 函数来引用到一个基本数据类型的集合中最小与最大的元素。例如:" #. Tag: para #, 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:" +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 "在传递一个集合的索引集或者是元素集(elementsindices 函数)或者传递一个子查询的结果的时候,可以使用 SQL 函数 any, some,all, exists, in:" #. Tag: para #, no-c-format -msgid "" -"Note that these constructs - size, elements, indices, minindex, " -"maxindex, minelement, " -"maxelement - can only be used in the where clause in " -"Hibernate3." -msgstr "" -"注意,在 Hibernate3 中,这些结构变量 — size," -"elementsindicesminindexmaxindexminelement," -"maxelement — 只能在 where 子句中使用。 " +msgid "Note that these constructs - size, elements, indices, minindex, maxindex, minelement, maxelement - can only be used in the where clause in Hibernate3." +msgstr "注意,在 Hibernate3 中,这些结构变量 — sizeelementsindicesminindexmaxindexminelementmaxelement — 只能在 where 子句中使用。 " #. Tag: para #, no-c-format -msgid "" -"Elements of indexed collections (arrays, lists, and maps) can be referred to " -"by index in a where clause only:" -msgstr "" -"一个被索引过的(有序的)集合的元素(arrays,lists,maps)可以在其他索引中被引" -"用(只能在 where 子句中): " +msgid "Elements of indexed collections (arrays, lists, and maps) can be referred to by index in a where clause only:" +msgstr "一个被索引过的(有序的)集合的元素(arrays,lists,maps)可以在其他索引中被引用(只能在 where 子句中): " #. Tag: para #, no-c-format -msgid "" -"The expression inside [] can even be an arithmetic " -"expression:" +msgid "The expression inside [] can even be an arithmetic expression:" msgstr "在 [] 中的表达式甚至可以是一个算数表达式:" #. Tag: para #, 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() 函数。" +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: para #, no-c-format @@ -964,12 +571,8 @@ msgstr "如果底层数据库支持标量的 SQL 函数,它们也可以被使 #. Tag: para #, no-c-format -msgid "" -"Consider how much longer and less readable the following query would be in " -"SQL:" -msgstr "" -"如果你还不能对所有的这些深信不疑,想想下面的查询。如果使用 SQL,语句长度会增" -"长多少,可读性会下降多少: " +msgid "Consider how much longer and less readable the following query would be in SQL:" +msgstr "如果你还不能对所有的这些深信不疑,想想下面的查询。如果使用 SQL,语句长度会增长多少,可读性会下降多少: " #. Tag: para #, no-c-format @@ -983,21 +586,13 @@ msgstr "order by 子句" #. Tag: para #, no-c-format -msgid "" -"The list returned by a query can be ordered by any property of a returned " -"class or components:" -msgstr "" -"查询返回的列表(list)可以按照一个返回的类或组件(components)中的任何属性" -"(property)进行排序: " +msgid "The list returned by a query can be ordered by any property of a returned class or components:" +msgstr "查询返回的列表(list)可以按照一个返回的类或组件(components)中的任何属性(property)进行排序: " #. Tag: para #, no-c-format -msgid "" -"The optional asc or desc indicate " -"ascending or descending order respectively." -msgstr "" -"可选的 ascdesc 关键字指明了按照升序" -"或降序进行排序。" +msgid "The optional asc or desc indicate ascending or descending order respectively." +msgstr "可选的 ascdesc 关键字指明了按照升序或降序进行排序。" #. Tag: title #, no-c-format @@ -1006,12 +601,8 @@ msgstr "group by 子句" #. Tag: para #, no-c-format -msgid "" -"A query that returns aggregate values can be grouped by any property of a " -"returned class or components:" -msgstr "" -"一个返回聚集值(aggregate values)的查询可以按照一个返回的类或组件" -"(components)中的任何属性(property)进行分组: " +msgid "A query that returns aggregate values can be grouped by any property of a returned class or components:" +msgstr "一个返回聚集值(aggregate values)的查询可以按照一个返回的类或组件(components)中的任何属性(property)进行分组: " #. Tag: para #, no-c-format @@ -1020,29 +611,13 @@ msgstr "having 子句在这里也允许使用。" #. Tag: para #, no-c-format -msgid "" -"SQL functions and aggregate functions are allowed in the having and order by clauses if they are supported by " -"the underlying database (i.e., not in MySQL)." -msgstr "" -"如果底层的数据库支持的话(例如不能在 MySQL 中使用),SQL 的一般函数与聚集函数" -"也可以出现在 havingorder by 子句" -"中。 " +msgid "SQL functions and aggregate functions are allowed in the having and order by clauses if they are supported by the underlying database (i.e., not in MySQL)." +msgstr "如果底层的数据库支持的话(例如不能在 MySQL 中使用),SQL 的一般函数与聚集函数也可以出现在 havingorder by 子句中。 " #. Tag: para #, no-c-format -msgid "" -"Neither the group by clause nor the order by clause can contain arithmetic expressions. Hibernate also does not " -"currently expand a grouped entity, so you cannot 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)。你必须明确的" -"列出所有的非聚集属性。 " +msgid "Neither the group by clause nor the order by clause can contain arithmetic expressions. Hibernate also does not currently expand a grouped entity, so you cannot 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)。你必须明确的列出所有的非聚集属性。 " #. Tag: title #, no-c-format @@ -1051,15 +626,8 @@ msgstr "子查询" #. Tag: para #, no-c-format -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 "" -"对于支持子查询的数据库,Hibernate 支持在查询中使用子查询。一个子查询必须被圆" -"括号包围起来(经常是 SQL 聚集函数的圆括号)。甚至相互关联的子查询(引用到外部" -"查询中的别名的子查询)也是允许的。" +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 "对于支持子查询的数据库,Hibernate 支持在查询中使用子查询。一个子查询必须被圆括号包围起来(经常是 SQL 聚集函数的圆括号)。甚至相互关联的子查询(引用到外部查询中的别名的子查询)也是允许的。" #. Tag: para #, no-c-format @@ -1067,14 +635,9 @@ msgid "Note that HQL subqueries can occur only in the select or where clauses." msgstr "注意,HQL 自查询只可以在 select 或者 where 子句中出现。 " #. Tag: para -#, fuzzy, no-c-format -msgid "" -"Note that subqueries can also utilize row value constructor syntax. See for more " -"information." -msgstr "" -"注意子查询也可以利用 row value constructor 语法。请参考 " -" 来获得详情。 " +#, no-c-format +msgid "Note that subqueries can also utilize row value constructor syntax. See for more information." +msgstr "注意子查询也可以利用 row value constructor 语法。请参考 来获得详情。" #. Tag: title #, no-c-format @@ -1083,90 +646,37 @@ msgstr "HQL 示例 " #. Tag: para #, no-c-format -msgid "" -"Hibernate queries can be quite powerful and complex. In fact, the power of " -"the query language is one of Hibernate's main strengths. The following " -"example queries are similar to queries that have been used on recent " -"projects. Please note that most queries you will write will be much simpler " -"than the following examples." -msgstr "" -"Hibernate 查询可以非常的强大与复杂。实际上,Hibernate 的一个主要卖点就是查询" -"语句的威力。这里有一些例子,它们与我在最近的一个项目中使用的查询非常相似。注" -"意你能用到的大多数查询比这些要简单的多。" +msgid "Hibernate queries can be quite powerful and complex. In fact, the power of the query language is one of Hibernate's main strengths. The following example queries are similar to queries that have been used on recent projects. Please note that most queries you will write will be much simpler than the following examples." +msgstr "Hibernate 查询可以非常的强大与复杂。实际上,Hibernate 的一个主要卖点就是查询语句的威力。这里有一些例子,它们与我在最近的一个项目中使用的查询非常相似。注意你能用到的大多数查询比这些要简单的多。" #. Tag: para #, no-c-format -msgid "" -"The following query returns the order id, number of items, the given minimum " -"total value and the total value of the order for all unpaid orders for a " -"particular customer. The results are ordered 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 查询,使用了ORDERORDER_LINEPRODUCT," -"CATALOGPRICE 库表。" +msgid "The following query returns the order id, number of items, the given minimum total value and the total value of the order for all unpaid orders for a particular customer. The results are ordered 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 查询,使用了ORDERORDER_LINEPRODUCTCATALOGPRICE 库表。" #. Tag: para #, no-c-format -msgid "" -"What a monster! Actually, in real life, I'm not very keen on subqueries, so " -"my query was really more like this:" -msgstr "" -"这简直是一个怪物!实际上,在现实生活中,我并不热衷于子查询,所以我的查询语句" -"看起来更像这个:" +msgid "What a monster! Actually, in real life, I'm not very keen on subqueries, so my query was really more like this:" +msgstr "这简直是一个怪物!实际上,在现实生活中,我并不热衷于子查询,所以我的查询语句看起来更像这个:" #. Tag: para #, 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 " -"查询,该查询使用了表 PAYMENTPAYMENT_STATUS 以及 PAYMENT_STATUS_CHANGE。" +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 查询,该查询使用了表 PAYMENTPAYMENT_STATUS 以及 PAYMENT_STATUS_CHANGE。" #. Tag: para #, no-c-format -msgid "" -"If the statusChanges collection was mapped as a list, " -"instead of a set, the query would have been much simpler to write." -msgstr "" -"如果我把 statusChanges 实例集映射为一个列表(list)而不是" -"一个集合(set),书写查询语句将更加简单。 " +msgid "If the statusChanges collection was mapped as a list, instead of a set, the query would have been much simpler to write." +msgstr "如果我把 statusChanges 实例集映射为一个列表(list)而不是一个集合(set),书写查询语句将更加简单。 " #. Tag: para #, 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() 函数用以返回" -"当前用户所属组织的组织帐号及组织未支付的账。它被转换成一个对表 " -"ACCOUNTPAYMENT," -"PAYMENT_STATUSACCOUNT_TYPE," -"ORGANIZATION 以及 ORG_USER 进行的三个" -"内连接,一个外连接和一个子选择的 SQL 查询。" +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() 函数用以返回当前用户所属组织的组织帐号及组织未支付的账。它被转换成一个对表 ACCOUNTPAYMENTPAYMENT_STATUSACCOUNT_TYPEORGANIZATION 以及 ORG_USER 进行的三个内连接,一个外连接和一个子选择的 SQL 查询。" #. Tag: para #, no-c-format -msgid "" -"For some databases, we would need to do away with the (correlated) subselect." +msgid "For some databases, we would need to do away with the (correlated) subselect." msgstr "对于一些数据库,我们需要弃用(相关的)子选择。" #. Tag: title @@ -1175,15 +685,9 @@ msgid "Bulk update and delete" msgstr "批量的 UPDATE 和 DELETE" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"HQL now supports update, delete and " -"insert ... select ... statements. See for more information." -msgstr "" -"HQL 现在支持 updatedelete 和 " -"insert ... select ...语句。查阅 以获得更多信息。" +#, no-c-format +msgid "HQL now supports update, delete and insert ... select ... statements. See for more information." +msgstr "HQL 现在支持 updatedeleteinsert ... select ...语句。查阅 以获得更多信息。 " #. Tag: title #, no-c-format @@ -1202,12 +706,8 @@ msgstr "若想根据一个集合的大小来进行排序,可以使用如下的 #. Tag: para #, 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)指定一个条件:" +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: para #, no-c-format @@ -1216,12 +716,8 @@ msgstr "如果你的数据库不支持子选择语句,使用下面的查询: #. Tag: para #, no-c-format -msgid "" -"As this solution cannot return a User with zero messages " -"because of the inner join, the following form is also useful:" -msgstr "" -"因为内连接(inner join)的原因,这个解决方案不能返回含有零个信息的 " -"User 类的实例,所以这种情况下使用下面的格式将是有帮助的: " +msgid "As this solution cannot return a User with zero messages because of the inner join, the following form is also useful:" +msgstr "因为内连接(inner join)的原因,这个解决方案不能返回含有零个信息的 User 类的实例,所以这种情况下使用下面的格式将是有帮助的: " #. Tag: para #, no-c-format @@ -1230,18 +726,13 @@ msgstr "JavaBean 的属性可以被绑定到一个命名查询(named query) #. Tag: para #, no-c-format -msgid "" -"Collections are pageable by using the Query interface " -"with a filter:" -msgstr "" -"通过将接口 Query 与一个过滤器(filter)一起使用,集合" -"(Collections)是可以分页的:" +msgid "Collections are pageable by using the Query interface with a filter:" +msgstr "通过将接口 Query 与一个过滤器(filter)一起使用,集合(Collections)是可以分页的:" #. Tag: para #, no-c-format msgid "Collection elements can be ordered or grouped using a query filter:" -msgstr "" -"通过使用查询过滤器(query filter)可以将集合(Collection)的元素分组或排序: " +msgstr "通过使用查询过滤器(query filter)可以将集合(Collection)的元素分组或排序: " #. Tag: para #, no-c-format @@ -1255,22 +746,13 @@ msgstr "组件" #. Tag: para #, no-c-format -msgid "" -"Components can be used similarly to the simple value types that are used in " -"HQL queries. They can appear in the select clause as " -"follows:" -msgstr "" -"在 HQL 查询里,组件可以和简单值类型一样使用。它们可以出现在 select 子句里: " +msgid "Components can be used similarly to the simple value types that are used in HQL queries. They can appear in the select clause as follows:" +msgstr "在 HQL 查询里,组件可以和简单值类型一样使用。它们可以出现在 select 子句里: " #. Tag: para #, no-c-format -msgid "" -"where the Person's name property is a component. Components can also be used " -"in the where clause:" -msgstr "" -"在这里,Person 的 name 属性是一个组件。组件也可以用在 where 子句里:" +msgid "where the Person's name property is a component. Components can also be used in the where clause:" +msgstr "在这里,Person 的 name 属性是一个组件。组件也可以用在 where 子句里:" #. Tag: para #, no-c-format @@ -1278,13 +760,9 @@ msgid "Components can also be used in the order by clause:" msgstr "组件也可以用在 order by 子句里:" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"Another common use of components is in row " -"value constructors." -msgstr "" -"组件的另外一个常见用法是在 行值(row " -"value)构造函数里。" +#, no-c-format +msgid "Another common use of components is in row value constructors." +msgstr "组件的另外一个常见用法是在 行值(row value)构造函数里。 " #. Tag: title #, no-c-format @@ -1293,52 +771,28 @@ msgstr "Row value 构造函数语法" #. Tag: para #, no-c-format -msgid "" -"HQL supports the use of ANSI SQL row value constructor " -"syntax, sometimes referred to AS 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 "" -"HQL 支持 ANSI SQL row value constructor 语法(有时也叫作 " -"tuple 语法),即使底层数据库可能不支持这个概念。在这里我们" -"通常指的是多值(multi-valued)的比较,典型地是和组件相关联。来看看一个定义了 " -"name 组件的实体 Person:" +msgid "HQL supports the use of ANSI SQL row value constructor syntax, sometimes referred to AS 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 "HQL 支持 ANSI SQL row value constructor 语法(有时也叫作 tuple 语法),即使底层数据库可能不支持这个概念。在这里我们通常指的是多值(multi-valued)的比较,典型地是和组件相关联。来看看一个定义了 name 组件的实体 Person:" #. Tag: para #, no-c-format -msgid "" -"That is valid syntax although it is a little verbose. You can make this more " -"concise by using row value constructor syntax:" -msgstr "" -"那是有效的语法,虽然有点冗长。我们可以使它更加简洁一点,并使用 row " -"value constructor 语法: " +msgid "That is valid syntax although it is a little verbose. You can make this more concise by using row value constructor syntax:" +msgstr "那是有效的语法,虽然有点冗长。我们可以使它更加简洁一点,并使用 row value constructor 语法: " #. Tag: para #, no-c-format -msgid "" -"It can also be useful to specify this in the select " -"clause:" +msgid "It can also be useful to specify this in the select clause:" msgstr "在 select 子句里指定这个也是很有用的:" #. Tag: para #, no-c-format -msgid "" -"Using row value constructor syntax can also be beneficial " -"when using subqueries that need to compare against multiple values:" -msgstr "" -"当使用需要比较多个值的子查询时,采用 row value constructor 语法也很有用处: " +msgid "Using row value constructor syntax can also be beneficial when using subqueries that need to compare against multiple values:" +msgstr "当使用需要比较多个值的子查询时,采用 row value constructor 语法也很有用处: " #. Tag: para #, 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 "" -"决定是否使用这个语法的一件因素就是:这个查询将依赖于元数据里的组件子属性" -"(sub-properties)的顺序。 " +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 "决定是否使用这个语法的一件因素就是:这个查询将依赖于元数据里的组件子属性(sub-properties)的顺序。 " #, fuzzy #~ msgid "" @@ -1381,10 +835,8 @@ msgstr "" #, fuzzy #~ msgid "" #~ msgstr "from Formula form full join form.parameter param" - #~ msgid "inner join" #~ msgstr "inner join(内连接)" - #~ msgid "left outer join" #~ msgstr "left outer join(左外连接)" @@ -1539,7 +991,6 @@ msgstr "" #~ msgstr "" #~ "select avg(cat.weight), sum(cat.weight), max(cat.weight), count(cat)\n" #~ "from Cat cat" - #~ msgid "count(*)" #~ msgstr "count(*)" @@ -2279,3 +1730,4 @@ msgstr "" #~ "where not ( cat.name, cat.color ) in (\n" #~ " select cat.name, cat.color from DomesticCat cat\n" #~ ")" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/query_sql.po b/documentation/manual/src/main/docbook/zh-CN/content/query_sql.po index dfaadb764c..978d713d42 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/query_sql.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/query_sql.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Collection_Mapping\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-03-12T00:03:47\n" -"PO-Revision-Date: 2010-01-11 10:42+1000\n" +"PO-Revision-Date: 2010-03-16 10:16+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,26 +21,13 @@ msgstr "Native SQL 查询" #. Tag: para #, no-c-format -msgid "" -"You can 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 应用的道路上的障碍。 " +msgid "You can 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 应用的道路上的障碍。 " #. Tag: para #, 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 " -"操作(包括存储过程) " +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 操作(包括存储过程) " #. Tag: title #, no-c-format @@ -49,15 +36,8 @@ msgstr "使用 SQLQuery" #. Tag: para #, no-c-format -msgid "" -"Execution of native SQL queries is controlled via the SQLQuery interface, which is obtained by calling Session." -"createSQLQuery(). The following sections describe how to use this " -"API for querying." -msgstr "" -"对原生 SQL 查询执行的控制是通过 SQLQuery 接口进行的,通过" -"执行Session.createSQLQuery()获取这个接口。下面来描述如何使" -"用这个 API 进行查询。 " +msgid "Execution of native SQL queries is controlled via the SQLQuery interface, which is obtained by calling Session.createSQLQuery(). The following sections describe how to use this API for querying." +msgstr "对原生 SQL 查询执行的控制是通过 SQLQuery 接口进行的,通过执行Session.createSQLQuery()获取这个接口。下面来描述如何使用这个 API 进行查询。 " #. Tag: title #, no-c-format @@ -71,24 +51,13 @@ msgstr "最基本的 SQL 查询就是获得一个标量(数值)的列表。" #. Tag: para #, no-c-format -msgid "" -"These will 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 来判定返回的标量值的实际顺序" -"和类型。 " +msgid "These will 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 #, 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(): " +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: para #, no-c-format @@ -107,48 +76,23 @@ msgstr "要返回的字段和类型" #. Tag: para #, no-c-format -msgid "" -"This will return Object arrays, but now it will not use " -"ResultSetMetadata 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 是使用 * 来" -"查询的,可能获得超过列出的这三个字段,也仅仅会返回这三个字段。 " +msgid "This will return Object arrays, but now it will not use ResultSetMetadata 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 #, no-c-format -msgid "" -"It is possible to leave out the type information for all or some of the " -"scalars." +msgid "It is possible to leave out the type information for all or some of the scalars." msgstr "对全部或者部分的标量值不设置类型信息也是可以的。" #. Tag: para #, no-c-format -msgid "" -"This is essentially the same query as before, but now " -"ResultSetMetaData is used to determine the type of NAME " -"and BIRTHDATE, where as the type of ID is explicitly specified." -msgstr "" -"基本上这和前面一个查询相同,只是此时使用 ResultSetMetaData " -"来决定 NAME 和 BIRTHDATE 的类型,而 ID 的类型是明确指出的。 " +msgid "This is essentially the same query as before, but now ResultSetMetaData is used to determine the type of NAME and BIRTHDATE, where as the type of ID is explicitly specified." +msgstr "基本上这和前面一个查询相同,只是此时使用 ResultSetMetaData 来决定 NAME 和 BIRTHDATE 的类型,而 ID 的类型是明确指出的。 " #. Tag: para #, 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 调用自行定" -"义。 " +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 调用自行定义。 " #. Tag: title #, no-c-format @@ -157,14 +101,8 @@ msgstr "实体查询(Entity queries)" #. Tag: para #, 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() 让原生查询返回实体对象。" +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: para #, no-c-format @@ -173,29 +111,13 @@ msgstr "要返回的实体" #. Tag: para #, 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 实体。" +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 #, 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 的" -"例子:" +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: para #, no-c-format @@ -209,43 +131,18 @@ msgstr "处理关联和集合类(Handling associations and collections)" #. Tag: para #, 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() 方法进行的,这个方法可" -"以让你将关联或集合连接进来。" +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() 方法进行的,这个方法可以让你将关联或集合连接进来。" #. Tag: para #, 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 you added an 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 的一" -"对多关联。 " +msgid "In this example, the returned Cat's will have their dog property fully initialized without any extra roundtrip to the database. Notice that you added an 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: para #, no-c-format -msgid "" -"At this stage you are reaching the limits of what is possible with native " -"queries, without starting to enhance the sql queries to make them usable in " -"Hibernate. Problems can arise when returning multiple entities of the same " -"type or when the default alias/column names are not enough." -msgstr "" -"到此为止,我们碰到了天花板:若不对 SQL 查询进行增强,这些已经是在 Hibernate " -"中使用原生 SQL 查询所能做到的最大可能了。下面的问题即将出现:返回多个同样类型" -"的实体怎么办?或者默认的别名/字段不够又怎么办? " +msgid "At this stage you are reaching the limits of what is possible with native queries, without starting to enhance the sql queries to make them usable in Hibernate. Problems can 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 #, no-c-format @@ -254,36 +151,18 @@ msgstr "返回多个实体(Returning multiple entities)" #. Tag: para #, 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 that join multiple tables, since the same column names can " -"appear in more than one table." -msgstr "" -"到目前为止,结果集字段名被假定为和映射文件中指定的的字段名是一致的。假若 SQL " -"查询连接了多个表,同一个字段名可能在多个表中出现多次,这就会造成问题。 " +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 that join multiple tables, since the same column names can appear in more than one table." +msgstr "到目前为止,结果集字段名被假定为和映射文件中指定的的字段名是一致的。假若 SQL 查询连接了多个表,同一个字段名可能在多个表中出现多次,这就会造成问题。 " #. Tag: para #, no-c-format -msgid "" -"Column alias injection is needed in the following query (which most likely " -"will fail):" +msgid "Column alias injection is needed in the following query (which most likely will fail):" msgstr "下面的查询中需要使用字段别名注射(这个例子本身会失败):" #. Tag: para #, no-c-format -msgid "" -"The query was intended to return two Cat instances per row: a cat and its " -"mother. The query will, however, fail because there is a conflict of names; " -"the instances are mapped to the same column names. Also, 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 specified in the mappings " -"(\"ID\" and \"NAME\")." -msgstr "" -"这个查询的本意是希望每行返回两个 Cat 实例,一个是 cat,另一个是它的妈妈。但是" -"因为它们的字段名被映射为相同的,而且在某些数据库中,返回的字段别名是“c.ID”," -"\"c.NAME\" 这样的形式,而它们和在映射文件中的名字(\"ID\" 和 \"NAME\")不匹" -"配,这就会造成失败。 " +msgid "The query was intended to return two Cat instances per row: a cat and its mother. The query will, however, fail because there is a conflict of names; the instances are mapped to the same column names. Also, 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 specified in the mappings (\"ID\" and \"NAME\")." +msgstr "这个查询的本意是希望每行返回两个 Cat 实例,一个是 cat,另一个是它的妈妈。但是因为它们的字段名被映射为相同的,而且在某些数据库中,返回的字段别名是“c.ID”,\"c.NAME\" 这样的形式,而它们和在映射文件中的名字(\"ID\" 和 \"NAME\")不匹配,这就会造成失败。 " #. Tag: para #, no-c-format @@ -292,9 +171,7 @@ msgstr "下面的形式可以解决字段名重复:" #. Tag: para #, no-c-format -msgid "" -"the SQL query string, with placeholders for Hibernate to inject column " -"aliases" +msgid "the SQL query string, with placeholders for Hibernate to inject column aliases" msgstr "SQL 查询语句,其中包含占位附来让 Hibernate 注射字段别名" #. Tag: para @@ -304,20 +181,8 @@ msgstr "查询返回的实体" #. Tag: para #, no-c-format -msgid "" -"The {cat.*} and {mother.*} notation used above is a shorthand for \"all " -"properties\". Alternatively, you can list the columns explicitly, but even " -"in this case Hibernate injects 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, you retrieve Cats and their mothers " -"from a different table (cat_log) to the one declared in the mapping " -"metadata. You can even use the property aliases in the where clause." -msgstr "" -"上面使用的 {cat.*} 和 {mother.*} 标记是作为“所有属性”的简写形式出现的。当然你" -"也可以明确地罗列出字段名,但在这个例子里面我们让 Hibernate 来为每个属性注射 " -"SQL 字段别名。字段别名的占位符是属性名加上表别名的前缀。在下面的例子中,我们" -"从另外一个表(cat_log)中通过映射元数据中的指定获取 Cat 和它的妈妈。注意,要" -"是我们愿意,我们甚至可以在 where 子句中使用属性别名。 " +msgid "The {cat.*} and {mother.*} notation used above is a shorthand for \"all properties\". Alternatively, you can list the columns explicitly, but even in this case Hibernate injects 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, you retrieve Cats and their mothers from a different table (cat_log) to the one declared in the mapping metadata. You can even use the property aliases in the where clause." +msgstr "上面使用的 {cat.*} 和 {mother.*} 标记是作为“所有属性”的简写形式出现的。当然你也可以明确地罗列出字段名,但在这个例子里面我们让 Hibernate 来为每个属性注射 SQL 字段别名。字段别名的占位符是属性名加上表别名的前缀。在下面的例子中,我们从另外一个表(cat_log)中通过映射元数据中的指定获取 Cat 和它的妈妈。注意,要是我们愿意,我们甚至可以在 where 子句中使用属性别名。 " #. Tag: title #, no-c-format @@ -326,26 +191,13 @@ msgstr "别名和属性引用(Alias and property references)" #. Tag: para #, no-c-format -msgid "" -"In most cases the above alias injection is needed. For queries relating to " -"more complex mappings, like composite properties, inheritance " -"discriminators, collections etc., you can use specific aliases that allow " -"Hibernate to inject the proper aliases." -msgstr "" -"大多数情况下,都需要上面的属性注射,但在使用更加复杂的映射,比如复合属性、通" -"过标识符构造继承树,以及集合类等等情况下,也有一些特别的别名,来允许 " -"Hibernate 注入合适的别名。 " +msgid "In most cases the above alias injection is needed. For queries relating to more complex mappings, like composite properties, inheritance discriminators, collections etc., you can use specific aliases that allow Hibernate to inject the proper aliases." +msgstr "大多数情况下,都需要上面的属性注射,但在使用更加复杂的映射,比如复合属性、通过标识符构造继承树,以及集合类等等情况下,也有一些特别的别名,来允许 Hibernate 注入合适的别名。 " #. Tag: para #, no-c-format -msgid "" -"The following table shows the different ways you can use the alias " -"injection. Please note that the alias names in the result are simply " -"examples; each alias will have a unique and probably different name when " -"used." -msgstr "" -"下表列出了使用别名注射参数的不同可能性。注意:下面结果中的别名只是示例,实用" -"时每个别名需要唯一并且不同的名字。 " +msgid "The following table shows the different ways you can use the alias injection. Please note that the alias names in the result are simply examples; each alias will have a unique and probably different name when used." +msgstr "下表列出了使用别名注射参数的不同可能性。注意:下面结果中的别名只是示例,实用时每个别名需要唯一并且不同的名字。 " #. Tag: title #, no-c-format @@ -373,14 +225,14 @@ msgid "A simple property" msgstr "简单属性" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "{[aliasname].[propertyname]" -msgstr "{[aliasname].[propertyname]" +msgstr "{[aliasname].[propertyname] " #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "A_NAME as {item.name}" -msgstr "{item.*}" +msgstr "A_NAME as {item.name}" #. Tag: entry #, no-c-format @@ -388,18 +240,14 @@ msgid "A composite property" msgstr "复合属性" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "{[aliasname].[componentname].[propertyname]}" -msgstr "{[aliasname].[componentname].[propertyname]}" +msgstr "{[aliasname].[componentname].[propertyname]} " #. Tag: entry -#, fuzzy, no-c-format -msgid "" -"CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}" -msgstr "" -"CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}" +#, no-c-format +msgid "CURRENCY as {item.amount.currency}, VALUE as {item.amount.value}" +msgstr "CURRENCY as {item.amount.currency}, VALUE as {item.amount.value} " #. Tag: entry #, no-c-format @@ -407,14 +255,14 @@ msgid "Discriminator of an entity" msgstr "实体辨别器(Discriminator of an entity)" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "{[aliasname].class}" -msgstr "{item.*}" +msgstr "{[aliasname].class}" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "DISC as {item.class}" -msgstr "{item.*}" +msgstr "DISC as {item.class}" #. Tag: entry #, no-c-format @@ -422,9 +270,9 @@ msgid "All properties of an entity" msgstr "实体的所有属性" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "{[aliasname].*}" -msgstr "{item.*}" +msgstr "{[aliasname].*}" #. Tag: entry #, no-c-format @@ -437,14 +285,14 @@ msgid "A collection key" msgstr "集合键(collection key)" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "{[aliasname].key}" -msgstr "{item.*}" +msgstr "{[aliasname].key}" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "ORGID as {coll.key}" -msgstr "{coll.*}" +msgstr "ORGID as {coll.key}" #. Tag: entry #, no-c-format @@ -452,14 +300,14 @@ msgid "The id of an collection" msgstr "集合 id" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "{[aliasname].id}" -msgstr "{item.*}" +msgstr "{[aliasname].id}" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "EMPID as {coll.id}" -msgstr "{coll.*}" +msgstr "EMPID as {coll.id}" #. Tag: entry #, no-c-format @@ -467,14 +315,14 @@ msgid "The element of an collection" msgstr "集合元素" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "{[aliasname].element}" -msgstr "{coll.element.*}" +msgstr "{[aliasname].element}" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "XID as {coll.element}" -msgstr "{coll.element.*}" +msgstr "XID as {coll.element}" #. Tag: entry #, no-c-format @@ -482,14 +330,14 @@ msgid "property of the element in the collection" msgstr "集合元素的属性 " #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "{[aliasname].element.[propertyname]}" -msgstr "{[aliasname].element.[propertyname]}" +msgstr "{[aliasname].element.[propertyname]} " #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "NAME as {coll.element.name}" -msgstr "{coll.element.*}" +msgstr "NAME as {coll.element.name}" #. Tag: entry #, no-c-format @@ -497,9 +345,9 @@ msgid "All properties of the element in the collection" msgstr "集合元素的所有属性" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "{[aliasname].element.*}" -msgstr "{coll.element.*}" +msgstr "{[aliasname].element.*}" #. Tag: entry #, no-c-format @@ -507,9 +355,9 @@ msgid "{coll.element.*}" msgstr "{coll.element.*}" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "All properties of the collection" -msgstr "集合的所有属性" +msgstr "集合的所有属性 " #. Tag: entry #, no-c-format @@ -523,12 +371,8 @@ msgstr "返回非受管实体(Returning non-managed entities)" #. Tag: para #, no-c-format -msgid "" -"It is possible to apply a ResultTransformer to native SQL queries, allowing " -"it to return non-managed entities." -msgstr "" -"可以对原生 sql 查询使用 ResultTransformer。这会返回不受 Hibernate 管理的实" -"体。 " +msgid "It is possible to apply a ResultTransformer to native SQL queries, allowing it to return non-managed entities." +msgstr "可以对原生 sql 查询使用 ResultTransformer。这会返回不受 Hibernate 管理的实体。 " #. Tag: para #, no-c-format @@ -537,13 +381,8 @@ msgstr "结果转换器(result transformer)" #. Tag: para #, 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 的值注射入对应的属性或者字段。" +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 的值注射入对应的属性或者字段。" #. Tag: title #, no-c-format @@ -552,13 +391,8 @@ msgstr "处理继承(Handling inheritance)" #. Tag: para #, no-c-format -msgid "" -"Native SQL queries which query for entities that are mapped as part of an " -"inheritance must include all properties for the baseclass and all its " -"subclasses." -msgstr "" -"原生 SQL 查询假若其查询结果实体是继承树中的一部分,它必须包含基类和所有子类的" -"所有属性。 " +msgid "Native SQL queries which query for entities that are mapped as part of an inheritance must include all properties for the baseclass and all its subclasses." +msgstr "原生 SQL 查询假若其查询结果实体是继承树中的一部分,它必须包含基类和所有子类的所有属性。 " #. Tag: title #, no-c-format @@ -577,52 +411,27 @@ msgstr "命名 SQL 查询" #. Tag: para #, no-c-format -msgid "" -"Named SQL queries can be defined in the mapping document and called in " -"exactly the same way as a named HQL query. In this case, you do " -"not need to call addEntity()." -msgstr "" -"可以在映射文档中定义查询的名字,然后就可以象调用一个命名的 HQL 查询一样直接调" -"用命名 SQL 查询.在这种情况下,我们 需要调用 " -"addEntity() 方法。 " +msgid "Named SQL queries can be defined in the mapping document and called in exactly the same way as a named HQL query. In this case, you do not need to call addEntity()." +msgstr "可以在映射文档中定义查询的名字,然后就可以象调用一个命名的 HQL 查询一样直接调用命名 SQL 查询.在这种情况下,我们 需要调用 addEntity() 方法。 " #. Tag: para #, no-c-format -msgid "" -"The <return-join> element is use to join " -"associations and the <load-collection> element is " -"used to define queries which initialize collections," -msgstr "" -"<return-join><load-collection> 元素是用来连接关联以及将查询定义为预先初始化各个集合的。 " +msgid "The <return-join> element is use to join associations and the <load-collection> element is used to define queries which initialize collections," +msgstr "<return-join><load-collection> 元素是用来连接关联以及将查询定义为预先初始化各个集合的。 " #. Tag: para #, 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 类型:" +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: para #, no-c-format -msgid "" -"You can externalize the resultset mapping information in a <" -"resultset> element which will allow you to either reuse them " -"across several named queries or through the setResultSetMapping() API." -msgstr "" -"你可以把结果集映射的信息放在外部的 <resultset> 元素" -"中,这样就可以在多个命名查询间,或者通过 setResultSetMapping() API 来访问。 " +msgid "You can externalize the resultset mapping information in a <resultset> element which will allow you to either reuse them across several named queries or through the setResultSetMapping() API." +msgstr "你可以把结果集映射的信息放在外部的 <resultset> 元素中,这样就可以在多个命名查询间,或者通过 setResultSetMapping() API 来访问。 " #. Tag: para #, no-c-format -msgid "" -"You can, alternatively, use the resultset mapping information in your hbm " -"files directly in java code." +msgid "You can, alternatively, use the resultset mapping information in your hbm files directly in java code." msgstr "另外,你可以在 java 代码中直接使用 hbm 文件中的结果集定义信息。 " #. Tag: title @@ -632,43 +441,23 @@ msgstr "使用 return-property 来明确地指定字段/别名" #. Tag: para #, no-c-format -msgid "" -"You can explicitly tell Hibernate what column aliases to use with " -"<return-property>, instead of using the {}" -"-syntax to let Hibernate inject its own aliases.For example:" -msgstr "" -"使用 <return-property> 你可以明确的告诉 Hibernate 使" -"用哪些字段别名,这取代了使用 {}-语法 来让 Hibernate 注入它" -"自己的别名。例如:" +msgid "You can explicitly tell Hibernate what column aliases to use with <return-property>, instead of using the {}-syntax to let Hibernate inject its own aliases.For example:" +msgstr "使用 <return-property> 你可以明确的告诉 Hibernate 使用哪些字段别名,这取代了使用 {}-语法 来让 Hibernate 注入它自己的别名。例如:" #. Tag: para #, no-c-format -msgid "" -"<return-property> also works with multiple columns. " -"This solves a limitation with the {}-syntax which cannot " -"allow fine grained control of multi-column properties." -msgstr "" -"<return-property> 也可用于多个字段,它解决了使用 " -"{}-语法不能细粒度控制多个字段的限制。 " +msgid "<return-property> also works with multiple columns. This solves a limitation with the {}-syntax which cannot allow fine grained control of multi-column properties." +msgstr "<return-property> 也可用于多个字段,它解决了使用 {}-语法不能细粒度控制多个字段的限制。 " #. Tag: para #, no-c-format -msgid "" -"In this example <return-property> was used in " -"combination with the {}-syntax for injection. This allows " -"users to choose how they want to refer column and properties." -msgstr "" -"注意在这个例子中,我们使用了 <return-property> 结合 " -"{} 的注入语法。允许用户来选择如何引用字段以及属性。 " +msgid "In this example <return-property> was used in combination with the {}-syntax for injection. This allows users to choose how they want to refer column and properties." +msgstr "注意在这个例子中,我们使用了 <return-property> 结合 {} 的注入语法。允许用户来选择如何引用字段以及属性。 " #. Tag: para #, no-c-format -msgid "" -"If your mapping has a discriminator you must use <return-" -"discriminator> to specify the discriminator column." -msgstr "" -"如果你映射一个识别器(discriminator),你必须使用 <return-" -"discriminator> 来指定识别器字段。" +msgid "If your mapping has a discriminator you must use <return-discriminator> to specify the discriminator column." +msgstr "如果你映射一个识别器(discriminator),你必须使用 <return-discriminator> 来指定识别器字段。" #. Tag: title #, no-c-format @@ -677,17 +466,8 @@ msgstr "使用存储过程来查询" #. Tag: para #, no-c-format -msgid "" -"Hibernate3 provides 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 和更高版本的存储过程例" -"子。 " +msgid "Hibernate3 provides 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: para #, no-c-format @@ -696,13 +476,8 @@ msgstr "在 Hibernate 里要要使用这个查询,你需要通过命名查询 #. Tag: para #, no-c-format -msgid "" -"Stored procedures currently only return scalars and entities. <" -"return-join> and <load-collection> are " -"not supported." -msgstr "" -"注意存储过程当前仅仅返回标量和实体现在。不支持 <return-join><load-collection>。 " +msgid "Stored procedures currently only return scalars and entities. <return-join> and <load-collection> are not supported." +msgstr "注意存储过程当前仅仅返回标量和实体现在。不支持 <return-join><load-collection>。 " #. Tag: title #, no-c-format @@ -711,38 +486,18 @@ msgstr "使用存储过程的规则和限制" #. Tag: para #, no-c-format -msgid "" -"You cannot use stored procedures with Hibernate unless you follow some " -"procedure/function 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() 来执行他们。这些规则针对于不同的数据库。因为数据库提供商有各种不同的" -"存储过程语法和语义。 " +msgid "You cannot use stored procedures with Hibernate unless you follow some procedure/function 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() 来执行他们。这些规则针对于不同的数据库。因为数据库提供商有各种不同的存储过程语法和语义。 " #. Tag: para #, no-c-format -msgid "" -"Stored procedure queries cannot be paged with setFirstResult()/" -"setMaxResults()." -msgstr "" -"对存储过程进行的查询无法使用 setFirstResult()/setMaxResults() 进行分页。 " +msgid "Stored procedure queries cannot be paged with setFirstResult()/setMaxResults()." +msgstr "对存储过程进行的查询无法使用 setFirstResult()/setMaxResults() 进行分页。 " #. Tag: para #, no-c-format -msgid "" -"The 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>) }。原生调用语法不被支持。 " +msgid "The 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>) }。原生调用语法不被支持。 " #. Tag: para #, no-c-format @@ -751,17 +506,8 @@ msgstr "对于 Oracle 有如下规则:" #. Tag: para #, 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 for further information." -msgstr "" -"函数必须返回一个结果集。存储过程的第一个参数必须是 OUT,它" -"返回一个结果集。这是通过 Oracle 9 或 10 的 SYS_REFCURSOR " -"类型来完成的。在 Oracle 中你需要定义一个 REF CURSOR 类型," -"参见 Oracle 的手册。 " +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 for further information." +msgstr "函数必须返回一个结果集。存储过程的第一个参数必须是 OUT,它返回一个结果集。这是通过 Oracle 9 或 10 的 SYS_REFCURSOR 类型来完成的。在 Oracle 中你需要定义一个 REF CURSOR 类型,参见 Oracle 的手册。 " #. Tag: para #, no-c-format @@ -770,23 +516,13 @@ msgstr "对于 Sybase 或者 MS SQL server 有如下规则:" #. Tag: para #, no-c-format -msgid "" -"The procedure must return a result set. Note that since these servers can " -"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 将取出第一条结果集作为它的返回值,其他将被丢弃。 " +msgid "The procedure must return a result set. Note that since these servers can 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 将取出第一条结果集作为它的返回值,其他将被丢弃。 " #. Tag: para #, 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,这可能会效率更" -"高,但这不是必需的。" +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,这可能会效率更高,但这不是必需的。" #. Tag: title #, no-c-format @@ -795,78 +531,38 @@ msgstr "定制 SQL 用来 create,update 和 delete" #. Tag: para #, no-c-format -msgid "" -"Hibernate3 can use custom SQL for create, update, and delete operations. The " -"SQL can be overridden at the statement level or inidividual column level. " -"This section describes statement overrides. For columns, see ." -msgstr "" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"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><sql-" -"update> 重载了这些语句。" +msgid "Hibernate3 can use custom SQL for create, update, and delete operations. The SQL can be overridden at the statement level or inidividual column level. This section describes statement overrides. For columns, see ." +msgstr "Hibernate3 可以自定义 create、update 和 delete 操作。SQL 可以在语句或单个字段级别进行覆盖。本节描述了语句覆盖。对于字段覆盖,请参考 。" #. Tag: para #, no-c-format -msgid "" -"The SQL is directly executed in your database, so you can use any dialect " -"you like. This will reduce the portability of your mapping if you use " -"database specific SQL." -msgstr "" -"这些 SQL 直接在你的数据库里执行,所以你可以自由的使用你喜欢的任意语法。但如果" -"你使用数据库特定的语法,这当然会降低你映射的可移植性。 " +msgid "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><sql-update> 重载了这些语句。 " #. Tag: para #, no-c-format -msgid "" -"Stored procedures are supported if the callable attribute " -"is set:" +msgid "The SQL is directly executed in your database, so you can use any dialect you like. This will reduce the portability of your mapping if you use database specific SQL." +msgstr "这些 SQL 直接在你的数据库里执行,所以你可以自由的使用你喜欢的任意语法。但如果你使用数据库特定的语法,这当然会降低你映射的可移植性。 " + +#. Tag: para +#, no-c-format +msgid "Stored procedures are supported if the callable attribute is set:" msgstr "如果设定 callable,则能够支持存储过程了。" #. Tag: para #, no-c-format -msgid "" -"The order of the positional parameters is vital, as they must be in the same " -"sequence as Hibernate expects them." +msgid "The order of the positional parameters is vital, as they must be in the same sequence as Hibernate expects them." msgstr "参数的位置顺序是非常重要的,他们必须和 Hibernate 所期待的顺序相同。 " #. Tag: para #, no-c-format -msgid "" -"You can view 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 view the expected sequence, do not include " -"your custom SQL in the mapping files, as this will override the Hibernate " -"generated static SQL." -msgstr "" -"你能够通过设定日志调试级别为 org.hiberante.persister.entity 来查看 Hibernate 所期待的顺序。在这个级别下,Hibernate 将会打印出" -"create,update 和 delete 实体的静态 SQL。(如果想看到预计的顺序。记得不要将定" -"制 SQL 包含在映射文件里,因为他们会重载 Hibernate 生成的静态 SQL。) " +msgid "You can view 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 view the expected sequence, do not include your custom SQL in the mapping files, as this will override the Hibernate generated static SQL." +msgstr "你能够通过设定日志调试级别为 org.hiberante.persister.entity 来查看 Hibernate 所期待的顺序。在这个级别下,Hibernate 将会打印出create,update 和 delete 实体的静态 SQL。(如果想看到预计的顺序。记得不要将定制 SQL 包含在映射文件里,因为他们会重载 Hibernate 生成的静态 SQL。) " #. Tag: para #, no-c-format -msgid "" -"The stored procedures are in most cases required to return the number of " -"rows inserted, updated and 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 操作的语" -"句的第一个参数注册为一个数值型输出参数。 " +msgid "The stored procedures are in most cases required to return the number of rows inserted, updated and 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: title #, no-c-format @@ -875,21 +571,13 @@ msgstr "定制装载 SQL" #. Tag: para #, no-c-format -msgid "" -"You can also declare your own SQL (or HQL) queries for entity loading. As " -"with inserts, updates, and deletes, this can be done at the individual " -"column level as described in or at the statement level. Here is an example of a statement level " -"override:" -msgstr "" +msgid "You can also declare your own SQL (or HQL) queries for entity loading. As with inserts, updates, and deletes, this can be done at the individual column level as described in or at the statement level. Here is an example of a statement level override:" +msgstr "你也可以为实体加载声明自己的 SQL(或 HQL)。如 所描述的,inserts、updates 和 deletes 可以在字段级别或语句级别来完成。下面是一个语句覆盖的例子:" #. Tag: para #, no-c-format -msgid "" -"This is just a named query declaration, as discussed earlier. You can " -"reference this named query in a class mapping:" -msgstr "" -"这只是一个前面讨论过的命名查询声明,你可以在类映射里引用这个命名查询。 " +msgid "This is just a named query declaration, as discussed earlier. You can reference this named query in a class mapping:" +msgstr "这只是一个前面讨论过的命名查询声明,你可以在类映射里引用这个命名查询。 " #. Tag: para #, no-c-format @@ -903,9 +591,7 @@ msgstr "你甚至可以定一个用于集合装载的查询: " #. Tag: para #, no-c-format -msgid "" -"You can also define an entity loader that loads a collection by join " -"fetching:" +msgid "You can also define an entity loader that loads a collection by join fetching:" msgstr "你甚至还可以定义一个实体装载器,它通过连接抓取装载一个集合: " #~ msgid "" @@ -1058,7 +744,6 @@ msgstr "你甚至还可以定义一个实体装载器,它通过连接抓取装 #, fuzzy #~ msgid "{[aliasname].*}" #~ msgstr "{[aliasname].*}" - #~ msgid "{item.*}" #~ msgstr "{item.*}" @@ -1097,7 +782,6 @@ msgstr "你甚至还可以定义一个实体装载器,它通过连接抓取装 #, fuzzy #~ msgid "{coll.element.*}" #~ msgstr "{coll.*}" - #~ msgid "{coll.*}" #~ msgstr "{coll.*}" @@ -1568,3 +1252,4 @@ msgstr "你甚至还可以定义一个实体装载器,它通过连接抓取装 #~ " ON pers.ID = emp.PERSON_ID\n" #~ " WHERE ID=?\n" #~ "</sql-query>" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/session_api.po b/documentation/manual/src/main/docbook/zh-CN/content/session_api.po index c7adfbb4f2..0fe357d2d0 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/session_api.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/session_api.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: session_api\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-03-12T00:03:48\n" -"PO-Revision-Date: 2009-12-04 14:00+1000\n" +"PO-Revision-Date: 2010-03-16 09:58+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -22,31 +22,13 @@ msgstr "与对象共事" #. Tag: para #, 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 natural object-oriented view of persistence " -"in Java applications." -msgstr "" -"Hibernate 是完整的对象/关系映射解决方案,它提供了对象状态管理" -"(state management)的功能,使开发者不再需要理会底层数据库系统的细" -"节。也就是说,相对于常见的 JDBC/SQL 持久层方案中需要管理 SQL 语句,Hibernate 采用了更自然的面向对象的视角来持久化 Java 应用中的数据。 " +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 natural object-oriented view of persistence in Java applications." +msgstr "Hibernate 是完整的对象/关系映射解决方案,它提供了对象状态管理(state management)的功能,使开发者不再需要理会底层数据库系统的细节。也就是说,相对于常见的 JDBC/SQL 持久层方案中需要管理 SQL 语句,Hibernate 采用了更自然的面向对象的视角来持久化 Java 应用中的数据。 " #. Tag: para #, 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 掌管妥当,只有" -"开发者在进行系统性能调优的时候才需要进行了解。" +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 掌管妥当,只有开发者在进行系统性能调优的时候才需要进行了解。" #. Tag: title #, no-c-format @@ -60,76 +42,23 @@ msgstr "Hibernate 定义并支持下列对象状态(state):" #. Tag: para #, 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 does not 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语" -"句) " +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 does not 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语句) " #. Tag: para #, 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 do not 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 语句。 " +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 do not 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 语句。 " #. Tag: para #, 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)。 " +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)。 " #. Tag: para #, no-c-format -msgid "" -"We will now discuss the states and state transitions (and the Hibernate " -"methods that trigger a transition) in more detail." -msgstr "" -"接下来我们来细致地讨论下状态(states)及状态间的转换(state transitions)(以" -"及触发状态转换的 Hibernate 方法)。 " +msgid "We will now discuss the states and state transitions (and the Hibernate methods that trigger a transition) in more detail." +msgstr "接下来我们来细致地讨论下状态(states)及状态间的转换(state transitions)(以及触发状态转换的 Hibernate 方法)。 " #. Tag: title #, no-c-format @@ -137,105 +66,39 @@ msgid "Making objects persistent" msgstr "使对象持久化" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"Newly instantiated instances of 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)的。" +#, no-c-format +msgid "Newly instantiated instances of 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)。" #. Tag: para #, 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 can 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()。 " +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 can 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 #, no-c-format -msgid "" -"persist() makes a transient instance persistent. However, " -"it does not 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() 使一个临时实例持久化。然而,它不保证立即把标识符" -"值分配给持久性实例,这会发生在冲刷(flush)的时候。persist() 也保证它在事务边界外调用时不会执行 INSERT 语句。" -"这对于长期运行的带有扩展会话/持久化上下文的会话是很有用的。" +msgid "persist() makes a transient instance persistent. However, it does not 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() 使一个临时实例持久化。然而,它不保证立即把标识符值分配给持久性实例,这会发生在冲刷(flush)的时候。persist() 也保证它在事务边界外调用时不会执行 INSERT 语句。这对于长期运行的带有扩展会话/持久化上下文的会话是很有用的。" #. Tag: para #, 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() 保证返回一个标识符。如果需要运行 INSERT 来获取标识" -"符(如 \"identity\" 而非 \"sequence\" 生成器),这个 INSERT 将立即执行,不管" -"你是否在事务内部还是外部。这对于长期运行的带有扩展会话/持久化上下文的会话来说" -"会出现问题。" +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() 保证返回一个标识符。如果需要运行 INSERT 来获取标识符(如 \"identity\" 而非 \"sequence\" 生成器),这个 INSERT 将立即执行,不管你是否在事务内部还是外部。这对于长期运行的带有扩展会话/持久化上下文的会话来说会出现问题。" #. Tag: para #, no-c-format -msgid "" -"Alternatively, you can assign the identifier using an overloaded version of " -"save()." +msgid "Alternatively, you can assign the identifier using an overloaded version of save()." msgstr "此外,你可以用一个重载版本的 save() 方法。 " #. Tag: para #, no-c-format -msgid "" -"If the object you make persistent has associated objects (e.g. the " -"kittens collection in the previous example), these " -"objects can 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 约束。 " +msgid "If the object you make persistent has associated objects (e.g. the kittens collection in the previous example), these objects can 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 约束。 " #. Tag: para #, no-c-format -msgid "" -"Usually you do not bother with this detail, as you will normally use " -"Hibernate's transitive persistence feature to save the " -"associated objects automatically. Then, even NOT NULL " -"constraint violations do not occur - Hibernate will take care of everything. " -"Transitive persistence is discussed later in this chapter." -msgstr "" -"通常你不会为这些细节烦心,因为你很可能会使用 Hibernate 的传播性持久" -"化(transitive persistence)功能自动保存相关联那些对象。这样连违" -"反 NOT NULL 约束的情况都不会出现了 — Hibernate 会管好所有" -"的事情。传播性持久化(transitive persistence)将在本章稍后讨论。" +msgid "Usually you do not bother with this detail, as you will normally use Hibernate's transitive persistence feature to save the associated objects automatically. Then, even NOT NULL constraint violations do not 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 #, no-c-format @@ -244,100 +107,43 @@ msgstr "装载对象" #. Tag: para #, no-c-format -msgid "" -"The load() methods of Session provide " -"a way of retrieving a persistent instance if you know its identifier. " -"load() takes a class object and loads the state into a " -"newly instantiated instance of that class in a persistent state." -msgstr "" -"如果你知道某个实例的持久化标识(identifier),你就可以使用 Sessionload() 方法来获取它。load() 的另一个参数是指定类的对象。本方法会创建指定类的持久化实例,并从数据" -"库加载其数据(state)。 " +msgid "The load() methods of Session provide a way of retrieving a persistent instance if you know its identifier. load() takes a class object and loads the state into a newly instantiated instance of that class in a persistent state." +msgstr "如果你知道某个实例的持久化标识(identifier),你就可以使用 Sessionload() 方法来获取它。load() 的另一个参数是指定类的对象。本方法会创建指定类的持久化实例,并从数据库加载其数据(state)。 " #. Tag: para #, no-c-format msgid "Alternatively, you can load state into a given instance:" -msgstr "" -"此外,你可以把数据(state)加载到指定的对象实例上(覆盖掉该实例原来的数据)。" +msgstr "此外,你可以把数据(state)加载到指定的对象实例上(覆盖掉该实例原来的数据)。" #. Tag: para #, no-c-format -msgid "" -"Be aware 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 is 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,那么使用这种" -"操作方式允许多个对象被一批装载(因为返回的是代理,无需从数据库中抓取所有对象" -"的数据)。 " +msgid "Be aware 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 is 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 #, 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。 " +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: para #, no-c-format -msgid "" -"You can 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 文档以获取更多" -"信息。 " +msgid "You can 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 文档以获取更多信息。 " #. Tag: para #, no-c-format -msgid "" -"Any associated instances or contained collections will not be 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)。 " +msgid "Any associated instances or contained collections will not be 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 #, 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() 方法强迫装载对象和它的集合。" -"如果你使用数据库触发器功能来处理对象的某些属性,这个方法就很有用了。" +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: para -#, fuzzy, no-c-format -msgid "" -"How much does Hibernate load from the database and how many SQL " -"SELECTs will it use? This depends on the " -"fetching strategy. This is explained in ." -msgstr "" -"此处通常会出现一个重要问题: Hibernate 会从数据库中装载多少东西?会执行多少条" -"相应的 SQLSELECT 语句?这取决于抓取策略" -"(fetching strategy),我们会在 中解释。 " +#, no-c-format +msgid "How much does Hibernate load from the database and how many SQL SELECTs will it use? This depends on the fetching strategy. This is explained in ." +msgstr "此处通常会出现一个重要问题: Hibernate 会从数据库中装载多少东西?会执行多少条相应的 SQLSELECT 语句?这取决于抓取策略(fetching strategy),我们会在 中解释。 " #. Tag: title #, no-c-format @@ -346,19 +152,8 @@ msgstr "查询" #. Tag: para #, no-c-format -msgid "" -"If you do not 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 can 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)转化为对象的支持。 " +msgid "If you do not 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 can 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)转化为对象的支持。 " #. Tag: title #, no-c-format @@ -367,36 +162,13 @@ msgstr "执行查询" #. Tag: para #, 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 对象:" +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: para #, 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 a persistent state. The " -"uniqueResult() method offers a shortcut if you know your " -"query will only return a single object. 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 through " -"a Set." -msgstr "" -"一个查询通常在调用 list() 时被执行,执行结果会完全装载进内" -"存中的一个集合(collection)。查询返回的对象处于持久(persistent)状态。如果" -"你知道的查询只会返回一个对象,可使用 list() 的快捷方式 " -"uniqueResult()。注意,使用集合预先抓取的查询往往会返回多次" -"根对象(他们的集合类都被初始化了)。你可以通过一个集合(Set)来过滤这些重复对象。" +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 a persistent state. The uniqueResult() method offers a shortcut if you know your query will only return a single object. 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 through a Set." +msgstr "一个查询通常在调用 list() 时被执行,执行结果会完全装载进内存中的一个集合(collection)。查询返回的对象处于持久(persistent)状态。如果你知道的查询只会返回一个对象,可使用 list() 的快捷方式 uniqueResult()。注意,使用集合预先抓取的查询往往会返回多次根对象(他们的集合类都被初始化了)。你可以通过一个集合(Set)来过滤这些重复对象。" #. Tag: title #, no-c-format @@ -405,24 +177,8 @@ msgstr "迭代式获取结果(Iterating results)" #. Tag: para #, no-c-format -msgid "" -"Occasionally, you might be able to achieve better performance by executing " -"the query using the iterate() method. This will 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 " -"语句实例化实际的对象。 " +msgid "Occasionally, you might be able to achieve better performance by executing the query using the iterate() method. This will 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: title #, no-c-format @@ -431,12 +187,8 @@ msgstr "返回元组(tuples)的查询" #. Tag: para #, no-c-format -msgid "" -"Hibernate queries sometimes return tuples of objects. Each tuple is returned " -"as an array:" -msgstr "" -"(译注:元组(tuples)指一条结果行包含多个对象) Hibernate 查询有时返回元组" -"(tuples),每个元组(tuples)以数组的形式返回: " +msgid "Hibernate queries sometimes return tuples of objects. Each tuple is returned as an array:" +msgstr "(译注:元组(tuples)指一条结果行包含多个对象) Hibernate 查询有时返回元组(tuples),每个元组(tuples)以数组的形式返回: " #. Tag: title #, no-c-format @@ -445,14 +197,8 @@ msgstr "标量(Scalar)结果" #. Tag: para #, no-c-format -msgid "" -"Queries can specify a property of a class in the select " -"clause. They can 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)的实体)。 " +msgid "Queries can specify a property of a class in the select clause. They can 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: title #, no-c-format @@ -461,23 +207,12 @@ msgstr "绑定参数" #. Tag: para #, 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 as follows:" -msgstr "" -"接口 Query 提供了对命名参数(named parameters)、JDBC 风格" -"的问号(?)参数进行绑定的方法。不同于 JDBC," -"Hibernate 对参数从 0 开始计数。 命名参数(named parameters)在查询" -"字符串中是形如 :name 的标识符。命名参数(named " -"parameters)的优点是: " +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 as follows:" +msgstr "接口 Query 提供了对命名参数(named parameters)、JDBC 风格的问号(?)参数进行绑定的方法。不同于 JDBC,Hibernate 对参数从 0 开始计数。 命名参数(named parameters)在查询字符串中是形如 :name 的标识符。命名参数(named parameters)的优点是: " #. Tag: para #, no-c-format -msgid "" -"named parameters are insensitive to the order they occur in the query string" +msgid "named parameters are insensitive to the order they occur in the query string" msgstr "命名参数(named parameters)与其在查询串中出现的顺序无关" #. Tag: para @@ -497,22 +232,13 @@ msgstr "分页" #. Tag: para #, no-c-format -msgid "" -"If you need to specify bounds upon your result set, that is, the maximum " -"number of rows you want to retrieve and/or the first row you want to " -"retrieve, you can use methods of the Query interface:" -msgstr "" -"如果你需要指定结果集的范围(希望返回的最大行数/或开始的行数),应该使用 " -"Query 接口提供的方法: " +msgid "If you need to specify bounds upon your result set, that is, the maximum number of rows you want to retrieve and/or the first row you want to retrieve, you can use methods of the Query interface:" +msgstr "如果你需要指定结果集的范围(希望返回的最大行数/或开始的行数),应该使用 Query 接口提供的方法: " #. Tag: para #, no-c-format -msgid "" -"Hibernate knows how to translate this limit query into the native SQL of " -"your DBMS." -msgstr "" -"Hibernate 知道如何将这个有限定条件的查询转换成你的数据库的原生 SQL(native " -"SQL)。" +msgid "Hibernate knows how to translate this limit query into the native SQL of your DBMS." +msgstr "Hibernate 知道如何将这个有限定条件的查询转换成你的数据库的原生 SQL(native SQL)。" #. Tag: title #, no-c-format @@ -521,26 +247,13 @@ msgstr "可滚动遍历(Scrollable iteration)" #. Tag: para #, no-c-format -msgid "" -"If your JDBC driver supports scrollable ResultSets, the " -"Query interface can be used to obtain a " -"ScrollableResults object that allows flexible navigation " -"of the query results." -msgstr "" -"如果你的 JDBC 驱动支持可滚动的 ResuleSetQuery 接口可以使用 ScrollableResults,允许你在查询结果" -"中灵活游走。 " +msgid "If your JDBC driver supports scrollable ResultSets, the Query interface can be used to obtain a ScrollableResults object that allows flexible navigation of the query results." +msgstr "如果你的 JDBC 驱动支持可滚动的 ResuleSetQuery 接口可以使用 ScrollableResults,允许你在查询结果中灵活游走。 " #. Tag: para #, 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()。 " +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()。 " #. Tag: title #, no-c-format @@ -549,13 +262,8 @@ msgstr "外置命名查询(Externalizing named queries)" #. Tag: para #, no-c-format -msgid "" -"You can 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包裹起来。" +msgid "You can 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: para #, no-c-format @@ -564,28 +272,13 @@ msgstr "参数绑定及执行以编程方式(programatically)完成:" #. Tag: para #, no-c-format -msgid "" -"The actual program code is independent of the query language that is used. " -"You can also define native SQL queries in metadata, or migrate existing " -"queries to Hibernate by placing them in mapping files." -msgstr "" -"请注意实际的程序代码与所用的查询语言无关,你也可在元数据中定义原生 SQL" -"(native SQL)查询,或将原有的其他的查询语句放在配置文件中,这样就可以让 " -"Hibernate 统一管理,达到迁移的目的。 " +msgid "The actual program code is independent of the query language that is used. You can also define native SQL queries in metadata, or migrate existing queries to Hibernate by placing them in mapping files." +msgstr "请注意实际的程序代码与所用的查询语言无关,你也可在元数据中定义原生 SQL(native SQL)查询,或将原有的其他的查询语句放在配置文件中,这样就可以让 Hibernate 统一管理,达到迁移的目的。 " #. Tag: para #, 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。 " +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。 " #. Tag: title #, no-c-format @@ -594,43 +287,23 @@ msgstr "过滤集合" #. Tag: para #, no-c-format -msgid "" -"A collection filter is a special type of query that can " -"be applied to a persistent collection or array. The query string can refer " -"to this, meaning the current collection element." -msgstr "" -"集合过滤器(filter)是一种用于一个持久化集合或者数组的特" -"殊的查询。查询字符串中可以使用 \"this\" 来引用集合中的当前" -"元素。 " +msgid "A collection filter is a special type of query that can be applied to a persistent collection or array. The query string can refer to this, meaning the current collection element." +msgstr "集合过滤器(filter)是一种用于一个持久化集合或者数组的特殊的查询。查询字符串中可以使用 \"this\" 来引用集合中的当前元素。 " #. Tag: para #, no-c-format -msgid "" -"The returned collection is considered a bag that is 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)”的隐含的含义不符," -"不过与我们期待的行为一致)。 " +msgid "The returned collection is considered a bag that is 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 #, no-c-format -msgid "" -"Observe that filters do not require a from clause, " -"although they can have one if required. Filters are not limited to returning " -"the collection elements themselves." -msgstr "" -"请注意过滤器(filter)并不需要 from 子句(当然需要的话它们" -"也可以加上)。过滤器(filter)不限定于只能返回集合元素本身。 " +msgid "Observe that filters do not require a from clause, although they can have one if required. Filters are not limited to returning the collection elements themselves." +msgstr "请注意过滤器(filter)并不需要 from 子句(当然需要的话它们也可以加上)。过滤器(filter)不限定于只能返回集合元素本身。 " #. Tag: para #, no-c-format -msgid "" -"Even an empty filter query is useful, e.g. to load a subset of elements in a " -"large collection:" -msgstr "" -"即使无条件的过滤器(filter)也是有意义的。例如,用于加载一个大集合的子集: " +msgid "Even an empty filter query is useful, e.g. to load a subset of elements in a large collection:" +msgstr "即使无条件的过滤器(filter)也是有意义的。例如,用于加载一个大集合的子集: " #. Tag: title #, no-c-format @@ -639,25 +312,13 @@ msgstr "条件查询(Criteria queries)" #. Tag: para #, 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。 " +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: para -#, fuzzy, no-c-format -msgid "" -"The Criteria and the associated Example API are discussed in more detail in ." -msgstr "" -"Criteria 以及相关的样例(Example)API " -"将会在 中详细讨论。 " +#, no-c-format +msgid "The Criteria and the associated Example API are discussed in more detail in ." +msgstr "Criteria 以及相关的样例(Example)API 将会在 中详细讨论。" #. Tag: title #, no-c-format @@ -666,28 +327,13 @@ msgstr "使用原生 SQL 的查询" #. Tag: para #, no-c-format -msgid "" -"You can express a query in SQL, using createSQLQuery() " -"and let Hibernate manage the mapping from result sets to objects. You can at " -"any time call session.connection() and use the JDBC " -"Connection directly. If you choose to use the Hibernate " -"API, you must enclose SQL aliases in braces:" -msgstr "" -"你可以使用 createSQLQuery() 方法,用 SQL 来描述查询,并由 " -"Hibernate 将结果集转换成对象。请注意,你可以在任何时候调用 session." -"connection() 来获得并使用 JDBC Connection 对" -"象。 如果你选择使用 Hibernate 的 API,你必须把 SQL 别名用大括号包围起来: " +msgid "You can express a query in SQL, using createSQLQuery() and let Hibernate manage the mapping from result sets to objects. You can at any time call session.connection() and use the JDBC Connection directly. If you choose to use the Hibernate API, you must enclose SQL aliases in braces:" +msgstr "你可以使用 createSQLQuery() 方法,用 SQL 来描述查询,并由 Hibernate 将结果集转换成对象。请注意,你可以在任何时候调用 session.connection() 来获得并使用 JDBC Connection 对象。 如果你选择使用 Hibernate 的 API,你必须把 SQL 别名用大括号包围起来: " #. Tag: para -#, fuzzy, no-c-format -msgid "" -"SQL queries can 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)的信" -"息。 " +#, no-c-format +msgid "SQL queries can 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 #, no-c-format @@ -696,61 +342,18 @@ msgstr "修改持久对象" #. Tag: para #, no-c-format -msgid "" -"Transactional persistent instances (i.e. objects " -"loaded, saved, created or queried by the Session) can be " -"manipulated by the application, and any changes to persistent state will be " -"persisted when the Session is flushed. This is 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. 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() 它,然后直接修改即可: " +msgid "Transactional persistent instances (i.e. objects loaded, saved, created or queried by the Session) can be manipulated by the application, and any changes to persistent state will be persisted when the Session is flushed. This is 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. 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: para #, no-c-format -msgid "" -"Sometimes this programming model is inefficient, as it requires in the same " -"session both an SQL SELECT to load an object and an SQL " -"UPDATE to persist its updated state. Hibernate offers an " -"alternate approach by using detached instances." -msgstr "" -"有时这种程序模型效率低下,因为它在同一 Session 里需要一条 SQL " -"SELECT 语句(用于加载对象) 以及一条 SQL UPDATE 语句(持久化更新的状态)。为此 Hibernate 提供了另一种途径,使用脱管" -"(detached)实例。 " +msgid "Sometimes this programming model is inefficient, as it requires in the same session both an SQL SELECT to load an object and an SQL UPDATE to persist its updated state. Hibernate offers an alternate approach by using detached instances." +msgstr "有时这种程序模型效率低下,因为它在同一 Session 里需要一条 SQL SELECT 语句(用于加载对象) 以及一条 SQL UPDATE 语句(持久化更新的状态)。为此 Hibernate 提供了另一种途径,使用脱管(detached)实例。 " #. Tag: para -#, fuzzy, no-c-format -msgid "" -"Hibernate does not offer its own API for direct execution of " -"UPDATE or DELETE statements. Hibernate " -"is a state management service, you do not 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 can, however, provide special mass operation functions. See for some possible batch operation tricks." -msgstr "" -"请注意 Hibernate 本身不提供直接执行 UPDATE 或 " -"DELETE 语句的 API。Hibernate 提供的是 state " -"management 服务,你不必考虑要使用的 statements。JDBC 是出色的执行 SQL 语句的 API,任何时候调用 session." -"connection() 你都可以得到一个 Connection 对象。 " -"此外,在联机事务处理(OLTP)程序中,大量操作(mass operations)与对象/关系映" -"射的观点是相冲突的。Hibernate 的将来版本可能会提供专门的进行大量操作(mass " -"operation)的功能。参考 ,寻找一些可用的批量" -"(batch)操作技巧。 " +#, no-c-format +msgid "Hibernate does not offer its own API for direct execution of UPDATE or DELETE statements. Hibernate is a state management service, you do not 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 can, however, provide special mass operation functions. See for some possible batch operation tricks." +msgstr "请注意 Hibernate 本身不提供直接执行 UPDATEDELETE 语句的 API。Hibernate 提供的是 state management 服务,你不必考虑要使用的 statements。JDBC 是出色的执行 SQL 语句的 API,任何时候调用 session.connection() 你都可以得到一个 Connection 对象。 此外,在联机事务处理(OLTP)程序中,大量操作(mass operations)与对象/关系映射的观点是相冲突的。Hibernate 的将来版本可能会提供专门的进行大量操作(mass operation)的功能。参考 ,寻找一些可用的批量(batch)操作技巧。" #. Tag: title #, no-c-format @@ -759,100 +362,43 @@ msgstr "修改脱管(Detached)对象" #. Tag: para #, 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 "" -"很多程序需要在某个事务中获取对象,然后将对象发送到界面层去操作,最后在一个新" -"的事务保存所做的修改。在高并发访问的环境中使用这种方式,通常使用附带版本信息" -"的数据来保证这些“长“工作单元之间的隔离。" +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 "很多程序需要在某个事务中获取对象,然后将对象发送到界面层去操作,最后在一个新的事务保存所做的修改。在高并发访问的环境中使用这种方式,通常使用附带版本信息的数据来保证这些“长“工作单元之间的隔离。" #. Tag: para #, 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() 重新关联脱管实例的办法来支持这种模型。" +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: para #, 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)的时候会抛出一个异常。" +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 #, no-c-format -msgid "" -"Use update() if you are certain that the session does not " -"contain an already persistent instance with the same identifier. Use " -"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 the reattachment of your detached instances is " -"the first operation that is executed." -msgstr "" -"如果你确定当前 session 没有包含与之具有相同持久化标识的持久实例,使用 " -"update()。如果想随时合并你的的改动而不考虑 session 的状" -"态,使用 merge()。换句话说,在一个新 session 中通常第一个" -"调用的是 update() 方法,以便保证重新关联脱管(detached)对" -"象的操作首先被执行。 " - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"The application should individually update() detached " -"instances that are reachable from the given detached instance " -"only if it wants their state to be updated. This can be " -"automated using transitive persistence. See for more information." -msgstr "" -"如果希望相关联的脱管对象(通过引用“可到达”的脱管对象)的数据也要更新到数据库" -"时(并且也仅仅在这种情况),可以对该相关联的脱管对象单独" -"调用 update() 当然这些可以自动完成,即通过使用传" -"播性持久化(transitive persistence),请看 。 " +msgid "Use update() if you are certain that the session does not contain an already persistent instance with the same identifier. Use 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 the reattachment of your detached instances is the first operation that is executed." +msgstr "如果你确定当前 session 没有包含与之具有相同持久化标识的持久实例,使用 update()。如果想随时合并你的的改动而不考虑 session 的状态,使用 merge()。换句话说,在一个新 session 中通常第一个调用的是 update() 方法,以便保证重新关联脱管(detached)对象的操作首先被执行。 " #. Tag: para #, 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)的对象必须是没有修改过的。" +msgid "The application should individually update() detached instances that are reachable from the given detached instance only if it wants their state to be updated. This can be automated using transitive persistence. See for more information." +msgstr "如果希望相关联的脱管对象(通过引用“可到达”的脱管对象)的数据也要更新到数据库时(并且也仅仅在这种情况),可以对该相关联的脱管对象单独调用 update() 当然这些可以自动完成,即通过使用传播性持久化(transitive persistence),请看 。" #. Tag: para #, 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() 的唯一用途。 " +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: para -#, fuzzy, no-c-format -msgid "" -"Other models for long units of work are discussed in ." -msgstr "" -"其他用于长时间工作单元的模型会在 " -"中讨论。 " +#, 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() 的唯一用途。 " + +#. Tag: para +#, no-c-format +msgid "Other models for long units of work are discussed in ." +msgstr "其他用于长时间工作单元的模型会在 中讨论。" #. Tag: title #, no-c-format @@ -861,39 +407,18 @@ msgstr "自动状态检测" #. Tag: para #, 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() 方法实现了这个功能。" +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: para #, 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()。有些程序从来不用这些方法。" +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()。有些程序从来不用这些方法。" #. Tag: para #, no-c-format -msgid "" -"Usually update() or saveOrUpdate() are " -"used in the following scenario:" -msgstr "" -"通常下面的场景会使用 update()saveOrUpdate():" +msgid "Usually update() or saveOrUpdate() are used in the following scenario:" +msgstr "通常下面的场景会使用 update()saveOrUpdate():" #. Tag: para #, no-c-format @@ -917,9 +442,7 @@ msgstr "该对象被返回到业务逻辑层" #. Tag: para #, no-c-format -msgid "" -"the application persists these modifications by calling update() in a second session" +msgid "the application persists these modifications by calling update() in a second session" msgstr "程序调用第二个 session 的 update() 方法持久这些改动" #. Tag: para @@ -934,39 +457,23 @@ msgstr "如果对象已经在本 session 中持久化了,不做任何事" #. Tag: para #, no-c-format -msgid "" -"if another object associated with the session has the same identifier, throw " -"an exception" -msgstr "" -"如果另一个与本 session 关联的对象拥有相同的持久化标识(identifier),抛出一个" -"异常" +msgid "if another object associated with the session has the same identifier, throw an exception" +msgstr "如果另一个与本 session 关联的对象拥有相同的持久化标识(identifier),抛出一个异常" #. Tag: para #, no-c-format msgid "if the object has no identifier property, save() it" -msgstr "" -"如果对象没有持久化标识(identifier)属性,对其调用 save()" +msgstr "如果对象没有持久化标识(identifier)属性,对其调用 save()" #. Tag: para #, no-c-format -msgid "" -"if the object's identifier has the value assigned to a newly instantiated " -"object, save() it" -msgstr "" -"如果对象的持久标识(identifier)表明其是一个新实例化的对象,对其调用 " -"save()。" +msgid "if the object's identifier has the value assigned to a newly instantiated object, save() it" +msgstr "如果对象的持久标识(identifier)表明其是一个新实例化的对象,对其调用 save()。" #. Tag: para #, 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() 它。 " +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() 它。 " #. Tag: para #, no-c-format @@ -980,21 +487,13 @@ msgstr "merge() 可非常不同:" #. Tag: para #, 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)的实例,用用户给出的对象的状态" -"覆盖旧有的持久实例" +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)的实例,用用户给出的对象的状态覆盖旧有的持久实例" #. Tag: para #, 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 没有相应的持久实例,则尝试从数据库中加载,或创建新的持久化实例" +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 没有相应的持久实例,则尝试从数据库中加载,或创建新的持久化实例" #. Tag: para #, no-c-format @@ -1003,9 +502,7 @@ msgstr "最后返回该持久实例" #. Tag: para #, no-c-format -msgid "" -"the given instance does not become associated with the session, it remains " -"detached" +msgid "the given instance does not become associated with the session, it remains detached" msgstr "用户给出的这个对象没有被关联到 session 上,它依旧是脱管的" #. Tag: title @@ -1015,28 +512,13 @@ msgstr "删除持久对象" #. Tag: para #, no-c-format -msgid "" -"Session.delete() will remove an object's state from the " -"database. Your application, however, can still hold a reference to a deleted " -"object. It is best to think of delete() as making a " -"persistent instance, transient." -msgstr "" -"使用 Session.delete() 会把对象的状态从数据库中移除。当然," -"你的应用程序可能仍然持有一个指向已删除对象的引用。所以,最好这样理解:" -"delete() 的用途是把一个持久实例变成瞬时(transient)实" -"例。 " +msgid "Session.delete() will remove an object's state from the database. Your application, however, can still hold a reference to a deleted object. It is best to think of delete() as making a persistent instance, transient." +msgstr "使用 Session.delete() 会把对象的状态从数据库中移除。当然,你的应用程序可能仍然持有一个指向已删除对象的引用。所以,最好这样理解:delete() 的用途是把一个持久实例变成瞬时(transient)实例。 " #. Tag: para #, no-c-format -msgid "" -"You can delete objects in any order, 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 约束冲突。例如" -"你删除了父对象,但是忘记删除其子对象。" +msgid "You can delete objects in any order, 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 约束冲突。例如你删除了父对象,但是忘记删除其子对象。" #. Tag: title #, no-c-format @@ -1045,71 +527,38 @@ msgstr "在两个不同数据库间复制对象" #. Tag: para #, no-c-format -msgid "" -"It is sometimes 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),将持久实例以及其关联的实例持久" -"到不同的数据库中的操作。 " +msgid "It is sometimes 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: para #, no-c-format -msgid "" -"The ReplicationMode determines how replicate() will deal with conflicts with existing rows in the database:" -msgstr "" -"ReplicationMode 决定在和数据库中已存在记录由冲突时," -"replicate() 如何处理。 " +msgid "The ReplicationMode determines how replicate() will deal with conflicts with existing rows in the database:" +msgstr "ReplicationMode 决定在和数据库中已存在记录由冲突时,replicate() 如何处理。 " #. Tag: para #, no-c-format -msgid "" -"ReplicationMode.IGNORE: ignores the object when there is " -"an existing database row with the same identifier" -msgstr "" -"ReplicationMode.IGNORE:当某个现有数据库记录具有相同标识符" -"时忽略它" +msgid "ReplicationMode.IGNORE: ignores the object when there is an existing database row with the same identifier" +msgstr "ReplicationMode.IGNORE:当某个现有数据库记录具有相同标识符时忽略它" #. Tag: para #, no-c-format -msgid "" -"ReplicationMode.OVERWRITE: overwrites any existing " -"database row with the same identifier" -msgstr "" -"ReplicationMode.OVERWRITE:用相同的标识符覆盖现有数据库记" -"录" +msgid "ReplicationMode.OVERWRITE: overwrites any existing database row with the same identifier" +msgstr "ReplicationMode.OVERWRITE:用相同的标识符覆盖现有数据库记录" #. Tag: para #, no-c-format -msgid "" -"ReplicationMode.EXCEPTION: throws an exception if there " -"is an existing database row with the same identifier" -msgstr "" -"ReplicationMode.EXCEPTION:当某个现有数据库记录具有相同标" -"识符时抛出异常" +msgid "ReplicationMode.EXCEPTION: throws an exception if there is an existing database row with the same identifier" +msgstr "ReplicationMode.EXCEPTION:当某个现有数据库记录具有相同标识符时抛出异常" #. Tag: para #, no-c-format -msgid "" -"ReplicationMode.LATEST_VERSION: overwrites the row if its " -"version number is earlier than the version number of the object, or ignore " -"the object otherwise" -msgstr "" -"ReplicationMode.LATEST_VERSION:如果当前的版本较新,则覆" -"盖,否则忽略" +msgid "ReplicationMode.LATEST_VERSION: overwrites the row if its version number is earlier than the version number of the object, or ignore the object otherwise" +msgstr "ReplicationMode.LATEST_VERSION:如果当前的版本较新,则覆盖,否则忽略" #. Tag: para #, 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 的缩写)" +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 的缩写)" #. Tag: title #, no-c-format @@ -1118,15 +567,8 @@ msgstr "Session 刷出(flush)" #. Tag: para #, no-c-format -msgid "" -"Sometimes 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, called flush, occurs by " -"default at the following points:" -msgstr "" -"每间隔一段时间,Session 会执行一些必需的 SQL 语句来把内存" -"中的对象的状态同步到 JDBC 连接中。这个过程被称为刷出(flush),默认会在下面的时间点执行: " +msgid "Sometimes 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, called flush, occurs by default at the following points:" +msgstr "每间隔一段时间,Session 会执行一些必需的 SQL 语句来把内存中的对象的状态同步到 JDBC 连接中。这个过程被称为刷出(flush),默认会在下面的时间点执行: " #. Tag: para #, no-c-format @@ -1150,12 +592,8 @@ msgstr "涉及的 SQL 语句会按照下面的顺序发出执行: " #. Tag: para #, no-c-format -msgid "" -"all entity insertions in the same order the corresponding objects were saved " -"using Session.save()" -msgstr "" -"所有对实体进行插入的语句,其顺序按照对象执行 Session.save() 的时间顺序 " +msgid "all entity insertions in the same order the corresponding objects were saved using Session.save()" +msgstr "所有对实体进行插入的语句,其顺序按照对象执行 Session.save() 的时间顺序 " #. Tag: para #, no-c-format @@ -1179,67 +617,28 @@ msgstr "所有进行集合插入的语句" #. Tag: para #, no-c-format -msgid "" -"all entity deletions in the same order the corresponding objects were " -"deleted using Session.delete()" -msgstr "" -"所有对实体进行删除的语句,其顺序按照对象执行 Session.delete() 的时间顺序 " +msgid "all entity deletions in the same order the corresponding objects were deleted using Session.delete()" +msgstr "所有对实体进行删除的语句,其顺序按照对象执行 Session.delete() 的时间顺序 " #. Tag: para #, no-c-format -msgid "" -"An exception is that objects using native ID generation " -"are inserted when they are saved." -msgstr "" -"有一个例外是,如果对象使用 native 方式来生成 ID(持久化标" -"识)的话,它们一执行 save 就会被插入。" +msgid "An exception is that objects using native ID generation are inserted when they are saved." +msgstr "有一个例外是,如果对象使用 native 方式来生成 ID(持久化标识)的话,它们一执行 save 就会被插入。" #. Tag: para #, no-c-format -msgid "" -"Except when you explicitly 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 or incorrect data." -msgstr "" -"除非你明确地发出了 flush() 指令,关于 Session 何" -"时会执行这些 JDBC 调用是完全无法保证的,只能保证它们执行的前后顺" -"序。当然,Hibernate 保证,Query.list(..) 绝对不会返回已经" -"失效的数据,也不会返回错误数据。 " +msgid "Except when you explicitly 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 or incorrect data." +msgstr "除非你明确地发出了 flush() 指令,关于 Session 何时会执行这些 JDBC 调用是完全无法保证的,只能保证它们执行的前后顺序。当然,Hibernate 保证,Query.list(..) 绝对不会返回已经失效的数据,也不会返回错误数据。 " #. Tag: para -#, fuzzy, 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 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 为打开或者断线状态的长" -"时间运行的工作单元很有用。(参见 )。 " +#, 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 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: para -#, fuzzy, 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 事务性行为的理解,因此我们将在 中讨论。" +#, 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 事务性行为的理解,因此我们将在 中讨论。 " #. Tag: title #, no-c-format @@ -1248,67 +647,23 @@ msgstr "传播性持久化(transitive persistence)" #. Tag: para #, 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 "" -"对每一个对象都要执行保存,删除或重关联操作让人感觉有点麻烦,尤其是在处理许多" -"彼此关联的对象的时候。一个常见的例子是父子关系。考虑下面的例子:" +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 "对每一个对象都要执行保存,删除或重关联操作让人感觉有点麻烦,尤其是在处理许多彼此关联的对象的时候。一个常见的例子是父子关系。考虑下面的例子:" #. Tag: para #, 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 and when the parent is deleted, the children will be deleted, etc. " -"This works for operations such as the removal of a child from the " -"collection. Since value-typed objects cannot have shared references, " -"Hibernate will detect this and delete the child from the database." -msgstr "" -"如果一个父子关系中的子对象是值类型(value typed)(例如,地址或字符串的集合)" -"的,他们的生命周期会依赖于父对象,可以享受方便的级联操作(Cascading),不需要" -"额外的动作。父对象被保存时,这些值类型(value typed)子对象也将被保存;父对象" -"被删除时,子对象也将被删除。这对将一个子对象从集合中移除是同样有效:" -"Hibernate 会检测到,并且因为值类型(value typed)的对象不可能被其他对象引用," -"所以 Hibernate 会在数据库中删除这个子对象。 " +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 and when the parent is deleted, the children will be deleted, etc. This works for operations such as the removal of a child from the collection. Since value-typed objects cannot have shared references, Hibernate will detect this and delete the child from the database." +msgstr "如果一个父子关系中的子对象是值类型(value typed)(例如,地址或字符串的集合)的,他们的生命周期会依赖于父对象,可以享受方便的级联操作(Cascading),不需要额外的动作。父对象被保存时,这些值类型(value typed)子对象也将被保存;父对象被删除时,子对象也将被删除。这对将一个子对象从集合中移除是同样有效:Hibernate 会检测到,并且因为值类型(value typed)的对象不可能被其他对象引用,所以 Hibernate 会在数据库中删除这个子对象。 " #. Tag: para #, 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 and support shared references. 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)的策略。 " +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 and support shared references. 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)的策略。 " #. Tag: para #, 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。如果你希望一个操作被顺着关联关系级联传播,你必须在映射文" -"件中指出这一点。例如:" +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。如果你希望一个操作被顺着关联关系级联传播,你必须在映射文件中指出这一点。例如:" #. Tag: para #, no-c-format @@ -1317,27 +672,13 @@ msgstr "级联风格(cascade style)是可组合的:" #. Tag: para #, no-c-format -msgid "" -"You can 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 "You can 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)。 " #. Tag: para #, 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() 操作应该被应用于" -"所有从关联中删除的对象。" +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 #, no-c-format @@ -1346,144 +687,63 @@ msgstr "建议:" #. Tag: para #, no-c-format -msgid "" -"It does not 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> 关系中比较有用。 " +msgid "It does not 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 #, 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\" 将其变为自动生命周期管理的对象" -"(lifecycle object)。 " +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\" 将其变为自动生命周期管理的对象(lifecycle object)。 " #. Tag: para #, 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\"。" +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 #, 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 " -"操作。" +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 #, no-c-format -msgid "" -"Furthermore, 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)操作准确语义如" -"下: " +msgid "Furthermore, 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 #, no-c-format -msgid "" -"If a parent is passed to persist(), all children are " -"passed to persist()" -msgstr "" -"如果父对象被 persist(),那么所有子对象也会被 " -"persist()" +msgid "If a parent is passed to persist(), all children are passed to persist()" +msgstr "如果父对象被 persist(),那么所有子对象也会被 persist()" #. Tag: para #, no-c-format -msgid "" -"If a parent is passed to merge(), all children are passed " -"to merge()" -msgstr "" -"如果父对象被 merge(),那么所有子对象也会被 merge" -"()" +msgid "If a parent is passed to merge(), all children are passed to merge()" +msgstr "如果父对象被 merge(),那么所有子对象也会被 merge()" #. Tag: para #, 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" -"()" +msgid "If a parent is passed to save(), update() or saveOrUpdate(), all children are passed to saveOrUpdate()" +msgstr "如果父对象被 save()update()saveOrUpdate(),那么所有子对象则会被 saveOrUpdate()" #. Tag: para #, 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()" +msgid "If a transient or detached child becomes referenced by a persistent parent, it is passed to saveOrUpdate()" +msgstr "如果某个持久的父对象引用了瞬时(transient)或者脱管(detached)的子对象,那么子对象将会被 saveOrUpdate()" #. Tag: para #, no-c-format -msgid "" -"If a parent is deleted, all children are passed to delete()" +msgid "If a parent is deleted, all children are passed to delete()" msgstr "如果父对象被删除,那么所有子对象也会被 delete()" #. Tag: para #, 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() 删除子对象。" +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 #, 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-update 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 的时候才作用到所有可触及的被关联对象上的。 " +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-update 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 #, no-c-format @@ -1492,32 +752,13 @@ msgstr "使用元数据" #. Tag: para #, no-c-format -msgid "" -"Hibernate requires a rich meta-level model of all entity and value types. " -"This model can be 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 objects that should not (e.g. immutable value types " -"and, possibly, associated entities)." -msgstr "" -"Hibernate 中有一个非常丰富的元级别(meta-level)的模型,含有所有的实体和值类" -"型数据的元数据。 有时这个模型对应用程序本身也会非常有用。比如说,应用程序可能" -"在实现一种“智能”的深度拷贝算法时,通过使用 Hibernate 的元数据来了解哪些对象应" -"该被拷贝(比如,可变的值类型数据),那些不应该(不可变的值类型数据,也许还有" -"某些被关联的实体)。 " +msgid "Hibernate requires a rich meta-level model of all entity and value types. This model can be 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 objects that should not (e.g. immutable value types and, possibly, associated entities)." +msgstr "Hibernate 中有一个非常丰富的元级别(meta-level)的模型,含有所有的实体和值类型数据的元数据。 有时这个模型对应用程序本身也会非常有用。比如说,应用程序可能在实现一种“智能”的深度拷贝算法时,通过使用 Hibernate 的元数据来了解哪些对象应该被拷贝(比如,可变的值类型数据),那些不应该(不可变的值类型数据,也许还有某些被关联的实体)。 " #. Tag: para #, no-c-format -msgid "" -"Hibernate exposes metadata via the ClassMetadata and " -"CollectionMetadata interfaces and the Type hierarchy. Instances of the metadata interfaces can be obtained " -"from the SessionFactory." -msgstr "" -"Hibernate 提供了 ClassMetadata 接口," -"CollectionMetadata 接口和 Type 层次体系" -"来访问元数据。可以通过 SessionFactory 获取元数据接口的实" -"例。 " +msgid "Hibernate exposes metadata via the ClassMetadata and CollectionMetadata interfaces and the Type hierarchy. Instances of the metadata interfaces can be obtained from the SessionFactory." +msgstr "Hibernate 提供了 ClassMetadata 接口,CollectionMetadata 接口和 Type 层次体系来访问元数据。可以通过 SessionFactory 获取元数据接口的实例。 " #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ msgstr "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" #~ msgstr "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ " ?\n" #~ "] ]>]]>" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ msgstr "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "]]>" #~ msgstr "]]>" - #~ msgid "" #~ "]]>" #~ msgstr "" #~ "]]>" - #~ msgid "" #~ "" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/toolset_guide.po b/documentation/manual/src/main/docbook/zh-CN/content/toolset_guide.po index 474c550352..d4854dcaee 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/toolset_guide.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/toolset_guide.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Collection_Mapping\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-02-11T05:38:16\n" -"PO-Revision-Date: 2009-12-04 15:04+1000\n" +"PO-Revision-Date: 2010-03-16 10:12+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,80 +21,38 @@ msgstr "工具箱指南" #. Tag: para #, no-c-format -msgid "" -"Roundtrip engineering with Hibernate is possible using a set of Eclipse " -"plugins, commandline tools, and Ant tasks." -msgstr "" -"可以通过一系列 Eclipse 插件、命令行工具和 Ant 任务来进行与 Hibernate 关联的转" -"换。 " +msgid "Roundtrip engineering with Hibernate is possible using a set of Eclipse plugins, commandline tools, and Ant tasks." +msgstr "可以通过一系列 Eclipse 插件、命令行工具和 Ant 任务来进行与 Hibernate 关联的转换。 " #. Tag: para #, no-c-format -msgid "" -"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 的插件,用于与现存数据库的逆向工程。 " +msgid "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 #, no-c-format -msgid "" -"Mapping Editor: an editor for Hibernate XML mapping " -"files that supports auto-completion and syntax highlighting. It also " -"supports semantic auto-completion for class names and property/field names, " -"making it more versatile than a normal XML editor." -msgstr "" -"Mapping Editor: Hibernate XML 映射文件的编辑器,支持自动" -"完成和语法高亮。它也支持对类名和属性/字段名的语义自动完成,比通常的 XML 编辑" -"器方便得多。 " +msgid "Mapping Editor: an editor for Hibernate XML mapping files that supports auto-completion and syntax highlighting. It also supports semantic auto-completion for class names and property/field names, making it more versatile than a normal XML editor." +msgstr "Mapping Editor: Hibernate XML 映射文件的编辑器,支持自动完成和语法高亮。它也支持对类名和属性/字段名的语义自动完成,比通常的 XML 编辑器方便得多。 " #. Tag: para #, no-c-format -msgid "" -"Console: the console is a new view in Eclipse. In " -"addition to a tree overview of your console configurations, you are also " -"provided with 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 中浏览结果。 " +msgid "Console: the console is a new view in Eclipse. In addition to a tree overview of your console configurations, you are also provided with 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 #, 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 to 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 映射文件。反向工程" -"支持可定制的模版。 " +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 to 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 #, no-c-format -msgid "" -"Please refer to the Hibernate Tools package " -"documentation for more information." -msgstr "" -"要得到更多信息,请查阅 Hibernate Tools 包及其文档。 " +msgid "Please refer to the Hibernate Tools package documentation for more information." +msgstr "要得到更多信息,请查阅 Hibernate Tools 包及其文档。 " #. Tag: para #, no-c-format -msgid "" -"However, the Hibernate main package comes bundled with an integrated tool : " -"SchemaExport aka hbm2ddl.It can even " -"be used from \"inside\" Hibernate." -msgstr "" -"同时,Hibernate 主发行包还附带了一个集成的工具(它甚至可以在 Hibernate“内" -"部”快速运行)SchemaExport ,也就是 hbm2ddl。 " +msgid "However, the Hibernate main package comes bundled with an integrated tool : SchemaExport aka hbm2ddl.It can even be used from \"inside\" Hibernate." +msgstr "同时,Hibernate 主发行包还附带了一个集成的工具(它甚至可以在 Hibernate“内部”快速运行)SchemaExport ,也就是 hbm2ddl。 " #. Tag: title #, no-c-format @@ -103,34 +61,18 @@ msgstr "Schema 自动生成(Automatic schema generation)" #. Tag: para #, no-c-format -msgid "" -"DDL can 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 也会同时生成。 " +msgid "DDL can 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 #, 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 是与供应商高度相关的。 " +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 #, no-c-format -msgid "" -"First, you must customize your mapping files to improve the generated " -"schema. The next section covers schema customization." -msgstr "" -"首先,要定制你的映射文件,来改善生成的 schema。下章将涵盖 schema 定制。" +msgid "First, you must customize your mapping files to improve the generated schema. The next section covers schema customization." +msgstr "首先,要定制你的映射文件,来改善生成的 schema。下章将涵盖 schema 定制。" #. Tag: title #, no-c-format @@ -139,94 +81,47 @@ msgstr "对 schema 定制化(Customizing the schema)" #. Tag: para #, no-c-format -msgid "" -"Many Hibernate mapping elements define optional attributes named " -"length, precision and scale. You can set the length, precision and scale of a column with this " -"attribute." -msgstr "" -"很多 Hibernate 映射元素定义了可选的 length、" -"precision 或者 scale 属性。你可以通过这" -"个属性设置字段的长度、精度、小数点位数。 " +msgid "Many Hibernate mapping elements define optional attributes named length, precision and scale. You can set the length, precision and scale of a column with this attribute." +msgstr "很多 Hibernate 映射元素定义了可选的 lengthprecision 或者 scale 属性。你可以通过这个属性设置字段的长度、精度、小数点位数。 " #. Tag: para #, no-c-format -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 约束)。 " +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 约束)。 " #. Tag: para #, no-c-format -msgid "" -"A unique-key attribute can 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. It is only used to group the " -"columns in the mapping file." -msgstr "" -"unique-key 属性可以对成组的字段指定一个唯一键约束(unique " -"key constraint)。目前,unique-key 属性指定的值在生成 DDL " -"时并不会被当作这个约束的名字,它们只是在用来在映射文件内" -"部用作区分的。 " +msgid "A unique-key attribute can 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. It is only used to group the columns in the mapping file." +msgstr "unique-key 属性可以对成组的字段指定一个唯一键约束(unique key constraint)。目前,unique-key 属性指定的值在生成 DDL 时并不会被当作这个约束的名字,它们只是在用来在映射文件内部用作区分的。 " #. Tag: para #, 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 can be " -"grouped into the same index by simply specifying the same index name." -msgstr "" -"index 属性会用对应的字段(一个或多个)生成一个 index,它指" -"出了这个 index 的名字。如果多个字段对应的 index 名字相同,就会生成包含这些字" -"段的 index。 " +msgid "An index attribute specifies the name of an index that will be created using the mapped column or columns. Multiple columns can be grouped into the same index by simply specifying the same index name." +msgstr "index 属性会用对应的字段(一个或多个)生成一个 index,它指出了这个 index 的名字。如果多个字段对应的 index 名字相同,就会生成包含这些字段的 index。 " #. Tag: para #, no-c-format -msgid "" -"A foreign-key attribute can be used to override the name " -"of any generated foreign key constraint." -msgstr "" -"foreign-key 属性可以用来覆盖任何生成的外键约束的名字。 " +msgid "A foreign-key attribute can be used to override the name of any generated foreign key constraint." +msgstr "foreign-key 属性可以用来覆盖任何生成的外键约束的名字。 " #. Tag: para #, no-c-format -msgid "" -"Many mapping elements also accept a child <column> " -"element. This is particularly useful for mapping multi-column types:" -msgstr "" -"很多映射元素还接受 <column> 子元素。这在定义跨越多字" -"段的类型时特别有用。" +msgid "Many mapping elements also accept a child <column> element. This is particularly useful for mapping multi-column types:" +msgstr "很多映射元素还接受 <column> 子元素。这在定义跨越多字段的类型时特别有用。" #. Tag: para #, no-c-format -msgid "" -"The default attribute allows you to 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 属性为字段指定一个默认值(在保存被映射的类的新实例" -"之前,你应该将同样的值赋于对应的属性)。" +msgid "The default attribute allows you to 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: para #, 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 数据" -"类型的映射。" +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: para #, no-c-format -msgid "" -"The check attribute allows you to specify a check " -"constraint." +msgid "The check attribute allows you to specify a check constraint." msgstr "check 属性允许用户指定一个约束检查。" #. Tag: para @@ -356,18 +251,8 @@ msgstr "foreign_key_name" #. Tag: entry #, 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 "" -"指明一个外键的名字,它是为关联生成的,或者是为 <one-to-one>, <many-to-one>, <key>, or <many-to-many> 映射元素。注意 " -"inverse=\"true\" 会被 SchemaExport 忽" -"略。" +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 "指明一个外键的名字,它是为关联生成的,或者是为 <one-to-one>, <many-to-one>, <key>, or <many-to-many> 映射元素。注意 inverse=\"true\" 会被 SchemaExport 忽略。" #. Tag: entry #, no-c-format @@ -375,15 +260,13 @@ msgid "sql-type" msgstr "sql-type" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "SQL column type" -msgstr "sql-type" +msgstr "SQL column type" #. Tag: entry #, no-c-format -msgid "" -"overrides the default column type (attribute of <column> element only)" +msgid "overrides the default column type (attribute of <column> element only)" msgstr "覆盖默认的字段类型(只能用于 <column> 属性)" #. Tag: entry @@ -413,20 +296,13 @@ msgstr "对字段或表加入 SQL 约束检查" #. Tag: para #, no-c-format -msgid "" -"The <comment> element allows you to specify " -"comments for the generated schema." -msgstr "" -"<comment> 元素可以让你在生成的 schema 中加入注释。" +msgid "The <comment> element allows you to specify comments for the generated schema." +msgstr "<comment> 元素可以让你在生成的 schema 中加入注释。" #. Tag: para #, 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 语句(假若支持的话)。 " +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 #, no-c-format @@ -435,30 +311,18 @@ msgstr "运行该工具" #. Tag: para #, no-c-format -msgid "" -"The SchemaExport tool writes a DDL script to standard out " -"and/or executes the DDL statements." -msgstr "" -"SchemaExport 工具把 DDL 脚本写到标准输出,同时/或者执行 " -"DDL 语句。" +msgid "The SchemaExport tool writes a DDL script to standard out and/or executes the DDL statements." +msgstr "SchemaExport 工具把 DDL 脚本写到标准输出,同时/或者执行 DDL 语句。" #. Tag: para #, no-c-format -msgid "" -"The following table displays the SchemaExport command " -"line options" +msgid "The following table displays the SchemaExport command line options" msgstr "下表显示了 SchemaExport 命令行选项" #. Tag: para #, no-c-format -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" +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: title #, no-c-format @@ -516,9 +380,9 @@ msgid "do not export to the database" msgstr "不执行在数据库中运行的步骤 " #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "--output=my_schema.ddl" -msgstr "scale" +msgstr "--output=my_schema.ddl" #. Tag: entry #, no-c-format @@ -526,9 +390,9 @@ msgid "output the ddl script to a file" msgstr "把输出的 ddl 脚本输出到一个文件" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "--naming=eg.MyNamingStrategy" -msgstr "--naming=eg.MyNamingStrategy" +msgstr "--naming=eg.MyNamingStrategy " #. Tag: entry #, no-c-format @@ -536,9 +400,9 @@ msgid "select a NamingStrategy" msgstr "选择 NamingStrategy" #. Tag: entry -#, fuzzy, no-c-format +#, no-c-format msgid "--config=hibernate.cfg.xml" -msgstr "hibernate.dialect" +msgstr "--config=hibernate.cfg.xml" #. Tag: entry #, no-c-format @@ -592,11 +456,8 @@ msgstr "可以通过如下方式指定数据库属性: " #. Tag: para #, no-c-format -msgid "" -"as system properties with -D<property>" -msgstr "" -"通过 -D<property> 系统参数" +msgid "as system properties with -D<property>" +msgstr "通过 -D<property> 系统参数" #. Tag: para #, no-c-format @@ -606,9 +467,7 @@ msgstr "在 hibernate.properties 文件中" #. Tag: para #, no-c-format msgid "in a named properties file with --properties" -msgstr "" -"位于一个其它名字的 properties 文件中,然后用 --properties " -"参数指定" +msgstr "位于一个其它名字的 properties 文件中,然后用 --properties 参数指定" #. Tag: para #, no-c-format @@ -682,8 +541,7 @@ msgstr "使用 Ant(Using Ant)" #. Tag: para #, no-c-format -msgid "" -"You can call SchemaExport from your Ant build script:" +msgid "You can call SchemaExport from your Ant build script:" msgstr "你可以在你的 Ant build 脚本中调用 SchemaExport:" #. Tag: title @@ -693,25 +551,13 @@ msgstr "对 schema 的增量更新(Incremental schema updates)" #. Tag: para #, no-c-format -msgid "" -"The SchemaUpdate tool will update an existing schema with " -"\"incremental\" changes. The SchemaUpdate depends upon " -"the JDBC metadata API and, as such, will not work with all JDBC drivers." -msgstr "" -"SchemaUpdate 工具对已存在的 schema 采用\"增量\"方式进行更" -"新。注意 SchemaUpdate 严重依赖于 JDBC metadata API,所以它" -"并非对所有 JDBC 驱动都有效。 " +msgid "The SchemaUpdate tool will update an existing schema with \"incremental\" changes. The SchemaUpdate depends upon the JDBC metadata API and, as such, will not work with all JDBC drivers." +msgstr "SchemaUpdate 工具对已存在的 schema 采用\"增量\"方式进行更新。注意 SchemaUpdate 严重依赖于 JDBC metadata API,所以它并非对所有 JDBC 驱动都有效。 " #. Tag: para #, no-c-format -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" +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: title #, no-c-format @@ -750,33 +596,17 @@ msgstr "Schema 校验" #. Tag: para #, no-c-format -msgid "" -"The SchemaValidator tool will validate that the existing " -"database schema \"matches\" your mapping documents. The " -"SchemaValidator depends heavily upon the JDBC metadata " -"API and, as such, will not work with all JDBC drivers. This tool is " -"extremely useful for testing." -msgstr "" -"SchemaValidator 工具会比较数据库现状是否与映射文档“匹配”。" -"注意,SchemaValidator 严重依赖于 JDBC 的 metadata API,因" -"此不是对所有的 JDBC 驱动都适用。这一工具在测试的时候特别有用。 " +msgid "The SchemaValidator tool will validate that the existing database schema \"matches\" your mapping documents. The SchemaValidator depends heavily upon the JDBC metadata API and, as such, will not work with all JDBC drivers. This tool is extremely useful for testing." +msgstr "SchemaValidator 工具会比较数据库现状是否与映射文档“匹配”。注意,SchemaValidator 严重依赖于 JDBC 的 metadata API,因此不是对所有的 JDBC 驱动都适用。这一工具在测试的时候特别有用。 " #. Tag: para #, no-c-format -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" +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 #, no-c-format -msgid "" -"The following table displays the SchemaValidator command " -"line options:" +msgid "The following table displays the SchemaValidator command line options:" msgstr "下表显示了 SchemaValidator 命令行参数:" #. Tag: title @@ -917,54 +747,40 @@ msgstr "你可以在 Ant 脚本中调用 SchemaValidator:" #~ " ...\n" #~ " <property name=\"bar\" type=\"float\"/>\n" #~ "</class>" - #~ msgid "length" #~ msgstr "length" - #~ msgid "precision" #~ msgstr "precision" - #~ msgid "scale" #~ msgstr "scale" - #~ msgid "not-null" #~ msgstr "not-null" - #~ msgid "true|false" #~ msgstr "true|false" - #~ msgid "unique" #~ msgstr "unique" - #~ msgid "index" #~ msgstr "index" - #~ msgid "index_name" #~ msgstr "index_name" - #~ msgid "unique-key" #~ msgstr "unique-key" - #~ msgid "unique_key_name" #~ msgstr "unique_key_name" - #~ msgid "foreign-key" #~ msgstr "foreign-key" #, fuzzy #~ msgid "foreign_key_name" #~ msgstr "foreign-key" - #~ msgid "sql-type" #~ msgstr "sql-type" #, fuzzy #~ msgid "SQL column type" #~ msgstr "SQL column type" - #~ msgid "default" #~ msgstr "default" - #~ msgid "check" #~ msgstr "check" @@ -993,16 +809,12 @@ msgstr "你可以在 Ant 脚本中调用 SchemaValidator:" #~ " <comment>Balance in USD</comment>\n" #~ " </column>\n" #~ "</property>" - #~ msgid "--quiet" #~ msgstr "--quiet" - #~ msgid "--drop" #~ msgstr "--drop" - #~ msgid "--create" #~ msgstr "--create" - #~ msgid "--text" #~ msgstr "--text" @@ -1013,13 +825,10 @@ msgstr "你可以在 Ant 脚本中调用 SchemaValidator:" #, fuzzy #~ msgid "--config=hibernate.cfg.xml" #~ msgstr "--config=hibernate.cfg.xml" - #~ msgid "--properties=hibernate.properties" #~ msgstr "--properties=hibernate.properties" - #~ msgid "--format" #~ msgstr "--format" - #~ msgid "--delimiter=;" #~ msgstr "--delimiter=;" @@ -1034,16 +843,12 @@ msgstr "你可以在 Ant 脚本中调用 SchemaValidator:" #, fuzzy #~ msgid "hibernate.connection.driver_class" #~ msgstr "hibernate.connection.url" - #~ msgid "hibernate.connection.url" #~ msgstr "hibernate.connection.url" - #~ msgid "hibernate.connection.username" #~ msgstr "hibernate.connection.username" - #~ msgid "hibernate.connection.password" #~ msgstr "hibernate.connection.password" - #~ msgid "hibernate.dialect" #~ msgstr "hibernate.dialect" @@ -1158,6 +963,6 @@ msgstr "你可以在 Ant 脚本中调用 SchemaValidator:" #~ " </fileset>\n" #~ " </schemaupdate>\n" #~ "</target>" - #~ msgid "" #~ msgstr "" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/transactions.po b/documentation/manual/src/main/docbook/zh-CN/content/transactions.po index dff8882925..4a0f26ca4a 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/transactions.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/transactions.po @@ -6,7 +6,7 @@ msgstr "" "Project-Id-Version: Collection_Mapping\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-02-11T05:38:16\n" -"PO-Revision-Date: 2010-01-11 10:41+1000\n" +"PO-Revision-Date: 2010-03-16 09:58+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -21,54 +21,23 @@ msgstr "事务和并发 " #. Tag: para #, no-c-format -msgid "" -"The most important point about Hibernate and concurrency control is that it " -"is easy to understand. Hibernate directly uses JDBC connections and JTA " -"resources without adding any additional locking behavior. It is recommended " -"that 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 查" -"询语言和你使用的数据库系统的事务隔离规范。 " +msgid "The most important point about Hibernate and concurrency control is that it is easy to understand. Hibernate directly uses JDBC connections and JTA resources without adding any additional locking behavior. It is recommended that 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 查询语言和你使用的数据库系统的事务隔离规范。 " #. Tag: para #, 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. " -"Through Session, which is also a transaction-scoped " -"cache, Hibernate provides repeatable reads for lookup by identifier and " -"entity queries and not reporting queries that return scalar values." -msgstr "" -"Hibernate 不锁定内存中的对象。你的应用程序会按照你的数据库事务的隔离级别规定" -"的那样运作。幸亏有了 Session,使得 Hibernate 通过标识符查" -"找,和实体查询(不是返回标量值的报表查询)提供了可重复的读取(Repeatable " -"reads)功能,Session 同时也是事务范围内的缓存(cache)。 " +msgid "Hibernate does not lock objects in memory. Your application can expect the behavior as defined by the isolation level of your database transactions. Through Session, which is also a transaction-scoped cache, Hibernate provides repeatable reads for lookup by identifier and entity queries and not reporting queries that return scalar values." +msgstr "Hibernate 不锁定内存中的对象。你的应用程序会按照你的数据库事务的隔离级别规定的那样运作。幸亏有了 Session,使得 Hibernate 通过标识符查找,和实体查询(不是返回标量值的报表查询)提供了可重复的读取(Repeatable reads)功能,Session 同时也是事务范围内的缓存(cache)。 " #. Tag: para #, no-c-format -msgid "" -"In addition to versioning for automatic optimistic concurrency control, " -"Hibernate also offers, using the SELECT FOR UPDATE " -"syntax, a (minor) API for pessimistic locking of rows. Optimistic " -"concurrency control and this API are discussed later in this chapter." -msgstr "" -"除了对自动乐观并发控制提供版本管理,针对行级悲观锁定,Hibernate 也提供了辅助" -"的(较小的)API,它使用了 SELECT FOR UPDATE 的 SQL 语法。" -"本章后面会讨论乐观并发控制和这个API。 " +msgid "In addition to versioning for automatic optimistic concurrency control, Hibernate also offers, using the SELECT FOR UPDATE syntax, a (minor) API for pessimistic locking of rows. Optimistic concurrency control and this API are discussed later in this chapter." +msgstr "除了对自动乐观并发控制提供版本管理,针对行级悲观锁定,Hibernate 也提供了辅助的(较小的)API,它使用了 SELECT FOR UPDATE 的 SQL 语法。本章后面会讨论乐观并发控制和这个API。 " #. Tag: para #, no-c-format -msgid "" -"The discussion of concurrency control in Hibernate begins with the " -"granularity of Configuration, SessionFactory, and Session, as well as database transactions " -"and long conversations." -msgstr "" -"我们从 Configuration层、SessionFactory " -"层,和 Session 层开始讨论 Hibernate 的并行控制、数据库事务" -"和应用程序的长事务。 " +msgid "The discussion of concurrency control in Hibernate begins with the granularity of Configuration, SessionFactory, and Session, as well as database transactions and long conversations." +msgstr "我们从 Configuration层、SessionFactory 层,和 Session 层开始讨论 Hibernate 的并行控制、数据库事务和应用程序的长事务。 " #. Tag: title #, no-c-format @@ -77,58 +46,23 @@ msgstr "Session 和事务范围(transaction scope)" #. Tag: para #, 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 的实例来创建。 " +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 的实例来创建。 " #. Tag: para #, no-c-format -msgid "" -"A Session is an inexpensive, non-threadsafe object that " -"should be used once and then discarded for: a single request, a conversation " -"or a single unit of work. A Session will not obtain a " -"JDBC Connection, or a Datasource, " -"unless it is needed. It will not consume any resources until used." -msgstr "" -"Session 对象的创建代价比较小,是非线程安全的,对于单个请" -"求,单个会话、单个的 工作单元而言,它只被使用一次,然后就丢弃。只有在需要的时" -"候,一个 Session 对象 才会获取一个 JDBC 的 " -"Connection(或一个Datasource)对象,因" -"此假若不使用的时候它不消费任何资源。 " +msgid "A Session is an inexpensive, non-threadsafe object that should be used once and then discarded for: a single request, a conversation or a single unit of work. A Session will not obtain a JDBC Connection, or a Datasource, unless it is needed. It will not consume any resources until used." +msgstr "Session 对象的创建代价比较小,是非线程安全的,对于单个请求,单个会话、单个的 工作单元而言,它只被使用一次,然后就丢弃。只有在需要的时候,一个 Session 对象 才会获取一个 JDBC 的 Connection(或一个Datasource)对象,因此假若不使用的时候它不消费任何资源。 " #. Tag: para #, no-c-format -msgid "" -"In order to reduce lock contention in the database, a database transaction " -"has to be as short as possible. Long database transactions will prevent your " -"application from scaling to a highly concurrent load. It is not recommended " -"that you hold a database transaction open during user think time until the " -"unit of work is complete." -msgstr "" -"此外我们还要考虑数据库事务。数据库事务应该尽可能的短,降低数据库中的锁争用。" -"数据库长事务会阻止你的应用程序扩展到高的并发负载。因此,假若在用户思考期间让" -"数据库事务开着,直到整个工作单元完成才关闭这个事务,这绝不是一个好的设计。 " +msgid "In order to reduce lock contention in the database, a database transaction has to be as short as possible. Long database transactions will prevent your application from scaling to a highly concurrent load. It is not recommended that you hold a database transaction open during user think time until the unit of work is complete." +msgstr "此外我们还要考虑数据库事务。数据库事务应该尽可能的短,降低数据库中的锁争用。数据库长事务会阻止你的应用程序扩展到高的并发负载。因此,假若在用户思考期间让数据库事务开着,直到整个工作单元完成才关闭这个事务,这绝不是一个好的设计。 " #. Tag: para #, 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? These questions are addressed in the following sections." -msgstr "" -"一个操作单元(Unit of work)的范围是多大?单个的 Hibernate Session 能跨越多个数据库事务吗?还是一个 Session 的作用范" -"围对应一个数据库事务的范围?应该何时打开 Session,何时关" -"闭 Session,你又如何划分数据库事务的边界呢?我们将在后续章" -"节解决这些问题。" +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? These questions are addressed in the following sections." +msgstr "一个操作单元(Unit of work)的范围是多大?单个的 Hibernate Session 能跨越多个数据库事务吗?还是一个 Session 的作用范围对应一个数据库事务的范围?应该何时打开 Session,何时关闭 Session,你又如何划分数据库事务的边界呢?我们将在后续章节解决这些问题。" #. Tag: title #, no-c-format @@ -136,138 +70,34 @@ msgid "Unit of work" msgstr "操作单元(Unit of work)" #. Tag: para -#, fuzzy, no-c-format -msgid "" -"First, let's define a unit of work. A unit of work is a design pattern " -"described by Martin Fowler as [maintaining] a list of objects " -"affected by a business transaction and coordinates the writing out of " -"changes and the resolution of concurrency problems. PoEAA In other words, its a series of operations we wish to carry out " -"against the database together. Basically, it is a transaction, though " -"fulfilling a unit of work will often span multiple physical database " -"transactions (see ). So really " -"we are talking about a more abstract notion of a transaction. The term " -"\"business transaction\" is also sometimes used in lieu of unit of work." -msgstr "" -"首先,让我们定义一个工作单元(unit of work)。工作单元是一个设计模式,Martin " -"Fowler 把它描述为 [maintaining] a list of objects affected by a " -"business transaction and coordinates the writing out of changes and the " -"resolution of concurrency problems. PoEAA 换句话" -"说,它是我们希望对数据库执行的一系列操作。基本上,它是一个事务,虽然完成一个" -"工作单元经常将跨越多个物理数据库事务(请参考 )。所以,实际上我们在讨论一个更抽象的事务概念。术语 " -"\"business transaction\" 有时也和工作单元一起使用。 " +#, no-c-format +msgid "First, let's define a unit of work. A unit of work is a design pattern described by Martin Fowler as [maintaining] a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems. PoEAA In other words, its a series of operations we wish to carry out against the database together. Basically, it is a transaction, though fulfilling a unit of work will often span multiple physical database transactions (see ). So really we are talking about a more abstract notion of a transaction. The term \"business transaction\" is also sometimes used in lieu of unit of work." +msgstr "首先,让我们定义一个工作单元(unit of work)。工作单元是一个设计模式,Martin Fowler 把它描述为 [maintaining] a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems. PoEAA 换句话说,它是我们希望对数据库执行的一系列操作。基本上,它是一个事务,虽然完成一个工作单元经常将跨越多个物理数据库事务(请参考 )。所以,实际上我们在讨论一个更抽象的事务概念。术语 \"business transaction\" 有时也和工作单元一起使用。" #. Tag: para #, no-c-format -msgid "" -"Do not use the session-per-operation antipattern: do " -"not open and close a Session for every simple database " -"call in a single thread. 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. This also means that auto-commit after " -"every single SQL statement is useless in an application as this mode is " -"intended for ad-hoc SQL console work. Hibernate disables, or expects the " -"application server to disable, auto-commit mode immediately. Database " -"transactions are never optional. All communication with a database has to " -"occur inside a transaction. 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 more maintainable and " -"extensible." -msgstr "" -"首先,别用 session-per-operation 这种反模式了,也就是" -"说,在单个线程中, 不要因为一次简单的数据库调用,就打开和关闭一次 " -"Session!数据库事务也是如此。 应用程序中的数据库调用是按照" -"计划好的次序,分组为原子的操作单元。(注意,这也意味着,应用程 序中,在单个" -"的 SQL 语句发送之后,自动事务提交(auto-commit)模式失效了。这种模式专门为SQL" -"控制台操作设计的。 Hibernate 禁止立即自动事务提交模式,或者期望应用服务器禁止" -"立即自动事务提交模式。)数据库事务绝不是可有可无的,任何与数据库之间的通讯都" -"必须在某个事务中进行,不管你是在读还是在写数据。对读数据而言,应该避免 auto-" -"commit 行为,因为很多小的事务比一个清晰定义的工作单元性能差。后者也更容易维护" -"和扩展。 " +msgid "Do not use the session-per-operation antipattern: do not open and close a Session for every simple database call in a single thread. 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. This also means that auto-commit after every single SQL statement is useless in an application as this mode is intended for ad-hoc SQL console work. Hibernate disables, or expects the application server to disable, auto-commit mode immediately. Database transactions are never optional. All communication with a database has to occur inside a transaction. 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 more maintainable and extensible." +msgstr "首先,别用 session-per-operation 这种反模式了,也就是说,在单个线程中, 不要因为一次简单的数据库调用,就打开和关闭一次 Session!数据库事务也是如此。 应用程序中的数据库调用是按照计划好的次序,分组为原子的操作单元。(注意,这也意味着,应用程 序中,在单个的 SQL 语句发送之后,自动事务提交(auto-commit)模式失效了。这种模式专门为SQL控制台操作设计的。 Hibernate 禁止立即自动事务提交模式,或者期望应用服务器禁止立即自动事务提交模式。)数据库事务绝不是可有可无的,任何与数据库之间的通讯都必须在某个事务中进行,不管你是在读还是在写数据。对读数据而言,应该避免 auto-commit 行为,因为很多小的事务比一个清晰定义的工作单元性能差。后者也更容易维护和扩展。 " #. Tag: para #, 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 sent 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. On completion of the work, and " -"once the response for the client has been prepared, the session is flushed " -"and closed. 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 之前提交事务。会话和请求之间" -"的关系是一对一的关系,这种模式对 于大多数应用程序来说是很棒的。 " +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 sent 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. On completion of the work, and once the response for the client has been prepared, the session is flushed and closed. 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 之前提交事务。会话和请求之间的关系是一对一的关系,这种模式对 于大多数应用程序来说是很棒的。 " #. Tag: para #, no-c-format -msgid "" -"The challenge lies in the implementation. Hibernate provides built-in " -"management of the \"current session\" to simplify this pattern. Start a " -"transaction when a server request has to be processed, and end the " -"transaction before the response is sent to the client. 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 use " -"programmatic transaction demarcation, for ease of use and code portability " -"use the Hibernate Transaction API shown later in this " -"chapter." -msgstr "" -"实现才是真正的挑战。Hibernate 内置了对\"当前 session(current session)\" 的" -"管理,用于简化此模式。你要做的一切就是在服务器端要处理请求的时候,开启事务," -"在响应发送给客户之前结束事务。你可以用任何方式来完成这一操作,通常的方案有 " -"ServletFilter,在 service 方法中进行 pointcut 的 AOP 拦截" -"器,或者 proxy/interception 容器。EJB 容器是实现横切诸如 EJB session bean 上" -"的事务分界,用 CMT 对事务进行声明等方面的标准手段。假若你决定使用编程式的事务" -"分界,请参考本章后面讲到的 Hibernate Transaction API,这对" -"易用性和代码可移植性都有好处。 " - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"Your application code can access a \"current session\" to process the " -"request by calling sessionFactory.getCurrentSession(). " -"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 " -"环境时,必须配置它,请参见 。 " +msgid "The challenge lies in the implementation. Hibernate provides built-in management of the \"current session\" to simplify this pattern. Start a transaction when a server request has to be processed, and end the transaction before the response is sent to the client. 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 use programmatic transaction demarcation, for ease of use and code portability use the Hibernate Transaction API shown later in this chapter." +msgstr "实现才是真正的挑战。Hibernate 内置了对\"当前 session(current session)\" 的管理,用于简化此模式。你要做的一切就是在服务器端要处理请求的时候,开启事务,在响应发送给客户之前结束事务。你可以用任何方式来完成这一操作,通常的方案有 ServletFilter,在 service 方法中进行 pointcut 的 AOP 拦截器,或者 proxy/interception 容器。EJB 容器是实现横切诸如 EJB session bean 上的事务分界,用 CMT 对事务进行声明等方面的标准手段。假若你决定使用编程式的事务分界,请参考本章后面讲到的 Hibernate Transaction API,这对易用性和代码可移植性都有好处。 " #. Tag: para #, no-c-format -msgid "" -"You can 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 achieved by implementing your own interceptor. However, this " -"will be difficult if you rely on EJBs with container-managed transactions. 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 relating to this Open Session in View pattern." -msgstr "" -"有时,将 Session 和数据库事务的边界延伸到\"展示层被渲染后" -"\"会带来便利。有些 serlvet 应用程序在对请求进行处理后,有个单独的渲染期,这种" -"延伸对这种程序特别有用。假若你实现你自己的拦截器,把事务边界延伸到展示层渲染" -"结束后非常容易。然而,假若你依赖有容器管理事务的 EJB,这就不太容易了,因为事" -"务会在 EJB 方法返回后结束,而那是在任何展示层渲染开始之前。请访问 Hibernate " -"网站和论坛,你可以找到 Open Session in View 这一模式的提" -"示和示例。 " +msgid "Your application code can access a \"current session\" to process the request by calling sessionFactory.getCurrentSession(). 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 环境时,必须配置它,请参见 。" + +#. Tag: para +#, no-c-format +msgid "You can 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 achieved by implementing your own interceptor. However, this will be difficult if you rely on EJBs with container-managed transactions. 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 relating to this Open Session in View pattern." +msgstr "有时,将 Session 和数据库事务的边界延伸到\"展示层被渲染后\"会带来便利。有些 serlvet 应用程序在对请求进行处理后,有个单独的渲染期,这种延伸对这种程序特别有用。假若你实现你自己的拦截器,把事务边界延伸到展示层渲染结束后非常容易。然而,假若你依赖有容器管理事务的 EJB,这就不太容易了,因为事务会在 EJB 方法返回后结束,而那是在任何展示层渲染开始之前。请访问 Hibernate 网站和论坛,你可以找到 Open Session in View 这一模式的提示和示例。 " #. Tag: title #, no-c-format @@ -276,141 +106,53 @@ msgstr "长对话" #. Tag: para #, no-c-format -msgid "" -"The session-per-request pattern is not the only way of designing units of " -"work. Many business processes require a whole series of interactions with " -"the user that are 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 的应用和企业应用中,跨用户交互的数据库事务是无法接受的。考虑下" -"面的例子: " +msgid "The session-per-request pattern is not the only way of designing units of work. Many business processes require a whole series of interactions with the user that are 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 的应用和企业应用中,跨用户交互的数据库事务是无法接受的。考虑下面的例子: " #. Tag: para #, 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)的。用户可以随意修改对话框中的数据对象。 " +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)的。用户可以随意修改对话框中的数据对象。 " #. Tag: para #, no-c-format -msgid "" -"The user clicks \"Save\" after 5 minutes and expects their modifications to " -"be made persistent. The user also expects that they were the only person " -"editing this information and that no conflicting modification has occurred." -msgstr "" -"5 分钟后,用户点击“保存”,期望所做出的修改被持久化;同时他也期望自己是唯一修" -"改这个信息的人,不会出现修改冲突。 " +msgid "The user clicks \"Save\" after 5 minutes and expects their modifications to be made persistent. The user also expects that they were the only person editing this information and that no conflicting modification has occurred." +msgstr "5 分钟后,用户点击“保存”,期望所做出的修改被持久化;同时他也期望自己是唯一修改这个信息的人,不会出现修改冲突。 " #. Tag: para #, no-c-format -msgid "" -"From the point of view of the user, we call this unit of work a long-running " -"conversation or application transaction. There are many ways to implement this in your application." -msgstr "" -"从用户的角度来看,我们把这个操作单元称为长时间运行的对话" -"(conversation),或者应用事务(application " -"transaction)。在你的应用程序中,可以有很多种方法来实现它。" +msgid "From the point of view of the user, we call this unit of work a long-running conversation or application transaction. There are many ways to implement this in your application." +msgstr "从用户的角度来看,我们把这个操作单元称为长时间运行的对话(conversation),或者应用事务(application transaction)。在你的应用程序中,可以有很多种方法来实现它。" #. Tag: para #, 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 an anti-pattern, since lock contention would not allow " -"the application to scale with the number of concurrent users." -msgstr "" -"头一个幼稚的做法是,在用户思考的过程中,保持 Session 和数" -"据库事务是打开的,保持数据库锁定,以阻止并发修改,从而保证数据库事务隔离级别" -"和原子操作。这种方式当然是一个反模式,因为锁争用会导致应用程序无法扩展并发用" -"户的数目。 " +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 an anti-pattern, since lock contention would not allow the application to scale with the number of concurrent users." +msgstr "头一个幼稚的做法是,在用户思考的过程中,保持 Session 和数据库事务是打开的,保持数据库锁定,以阻止并发修改,从而保证数据库事务隔离级别和原子操作。这种方式当然是一个反模式,因为锁争用会导致应用程序无法扩展并发用户的数目。 " #. Tag: para #, no-c-format -msgid "" -"You have to use several database transactions to implement the conversation. " -"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 (for example, in a wizard-style dialog spanning " -"several request/response cycles). This is easier to implement than it might " -"sound, especially if you utilize some of Hibernate's features:" -msgstr "" -"很明显,我们必须使用多个数据库事务来实现这个对话。在这个例子中,维护业务处理" -"的 事务隔离变成了应用程序层的部分责任。一个对话通常跨越多个数据库事务。如果仅" -"仅只有一个数据库事务(最后的那个事务)保存更新过的数据,而所有其他事务只是单" -"纯的读取数据(例如在一个跨越多个请求/响应周期的向导风格的对话框中),那么应用" -"程序事务将保证其原子性。这种方式比听起来还要容易实现,特别是当你使用了 " -"Hibernate 的下述特性的时候: " +msgid "You have to use several database transactions to implement the conversation. 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 (for example, in a wizard-style dialog spanning several request/response cycles). This is easier to implement than it might sound, especially if you utilize some of Hibernate's features:" +msgstr "很明显,我们必须使用多个数据库事务来实现这个对话。在这个例子中,维护业务处理的 事务隔离变成了应用程序层的部分责任。一个对话通常跨越多个数据库事务。如果仅仅只有一个数据库事务(最后的那个事务)保存更新过的数据,而所有其他事务只是单纯的读取数据(例如在一个跨越多个请求/响应周期的向导风格的对话框中),那么应用程序事务将保证其原子性。这种方式比听起来还要容易实现,特别是当你使用了 Hibernate 的下述特性的时候: " #. Tag: para #, no-c-format -msgid "" -"Automatic Versioning: Hibernate can perform automatic " -"optimistic concurrency control for you. It can automatically detect if a " -"concurrent modification occurred during user think time. Check for this at " -"the end of the conversation." -msgstr "" -"自动版本化:Hibernate 能够自动进行乐观并发控制,如果在用" -"户思考的过程中发生并发修改,Hibernate 能够自动检测到。一般我们只在对话结束时" -"才检查。" +msgid "Automatic Versioning: Hibernate can perform automatic optimistic concurrency control for you. It can automatically detect if a concurrent modification occurred during user think time. Check for this at the end of the conversation." +msgstr "自动版本化:Hibernate 能够自动进行乐观并发控制,如果在用户思考的过程中发生并发修改,Hibernate 能够自动检测到。一般我们只在对话结束时才检查。" #. Tag: para #, no-c-format -msgid "" -"Detached Objects: if you decide to use the " -"session-per-request pattern, all loaded instances will " -"be in the 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。自动版本化被" -"用来隔离并发修改。" +msgid "Detached Objects: if you decide to use the session-per-request pattern, all loaded instances will be in the 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。自动版本化被用来隔离并发修改。" #. Tag: para #, no-c-format -msgid "" -"Extended (or Long) Session: the Hibernate " -"Session can 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 will not be allowed to be flushed automatically, " -"but explicitly." -msgstr "" -"Extended (or Long) Session:Hibernate 的 " -"Session 可以在数据库事务提交之后和底层的 JDBC 连接断开,当" -"一个新的客户端请求到来的时候,它又重新连接上底层的 JDBC 连接。这种模式被称之" -"为session-per-conversation,这种情况可 能会造成不必要的 " -"Session 和 JDBC 连接的重新关联。自动版本化被用来隔离并发修改," -"Session 通常不允许自动 flush,而是显性地 flush。 " +msgid "Extended (or Long) Session: the Hibernate Session can 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 will not be allowed to be flushed automatically, but explicitly." +msgstr "Extended (or Long) Session:Hibernate 的 Session 可以在数据库事务提交之后和底层的 JDBC 连接断开,当一个新的客户端请求到来的时候,它又重新连接上底层的 JDBC 连接。这种模式被称之为session-per-conversation,这种情况可 能会造成不必要的 Session 和 JDBC 连接的重新关联。自动版本化被用来隔离并发修改,Session 通常不允许自动 flush,而是显性地 flush。 " #. Tag: para #, no-c-format -msgid "" -"Both session-per-request-with-detached-objects and " -"session-per-conversation have advantages and " -"disadvantages. These disadvantages are discussed later in this chapter in " -"the context of optimistic concurrency control." -msgstr "" -"session-per-request-with-detached-objects 和 " -"session-per-conversation 各有优缺点,我们在本章后面乐观" -"并发控制那部分再进行讨论。 " +msgid "Both session-per-request-with-detached-objects and session-per-conversation have advantages and disadvantages. These disadvantages are discussed later in this chapter in the context of optimistic concurrency control." +msgstr "session-per-request-with-detached-objectssession-per-conversation 各有优缺点,我们在本章后面乐观并发控制那部分再进行讨论。 " #. Tag: title #, no-c-format @@ -419,15 +161,8 @@ msgstr "关注对象标识(Considering object identity)" #. Tag: para #, no-c-format -msgid "" -"An application can concurrently access the same persistent state in two " -"different Sessions. However, an instance of a persistent " -"class is never shared between two Session instances. It " -"is for this reason that there are two different notions of identity:" -msgstr "" -"应用程序可能在两个不同的 Session 中并发访问同一持久化状" -"态,但是,一个持久化类的实例无法在两个 Session 中共享。因" -"此有两种不同的标识语义: " +msgid "An application can concurrently access the same persistent state in two different Sessions. However, an instance of a persistent class is never shared between two Session instances. It is for this reason that there are two different notions of identity:" +msgstr "应用程序可能在两个不同的 Session 中并发访问同一持久化状态,但是,一个持久化类的实例无法在两个 Session 中共享。因此有两种不同的标识语义: " #. Tag: term #, no-c-format @@ -435,9 +170,9 @@ msgid "Database Identity" msgstr "数据库标识" #. Tag: para -#, fuzzy, no-c-format +#, no-c-format msgid "foo.getId().equals( bar.getId() )" -msgstr "foo.getId().equals( bar.getId() )" +msgstr "foo.getId().equals( bar.getId() ) " #. Tag: term #, no-c-format @@ -451,79 +186,18 @@ msgstr "foo==bar" #. Tag: para #, no-c-format -msgid "" -"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. 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 an optimistic approach and automatic versioning at flush/" -"commit time." -msgstr "" -"对于那些关联到 特定 Session(也就是在" -"单个 Session 的范围内)上的对象来说,这两种标识的语义是等" -"价的,与数据库标识对应的 JVM 标识是由 Hibernate 来保证的。不过,当应用程序在" -"两个不同的 session 中并发访问具有同一持久化标识的业务对象实例的时候,这个业务" -"对象的两个实例事实上是不相同的(从 JVM 识别来看)。这种冲突可以通过在同步和提" -"交的时候使用自动版本化和乐观锁定方法来解决。 " +msgid "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. 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 an optimistic approach and automatic versioning at flush/commit time." +msgstr "对于那些关联到 特定 Session(也就是在单个 Session 的范围内)上的对象来说,这两种标识的语义是等价的,与数据库标识对应的 JVM 标识是由 Hibernate 来保证的。不过,当应用程序在两个不同的 session 中并发访问具有同一持久化标识的业务对象实例的时候,这个业务对象的两个实例事实上是不相同的(从 JVM 识别来看)。这种冲突可以通过在同步和提交的时候使用自动版本化和乐观锁定方法来解决。 " #. Tag: para #, 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 means that it does not need expensive locking or " -"other means of synchronization. The application does not need to synchronize " -"on any business object, as long as it maintains a single thread per " -"Session. Within a Session the " -"application can safely use == to compare objects." -msgstr "" -"这种方式把关于并发的头疼问题留给了 Hibernate 和数据库;由于在单个线程内,操作" -"单元中的对象识别不 需要代价昂贵的锁定或其他意义上的同步,因此它同时可以提供最" -"好的可伸缩性。只要在单个线程只持有一个 Session,应用程序就" -"不需要同步任何业务对象。在 Session 的范围内,应用程序可以" -"放心的使用 == 进行对象比较。 " +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 means that it does not need expensive locking or other means of synchronization. The application does not need to synchronize on any business object, as long as it maintains a single thread per Session. Within a Session the application can safely use == to compare objects." +msgstr "这种方式把关于并发的头疼问题留给了 Hibernate 和数据库;由于在单个线程内,操作单元中的对象识别不 需要代价昂贵的锁定或其他意义上的同步,因此它同时可以提供最好的可伸缩性。只要在单个线程只持有一个 Session,应用程序就不需要同步任何业务对象。在 Session 的范围内,应用程序可以放心的使用 == 进行对象比较。 " #. Tag: para #, no-c-format -msgid "" -"However, an application that uses == outside of a " -"Session might produce 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). JVM identity, " -"however, is by definition not guaranteed for instances in a detached state. " -"The developer has to override the equals() and " -"hashCode() methods in persistent classes and implement " -"their own notion of object equality. There is one caveat: never use the " -"database identifier to implement equality. Use a business key that is 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 do not 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. Please 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 对象标识和" -"判等行为如何实现的问题。 " +msgid "However, an application that uses == outside of a Session might produce 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). JVM identity, however, is by definition not guaranteed for instances in a detached state. The developer has to override the equals() and hashCode() methods in persistent classes and implement their own notion of object equality. There is one caveat: never use the database identifier to implement equality. Use a business key that is 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 do not 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. Please 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 对象标识和判等行为如何实现的问题。 " #. Tag: title #, no-c-format @@ -532,79 +206,23 @@ msgstr "常见问题" #. Tag: para #, no-c-format -msgid "" -"Do not use the anti-patterns session-per-user-session " -"or session-per-application (there are, however, rare " -"exceptions to this rule). Some of the following issues might also arise " -"within the recommended patterns, so ensure that you understand the " -"implications before making a design decision:" -msgstr "" -"决不要使用反模式 session-per-user-session 或者 " -" session-per-application(当然,这个规定几乎没有例外)。" -"请注意,下述一些问题可能也会出现在我们推荐的模式中,在你作出某个设计决定之" -"前,请务必理解该模式的应用前提。 " +msgid "Do not use the anti-patterns session-per-user-session or session-per-application (there are, however, rare exceptions to this rule). Some of the following issues might also arise within the recommended patterns, so ensure that you understand the implications before making a design decision:" +msgstr "决不要使用反模式 session-per-user-session 或者 session-per-application(当然,这个规定几乎没有例外)。请注意,下述一些问题可能也会出现在我们推荐的模式中,在你作出某个设计决定之前,请务必理解该模式的应用前提。 " #. Tag: para #, no-c-format -msgid "" -"A Session is not thread-safe. Things that work " -"concurrently, like HTTP requests, session beans, or Swing workers, will " -"cause race conditions if a Session instance is shared. If " -"you keep your Hibernate Session in your " -"HttpSession (this is discussed later in the chapter), you " -"should consider synchronizing access to your Http session. Otherwise, a user " -"that clicks reload fast enough can 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。 " +msgid "A Session is not thread-safe. Things that work concurrently, like HTTP requests, session beans, or Swing workers, will cause race conditions if a Session instance is shared. If you keep your Hibernate Session in your HttpSession (this is discussed later in the chapter), you should consider synchronizing access to your Http session. Otherwise, a user that clicks reload fast enough can 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。 " #. Tag: para #, no-c-format -msgid "" -"An exception thrown by Hibernate means you have to rollback your database " -"transaction and close the Session immediately (this is " -"discussed in more detail later in the chapter). If your Session is bound to the application, you have to stop the application. " -"Rolling back the database transaction does not put your business objects " -"back into the state they were at the start of the transaction. This means " -"that the database state and the business objects will be out of sync. " -"Usually this is not a problem, because exceptions are not recoverable and " -"you will have to start over after rollback anyway." -msgstr "" -"一个由 Hibernate 抛出的异常意味着你必须立即回滚数据库事务,并立即关闭 " -"Session(稍后会展开讨论)。如果你的 Session 绑定到一个应用程序上,你必须停止该应用程序。回滚数据库事务并不会把你" -"的业务对象退回到事务启动时候的状态。这意味着数据库状态和业务对象状态不同步。" -"通常情况下,这不是什么问题,因为异常是不可恢复的,你必须在回滚之后重新开始执" -"行。 " +msgid "An exception thrown by Hibernate means you have to rollback your database transaction and close the Session immediately (this is discussed in more detail later in the chapter). If your Session is bound to the application, you have to stop the application. Rolling back the database transaction does not put your business objects back into the state they were at the start of the transaction. This means that the database state and the business objects will be out of sync. Usually this is not a problem, because exceptions are not recoverable and you will have to start over after rollback anyway." +msgstr "一个由 Hibernate 抛出的异常意味着你必须立即回滚数据库事务,并立即关闭 Session(稍后会展开讨论)。如果你的 Session 绑定到一个应用程序上,你必须停止该应用程序。回滚数据库事务并不会把你的业务对象退回到事务启动时候的状态。这意味着数据库状态和业务对象状态不同步。通常情况下,这不是什么问题,因为异常是不可恢复的,你必须在回滚之后重新开始执行。 " #. Tag: para -#, fuzzy, no-c-format -msgid "" -"The Session caches every object that is in a persistent " -"state (watched and checked for dirty state by Hibernate). If you keep it " -"open for a long time or simply load too much data, it will grow endlessly " -"until you get an OutOfMemoryException. One solution is to call clear" -"() and evict() to manage the Session cache, but you 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 higher probability of stale data." -msgstr "" -"Session 缓存了处于持久化状态的每个对象(Hibernate 会监视和" -"检查脏数据)。 这意味着,如果你让 Session 打开很长一段时" -"间,或是仅仅载入了过多的数据, Session 占用的内存会一直增" -"长,直到抛出 OutOfMemoryException 异常。这个 问题的一个解决方法是调用 " -"clear()evict() 来管理 " -"Session 的缓存,但是如果你需要大批量数据操作的话,最好考虑" -"使用存储过程。在中有一些解决方案。在用户会话期间一直" -"保持 Session 打开也意味着出现脏数据的可能性很高。 " +#, no-c-format +msgid "The Session caches every object that is in a persistent state (watched and checked for dirty state by Hibernate). If you keep it open for a long time or simply load too much data, it will grow endlessly until you get an OutOfMemoryException. One solution is to call clear() and evict() to manage the Session cache, but you 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 higher probability of stale data." +msgstr "Session 缓存了处于持久化状态的每个对象(Hibernate 会监视和检查脏数据)。 这意味着,如果你让 Session 打开很长一段时间,或是仅仅载入了过多的数据, Session 占用的内存会一直增长,直到抛出 OutOfMemoryException 异常。这个 问题的一个解决方法是调用 clear()evict() 来管理 Session 的缓存,但是如果你需要大批量数据操作的话,最好考虑使用存储过程。在中有一些解决方案。在用户会话期间一直保持 Session 打开也意味着出现脏数据的可能性很高。 " #. Tag: title #, no-c-format @@ -613,64 +231,22 @@ msgstr "数据库事务声明" #. Tag: para #, no-c-format -msgid "" -"Database, 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 "" -"数据库(或者系统)事务的声明总是必须的。在数据库事务之外,就无法和数据库通讯" -"(这可能会让那些习惯于自动提交事务模式的开发人员感到迷惑)。永远使用清晰的事" -"务声明,即使只读操作也是如此。进行 显式的事务声明并不总是需要的,这取决于你的" -"事务隔离级别和数据库的能力,但不管怎么说,声明事务总归有益无害。当然,一个单" -"独的数据库事务总是比很多琐碎的事务性能更好,即时对读数据而言也是一样。 " +msgid "Database, 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 "数据库(或者系统)事务的声明总是必须的。在数据库事务之外,就无法和数据库通讯(这可能会让那些习惯于自动提交事务模式的开发人员感到迷惑)。永远使用清晰的事务声明,即使只读操作也是如此。进行 显式的事务声明并不总是需要的,这取决于你的事务隔离级别和数据库的能力,但不管怎么说,声明事务总归有益无害。当然,一个单独的数据库事务总是比很多琐碎的事务性能更好,即时对读数据而言也是一样。 " #. Tag: para #, 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 (begin, commit, or rollback database transactions) themselves. 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 的同步也可以自动完成。 " +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 (begin, commit, or rollback database transactions) themselves. 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 的同步也可以自动完成。 " #. Tag: para #, 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 use programmatic " -"transaction demarcation. 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。 " +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 use programmatic transaction demarcation. 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。 " #. Tag: para #, no-c-format -msgid "" -"Ending a Session usually involves four distinct phases:" +msgid "Ending a Session usually involves four distinct phases:" msgstr "通常情况下,结束 Session 包含了四个不同的阶段: " #. Tag: para @@ -695,13 +271,8 @@ msgstr "处理异常" #. Tag: para #, no-c-format -msgid "" -"We discussed Flushing the session earlier, so we will now have a closer look " -"at transaction demarcation and exception handling in both managed and non-" -"managed environments." -msgstr "" -"session 的同步(flush,刷出)前面已经讨论过了,我们现在进一步考察在托管和非托" -"管环境下的事务声明和异常处理。 " +msgid "We discussed Flushing the session earlier, so we will now have a closer look at transaction demarcation and exception handling in both managed and non-managed environments." +msgstr "session 的同步(flush,刷出)前面已经讨论过了,我们现在进一步考察在托管和非托管环境下的事务声明和异常处理。 " #. Tag: title #, no-c-format @@ -710,73 +281,28 @@ msgstr "非托管环境" #. Tag: para #, 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 处理方式如下所示: " - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"You do not have to flush() the Session " -"explicitly: the call to commit() automatically triggers " -"the synchronization depending on 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 " -"的 )。调用 close() 标志 session 的结束。close() 方法重要的暗示是," -"session 释放了 JDBC 连接。这段 Java 代码在非托管环境下和 " -"JTA 环境下都可以运行。" +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 处理方式如下所示: " #. Tag: para #, no-c-format -msgid "" -"As outlined earlier, a much more flexible solution is Hibernate's built-in " -"\"current session\" context management:" -msgstr "" -"更加灵活的方案是 Hibernate 内置的 \"current session\" 上下文管理,前文已经讲" -"过: " +msgid "You do not have to flush() the Session explicitly: the call to commit() automatically triggers the synchronization depending on 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 的 )。调用 close() 标志 session 的结束。close() 方法重要的暗示是,session 释放了 JDBC 连接。这段 Java 代码在非托管环境下和 JTA 环境下都可以运行。 " #. Tag: para #, no-c-format -msgid "" -"You will not 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 by accessing a " -"SessionFactory. Exception handling is discussed later in " -"this chapter." -msgstr "" -"你很可能从未在一个通常的应用程序的业务代码中见过这样的代码片断:致命的(系" -"统)异常应该总是 在应用程序“顶层”被捕获。换句话说,执行 Hibernate 调用的代码" -"(在持久层)和处理 RuntimeException 异常的代码(通常只能清" -"理和退出应用程序)应该在不同 的应用程序逻辑层。Hibernate 的当前上下文管理可以" -"极大地简化这一设计,你所有的一切就是 SessionFactory。异常" -"处理将在本章稍后进行讨论。 " +msgid "As outlined earlier, a much more flexible solution is Hibernate's built-in \"current session\" context management:" +msgstr "更加灵活的方案是 Hibernate 内置的 \"current session\" 上下文管理,前文已经讲过: " #. Tag: para #, no-c-format -msgid "" -"You should select org.hibernate.transaction.JDBCTransactionFactory, which is the default, and for the second example select " -"\"thread\" as your hibernate." -"current_session_context_class." -msgstr "" -"请注意,你应该选择 org.hibernate.transaction." -"JDBCTransactionFactory (这是默认选项),对第二个例子来说," -"hibernate.current_session_context_class应该是 " -"\"thread\"。" +msgid "You will not 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 by accessing a SessionFactory. Exception handling is discussed later in this chapter." +msgstr "你很可能从未在一个通常的应用程序的业务代码中见过这样的代码片断:致命的(系统)异常应该总是 在应用程序“顶层”被捕获。换句话说,执行 Hibernate 调用的代码(在持久层)和处理 RuntimeException 异常的代码(通常只能清理和退出应用程序)应该在不同 的应用程序逻辑层。Hibernate 的当前上下文管理可以极大地简化这一设计,你所有的一切就是 SessionFactory。异常处理将在本章稍后进行讨论。 " + +#. Tag: para +#, no-c-format +msgid "You should select org.hibernate.transaction.JDBCTransactionFactory, which is the default, and for the second example select \"thread\" as your hibernate.current_session_context_class." +msgstr "请注意,你应该选择 org.hibernate.transaction.JDBCTransactionFactory (这是默认选项),对第二个例子来说,hibernate.current_session_context_class应该是 \"thread\"。" #. Tag: title #, no-c-format @@ -785,110 +311,38 @@ msgstr "使用 JTA" #. Tag: para #, no-c-format -msgid "" -"If your persistence layer runs in an application server (for example, 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 集成。 " +msgid "If your persistence layer runs in an application server (for example, 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 集成。 " #. Tag: para #, 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. The transaction management code is " -"identical to the non-managed environment." -msgstr "" -"如果你使用 bean 管理事务(BMT),可以通过使用 Hibernate 的 " -"Transaction API 来告诉应用服务器启动和结束 BMT 事务。因" -"此,事务管理代码和在非托管环境下是一样的。 " +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. The transaction management code is identical to the non-managed environment." +msgstr "如果你使用 bean 管理事务(BMT),可以通过使用 Hibernate 的 Transaction API 来告诉应用服务器启动和结束 BMT 事务。因此,事务管理代码和在非托管环境下是一样的。 " #. Tag: para #, no-c-format -msgid "" -"If you want to use a transaction-bound Session, that is, " -"the getCurrentSession() functionality for easy context " -"propagation, use the JTA UserTransaction API directly:" -msgstr "" -"如果你希望使用与事务绑定的 Session,也就是使用 " -"getCurrentSession() 来简化上下文管理,你将不得不直接使用 " -"JTA UserTransaction API。 " +msgid "If you want to use a transaction-bound Session, that is, the getCurrentSession() functionality for easy context propagation, use the JTA UserTransaction API directly:" +msgstr "如果你希望使用与事务绑定的 Session,也就是使用 getCurrentSession() 来简化上下文管理,你将不得不直接使用 JTA UserTransaction API。 " #. Tag: para #, no-c-format -msgid "" -"With CMT, transaction demarcation is completed in session bean deployment " -"descriptors, not programmatically. The code is reduced to:" -msgstr "" -"在 CMT 方式下,事务声明是在 session bean 的部署描述符中,而不需要编程。因此," -"代码被简化为:" +msgid "With CMT, transaction demarcation is completed in session bean deployment descriptors, not programmatically. The code is reduced to:" +msgstr "在 CMT 方式下,事务声明是在 session bean 的部署描述符中,而不需要编程。因此,代码被简化为:" #. Tag: para #, no-c-format -msgid "" -"In a CMT/EJB, even rollback happens automatically. An unhandled " -"RuntimeException thrown by a session bean method tells " -"the container to set the global transaction to rollback. 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。" +msgid "In a CMT/EJB, even rollback happens automatically. An unhandled RuntimeException thrown by a session bean method tells the container to set the global transaction to rollback. 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。" #. Tag: para #, no-c-format -msgid "" -"When configuring Hibernate's transaction factory, choose org." -"hibernate.transaction.JTATransactionFactory if you use JTA " -"directly (BMT), and org.hibernate.transaction." -"CMTTransactionFactory in a CMT session bean. Remember to also set " -"hibernate.transaction.manager_lookup_class. Ensure that " -"your hibernate.current_session_context_class is either " -"unset (backwards compatibility), or is 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\"。 " +msgid "When configuring Hibernate's transaction factory, choose org.hibernate.transaction.JTATransactionFactory if you use JTA directly (BMT), and org.hibernate.transaction.CMTTransactionFactory in a CMT session bean. Remember to also set hibernate.transaction.manager_lookup_class. Ensure that your hibernate.current_session_context_class is either unset (backwards compatibility), or is 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 #, 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 " -"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) explicitly " -"from a finally block. Most applications can easily avoid " -"using scroll() or iterate() 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()。) " +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 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) explicitly from a finally block. Most applications can easily avoid using scroll() or iterate() 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 #, no-c-format @@ -897,117 +351,43 @@ msgstr "异常处理" #. Tag: para #, no-c-format -msgid "" -"If the Session throws an exception, including any " -"SQLException, 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。" +msgid "If the Session throws an exception, including any SQLException, 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。" #. Tag: para #, 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 was not in older versions of Hibernate. In our opinion, we should not " -"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 " -"either 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 that are not a HibernateException. " -"These are not recoverable and appropriate action should be taken." -msgstr "" -"HibernateException 是一个非检查期异常(这不同于 Hibernate " -"老的版本),它封装了 Hibernate 持久层可能出现的大多数错误。我们的观点是,不应" -"该强迫应用程序开发人员 在底层捕获无法恢复的异常。在大多数软件系统中,非检查期" -"异常和致命异常都是在相应方法调用 的堆栈的顶层被处理的(也就是说,在软件上面的" -"逻辑层),并且提供一个错误信息给应用软件的用户 (或者采取其他某些相应的操" -"作)。请注意,Hibernate 也有可能抛出其他并不属于 " -"HibernateException 的非检查期异常。这些异常同样也是无法恢" -"复的,应该 采取某些相应的操作去处理。" +msgid "The HibernateException, which wraps most of the errors that can occur in a Hibernate persistence layer, is an unchecked exception. It was not in older versions of Hibernate. In our opinion, we should not 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 either 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 that are not a HibernateException. These are not recoverable and appropriate action should be taken." +msgstr "HibernateException 是一个非检查期异常(这不同于 Hibernate 老的版本),它封装了 Hibernate 持久层可能出现的大多数错误。我们的观点是,不应该强迫应用程序开发人员 在底层捕获无法恢复的异常。在大多数软件系统中,非检查期异常和致命异常都是在相应方法调用 的堆栈的顶层被处理的(也就是说,在软件上面的逻辑层),并且提供一个错误信息给应用软件的用户 (或者采取其他某些相应的操作)。请注意,Hibernate 也有可能抛出其他并不属于 HibernateException 的非检查期异常。这些异常同样也是无法恢复的,应该 采取某些相应的操作去处理。" #. Tag: para #, no-c-format -msgid "" -"Hibernate wraps SQLExceptions thrown while interacting " -"with the database in a JDBCException. In fact, Hibernate " -"will attempt to convert the exception into a more meaningful 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 子类型是: " +msgid "Hibernate wraps SQLExceptions thrown while interacting with the database in a JDBCException. In fact, Hibernate will attempt to convert the exception into a more meaningful 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 子类型是: " #. Tag: para #, no-c-format -msgid "" -"JDBCConnectionException: indicates an error with the " -"underlying JDBC communication." -msgstr "" -"JDBCConnectionException:指明底层的 JDBC 通讯出现错误。" +msgid "JDBCConnectionException: indicates an error with the underlying JDBC communication." +msgstr "JDBCConnectionException:指明底层的 JDBC 通讯出现错误。" #. Tag: para #, no-c-format -msgid "" -"SQLGrammarException: indicates a grammar or syntax " -"problem with the issued SQL." -msgstr "" -"SQLGrammarException:指明发送的 SQL 语句的语法或者格式错" -"误。" +msgid "SQLGrammarException: indicates a grammar or syntax problem with the issued SQL." +msgstr "SQLGrammarException:指明发送的 SQL 语句的语法或者格式错误。" #. Tag: para #, no-c-format -msgid "" -"ConstraintViolationException: indicates some form of " -"integrity constraint violation." -msgstr "" -"ConstraintViolationException:指明某种类型的约束违例错误" +msgid "ConstraintViolationException: indicates some form of integrity constraint violation." +msgstr "ConstraintViolationException:指明某种类型的约束违例错误" #. Tag: para #, no-c-format -msgid "" -"LockAcquisitionException: indicates an error acquiring a " -"lock level necessary to perform the requested operation." -msgstr "" -"LockAcquisitionException:指明了在执行请求操作时,获取所需" -"的锁级别时出现的错误。" +msgid "LockAcquisitionException: indicates an error acquiring a lock level necessary to perform the requested operation." +msgstr "LockAcquisitionException:指明了在执行请求操作时,获取所需的锁级别时出现的错误。" #. Tag: para #, no-c-format -msgid "" -"GenericJDBCException: a generic exception which did not " -"fall into any of the other categories." -msgstr "" -"GenericJDBCException:不属于任何其他种类的原生异常。" +msgid "GenericJDBCException: a generic exception which did not fall into any of the other categories." +msgstr "GenericJDBCException:不属于任何其他种类的原生异常。" #. Tag: title #, no-c-format @@ -1016,33 +396,13 @@ msgstr "事务超时" #. Tag: para #, no-c-format -msgid "" -"An 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 functionality is abstracted by the " -"Hibernate Transaction object." -msgstr "" -"EJB 这样的托管环境有一项极为重要的特性,而它从未在非托管环境中提供过,那就是" -"事务超时。在出现错误的事务行为的时候,超时可以确保不会无限挂起资源、对用户没" -"有交代。在托管(JTA)环境之外,Hibernate 无法完全提供这一功能。但是," -"Hiberante 至少可以控制数据访问,确保数据库级别的死锁,和返回巨大结果集的查询" -"被限定在一个规定的时间内。在托管环境中,Hibernate 会把事务超时转交给 JTA。这" -"一功能通过 Hibernate Transaction 对象进行抽象。 " +msgid "An 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 functionality is abstracted by the Hibernate Transaction object." +msgstr "EJB 这样的托管环境有一项极为重要的特性,而它从未在非托管环境中提供过,那就是事务超时。在出现错误的事务行为的时候,超时可以确保不会无限挂起资源、对用户没有交代。在托管(JTA)环境之外,Hibernate 无法完全提供这一功能。但是,Hiberante 至少可以控制数据访问,确保数据库级别的死锁,和返回巨大结果集的查询被限定在一个规定的时间内。在托管环境中,Hibernate 会把事务超时转交给 JTA。这一功能通过 Hibernate Transaction 对象进行抽象。 " #. Tag: para #, no-c-format -msgid "" -"setTimeout() cannot be called in a CMT bean, where " -"transaction timeouts must be defined declaratively." -msgstr "" -"注意 setTimeout() 不应该在 CMT bean 中调用,此时事务超时值" -"应该是被声明式定义的。 " +msgid "setTimeout() cannot be called in a CMT bean, where transaction timeouts must be defined declaratively." +msgstr "注意 setTimeout() 不应该在 CMT bean 中调用,此时事务超时值应该是被声明式定义的。 " #. Tag: title #, no-c-format @@ -1051,20 +411,8 @@ msgstr "乐观并发控制(Optimistic concurrency control)" #. Tag: para #, 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 three possible approaches to " -"writing application code that uses optimistic concurrency. The use cases we " -"discuss are in the context of long conversations, but version checking also " -"has the benefit of preventing lost updates in single database transactions." -msgstr "" -"唯一能够同时保持高并发和高可伸缩性的方法就是使用带版本化的乐观并发控制。版本" -"检查使用版本号、 或者时间戳来检测更新冲突(并且防止更新丢失)。Hibernate 为使" -"用乐观并发控制的代码提供了三种可 能的方法,应用程序在编写这些代码时,可以采用" -"它们。我们已经在前面应用程序对话那部分展示了 乐观并发控制的应用场景,此外,在" -"单个数据库事务范围内,版本检查也提供了防止更新丢失的好处。 " +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 three possible approaches to writing application code that uses optimistic concurrency. The use cases we discuss are in the context of long conversations, but version checking also has the benefit of preventing lost updates in single database transactions." +msgstr "唯一能够同时保持高并发和高可伸缩性的方法就是使用带版本化的乐观并发控制。版本检查使用版本号、 或者时间戳来检测更新冲突(并且防止更新丢失)。Hibernate 为使用乐观并发控制的代码提供了三种可 能的方法,应用程序在编写这些代码时,可以采用它们。我们已经在前面应用程序对话那部分展示了 乐观并发控制的应用场景,此外,在单个数据库事务范围内,版本检查也提供了防止更新丢失的好处。 " #. Tag: title #, no-c-format @@ -1073,60 +421,23 @@ msgstr "应用程序级别的版本检查(Application version checking)" #. Tag: para #, 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. The application is forced 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 最相似。 " +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. The application is forced 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: para #, 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 会自动增加版本号。" +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 会自动增加版本号。" #. Tag: para #, no-c-format -msgid "" -"If you are operating in a low-data-concurrency environment, and do not " -"require version checking, you can use this approach and skip the version " -"check. In this case, last commit wins is the default " -"strategy for long conversations. Be aware 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)就是你的长对话的默认处理" -"策略。请记住这种策略可能会让应用软件的用户感到困惑,因为他们有可能会碰上更新" -"丢失掉却没有出错信息,或者需要合并更改冲突的情况。 " +msgid "If you are operating in a low-data-concurrency environment, and do not require version checking, you can use this approach and skip the version check. In this case, last commit wins is the default strategy for long conversations. Be aware 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)就是你的长对话的默认处理策略。请记住这种策略可能会让应用软件的用户感到困惑,因为他们有可能会碰上更新丢失掉却没有出错信息,或者需要合并更改冲突的情况。 " #. Tag: para #, no-c-format -msgid "" -"Manual version checking is only feasible in trivial circumstances and not " -"practical for most applications. Often not only single instances, but " -"complete graphs of modified objects, have to be checked. Hibernate offers " -"automatic version checking with either an extended Session or detached instances as the design paradigm." -msgstr "" -"很明显,手工进行版本检查只适合于某些软件规模非常小的应用场景,对于大多数软件" -"应用场景来说并不现实。通常情况下,不仅是单个对象实例需要进行版本检查,整个被" -"修改过的关联对象图也都需要进行版本检查。作为标准设计范例,Hibernate 使用扩展" -"周期的 Session 的方式,或者脱管对象实例的方式来提供自动版" -"本检查。 " +msgid "Manual version checking is only feasible in trivial circumstances and not practical for most applications. Often not only single instances, but complete graphs of modified objects, have to be checked. Hibernate offers automatic version checking with either an extended Session or detached instances as the design paradigm." +msgstr "很明显,手工进行版本检查只适合于某些软件规模非常小的应用场景,对于大多数软件应用场景来说并不现实。通常情况下,不仅是单个对象实例需要进行版本检查,整个被修改过的关联对象图也都需要进行版本检查。作为标准设计范例,Hibernate 使用扩展周期的 Session 的方式,或者脱管对象实例的方式来提供自动版本检查。 " #. Tag: title #, no-c-format @@ -1135,80 +446,23 @@ msgstr "扩展周期的 session 和自动版本化" #. Tag: para #, no-c-format -msgid "" -"A single Session instance and its persistent instances " -"that are used for the whole conversation are known as session-per-" -"conversation. Hibernate checks instance versions at flush time, " -"throwing an exception if concurrent modification is detected. It is 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 在" -"同步的时候进行对象实例的版本检查,如果检测到并发修改则抛出异常。由开发人员来" -"决定是否需要捕获和处理这个异常(通常的抉择是给用户 提供一个合并更改,或者在无" -"脏数据情况下重新进行业务对话的机会)。 " +msgid "A single Session instance and its persistent instances that are used for the whole conversation are known as session-per-conversation. Hibernate checks instance versions at flush time, throwing an exception if concurrent modification is detected. It is 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 #, 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 does not version " -"check or reattach detached instances, nor does it have to reload instances " -"in every database transaction." -msgstr "" -"在等待用户交互的时候, Session 断开底层的 JDBC 连接。这种" -"方式以数据库访问的角度来说是最高效的方式。应用程序不需要关心版本检查或脱管对" -"象实例的重新关联,在每个数据库事务中,应用程序也不需要载入读取对象实例。 " +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 does not version check or reattach detached instances, nor does it have to reload instances in every database transaction." +msgstr "在等待用户交互的时候, Session 断开底层的 JDBC 连接。这种方式以数据库访问的角度来说是最高效的方式。应用程序不需要关心版本检查或脱管对象实例的重新关联,在每个数据库事务中,应用程序也不需要载入读取对象实例。 " #. Tag: para #, no-c-format -msgid "" -"The foo object 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 are not updating, you can call Session.lock() with " -"LockMode.READ on any objects that might have been updated " -"by another transaction. You do not 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. Only this last database transaction " -"will include the flush() operation, and then " -"close() the session to end the conversation." -msgstr "" -"foo 对象知道它是在哪个 Session 中被装入" -"的。在一个旧 session 中开启一个新的数据库事务,会导致 session 获取一个新的连" -"接,并恢复 session 的功能。将数据库事务提交,使得 session 从 JDBC 连接断开," -"并将此连接交还给连接池。在重新连接之后,要强制对你没有更新的数据进行一次版本" -"检查,你可以对所有可能被其他事务修改过的对象,使用参数 LockMode." -"READ 来调用 Session.lock()。你不用 lock 任何你" -"正在更新的数据。一般你会在扩展的 Session 上设置 FlushMode.NEVER,因此只有最后一个数据库事" -"务循环才会真正的把整个对话中发生的修改发送到数据库。因此,只有这最后一次数据" -"库事务才会包含 flush() 操作,然后在整个对话结束后,还要 " -"close() 这个 session。 " +msgid "The foo object 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 are not updating, you can call Session.lock() with LockMode.READ on any objects that might have been updated by another transaction. You do not 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. Only this last database transaction will include the flush() operation, and then close() the session to end the conversation." +msgstr "foo 对象知道它是在哪个 Session 中被装入的。在一个旧 session 中开启一个新的数据库事务,会导致 session 获取一个新的连接,并恢复 session 的功能。将数据库事务提交,使得 session 从 JDBC 连接断开,并将此连接交还给连接池。在重新连接之后,要强制对你没有更新的数据进行一次版本检查,你可以对所有可能被其他事务修改过的对象,使用参数 LockMode.READ 来调用 Session.lock()。你不用 lock 任何你正在更新的数据。一般你会在扩展的 Session 上设置 FlushMode.NEVER,因此只有最后一个数据库事务循环才会真正的把整个对话中发生的修改发送到数据库。因此,只有这最后一次数据库事务才会包含 flush() 操作,然后在整个对话结束后,还要 close() 这个 session。 " #. Tag: para #, no-c-format -msgid "" -"This pattern is problematic if the Session is too big to " -"be stored during user think time (for example, an HttpSession should be kept as small as possible). As the Session is also the first-level cache and contains all loaded objects, we " -"can probably use this strategy only for a few request/response cycles. Use a " -"Session only for a single conversation as it will soon " -"have stale data." -msgstr "" -"如果在用户思考的过程中,Session 因为太大了而不能保存,那么" -"这种模式是有问题的。举例来说,一个 HttpSession 应该尽可能" -"的小。由于 Session 是一级缓存,并且保持了所有被载入过的对" -"象,因此我们只应该在那些少量的 request/response 情况下使用这种策略。你应该只" -"把一个 Session 用于单个对话,因为它很快就会出现脏数据。 " +msgid "This pattern is problematic if the Session is too big to be stored during user think time (for example, an HttpSession should be kept as small as possible). As the Session is also the first-level cache and contains all loaded objects, we can probably use this strategy only for a few request/response cycles. Use a Session only for a single conversation as it will soon have stale data." +msgstr "如果在用户思考的过程中,Session 因为太大了而不能保存,那么这种模式是有问题的。举例来说,一个 HttpSession 应该尽可能的小。由于 Session 是一级缓存,并且保持了所有被载入过的对象,因此我们只应该在那些少量的 request/response 情况下使用这种策略。你应该只把一个 Session 用于单个对话,因为它很快就会出现脏数据。 " #. Tag: title #, no-c-format @@ -1217,42 +471,18 @@ msgstr "注意" #. Tag: para #, no-c-format -msgid "" -"Earlier versions of Hibernate 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 进行 " -"disconnect 和 reconnect。这些方法现在已经过时了,打开事务和关闭事务会起到同样" -"的效果。" +msgid "Earlier versions of Hibernate 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 进行 disconnect 和 reconnect。这些方法现在已经过时了,打开事务和关闭事务会起到同样的效果。" #. Tag: para #, no-c-format -msgid "" -"Keep the disconnected Session close to the persistence " -"layer. Use an EJB stateful session bean to hold the Session in a three-tier environment. Do not 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 中。 " +msgid "Keep the disconnected Session close to the persistence layer. Use an EJB stateful session bean to hold the Session in a three-tier environment. Do not 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 中。 " #. Tag: para #, 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 以获得示例。 " +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 以获得示例。 " #. Tag: title #, no-c-format @@ -1261,42 +491,18 @@ msgstr "脱管对象(deatched object)和自动版本化" #. Tag: para #, 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() 来重新关联该对象实例。" +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: para #, no-c-format -msgid "" -"Again, Hibernate will check instance versions during flush, throwing an " -"exception if conflicting updates occurred." -msgstr "" -"Hibernate 会再一次在同步的时候检查对象实例的版本,如果发生更新冲突,就抛出异" -"常。 " +msgid "Again, Hibernate will check instance versions during flush, throwing an exception if conflicting updates occurred." +msgstr "Hibernate 会再一次在同步的时候检查对象实例的版本,如果发生更新冲突,就抛出异常。 " #. Tag: para #, no-c-format -msgid "" -"You can also call lock() instead of update(), and use LockMode.READ (performing a version " -"check and bypassing all caches) if you are sure that the object has not been " -"modified." -msgstr "" -"如果你确信对象没有被修改过,你也可以调用 lock() 来设置 " -"LockMode.READ(绕过所有的缓存,执行版本检查),从而取代 " -"update() 操作。 " +msgid "You can also call lock() instead of update(), and use LockMode.READ (performing a version check and bypassing all caches) if you are sure that the object has not been modified." +msgstr "如果你确信对象没有被修改过,你也可以调用 lock() 来设置 LockMode.READ(绕过所有的缓存,执行版本检查),从而取代 update() 操作。 " #. Tag: title #, no-c-format @@ -1305,77 +511,23 @@ msgstr "定制自动版本化行为" #. Tag: para #, no-c-format -msgid "" -"You can 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 将不再增加版本号。 " +msgid "You can 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 将不再增加版本号。 " #. Tag: para #, no-c-format -msgid "" -"Legacy database schemas are often static and cannot be modified. Or, other " -"applications might access the same database and will not know how to handle " -"version numbers or even timestamps. In both cases, versioning cannot rely on " -"a particular column in a table. To force a version check with a comparison " -"of the state of all fields in a row but without a version or timestamp " -"property mapping, turn on optimistic-lock=\"all\" in the " -"<class> mapping. This conceptually only works if " -"Hibernate can compare the old and the 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 模式。 " +msgid "Legacy database schemas are often static and cannot be modified. Or, other applications might access the same database and will not know how to handle version numbers or even timestamps. In both cases, versioning cannot rely on a particular column in a table. To force a version check with a comparison of the state of all fields in a row but without a version or timestamp property mapping, turn on optimistic-lock=\"all\" in the <class> mapping. This conceptually only works if Hibernate can compare the old and the 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 模式。 " #. Tag: para #, no-c-format -msgid "" -"Concurrent modification can be permitted in instances where the changes that " -"have been made do not 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 在同步的时候将只比较有脏数据的字段。 " +msgid "Concurrent modification can be permitted in instances where the changes that have been made do not 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 在同步的时候将只比较有脏数据的字段。 " #. Tag: para #, no-c-format -msgid "" -"In both cases, with dedicated version/timestamp columns or with a 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 may execute unnecessary 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 occur " -"before updating the row." -msgstr "" -"在以上所有场景中,不管是专门设置一个版本/时间戳列,还是进行全部字段/脏数据字" -"段比较,Hibernate 都会针对每个实体对象发送一条 UPDATE(带" -"有相应的 WHERE 语句 )的 SQL 语句来执行版本检查和数据更" -"新。如果你对关联实体 设置级联关系使用传播性持久化(transitive persistence)," -"那么 Hibernate 可能会执行不必 要的update语句。这通常不是个问题,但是数据库里" -"面对 on update 点火 的触发器可能在脱管对象没有任何更改的" -"情况下被触发。因此,你可以在 <class> 的映射中,通过" -"设置select-before-update=\"true\" 来定制这一行为,强制 " -"Hibernate SELECT 这个对象实例,从而保证,在更新记录之前," -"对象的确是被修改过。 " +msgid "In both cases, with dedicated version/timestamp columns or with a 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 may execute unnecessary 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 occur before updating the row." +msgstr "在以上所有场景中,不管是专门设置一个版本/时间戳列,还是进行全部字段/脏数据字段比较,Hibernate 都会针对每个实体对象发送一条 UPDATE(带有相应的 WHERE 语句 )的 SQL 语句来执行版本检查和数据更新。如果你对关联实体 设置级联关系使用传播性持久化(transitive persistence),那么 Hibernate 可能会执行不必 要的update语句。这通常不是个问题,但是数据库里面对 on update 点火 的触发器可能在脱管对象没有任何更改的情况下被触发。因此,你可以在 <class> 的映射中,通过设置select-before-update=\"true\" 来定制这一行为,强制 Hibernate SELECT 这个对象实例,从而保证,在更新记录之前,对象的确是被修改过。 " #. Tag: title #, no-c-format @@ -1384,103 +536,53 @@ msgstr "悲观锁定(Pessimistic Locking) " #. Tag: para #, no-c-format -msgid "" -"It is not intended that users spend much time worrying about locking " -"strategies. It is 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 wish to obtain exclusive pessimistic locks or re-obtain " -"locks at the start of a new transaction." -msgstr "" -"用户其实并不需要花很多精力去担心锁定策略的问题。通常情况下,只要为 JDBC 连接" -"指定一下隔离级别,然后让数据库去搞定一切就够了。然而,高级用户有时候希望进行" -"一个排它的悲观锁定,或者在一个新的事务启动的时候,重新进行锁定。 " +msgid "It is not intended that users spend much time worrying about locking strategies. It is 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 wish to obtain exclusive pessimistic locks or re-obtain locks at the start of a new transaction." +msgstr "用户其实并不需要花很多精力去担心锁定策略的问题。通常情况下,只要为 JDBC 连接指定一下隔离级别,然后让数据库去搞定一切就够了。然而,高级用户有时候希望进行一个排它的悲观锁定,或者在一个新的事务启动的时候,重新进行锁定。 " #. Tag: para #, no-c-format -msgid "" -"Hibernate will always use the locking mechanism of the database; it never " -"lock objects in memory." +msgid "Hibernate will always use the locking mechanism of the database; it never lock objects in memory." msgstr "Hibernate 总是使用数据库的锁定机制,从不在内存中锁定对象。" #. Tag: para #, no-c-format -msgid "" -"The LockMode class defines the different lock levels that " -"can be acquired by Hibernate. A lock is obtained by the following mechanisms:" -msgstr "" -"类 LockMode 定义了 Hibernate 所需的不同的锁定级别。一个锁" -"定可以通过以下的机制来设置:" +msgid "The LockMode class defines the different lock levels that can be acquired by Hibernate. A lock is obtained by the following mechanisms:" +msgstr "类 LockMode 定义了 Hibernate 所需的不同的锁定级别。一个锁定可以通过以下的机制来设置:" #. Tag: para #, no-c-format -msgid "" -"LockMode.WRITE is acquired automatically when Hibernate " -"updates or inserts a row." -msgstr "" -"当 Hibernate 更新或者插入一行记录的时候,锁定级别自动设置为 " -"LockMode.WRITE。" +msgid "LockMode.WRITE is acquired automatically when Hibernate updates or inserts a row." +msgstr "当 Hibernate 更新或者插入一行记录的时候,锁定级别自动设置为 LockMode.WRITE。" #. Tag: para #, no-c-format -msgid "" -"LockMode.UPGRADE can be acquired upon explicit user " -"request using SELECT ... FOR UPDATE on databases which " -"support that syntax." -msgstr "" -"当用户显式的使用数据库支持的 SQL 格式 SELECT ... FOR UPDATE 发送 SQL 的时候,锁定级别设置为 LockMode.UPGRADE。 " +msgid "LockMode.UPGRADE can be acquired upon explicit user request using SELECT ... FOR UPDATE on databases which support that syntax." +msgstr "当用户显式的使用数据库支持的 SQL 格式 SELECT ... FOR UPDATE 发送 SQL 的时候,锁定级别设置为 LockMode.UPGRADE。 " #. Tag: para #, no-c-format -msgid "" -"LockMode.UPGRADE_NOWAIT can be acquired upon explicit " -"user request using a SELECT ... FOR UPDATE NOWAIT under " -"Oracle." -msgstr "" -"当用户显式的使用 Oracle 数据库的 SQL 语句 SELECT ... FOR UPDATE " -"NOWAIT 的时候,锁定级别设置 LockMode.UPGRADE_NOWAIT。 " +msgid "LockMode.UPGRADE_NOWAIT can be acquired upon explicit user request using a SELECT ... FOR UPDATE NOWAIT under Oracle." +msgstr "当用户显式的使用 Oracle 数据库的 SQL 语句 SELECT ... FOR UPDATE NOWAIT 的时候,锁定级别设置 LockMode.UPGRADE_NOWAIT。 " #. Tag: para #, no-c-format -msgid "" -"LockMode.READ is acquired automatically when Hibernate " -"reads data under Repeatable Read or Serializable isolation level. It can be " -"re-acquired by explicit user request." -msgstr "" -"当 Hibernate 在“可重复读”或者是“序列化”数据库隔离级别下读取数据的时候,锁定模" -"式自动设置为 LockMode.READ。这种模式也可以通过用户显式指定" -"进行设置。 " +msgid "LockMode.READ is acquired automatically when Hibernate reads data under Repeatable Read or Serializable isolation level. It can be re-acquired by explicit user request." +msgstr "当 Hibernate 在“可重复读”或者是“序列化”数据库隔离级别下读取数据的时候,锁定模式自动设置为 LockMode.READ。这种模式也可以通过用户显式指定进行设置。 " #. Tag: para #, 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() 脱离该" -"模式。" +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() 脱离该模式。" #. Tag: para #, no-c-format -msgid "" -"The \"explicit user request\" is expressed in one of the following ways:" +msgid "The \"explicit user request\" is expressed in one of the following ways:" msgstr "\"显式的用户指定\"可以通过以下几种方式之一来表示:" #. Tag: para #, no-c-format -msgid "" -"A call to Session.load(), specifying a LockMode." -msgstr "" -"调用 Session.load() 的时候指定锁定模式" -"(LockMode)。" +msgid "A call to Session.load(), specifying a LockMode." +msgstr "调用 Session.load() 的时候指定锁定模式(LockMode)。" #. Tag: para #, no-c-format @@ -1494,46 +596,18 @@ msgstr "调用 Query.setLockMode()。" #. Tag: para #, 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() 方法。" +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() 方法。" #. Tag: para #, 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 "" -"如果指定的锁定模式是 READUPGRADE 或 " -"UPGRADE_NOWAIT,那么 Session.lock() 就" -"执行版本号检查。(在 UPGRADE 或者 " -"UPGRADE_NOWAIT 锁定模式下,执行 SELECT ... FOR " -"UPDATE这样的SQL语句。)" +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 "如果指定的锁定模式是 READUPGRADEUPGRADE_NOWAIT,那么 Session.lock() 就执行版本号检查。(在 UPGRADE 或者 UPGRADE_NOWAIT 锁定模式下,执行 SELECT ... FOR UPDATE这样的SQL语句。)" #. Tag: para #, no-c-format -msgid "" -"If the requested lock mode is not supported by the database, Hibernate uses " -"an appropriate alternate mode instead of throwing an exception. This ensures " -"that applications are portable." -msgstr "" -"如果数据库不支持用户设置的锁定模式,Hibernate 将使用适当的替代模式(而不是扔" -"出异常)。这一点可以确保应用程序的可移植性。 " +msgid "If the requested lock mode is not supported by the database, Hibernate uses an appropriate alternate mode instead of throwing an exception. This ensures that applications are portable." +msgstr "如果数据库不支持用户设置的锁定模式,Hibernate 将使用适当的替代模式(而不是扔出异常)。这一点可以确保应用程序的可移植性。 " #. Tag: title #, no-c-format @@ -1542,133 +616,51 @@ msgstr "连接释放模式(Connection Release Modes) " #. Tag: para #, no-c-format -msgid "" -"One of the legacies of Hibernate 2.x JDBC connection management meant that a " -"Session would obtain a connection when it was first " -"required and then maintain that connection until the session was closed. " -"Hibernate 3.x introduced the notion of connection release modes that would " -"instruct a session how to handle its JDBC connections. 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 的不同枚举值来使用不用的释放模式:" +msgid "One of the legacies of Hibernate 2.x JDBC connection management meant that a Session would obtain a connection when it was first required and then maintain that connection until the session was closed. Hibernate 3.x introduced the notion of connection release modes that would instruct a session how to handle its JDBC connections. 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 的不同枚举值来使用不用的释放模式:" #. Tag: para #, no-c-format -msgid "" -"ON_CLOSE: is the legacy behavior described above. The " -"Hibernate session obtains a connection when it first needs to perform some " -"JDBC access and maintains that connection until the session is closed." -msgstr "" -"ON_CLOSE:基本上就是上面提到的老式行为。Hibernate session " -"在第一次需要进行 JDBC 操作的时候获取连接,然后持有它,直到 session 关闭。" +msgid "ON_CLOSE: is the legacy behavior described above. The Hibernate session obtains a connection when it first needs to perform some JDBC access and maintains that connection until the session is closed." +msgstr "ON_CLOSE:基本上就是上面提到的老式行为。Hibernate session 在第一次需要进行 JDBC 操作的时候获取连接,然后持有它,直到 session 关闭。" #. Tag: para #, no-c-format -msgid "" -"AFTER_TRANSACTION: releases connections after a " -"org.hibernate.Transaction has been completed." -msgstr "" -"AFTER_TRANSACTION:在 org.hibernate.Transaction 结束后释放连接。" +msgid "AFTER_TRANSACTION: releases connections after a org.hibernate.Transaction has been completed." +msgstr "AFTER_TRANSACTION:在 org.hibernate.Transaction 结束后释放连接。" #. Tag: para #, no-c-format -msgid "" -"AFTER_STATEMENT (also referred to as aggressive release): " -"releases connections after 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。" +msgid "AFTER_STATEMENT (also referred to as aggressive release): releases connections after 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。" #. Tag: para #, no-c-format -msgid "" -"The configuration parameter hibernate.connection.release_mode is used to specify which release mode to use. The possible values " -"are as follows:" -msgstr "" -"hibernate.connection.release_mode 配置参数用来指定使用哪一" -"种释放模式。可能的值有: " +msgid "The configuration parameter hibernate.connection.release_mode is used to specify which release mode to use. The possible values are as follows:" +msgstr "hibernate.connection.release_mode 配置参数用来指定使用哪一种释放模式。可能的值有: " #. Tag: para #, 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. Do not 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," -"或者给用户代码带来误导。" +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. Do not 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,或者给用户代码带来误导。" #. Tag: para #, no-c-format -msgid "" -"on_close: uses ConnectionReleaseMode.ON_CLOSE. This " -"setting is left for backwards compatibility, but its use is discouraged." -msgstr "" -"on_close:使用 ConnectionReleaseMode.ON_CLOSE。这种方式是" -"为了向下兼容的,但是已经完全不被鼓励使用了。" +msgid "on_close: uses ConnectionReleaseMode.ON_CLOSE. This setting is left for backwards compatibility, but its use is discouraged." +msgstr "on_close:使用 ConnectionReleaseMode.ON_CLOSE。这种方式是为了向下兼容的,但是已经完全不被鼓励使用了。" #. Tag: para #, no-c-format -msgid "" -"after_transaction: uses 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 那样被释放。" +msgid "after_transaction: uses 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 那样被释放。" #. Tag: para #, no-c-format -msgid "" -"after_statement: uses 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 you make a call into ConnectionProvider." -"getConnection() or in auto-commit environments where it does not " -"matter if we re-establish the same connection." -msgstr "" -"after_statement:使用 ConnectionReleaseMode." -"AFTER_STATEMENT。除此之外,会查询配置的 ConnectionProvider,是否它支持这一设置(supportsAggressiveRelease())。假若不支持,释放模式会被设置为 ConnectionReleaseMode." -"AFTER_TRANSACTION。只有在你每次调用 ConnectionProvider." -"getConnection() 获取底层 JDBC 连接的时候,都可以确信获得同一个连接" -"的时候,这一设置才是安全的;或者在 auto-commit 环境中,你可以不管是否每次都获" -"得同一个连接的时候,这才是安全的。" +msgid "after_statement: uses 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 you make a call into ConnectionProvider.getConnection() or in auto-commit environments where it does not matter if we re-establish the same connection." +msgstr "after_statement:使用 ConnectionReleaseMode.AFTER_STATEMENT。除此之外,会查询配置的 ConnectionProvider,是否它支持这一设置(supportsAggressiveRelease())。假若不支持,释放模式会被设置为 ConnectionReleaseMode.AFTER_TRANSACTION。只有在你每次调用 ConnectionProvider.getConnection() 获取底层 JDBC 连接的时候,都可以确信获得同一个连接的时候,这一设置才是安全的;或者在 auto-commit 环境中,你可以不管是否每次都获得同一个连接的时候,这才是安全的。" #~ msgid "foo==bar" #~ msgstr "foo==bar" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" - #~ msgid "" #~ "" + diff --git a/documentation/manual/src/main/docbook/zh-CN/content/tutorial.po b/documentation/manual/src/main/docbook/zh-CN/content/tutorial.po index 3e4e473e1e..c57e5679da 100644 --- a/documentation/manual/src/main/docbook/zh-CN/content/tutorial.po +++ b/documentation/manual/src/main/docbook/zh-CN/content/tutorial.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: tutorial\n" "Report-Msgid-Bugs-To: http://bugs.kde.org\n" "POT-Creation-Date: 2010-02-11T05:38:16\n" -"PO-Revision-Date: 2010-01-11 10:56+1000\n" +"PO-Revision-Date: 2010-03-16 09:56+1000\n" "Last-Translator: Xi HUANG \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -22,34 +22,18 @@ msgstr "教程" #. Tag: para #, no-c-format -msgid "" -"Intended for new users, this chapter provides an step-by-step introduction " -"to Hibernate, starting with a simple application using an in-memory " -"database. The tutorial is based on an earlier tutorial developed by Michael " -"Gloegl. All code is contained in the tutorials/web " -"directory of the project source." -msgstr "" -"面向新用户,从一个简单的使用内存数据库的例子开始,本章提供对 Hibernate 的逐步" -"介绍。本教程基于 Michael Gloegl 早期编写的手册。所有代码都包含在 " -"tutorials/web 目录下。" +msgid "Intended for new users, this chapter provides an step-by-step introduction to Hibernate, starting with a simple application using an in-memory database. The tutorial is based on an earlier tutorial developed by Michael Gloegl. All code is contained in the tutorials/web directory of the project source." +msgstr "面向新用户,从一个简单的使用内存数据库的例子开始,本章提供对 Hibernate 的逐步介绍。本教程基于 Michael Gloegl 早期编写的手册。所有代码都包含在 tutorials/web 目录下。" #. Tag: para #, no-c-format -msgid "" -"This tutorial expects the user have knowledge of both Java and SQL. If you " -"have a limited knowledge of JAVA or SQL, it is advised that you start with a " -"good introduction to that technology prior to attempting to learn Hibernate." -msgstr "" -"本教程期望用户具备 Java 和 SQL 知识。如果你这方面的知识有限,我们建议你在学" -"习 Hibernate 之前先好好了解这些技术。" +msgid "This tutorial expects the user have knowledge of both Java and SQL. If you have a limited knowledge of JAVA or SQL, it is advised that you start with a good introduction to that technology prior to attempting to learn Hibernate." +msgstr "本教程期望用户具备 Java 和 SQL 知识。如果你这方面的知识有限,我们建议你在学习 Hibernate 之前先好好了解这些技术。" #. Tag: para #, no-c-format -msgid "" -"The distribution contains another example application under the " -"tutorial/eg project source directory." -msgstr "" -"本版本在源代码目录 tutorial/eg 下还包含另外一个例程。" +msgid "The distribution contains another example application under the tutorial/eg project source directory." +msgstr "本版本在源代码目录 tutorial/eg 下还包含另外一个例程。" #. Tag: title #, no-c-format @@ -58,25 +42,13 @@ msgstr "第一部分 - 第一个 Hibernate 应用程序" #. Tag: para #, no-c-format -msgid "" -"For this example, we will set up a small database application that can store " -"events we want to attend and information about the host(s) of these events." -msgstr "" -"在这个例子里,我们将设立一个小应用程序可以保存我们希望参加的活动(events)和" -"这些活动主办方的相关信息。(译者注:在本教程的后面部分,我们将直接使用 event " -"而不是它的中文翻译“活动”,以免混淆。)" +msgid "For this example, we will set up a small database application that can store events we want to attend and information about the host(s) of these events." +msgstr "在这个例子里,我们将设立一个小应用程序可以保存我们希望参加的活动(events)和这些活动主办方的相关信息。(译者注:在本教程的后面部分,我们将直接使用 event 而不是它的中文翻译“活动”,以免混淆。)" #. Tag: para #, no-c-format -msgid "" -"Although you can use whatever database you feel comfortable using, we will " -"use HSQLDB (an in-memory, Java " -"database) to avoid describing installation/setup of any particular database " -"servers." -msgstr "" -"虽然你可以使用任何数据库,我们还是用 HSQLDB(一个用 Java 编写的内存数据库)来避免花费篇章对数据库服务器" -"的安装/配置进行解释。" +msgid "Although you can use whatever database you feel comfortable using, we will use HSQLDB (an in-memory, Java database) to avoid describing installation/setup of any particular database servers." +msgstr "虽然你可以使用任何数据库,我们还是用 HSQLDB(一个用 Java 编写的内存数据库)来避免花费篇章对数据库服务器的安装/配置进行解释。" #. Tag: title #, no-c-format @@ -85,65 +57,22 @@ msgstr "设置" #. Tag: para #, no-c-format -msgid "" -"The first thing we need to do is to set up the development environment. We " -"will be using the \"standard layout\" advocated by alot of build tools such " -"as Maven. Maven, in particular, has " -"a good resource describing this layout. As this tutorial is to be a web application, we will be creating and " -"making use of src/main/java, src/main/" -"resources and src/main/webapp directories." -msgstr "" -"我们需要做的第一件事情是设置开发环境。我们将使用许多构建工具如 Maven 所鼓吹的“标准格式”。特别是 Maven,它的资源" -"对这个格式(layout)有着很好的描" -"述。因为本教程使用的是 web 应用程序,我么将创建和使用 src/main/" -"javasrc/main/resourcessrc/" -"main/webapp 目录。" +msgid "The first thing we need to do is to set up the development environment. We will be using the \"standard layout\" advocated by alot of build tools such as Maven. Maven, in particular, has a good resource describing this layout. As this tutorial is to be a web application, we will be creating and making use of src/main/java, src/main/resources and src/main/webapp directories." +msgstr "我们需要做的第一件事情是设置开发环境。我们将使用许多构建工具如 Maven 所鼓吹的“标准格式”。特别是 Maven,它的资源对这个格式(layout)有着很好的描述。因为本教程使用的是 web 应用程序,我么将创建和使用 src/main/javasrc/main/resourcessrc/main/webapp 目录。" #. Tag: para #, no-c-format -msgid "" -"We will be using Maven in this tutorial, taking advantage of its transitive " -"dependency management capabilities as well as the ability of many IDEs to " -"automatically set up a project for us based on the maven descriptor." -msgstr "" -"在本教程里我们将使用 Maven,利用其 transitive dependency 管理以及根据 Maven " -"描述符用 IDE 自动设置项目的能力。" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"It is not a requirement to use Maven. If you wish to use something else to " -"build this tutoial (such as Ant), the layout will remain the same. The only " -"change is that you will need to manually account for all the needed " -"dependencies. If you use something like Ivy providing transitive dependency management you would " -"still use the dependencies mentioned below. Otherwise, you'd need to grab " -"all dependencies, both explicit and transitive, and add " -"them to the project's classpath. If working from the Hibernate distribution " -"bundle, this would mean hibernate3.jar, all artifacts " -"in the lib/required directory and all files from either " -"the lib/bytecode/cglib or lib/bytecode/" -"javassist directory; additionally you will need both the servlet-" -"api jar and one of the slf4j logging backends." -msgstr "" -"Maven 并不要求这样。如果你希望使用其他技术来构建这个教程(如 Ant),格式将保" -"持不变。唯一的改变是你将需要手工管理所有的依赖关系。如果你使用 Ivy 来提供 transitive dependency 管" -"理,你将仍然下面提到的依赖关系。否则,你将需要找到所有的依赖关系(显性的和过" -"渡的)并把它们添加到项目的 classpath 里。如果使用 Hibernate 捆绑版本,这意味" -"着 hibernate3.jarlib/required 目" -"录下的所有 artifact 和 lib/bytecode/cglib 或 " -"lib/bytecode/javassist 下的所有文件,此外你将需要 " -"servlet-api jar 和一个 slf4j 日志后台文件。 " +msgid "We will be using Maven in this tutorial, taking advantage of its transitive dependency management capabilities as well as the ability of many IDEs to automatically set up a project for us based on the maven descriptor." +msgstr "在本教程里我们将使用 Maven,利用其 transitive dependency 管理以及根据 Maven 描述符用 IDE 自动设置项目的能力。" #. Tag: para #, no-c-format -msgid "" -"Save this file as pom.xml in the project root directory." +msgid "It is not a requirement to use Maven. If you wish to use something else to build this tutoial (such as Ant), the layout will remain the same. The only change is that you will need to manually account for all the needed dependencies. If you use something like Ivy providing transitive dependency management you would still use the dependencies mentioned below. Otherwise, you'd need to grab all dependencies, both explicit and transitive, and add them to the project's classpath. If working from the Hibernate distribution bundle, this would mean hibernate3.jar, all artifacts in the lib/required directory and all files from either the lib/bytecode/cglib or lib/bytecode/javassist directory; additionally you will need both the servlet-api jar and one of the slf4j logging backends." +msgstr "Maven 并不要求这样。如果你希望使用其他技术来构建这个教程(如 Ant),格式将保持不变。唯一的改变是你将需要手工管理所有的依赖关系。如果你使用 Ivy 来提供 transitive dependency 管理,你将仍然下面提到的依赖关系。否则,你将需要找到所有的依赖关系(显性的和过渡的)并把它们添加到项目的 classpath 里。如果使用 Hibernate 捆绑版本,这意味着 hibernate3.jarlib/required 目录下的所有 artifact 和 lib/bytecode/cgliblib/bytecode/javassist 下的所有文件,此外你将需要 servlet-api jar 和一个 slf4j 日志后台文件。 " + +#. Tag: para +#, no-c-format +msgid "Save this file as pom.xml in the project root directory." msgstr "把这个文件保存为项目根目录下的 pom.xml。" #. Tag: title @@ -153,75 +82,28 @@ msgstr "第一个 class" #. Tag: para #, no-c-format -msgid "" -"Next, we create a class that represents the event we want to store in the " -"database; it is a simple JavaBean class with some properties:" -msgstr "" -"接下来我们创建一个类,用来代表那些我们希望储存在数据库里的 event,这是一个具" -"有一些属性的简单 JavaBean 类:" +msgid "Next, we create a class that represents the event we want to store in the database; it is a simple JavaBean class with some properties:" +msgstr "接下来我们创建一个类,用来代表那些我们希望储存在数据库里的 event,这是一个具有一些属性的简单 JavaBean 类:" #. Tag: para #, no-c-format -msgid "" -"This class uses standard JavaBean naming conventions for property getter and " -"setter methods, as well as private visibility for the fields. Although this " -"is the recommended design, it is not required. Hibernate can also access " -"fields directly, the benefit of accessor methods is robustness for " -"refactoring." -msgstr "" -"你可以看到这个类对属性的存取方法(getter and setter method)使用了标准 " -"JavaBean 命名约定,同时把类属性(field)的访问级别设成私有的(private)。这是" -"推荐的设计,但并不是必须的。Hibernate 也可以直接访问这些 field,而使用访问方" -"法(accessor method)的好处是提供了重构时的健壮性(robustness)。" +msgid "This class uses standard JavaBean naming conventions for property getter and setter methods, as well as private visibility for the fields. Although this is the recommended design, it is not required. Hibernate can also access fields directly, the benefit of accessor methods is robustness for refactoring." +msgstr "你可以看到这个类对属性的存取方法(getter and setter method)使用了标准 JavaBean 命名约定,同时把类属性(field)的访问级别设成私有的(private)。这是推荐的设计,但并不是必须的。Hibernate 也可以直接访问这些 field,而使用访问方法(accessor method)的好处是提供了重构时的健壮性(robustness)。" #. Tag: para #, 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, " -"especially web applications, need to distinguish objects by identifier, so " -"you should consider this a feature rather than a limitation. However, we " -"usually do not manipulate the identity of an object, hence the setter method " -"should be private. Only Hibernate will assign identifiers when an object is " -"saved. Hibernate can access public, private, and protected accessor methods, " -"as well as public, private and 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。所以选择哪种方" -"式完全取决于你,你可以使你的选择与你的应用程序设计相吻合。 " +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, especially web applications, need to distinguish objects by identifier, so you should consider this a feature rather than a limitation. However, we usually do not manipulate the identity of an object, hence the setter method should be private. Only Hibernate will assign identifiers when an object is saved. Hibernate can access public, private, and protected accessor methods, as well as public, private and 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 #, 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 or public 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)的情况下,从" -"持久化类里获取数据会更有效率。 " +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 or public 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 #, no-c-format -msgid "" -"Save this file to the src/main/java/org/hibernate/tutorial/domain directory." -msgstr "" -"把这个文件保存到 src/main/java/org/hibernate/tutorial/domain 目录下。" +msgid "Save this file to the src/main/java/org/hibernate/tutorial/domain directory." +msgstr "把这个文件保存到 src/main/java/org/hibernate/tutorial/domain 目录下。" #. Tag: title #, no-c-format @@ -230,15 +112,8 @@ msgstr "映射文件" #. Tag: para #, 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)。" +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)。" #. Tag: para #, no-c-format @@ -247,194 +122,68 @@ msgstr "一个映射文件的基本结构看起来像这样:" #. Tag: para #, no-c-format -msgid "" -"Hibernate DTD is sophisticated. You can use it for auto-completion of XML " -"mapping elements and attributes in your editor or IDE. Opening up the DTD " -"file in your text editor is the easiest way to get an overview of all " -"elements and attributes, and to view the defaults, as well as some comments. " -"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 " -"hibernate-core.jar (it is also included in the " -"hibernate3.jar, if using the distribution bundle)." -msgstr "" -"注意 Hibernate 的 DTD 是非常复杂的。你的编辑器或者 IDE 里使用它来自动完成那些" -"用来映射的 XML 元素(element)和属性(attribute)。你也可以在文本编辑器里打" -"开 DTD — 这是最简单的方式来概览所有的元素和 attribute,并查看它们的缺省值以及" -"注释。注意 Hibernate 不会从 web 加载 DTD 文件,但它会首先在应用程序的 " -"classpath 中查找。DTD 文件已包括在 hibernate3.jar 里,同时" -"也在 Hibernate 发布包的 src/ 目录下。 " +msgid "Hibernate DTD is sophisticated. You can use it for auto-completion of XML mapping elements and attributes in your editor or IDE. Opening up the DTD file in your text editor is the easiest way to get an overview of all elements and attributes, and to view the defaults, as well as some comments. 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 hibernate-core.jar (it is also included in the hibernate3.jar, if using the distribution bundle)." +msgstr "注意 Hibernate 的 DTD 是非常复杂的。你的编辑器或者 IDE 里使用它来自动完成那些用来映射的 XML 元素(element)和属性(attribute)。你也可以在文本编辑器里打开 DTD — 这是最简单的方式来概览所有的元素和 attribute,并查看它们的缺省值以及注释。注意 Hibernate 不会从 web 加载 DTD 文件,但它会首先在应用程序的 classpath 中查找。DTD 文件已包括在 hibernate3.jar 里,同时也在 Hibernate 发布包的 src/ 目录下。 " #. Tag: para #, no-c-format -msgid "" -"We will omit the DTD declaration in future examples to shorten the code. It " -"is, of course, not optional." -msgstr "" -"为缩短代码长度,在以后的例子里我们会省略 DTD 的声明。当然,在实际的应用程序" -"中,DTD 声明是必需的。 " +msgid "We will omit the DTD declaration in future examples to shorten the code. It is, of course, not optional." +msgstr "为缩短代码长度,在以后的例子里我们会省略 DTD 的声明。当然,在实际的应用程序中,DTD 声明是必需的。 " #. Tag: para #, no-c-format -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 a mapping to a table in the SQL database:" -msgstr "" -"在 hibernate-mapping 标签(tag)之间, 含有一个 " -"class 元素。所有的持久化实体类(再次声明,或许接下来会有依" -"赖类,就是那些次要的实体)都需要一个这样的映射,来把类对象映射到 SQL 数据库里" -"的表:" +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 a mapping to a table in the SQL database:" +msgstr "在 hibernate-mapping 标签(tag)之间, 含有一个 class 元素。所有的持久化实体类(再次声明,或许接下来会有依赖类,就是那些次要的实体)都需要一个这样的映射,来把类对象映射到 SQL 数据库里的表:" #. Tag: para #, no-c-format -msgid "" -"So far we have told Hibernate how to persist and load object of class " -"Event to the table EVENTS. Each " -"instance is now represented by a row in that table. Now we can continue by " -"mapping the unique identifier property to the tables primary key. As we do " -"not 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 的标识符生成策略来产生代理" -"主键字段:" +msgid "So far we have told Hibernate how to persist and load object of class Event to the table EVENTS. Each instance is now represented by a row in that table. Now we can continue by mapping the unique identifier property to the tables primary key. As we do not 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: para #, no-c-format -msgid "" -"The id element is the declaration of the identifier " -"property. The name=\"id\" mapping attribute declares the " -"name of the JavaBean property and tells Hibernate to use the getId()" -" and setId() methods to access the property. " -"The column attribute tells Hibernate which column of the EVENTS table holds the primary key value." -msgstr "" -"id 元素是对 identifier 属性的声明。name=\"id\" 映射属性声明了 JavaBean 属性的名称并告诉 Hibernate 使用 " -"getId()setId() 方法来访问这个属性。" -"column 属性告诉 Hibernate EVENTS 表的哪个字段持有主键值。" +msgid "The id element is the declaration of the identifier property. The name=\"id\" mapping attribute declares the name of the JavaBean property and tells Hibernate to use the getId() and setId() methods to access the property. The column attribute tells Hibernate which column of the EVENTS table holds the primary key value." +msgstr "id 元素是对 identifier 属性的声明。name=\"id\" 映射属性声明了 JavaBean 属性的名称并告诉 Hibernate 使用 getId()setId() 方法来访问这个属性。column 属性告诉 Hibernate EVENTS 表的哪个字段持有主键值。" #. Tag: para #, no-c-format -msgid "" -"The nested generator element specifies the identifier " -"generation strategy (aka how are identifier values generated?). In this case " -"we choose native, which offers a level of portability " -"depending on the configured database dialect. Hibernate supports database " -"generated, globally unique, as well as application assigned, identifiers. " -"Identifier value generation is also one of Hibernate's many extension points " -"and you can plugin in your own strategy." -msgstr "" -"嵌套的 generator 元素指定标识符的生成策略(也就是标识符值" -"是怎么产生的)。在这个例子里,我们选择 native,它提供了取" -"决于数据库方言的可移植性。Hibernate 数据库生成的、全局性唯一的以及应用程序分" -"配的标识符。标识符值的生成也是 Hibernate 的扩展功能之一,你可以插入自己的策" -"略。" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"native is no longer consider the best strategy in terms " -"of portability. for further discussion, see " -msgstr "" -"从移植性来说,native 不再被认为是最好的策略。进一步的讨" -"论,请参考 。" +msgid "The nested generator element specifies the identifier generation strategy (aka how are identifier values generated?). In this case we choose native, which offers a level of portability depending on the configured database dialect. Hibernate supports database generated, globally unique, as well as application assigned, identifiers. Identifier value generation is also one of Hibernate's many extension points and you can plugin in your own strategy." +msgstr "嵌套的 generator 元素指定标识符的生成策略(也就是标识符值是怎么产生的)。在这个例子里,我们选择 native,它提供了取决于数据库方言的可移植性。Hibernate 数据库生成的、全局性唯一的以及应用程序分配的标识符。标识符值的生成也是 Hibernate 的扩展功能之一,你可以插入自己的策略。" #. Tag: para #, no-c-format -msgid "" -"Lastly, we need to tell Hibernate about the remaining entity class " -"properties. By default, no properties of the class are considered persistent:" -msgstr "" -"最后我们在映射文件里面包含需要持久化属性的声明。默认情况下,类里面的属性都被" -"视为非持久化的: " +msgid "native is no longer consider the best strategy in terms of portability. for further discussion, see " +msgstr "从移植性来说,native 不再被认为是最好的策略。进一步的讨论,请参考 。 " #. Tag: para #, no-c-format -msgid "" -"Similar to the id element, the name " -"attribute of the property element tells Hibernate which " -"getter and setter methods to use. In this case, Hibernate will search for " -"getDate(), setDate(), getTitle" -"() and setTitle() methods." -msgstr "" -"和 id 元素一样,property 元素的 " -"name 属性告诉 Hibernate 使用哪个 getter 和 setter 方法。在" -"此例中,Hibernate 会寻找 getDate()setDate()getTitle()setTitle() 方" -"法。 " +msgid "Lastly, we need to tell Hibernate about the remaining entity class properties. By default, no properties of the class are considered persistent:" +msgstr "最后我们在映射文件里面包含需要持久化属性的声明。默认情况下,类里面的属性都被视为非持久化的: " #. Tag: para #, no-c-format -msgid "" -"Why does the date property mapping include the " -"column attribute, but the title does " -"not? Without the column attribute, Hibernate by default " -"uses the property name as the column name. This works for title, however, date is a reserved keyword in most " -"databases so you will need to map it to a different name." -msgstr "" -"为什么 date 属性的映射含有 column " -"attribute,而 title 却没有?当没有设定 column attribute 的时候,Hibernate 缺省地使用 JavaBean 的属性名作为字段名。" -"对于 title,这样工作得很好。然而,date " -"在多数的数据库里,是一个保留关键字,所以我们最好把它映射成一个不同的名字。 " +msgid "Similar to the id element, the name attribute of the property element tells Hibernate which getter and setter methods to use. In this case, Hibernate will search for getDate(), setDate(), getTitle() and setTitle() methods." +msgstr "和 id 元素一样,property 元素的 name 属性告诉 Hibernate 使用哪个 getter 和 setter 方法。在此例中,Hibernate 会寻找 getDate()setDate()getTitle()setTitle() 方法。 " #. Tag: para #, no-c-format -msgid "" -"The title mapping also lacks a type " -"attribute. The types declared and used in the mapping files are not Java " -"data types; they are not SQL database types either. These types are 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 cannot know if the property, " -"which is of java.util.Date, should map to a SQL " -"date, timestamp, or time column. Full date and time information is preserved 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 转换器,这样我们预留了日期和时间的全部信息。 " +msgid "Why does the date property mapping include the column attribute, but the title does not? Without the column attribute, Hibernate by default uses the property name as the column name. This works for title, however, date is a reserved keyword in most databases so you will need to map it to a different name." +msgstr "为什么 date 属性的映射含有 column attribute,而 title 却没有?当没有设定 column attribute 的时候,Hibernate 缺省地使用 JavaBean 的属性名作为字段名。对于 title,这样工作得很好。然而,date 在多数的数据库里,是一个保留关键字,所以我们最好把它映射成一个不同的名字。 " #. Tag: para #, no-c-format -msgid "" -"Hibernate makes this mapping type determination using reflection when the " -"mapping files are processed. This can take time and resources, so if startup " -"performance is important you should consider explicitly defining the type to " -"use." -msgstr "" -"当处理映射文件时,Hibernate 用反射(reflection)来决定这个映射类型。这需要时" -"间和资源,所以如果你注重启动性能,你应该考虑显性地定义所用的类型。" +msgid "The title mapping also lacks a type attribute. The types declared and used in the mapping files are not Java data types; they are not SQL database types either. These types are 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 cannot know if the property, which is of java.util.Date, should map to a SQL date, timestamp, or time column. Full date and time information is preserved 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 #, no-c-format -msgid "" -"Save this mapping file as src/main/resources/org/hibernate/" -"tutorial/domain/Event.hbm.xml." -msgstr "" -"把这个映射文件保存为 src/main/resources/org/hibernate/tutorial/" -"domain/Event.hbm.xml。" +msgid "Hibernate makes this mapping type determination using reflection when the mapping files are processed. This can take time and resources, so if startup performance is important you should consider explicitly defining the type to use." +msgstr "当处理映射文件时,Hibernate 用反射(reflection)来决定这个映射类型。这需要时间和资源,所以如果你注重启动性能,你应该考虑显性地定义所用的类型。" + +#. Tag: para +#, no-c-format +msgid "Save this mapping file as src/main/resources/org/hibernate/tutorial/domain/Event.hbm.xml." +msgstr "把这个映射文件保存为 src/main/resources/org/hibernate/tutorial/domain/Event.hbm.xml。" #. Tag: title #, no-c-format @@ -443,76 +192,33 @@ msgstr "Hibernate 配置" #. Tag: para #, no-c-format -msgid "" -"At this point, you should have the persistent class and its mapping file in " -"place. It is now time to configure Hibernate. First let's set up HSQLDB to " -"run in \"server mode\"" -msgstr "" -"此时,你应该有了持久化类和它的映射文件。现在是配置 Hibernate 的时候了。首先让" -"我们设立 HSQLDB 使其运行在“服务器模式”。" +msgid "At this point, you should have the persistent class and its mapping file in place. It is now time to configure Hibernate. First let's set up HSQLDB to run in \"server mode\"" +msgstr "此时,你应该有了持久化类和它的映射文件。现在是配置 Hibernate 的时候了。首先让我们设立 HSQLDB 使其运行在“服务器模式”。" #. Tag: para -#, fuzzy, no-c-format +#, no-c-format msgid "We do this do that the data remains between runs." -msgstr "数据在程序运行期间需要保持有效。" +msgstr "数据在程序运行期间需要保持有效。 " #. Tag: para #, no-c-format -msgid "" -"We will utilize the Maven exec plugin to launch the HSQLDB server by " -"running: mvn exec:java -Dexec.mainClass=\"org.hsqldb.Server\" -" -"Dexec.args=\"-database.0 file:target/data/tutorial\" You will 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 HSQLDB, delete all files in the target/data directory, and start HSQLDB again." -msgstr "" -"在开发的根目录下创建一个 data 目录 - 这是 HSQL DB 存储数" -"据文件的地方。此时在 data 目录中运行 java -classpath ../lib/hsqldb." -"jar org.hsqldb.Server 就可启动数据库。你可以在 log 中看到它的启动," -"及绑定到 TCP/IP 套接字,这正是我们的应用程序稍后会连接的地方。如果你希望在本" -"例中运行一个全新的数据库,就在窗口中按下 CTRL + C 来关闭 " -"HSQL 数据库,并删除 data/ 目录下的所有文件,再重新启动 " -"HSQL 数据库。 " +msgid "We will utilize the Maven exec plugin to launch the HSQLDB server by running: mvn exec:java -Dexec.mainClass=\"org.hsqldb.Server\" -Dexec.args=\"-database.0 file:target/data/tutorial\" You will 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 HSQLDB, delete all files in the target/data directory, and start HSQLDB again." +msgstr "在开发的根目录下创建一个 data 目录 - 这是 HSQL DB 存储数据文件的地方。此时在 data 目录中运行 java -classpath ../lib/hsqldb.jar org.hsqldb.Server 就可启动数据库。你可以在 log 中看到它的启动,及绑定到 TCP/IP 套接字,这正是我们的应用程序稍后会连接的地方。如果你希望在本例中运行一个全新的数据库,就在窗口中按下 CTRL + C 来关闭 HSQL 数据库,并删除 data/ 目录下的所有文件,再重新启动 HSQL 数据库。 " #. Tag: para #, no-c-format -msgid "" -"Hibernate will be connecting to the database on behalf of your application, " -"so it needs to know how to obtain connections. For this tutorial we will be " -"using a standalone connection pool (as opposed to a javax.sql." -"DataSource). Hibernate comes with support for two third-" -"party open source JDBC connection pools: c3p0 and proxool. However, we will be using the Hibernate built-in " -"connection pool for this tutorial." -msgstr "" -"Hibernate 将为你的应用程序连接到数据库,所以它需要知道如何获取连接。在这个教" -"程里,我们使用一个独立连接池(和 javax.sql.DataSource 相反)。Hibernate 支持两个第三方的开源 JDBC 连接池:c3p0proxool。然而,在本教程里我们将使" -"用 Hibernate 内置的连接池。" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"The built-in Hibernate connection pool is in no way intended for production " -"use. It lacks several features found on any decent connection pool." -msgstr "嵌入的 Hibernate 连接池不用于产品环境。" +msgid "Hibernate will be connecting to the database on behalf of your application, so it needs to know how to obtain connections. For this tutorial we will be using a standalone connection pool (as opposed to a javax.sql.DataSource). Hibernate comes with support for two third-party open source JDBC connection pools: c3p0 and proxool. However, we will be using the Hibernate built-in connection pool for this tutorial." +msgstr "Hibernate 将为你的应用程序连接到数据库,所以它需要知道如何获取连接。在这个教程里,我们使用一个独立连接池(和 javax.sql.DataSource 相反)。Hibernate 支持两个第三方的开源 JDBC 连接池:c3p0proxool。然而,在本教程里我们将使用 Hibernate 内置的连接池。" #. Tag: para #, no-c-format -msgid "" -"For Hibernate's configuration, we can use a simple hibernate." -"properties file, a 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 配置文" -"件: " +msgid "The built-in Hibernate connection pool is in no way intended for production use. It lacks several features found on any decent connection pool." +msgstr "嵌入的 Hibernate 连接池不用于产品环境。它缺乏连接池里的几个功能。" + +#. Tag: para +#, no-c-format +msgid "For Hibernate's configuration, we can use a simple hibernate.properties file, a 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: para #, no-c-format @@ -521,63 +227,28 @@ msgstr "请注意,这个配置文件指定了一个不同的 DTD。" #. Tag: para #, no-c-format -msgid "" -"You configure Hibernate's SessionFactory. SessionFactory " -"is a global factory responsible for a particular database. If you have " -"several databases, for easier startup you should use several <" -"session-factory> configurations in several configuration files." -msgstr "" -"注意这个 XML 配置使用了一个不同的 DTD。在这里,我们配置了 Hibernate 的" -"SessionFactory — 一个关联于特定数据库全局的工厂" -"(factory)。如果你要使用多个数据库,就要用多个的 <session-" -"factory>,通常把它们放在多个配置文件中(为了更容易启动)。 " +msgid "You configure Hibernate's SessionFactory. SessionFactory is a global factory responsible for a particular database. If you have several databases, for easier startup you should use several <session-factory> configurations in several configuration files." +msgstr "注意这个 XML 配置使用了一个不同的 DTD。在这里,我们配置了 Hibernate 的SessionFactory — 一个关联于特定数据库全局的工厂(factory)。如果你要使用多个数据库,就要用多个的 <session-factory>,通常把它们放在多个配置文件中(为了更容易启动)。 " #. Tag: para #, 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." -msgstr "" -"签名 4 个 property 元素包含了 JDBC 连接所必需的配置。方言 " -"property 元素指定了 Hibernate 生成的特定 SQL 语句。" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"In most cases, Hibernate is able to properly determine which dialect to use. " -"See for more information." -msgstr "" -"在大多数情况下,Hibernate 都能够正确地决定所使用的方言。更多信息请参考 。" +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." +msgstr "签名 4 个 property 元素包含了 JDBC 连接所必需的配置。方言 property 元素指定了 Hibernate 生成的特定 SQL 语句。" #. Tag: para #, no-c-format -msgid "" -"Hibernate's automatic session management for persistence contexts is " -"particularly useful in this context. The hbm2ddl.auto " -"option turns on automatic generation of database schemas directly into the " -"database. This can also be turned off by removing the configuration option, " -"or redirected to a file with the help of the SchemaExport " -"Ant task. Finally, 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 重定向到" -"文件中。最后,在配置中为持久化类加入映射文件。 " +msgid "In most cases, Hibernate is able to properly determine which dialect to use. See for more information." +msgstr "在大多数情况下,Hibernate 都能够正确地决定所使用的方言。更多信息请参考 。 " #. Tag: para #, no-c-format -msgid "" -"Save this file as hibernate.cfg.xml into the " -"src/main/resources directory." -msgstr "" -"把这个文件保存为 src/main/resources 目录下的 " -"hibernate.cfg.xml。" +msgid "Hibernate's automatic session management for persistence contexts is particularly useful in this context. The hbm2ddl.auto option turns on automatic generation of database schemas directly into the database. This can also be turned off by removing the configuration option, or redirected to a file with the help of the SchemaExport Ant task. Finally, 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 重定向到文件中。最后,在配置中为持久化类加入映射文件。 " + +#. Tag: para +#, no-c-format +msgid "Save this file as hibernate.cfg.xml into the src/main/resources directory." +msgstr "把这个文件保存为 src/main/resources 目录下的 hibernate.cfg.xml。" #. Tag: title #, no-c-format @@ -586,19 +257,8 @@ msgstr "用 Maven 构建 " #. Tag: para #, no-c-format -msgid "" -"We will now build the tutorial with Maven. You will need to have Maven " -"installed; it is available from the Maven download page. Maven will read the /" -"pom.xml file we created earlier and know how to perform some " -"basic project tasks. First, lets run the compile goal to " -"make sure we can compile everything so far:" -msgstr "" -"我们将用 Maven 构建这个教程。你将需要安装 Maven;你可以从 Maven 下载页面获得 Maven。" -"Maen 将读取我们先前创建的 /pom.xml 并知道执行基本的项目" -"任务。首先,让我们运行 compile 目标来确保我们可以编译到目" -"前为止的所有程序:" +msgid "We will now build the tutorial with Maven. You will need to have Maven installed; it is available from the Maven download page. Maven will read the /pom.xml file we created earlier and know how to perform some basic project tasks. First, lets run the compile goal to make sure we can compile everything so far:" +msgstr "我们将用 Maven 构建这个教程。你将需要安装 Maven;你可以从 Maven 下载页面获得 Maven。Maen 将读取我们先前创建的 /pom.xml 并知道执行基本的项目任务。首先,让我们运行 compile 目标来确保我们可以编译到目前为止的所有程序:" #. Tag: title #, no-c-format @@ -607,102 +267,37 @@ msgstr "启动和辅助类" #. Tag: para #, no-c-format -msgid "" -"It is time to load and store some Event objects, but " -"first you have to complete the setup with some infrastructure code. You have " -"to startup Hibernate by building a global org.hibernate." -"SessionFactory object and storing it somewhere for easy " -"access in application code. A org.hibernate.SessionFactory is used to obtain org.hibernate.Session instances. A org.hibernate.Session represents a single-threaded unit of work. The " -"org.hibernate.SessionFactory is a thread-safe " -"global object that is instantiated once." -msgstr "" -"是时候来加载和储存一些 Event 对象了,但首先我们得编写一些" -"基础的代码以完成设置。我们必须启动 Hibernate,此过程包括创建一个全局的 " -"SessoinFactory,并把它储存在应用程序代码容易访问的地方。" -"SessionFactory 可以创建并打开新的 Session。一个 Session 代表一个单线程的单元操作," -"org.hibernate.SessionFactory 则是个线程安全的" -"全局对象,只需要被实例化一次。 " +msgid "It is time to load and store some Event objects, but first you have to complete the setup with some infrastructure code. You have to startup Hibernate by building a global org.hibernate.SessionFactory object and storing it somewhere for easy access in application code. A org.hibernate.SessionFactory is used to obtain org.hibernate.Session instances. A org.hibernate.Session represents a single-threaded unit of work. The org.hibernate.SessionFactory is a thread-safe global object that is instantiated once." +msgstr "是时候来加载和储存一些 Event 对象了,但首先我们得编写一些基础的代码以完成设置。我们必须启动 Hibernate,此过程包括创建一个全局的 SessoinFactory,并把它储存在应用程序代码容易访问的地方。SessionFactory 可以创建并打开新的 Session。一个 Session 代表一个单线程的单元操作,org.hibernate.SessionFactory 则是个线程安全的全局对象,只需要被实例化一次。 " #. Tag: para #, no-c-format -msgid "" -"We will create a HibernateUtil helper class that takes " -"care of startup and makes accessing the org.hibernate." -"SessionFactory more convenient." -msgstr "" -"我们将创建一个 HibernateUtil 辅助类(helper class)来负责" -"启动 Hibernate 和更方便地操作 org.hibernate.SessionFactory。让我们来看一下它的实现:" +msgid "We will create a HibernateUtil helper class that takes care of startup and makes accessing the org.hibernate.SessionFactory more convenient." +msgstr "我们将创建一个 HibernateUtil 辅助类(helper class)来负责启动 Hibernate 和更方便地操作 org.hibernate.SessionFactory。让我们来看一下它的实现:" #. Tag: para #, no-c-format -msgid "" -"Save this code as src/main/java/org/hibernate/tutorial/util/" -"HibernateUtil.java" -msgstr "" -"把这段代码保存为 src/main/java/org/hibernate/tutorial/util/" -"HibernateUtil.java。" +msgid "Save this code as src/main/java/org/hibernate/tutorial/util/HibernateUtil.java" +msgstr "把这段代码保存为 src/main/java/org/hibernate/tutorial/util/HibernateUtil.java。" #. Tag: para #, no-c-format -msgid "" -"This class not only produces the global org.hibernate." -"SessionFactory reference in its static initializer; it also " -"hides the fact that it uses a static singleton. We might just as well have " -"looked up the org.hibernate.SessionFactory " -"reference from JNDI in an application server or any other location for that " -"matter." -msgstr "" -"这个类不但在它的静态初始化过程(仅当加载这个类的时候被 JVM 执行一次)中产生全" -"局的 org.hibernate.SessionFactory,而且隐藏了" -"它使用了静态 singleton 的事实。它也可能在应用程序服务器中的 JNDI 查找 " -"org.hibernate.SessionFactory。" +msgid "This class not only produces the global org.hibernate.SessionFactory reference in its static initializer; it also hides the fact that it uses a static singleton. We might just as well have looked up the org.hibernate.SessionFactory reference from JNDI in an application server or any other location for that matter." +msgstr "这个类不但在它的静态初始化过程(仅当加载这个类的时候被 JVM 执行一次)中产生全局的 org.hibernate.SessionFactory,而且隐藏了它使用了静态 singleton 的事实。它也可能在应用程序服务器中的 JNDI 查找 org.hibernate.SessionFactory。" #. Tag: para #, no-c-format -msgid "" -"If you give the org.hibernate.SessionFactory " -"a name in your configuration, Hibernate will try to bind it to JNDI under " -"that name after it has been built. Another, better option is to use a JMX " -"deployment and let the JMX-capable container instantiate and bind a " -"HibernateService to JNDI. Such advanced options are " -"discussed later." -msgstr "" -"如果你在配置文件中给 org.hibernate.SessionFactory 一个名字,在 它创建后,Hibernate 会试着把它绑定到 JNDI。要完全" -"避免这样的代码,你也可以使用 JMX 部署,让具有 JMX 能力的容器来实例化 " -"HibernateService 并把它绑定到 JNDI。这些高级可选项在后面的" -"章节中会讨论到。" +msgid "If you give the org.hibernate.SessionFactory a name in your configuration, Hibernate will try to bind it to JNDI under that name after it has been built. Another, better option is to use a JMX deployment and let the JMX-capable container instantiate and bind a HibernateService to JNDI. Such advanced options are discussed later." +msgstr "如果你在配置文件中给 org.hibernate.SessionFactory 一个名字,在 它创建后,Hibernate 会试着把它绑定到 JNDI。要完全避免这样的代码,你也可以使用 JMX 部署,让具有 JMX 能力的容器来实例化 HibernateService 并把它绑定到 JNDI。这些高级可选项在后面的章节中会讨论到。" #. Tag: para #, no-c-format -msgid "" -"You now need to configure a logging system. Hibernate uses commons logging " -"and provides two choices: Log4j and JDK 1.4 logging. Most developers prefer " -"Log4j: copy log4j.properties from the Hibernate " -"distribution in the etc/ directory to your src directory, next to hibernate.cfg.xml. If you " -"prefer to have more verbose output than that provided in the example " -"configuration, you can change the settings. By default, only the Hibernate " -"startup message is shown on stdout." -msgstr "" -"再次编译这个应用程序应该不会有问题。最后我们需要配置一个日志(logging)系统 — " -"Hibernate 使用通用日志接口,允许你在 Log4j 和 JDK 1.4 日志之间进行选择。多数" -"开发者更喜欢 Log4j:从 Hibernate 的发布包中(它在 etc/ 目" -"录下)拷贝 log4j.properties 到你的 src " -"目录,与 hibernate.cfg.xml 放在一起。看一下配置示例,如果" -"你希望看到更加详细的输出信息,你可以修改配置。默认情况下,只有 Hibernate 的启" -"动信息才会显示在标准输出上。 " +msgid "You now need to configure a logging system. Hibernate uses commons logging and provides two choices: Log4j and JDK 1.4 logging. Most developers prefer Log4j: copy log4j.properties from the Hibernate distribution in the etc/ directory to your src directory, next to hibernate.cfg.xml. If you prefer to have more verbose output than that provided in the example configuration, you can change the settings. By default, only the Hibernate startup message is shown on stdout." +msgstr "再次编译这个应用程序应该不会有问题。最后我们需要配置一个日志(logging)系统 — Hibernate 使用通用日志接口,允许你在 Log4j 和 JDK 1.4 日志之间进行选择。多数开发者更喜欢 Log4j:从 Hibernate 的发布包中(它在 etc/ 目录下)拷贝 log4j.properties 到你的 src 目录,与 hibernate.cfg.xml 放在一起。看一下配置示例,如果你希望看到更加详细的输出信息,你可以修改配置。默认情况下,只有 Hibernate 的启动信息才会显示在标准输出上。 " #. Tag: para #, no-c-format -msgid "" -"The tutorial infrastructure is complete and you are now ready to do some " -"real work with Hibernate." +msgid "The tutorial infrastructure is complete and you are now ready to do some real work with Hibernate." msgstr "示例的基本框架完成了 — 现在我们可以用 Hibernate 来做些真正的工作。 " #. Tag: title @@ -712,140 +307,48 @@ msgstr "加载并存储对象" #. Tag: para #, no-c-format -msgid "" -"We are now ready to start doing some real worjk with Hibernate. Let's start " -"by writing an EventManager class with a main() method:" -msgstr "" -"我们终于可以使用 Hibernate 来加载和存储对象了,编写一个带有 main() 方法的 EventManager 类: " +msgid "We are now ready to start doing some real worjk with Hibernate. Let's start by writing an EventManager class with a main() method:" +msgstr "我们终于可以使用 Hibernate 来加载和存储对象了,编写一个带有 main() 方法的 EventManager 类: " #. Tag: para #, no-c-format -msgid "" -"In createAndStoreEvent() we created a new Event object and handed it over to Hibernate. At that point, Hibernate " -"takes care of the SQL and executes an INSERT on the " -"database." -msgstr "" -"在 createAndStoreEvent() 来里我们创建了一个新的 " -"Event 对象并把它传递给 Hibernate。现在 Hibernate 负责与 " -"SQL 打交道,并把 INSERT 命令传给数据库。" +msgid "In createAndStoreEvent() we created a new Event object and handed it over to Hibernate. At that point, Hibernate takes care of the SQL and executes an INSERT on the database." +msgstr "在 createAndStoreEvent() 来里我们创建了一个新的 Event 对象并把它传递给 Hibernate。现在 Hibernate 负责与 SQL 打交道,并把 INSERT 命令传给数据库。" #. Tag: para #, no-c-format -msgid "" -"A org.hibernate.Session is designed to represent a " -"single unit of work (a single atmoic piece of work to be performed). For now " -"we will keep things simple and assume a one-to-one granularity between a " -"Hibernate org.hibernate.Session and a database " -"transaction. To shield our code from the actual underlying transaction " -"system we use the Hibernate org.hibernate.Transaction API. In this particular case we are using JDBC-based " -"transactional semantics, but it could also run with JTA." -msgstr "" -"一个 org.hibernate.Session 就是个单一的工作单元。我们" -"暂时让事情简单一些,并假设 Hibernate org.hibernate.Session 和数据库事务是一一对应的。为了让我们的代码从底层的事务系统中脱离出" -"来(此例中是 JDBC,但也可能是 JTA),我们使用 org.hibernate." -"Transaction API。在这个例子里我们使用基于 JDBC 的事务性 " -"semantic,但它也可以和 JTA 一起运行。" +msgid "A org.hibernate.Session is designed to represent a single unit of work (a single atmoic piece of work to be performed). For now we will keep things simple and assume a one-to-one granularity between a Hibernate org.hibernate.Session and a database transaction. To shield our code from the actual underlying transaction system we use the Hibernate org.hibernate.Transaction API. In this particular case we are using JDBC-based transactional semantics, but it could also run with JTA." +msgstr "一个 org.hibernate.Session 就是个单一的工作单元。我们暂时让事情简单一些,并假设 Hibernate org.hibernate.Session 和数据库事务是一一对应的。为了让我们的代码从底层的事务系统中脱离出来(此例中是 JDBC,但也可能是 JTA),我们使用 org.hibernate.Transaction API。在这个例子里我们使用基于 JDBC 的事务性 semantic,但它也可以和 JTA 一起运行。" #. Tag: para #, 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 org.hibernate.SessionFactory. The " -"getCurrentSession() method always returns the \"current\" " -"unit of work. Remember that we switched the configuration option for this " -"mechanism to \"thread\" in our src/main/resources/hibernate.cfg." -"xml? Due to that setting, the context of a current unit of work " -"is bound to the current Java thread that executes the application." -msgstr "" -"sessionFactory.getCurrentSession() 是干什么的呢?首先,只" -"要你持有 org.hibernate.SessionFactory,大可在" -"任何时候、任何地点调用这个方法。getCurrentSession() 方法总" -"会返回“当前的”工作单元。记得我们在 src/main/resources/hibernate." -"cfg.xml 中把这一配置选项调整为 \"thread\" 了吗?因此,因此,当前工" -"作单元被绑定到当前执行我们应用程序的 Java 线程。但是,这并非是完全准确的,你还" -"得考虑工作单元的生命周期范围(scope),它何时开始,又何时结束。" +msgid "What does sessionFactory.getCurrentSession() do? First, you can call it as many times and anywhere you like once you get hold of your org.hibernate.SessionFactory. The getCurrentSession() method always returns the \"current\" unit of work. Remember that we switched the configuration option for this mechanism to \"thread\" in our src/main/resources/hibernate.cfg.xml? Due to that setting, the context of a current unit of work is bound to the current Java thread that executes the application." +msgstr "sessionFactory.getCurrentSession() 是干什么的呢?首先,只要你持有 org.hibernate.SessionFactory,大可在任何时候、任何地点调用这个方法。getCurrentSession() 方法总会返回“当前的”工作单元。记得我们在 src/main/resources/hibernate.cfg.xml 中把这一配置选项调整为 \"thread\" 了吗?因此,因此,当前工作单元被绑定到当前执行我们应用程序的 Java 线程。但是,这并非是完全准确的,你还得考虑工作单元的生命周期范围(scope),它何时开始,又何时结束。" #. Tag: para #, no-c-format -msgid "" -"Hibernate offers three methods of current session tracking. The \"thread\" " -"based method is not intended for production use; it is merely useful for " -"prototyping and tutorials such as this one. Current session tracking is " -"discussed in more detail later on." -msgstr "" -"Hibernate 提供三种跟踪当前会话的方法。基于“线程”的方法不适合于产品环境,它仅" -"用于 prototyping 和教学用途。后面将更详细地讨论会话跟踪。" +msgid "Hibernate offers three methods of current session tracking. The \"thread\" based method is not intended for production use; it is merely useful for prototyping and tutorials such as this one. Current session tracking is discussed in more detail later on." +msgstr "Hibernate 提供三种跟踪当前会话的方法。基于“线程”的方法不适合于产品环境,它仅用于 prototyping 和教学用途。后面将更详细地讨论会话跟踪。" #. Tag: para #, no-c-format -msgid "" -"A org.hibernate.Session begins when the first call to " -"getCurrentSession() is made for the current thread. It is " -"then bound by Hibernate to the current thread. When the transaction ends, " -"either through commit or rollback, Hibernate automatically unbinds the " -"org.hibernate.Session from the thread and closes it " -"for you. If you call getCurrentSession() again, you get a " -"new org.hibernate.Session and can start a new unit of " -"work." -msgstr "" -"org.hibernate.Session 在第一次被使用的时候,即第一次调" -"用 getCurrentSession() 的时候,其生命周期就开始。然后它被 " -"Hibernate 绑定到当前线程。当事务结束的时候,不管是提交还是回滚,Hibernate 会" -"自动把 org.hibernate.Session 从当前线程剥离,并且关闭" -"它。假若你再次调用 getCurrentSession(),你会得到一个新的 " -"org.hibernate.Session,并且开始一个新的工作单元。" +msgid "A org.hibernate.Session begins when the first call to getCurrentSession() is made for the current thread. It is then bound by Hibernate to the current thread. When the transaction ends, either through commit or rollback, Hibernate automatically unbinds the org.hibernate.Session from the thread and closes it for you. If you call getCurrentSession() again, you get a new org.hibernate.Session and can start a new unit of work." +msgstr "org.hibernate.Session 在第一次被使用的时候,即第一次调用 getCurrentSession() 的时候,其生命周期就开始。然后它被 Hibernate 绑定到当前线程。当事务结束的时候,不管是提交还是回滚,Hibernate 会自动把 org.hibernate.Session 从当前线程剥离,并且关闭它。假若你再次调用 getCurrentSession(),你会得到一个新的 org.hibernate.Session,并且开始一个新的工作单元。" #. Tag: para #, no-c-format -msgid "" -"Related to the unit of work scope, should the Hibernate org." -"hibernate.Session be used to execute one or several database " -"operations? The above example uses one org.hibernate.Session for one operation. However this is pure coincidence; the example " -"is just not complex enough to show any other approach. The scope of a " -"Hibernate org.hibernate.Session is flexible but you " -"should never design your application to use a new Hibernate org." -"hibernate.Session for every database " -"operation. Even though it is used in the following examples, consider " -"session-per-operation an anti-pattern. A real web " -"application is shown later in the tutorial which will help illustrate this." -msgstr "" -"和工作单元的生命周期这个话题相关,Hibernate org.hibernate." -"Session 是否被应该用来执行多次数据库操作?上面的例子对每一次操作" -"使用了一个 org.hibernate.Session,这完全是巧合,这个例" -"子不是很复杂,无法展示其他方式。Hibernate org.hibernate.Session 的生命周期可以很灵活,但是你绝不要把你的应用程序设计成为" -"每一次数据库操作都用一个新的 Hibernate org.hibernate." -"Session。因此就算下面的例子(它们都很简单)中你可以看到这种用法," -"记住每次操作一个 session 是一个反模式。在本教程的后面会" -"展示一个真正的(web)程序。" - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"See for more information about transaction " -"handling and demarcation. The previous example also skipped any error " -"handling and rollback." -msgstr "" -"关于事务处理及事务边界界定的详细信息,请参看 。在上面的例子中,我们也忽略了所有的错误与回滚的处理。" +msgid "Related to the unit of work scope, should the Hibernate org.hibernate.Session be used to execute one or several database operations? The above example uses one org.hibernate.Session for one operation. However this is pure coincidence; the example is just not complex enough to show any other approach. The scope of a Hibernate org.hibernate.Session is flexible but you should never design your application to use a new Hibernate org.hibernate.Session for every database operation. Even though it is used in the following examples, consider session-per-operation an anti-pattern. A real web application is shown later in the tutorial which will help illustrate this." +msgstr "和工作单元的生命周期这个话题相关,Hibernate org.hibernate.Session 是否被应该用来执行多次数据库操作?上面的例子对每一次操作使用了一个 org.hibernate.Session,这完全是巧合,这个例子不是很复杂,无法展示其他方式。Hibernate org.hibernate.Session 的生命周期可以很灵活,但是你绝不要把你的应用程序设计成为每一次数据库操作都用一个新的 Hibernate org.hibernate.Session。因此就算下面的例子(它们都很简单)中你可以看到这种用法,记住每次操作一个 session 是一个反模式。在本教程的后面会展示一个真正的(web)程序。" #. Tag: para #, no-c-format -msgid "" -"To run this, we will make use of the Maven exec plugin to call our class " -"with the necessary classpath setup: mvn exec:java -Dexec.mainClass=" -"\"org.hibernate.tutorial.EventManager\" -Dexec.args=\"store\"" -msgstr "" -"要运行它,我们将使用 Maven exec 插件以及必要的 classpath 设置来进行调用:" -"mvn exec:java -Dexec.mainClass=\"org.hibernate.tutorial.EventManager" -"\" -Dexec.args=\"store\"。" +msgid "See for more information about transaction handling and demarcation. The previous example also skipped any error handling and rollback." +msgstr "关于事务处理及事务边界界定的详细信息,请参看 。在上面的例子中,我们也忽略了所有的错误与回滚的处理。 " + +#. Tag: para +#, no-c-format +msgid "To run this, we will make use of the Maven exec plugin to call our class with the necessary classpath setup: mvn exec:java -Dexec.mainClass=\"org.hibernate.tutorial.EventManager\" -Dexec.args=\"store\"" +msgstr "要运行它,我们将使用 Maven exec 插件以及必要的 classpath 设置来进行调用:mvn exec:java -Dexec.mainClass=\"org.hibernate.tutorial.EventManager\" -Dexec.args=\"store\"。" #. Tag: para #, no-c-format @@ -854,12 +357,8 @@ msgstr "你可能需要先执行 mvn compile。" #. Tag: para #, no-c-format -msgid "" -"You should see Hibernate starting up and, depending on your configuration, " -"lots of log output. Towards the end, the following line will be displayed:" -msgstr "" -"你应该会看到,编译以后,Hibernate 根据你的配置启动,并产生一大堆的输出日志。" -"在日志最后你会看到下面这行: " +msgid "You should see Hibernate starting up and, depending on your configuration, lots of log output. Towards the end, the following line will be displayed:" +msgstr "你应该会看到,编译以后,Hibernate 根据你的配置启动,并产生一大堆的输出日志。在日志最后你会看到下面这行: " #. Tag: para #, no-c-format @@ -869,8 +368,7 @@ msgstr "执行 HQL INSERT 语句的例子如下: " #. Tag: para #, no-c-format msgid "To list stored events an option is added to the main method:" -msgstr "" -"我们想要列出所有已经被存储的 events,就要增加一个条件分支选项到 main 方法中:" +msgstr "我们想要列出所有已经被存储的 events,就要增加一个条件分支选项到 main 方法中:" #. Tag: para #, no-c-format @@ -878,30 +376,14 @@ msgid "A new listEvents() method is also added:" msgstr "我们也增加一个新的 listEvents() 方法: " #. Tag: para -#, fuzzy, no-c-format -msgid "" -"Here, we are using a Hibernate Query Language (HQL) 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. See for more information." -msgstr "" -"我们在这里是用一个 HQL(Hibernate Query Language-Hibernate查询语言)查询语句" -"来从数据库中加载所有存在的 Event 对象。Hibernate 会生成适" -"当的 SQL,把它发送到数据库,并操作从查询得到数据的 Event " -"对象。当然,你可以使用 HQL 来创建更加复杂的查询。更多信息请参考 。" +#, no-c-format +msgid "Here, we are using a Hibernate Query Language (HQL) 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. See for more information." +msgstr "我们在这里是用一个 HQL(Hibernate Query Language-Hibernate查询语言)查询语句来从数据库中加载所有存在的 Event 对象。Hibernate 会生成适当的 SQL,把它发送到数据库,并操作从查询得到数据的 Event 对象。当然,你可以使用 HQL 来创建更加复杂的查询。更多信息请参考 。 " #. Tag: para #, no-c-format -msgid "" -"Now we can call our new functionality, again using the Maven exec plugin: " -"mvn exec:java -Dexec.mainClass=\"org.hibernate.tutorial.EventManager" -"\" -Dexec.args=\"list\"" -msgstr "" -"现在我们可以再次用 Maven exec plugin - mvn exec:java -Dexec." -"mainClass=\"org.hibernate.tutorial.EventManager\" -Dexec.args=\"list\" 调用新的功能了。" +msgid "Now we can call our new functionality, again using the Maven exec plugin: mvn exec:java -Dexec.mainClass=\"org.hibernate.tutorial.EventManager\" -Dexec.args=\"list\"" +msgstr "现在我们可以再次用 Maven exec plugin - mvn exec:java -Dexec.mainClass=\"org.hibernate.tutorial.EventManager\" -Dexec.args=\"list\" 调用新的功能了。" #. Tag: title #, no-c-format @@ -910,16 +392,8 @@ msgstr "第二部分 - 关联映射" #. Tag: para #, no-c-format -msgid "" -"So far we have mapped a single persistent entity class to a table in " -"isolation. Let's expand on that a bit and add some class associations. We " -"will add people to the application and store a list of events in which they " -"participate." -msgstr "" -"我们已经映射了一个持久化实体类到表上。让我们在这个基础上增加一些类之间的关" -"联。首先我们往应用程序里增加人(people)的概念,并存储他们所参与的一个 Event " -"列表。(译者注:与 Event 一样,我们在后面将直接使用 person 来表示“人”而不是它" -"的中文翻译) " +msgid "So far we have mapped a single persistent entity class to a table in isolation. Let's expand on that a bit and add some class associations. We will add people to the application and store a list of events in which they participate." +msgstr "我们已经映射了一个持久化实体类到表上。让我们在这个基础上增加一些类之间的关联。首先我们往应用程序里增加人(people)的概念,并存储他们所参与的一个 Event 列表。(译者注:与 Event 一样,我们在后面将直接使用 person 来表示“人”而不是它的中文翻译) " #. Tag: title #, no-c-format @@ -933,21 +407,13 @@ msgstr "最初简单的 Person 类: " #. Tag: para #, no-c-format -msgid "" -"Save this to a file named src/main/java/org/hibernate/tutorial/" -"domain/Person.java" -msgstr "" -"把它保存为文件 src/main/java/org/hibernate/tutorial/domain/Person." -"java。" +msgid "Save this to a file named src/main/java/org/hibernate/tutorial/domain/Person.java" +msgstr "把它保存为文件 src/main/java/org/hibernate/tutorial/domain/Person.java。" #. Tag: para #, no-c-format -msgid "" -"Next, create the new mapping file as src/main/resources/org/" -"hibernate/tutorial/domain/Person.hbm.xml" -msgstr "" -"然后,创建新的映射文件 src/main/resources/org/hibernate/tutorial/" -"domain/Person.hbm.xml。" +msgid "Next, create the new mapping file as src/main/resources/org/hibernate/tutorial/domain/Person.hbm.xml" +msgstr "然后,创建新的映射文件 src/main/resources/org/hibernate/tutorial/domain/Person.hbm.xml。" #. Tag: para #, no-c-format @@ -956,14 +422,8 @@ msgstr "最后,把新的映射加入到 Hibernate 的配置中:" #. Tag: para #, no-c-format -msgid "" -"Create an association between these two entities. Persons can participate in " -"events, and events have participants. The design questions you have to deal " -"with are: directionality, multiplicity, and collection behavior." -msgstr "" -"现在我们在这两个实体之间创建一个关联。显然,persons 可以参与一系列 events," -"而 events 也有不同的参加者(persons)。我们需要处理的设计问题是关联方向" -"(directionality),阶数(multiplicity)和集合(collection)的行为。 " +msgid "Create an association between these two entities. Persons can participate in events, and events have participants. The design questions you have to deal with are: directionality, multiplicity, and collection behavior." +msgstr "现在我们在这两个实体之间创建一个关联。显然,persons 可以参与一系列 events,而 events 也有不同的参加者(persons)。我们需要处理的设计问题是关联方向(directionality),阶数(multiplicity)和集合(collection)的行为。 " #. Tag: title #, no-c-format @@ -972,65 +432,18 @@ msgstr "单向 Set-based 的关联" #. Tag: para #, no-c-format -msgid "" -"By adding a collection of events to the Person class, you " -"can easily navigate to the events for a particular person, without executing " -"an explicit query - by calling Person#getEvents. Multi-" -"valued associations are represented in Hibernate by one of the Java " -"Collection Framework contracts; here we choose a java.util." -"Set because the collection will not contain duplicate " -"elements and the ordering is not relevant to our examples:" -msgstr "" -"我们将向 Person 类增加一连串的 events。那样,通过调用 " -"aPerson.getEvents(),就可以轻松地导航到特定 person 所参与" -"的 events,而不用去执行一个显式的查询。我们使用 Java 的集合类(collection):" -"Set,因为 set 不包含重复的元素及与我们无关的排序。 " +msgid "By adding a collection of events to the Person class, you can easily navigate to the events for a particular person, without executing an explicit query - by calling Person#getEvents. Multi-valued associations are represented in Hibernate by one of the Java Collection Framework contracts; here we choose a java.util.Set because the collection will not contain duplicate elements and the ordering is not relevant to our examples:" +msgstr "我们将向 Person 类增加一连串的 events。那样,通过调用 aPerson.getEvents(),就可以轻松地导航到特定 person 所参与的 events,而不用去执行一个显式的查询。我们使用 Java 的集合类(collection):Set,因为 set 不包含重复的元素及与我们无关的排序。 " #. Tag: para #, no-c-format -msgid "" -"Before mapping this association, let's consider the other side. We could " -"just keep this unidirectional or create another collection on the " -"Event, if we wanted to be able to navigate it from both " -"directions. This is not necessary, from a functional perspective. You can " -"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 is called a many-to-many association. " -"Hence, we use Hibernate's many-to-many mapping:" -msgstr "" -"在映射这个关联之前,先考虑一下此关联的另外一端。很显然,我们可以保持这个关联" -"是单向的。或者,我们可以在 Event 里创建另外一个集合,如果" -"希望能够双向地导航,如:anEvent.getParticipants()。从功能" -"的角度来说,这并不是必须的。因为你总可以显式地执行一个查询,以获得某个特定 " -"event 的所有参与者。这是个在设计时需要做出的选择,完全由你来决定,但此讨论中" -"关于关联的阶数是清楚的:即两端都是“多”值的,我们把它叫做多对多" -"(many-to-many)关联。因而,我们使用 Hibernate 的多对多映射: " +msgid "Before mapping this association, let's consider the other side. We could just keep this unidirectional or create another collection on the Event, if we wanted to be able to navigate it from both directions. This is not necessary, from a functional perspective. You can 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 is called a many-to-many association. Hence, we use Hibernate's many-to-many mapping:" +msgstr "在映射这个关联之前,先考虑一下此关联的另外一端。很显然,我们可以保持这个关联是单向的。或者,我们可以在 Event 里创建另外一个集合,如果希望能够双向地导航,如:anEvent.getParticipants()。从功能的角度来说,这并不是必须的。因为你总可以显式地执行一个查询,以获得某个特定 event 的所有参与者。这是个在设计时需要做出的选择,完全由你来决定,但此讨论中关于关联的阶数是清楚的:即两端都是“多”值的,我们把它叫做多对多(many-to-many)关联。因而,我们使用 Hibernate 的多对多映射: " #. Tag: para #, no-c-format -msgid "" -"Hibernate supports a broad range of collection mappings, a set being most common. For a many-to-many association, or n:" -"m entity relationship, an association table is required. Each row " -"in this table represents a link between a person and an event. The table " -"name is decalred using the table attribute of the " -"set element. The identifier column name in the " -"association, for the person 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 (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 集合中对象的类(也就是位于这个集合所代表的关联另" -"外一端的类)。 " +msgid "Hibernate supports a broad range of collection mappings, a set being most common. For a many-to-many association, or n:m entity relationship, an association table is required. Each row in this table represents a link between a person and an event. The table name is decalred using the table attribute of the set element. The identifier column name in the association, for the person 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 (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 #, no-c-format @@ -1044,122 +457,38 @@ msgstr "使关联工作" #. Tag: para #, no-c-format -msgid "" -"Now we will bring some people and events together in a new method in " -"EventManager:" -msgstr "" -"我们把一些 people 和 events 一起放到 EventManager 的新方法" -"中: " +msgid "Now we will bring some people and events together in a new method in EventManager:" +msgstr "我们把一些 people 和 events 一起放到 EventManager 的新方法中: " #. Tag: para #, no-c-format -msgid "" -"After loading a Person and an Event, " -"simply modify the collection using the normal collection methods. 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. 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 org.hibernate.Session, 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." -msgstr "" -"在加载一 PersonEvent 后,使用普通的" -"集合方法就可容易地修改我们定义的集合。如你所见,没有显式的 update()" -"save(),Hibernate 会自动检测到集合已经被修改" -"并需要更新回数据库。这叫做自动脏检查(automatic dirty checking),你也可以尝试修改任何对象的 name 或者 date 属性,只要他们处于" -"持久化状态,也就是被绑定到某个 Hibernate 的 " -"Session 上(如:他们刚刚在一个单元操作被加载或者保存)," -"Hibernate 监视任何改变并在后台隐式写的方式执行 SQL。同步内存状态和数据库的过" -"程,通常只在单元操作结束的时候发生,称此过程为清理缓存(flushing)" -"。在我们的代码中,工作单元由数据库事务的提交(或者回滚)来结束——这" -"是由 CurrentSessionContext 类的 thread " -"配置选项定义的。 " +msgid "After loading a Person and an Event, simply modify the collection using the normal collection methods. 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. 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 org.hibernate.Session, 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." +msgstr "在加载一 PersonEvent 后,使用普通的集合方法就可容易地修改我们定义的集合。如你所见,没有显式的 update()save(),Hibernate 会自动检测到集合已经被修改并需要更新回数据库。这叫做自动脏检查(automatic dirty checking),你也可以尝试修改任何对象的 name 或者 date 属性,只要他们处于持久化状态,也就是被绑定到某个 Hibernate 的 Session 上(如:他们刚刚在一个单元操作被加载或者保存),Hibernate 监视任何改变并在后台隐式写的方式执行 SQL。同步内存状态和数据库的过程,通常只在单元操作结束的时候发生,称此过程为清理缓存(flushing)。在我们的代码中,工作单元由数据库事务的提交(或者回滚)来结束——这是由 CurrentSessionContext 类的 thread 配置选项定义的。 " #. Tag: para #, no-c-format -msgid "" -"You can load person and event in different units of work. Or you can modify " -"an object outside of a org.hibernate.Session, " -"when it is not in persistent state (if it was persistent before, this state " -"is called detached). You can even modify a collection " -"when it is detached:" -msgstr "" -"当然,你也可以在不同的单元操作里面加载 person 和 event。或在 " -"Session 以外修改不是处在持久化(persistent)状态下的对象" -"(如果该对象以前曾经被持久化,那么我们称这个状态为脱管(detached)" -")。你甚至可以在一个集合被脱管时修改它: " +msgid "You can load person and event in different units of work. Or you can modify an object outside of a org.hibernate.Session, when it is not in persistent state (if it was persistent before, this state is called detached). You can even modify a collection when it is detached:" +msgstr "当然,你也可以在不同的单元操作里面加载 person 和 event。或在 Session 以外修改不是处在持久化(persistent)状态下的对象(如果该对象以前曾经被持久化,那么我们称这个状态为脱管(detached))。你甚至可以在一个集合被脱管时修改它: " #. Tag: para #, no-c-format -msgid "" -"The call to update makes a detached object persistent " -"again by binding 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 的调用使一个脱管对象重新持久化,你可以说它被绑定" -"到一个新的单元操作上,所以在脱管状态下对它所做的任何修改都会被保存到数据库" -"里。这也包括你对这个实体对象的集合所作的任何改动(增加/删除)。 " +msgid "The call to update makes a detached object persistent again by binding 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 #, no-c-format -msgid "" -"This is not much use in our example, but it is an important concept you can " -"incorporate into your own application. Complete this exercise by adding a " -"new action to the main method of the EventManager 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() 方法返回它(你可能需要修改前面的一些方" -"法来返回那个标识符): " +msgid "This is not much use in our example, but it is an important concept you can incorporate into your own application. Complete this exercise by adding a new action to the main method of the EventManager 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: para #, no-c-format -msgid "" -"This is 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 java.lang.String. We " -"call these classes value types, and their instances " -"depend on a particular entity. Instances of these types " -"do not have their own identity, nor are they shared between entities. Two " -"persons do not reference the same firstname object, even " -"if they have the same first name. Value types cannot only be found in the " -"JDK , but you can also write dependent classes yourself such as an " -"Address or MonetaryAmount class. In " -"fact, in a Hibernate application all JDK classes are considered value types." -msgstr "" -"上面是个关于两个同等重要的实体类间关联的例子。像前面所提到的那样,在特定的模" -"型中也存在其它的类和类型,这些类和类型通常是“次要的”。你已看到过其中的一些," -"像 intString。我们称这些类为" -"值类型(value type),它们的实例依赖(depend)" -"在某个特定的实体上。这些类型的实例没有它们自己的标识(identity)," -"也不能在实体间被共享(比如,两个 person 不能引用同一个 firstname 对象,即使他们有相同的 first name)。当然,值类型并不仅仅在 JDK 中存" -"在(事实上,在一个 Hibernate 应用程序中,所有的 JDK 类都被视为值类型),而且" -"你也可以编写你自己的依赖类,例如 Address," -"MonetaryAmount。 " +msgid "This is 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 java.lang.String. We call these classes value types, and their instances depend on a particular entity. Instances of these types do not have their own identity, nor are they shared between entities. Two persons do not reference the same firstname object, even if they have the same first name. Value types cannot only be found in the JDK , but you can also write dependent classes yourself such as an Address or MonetaryAmount class. In fact, in a Hibernate application all JDK classes are considered value types." +msgstr "上面是个关于两个同等重要的实体类间关联的例子。像前面所提到的那样,在特定的模型中也存在其它的类和类型,这些类和类型通常是“次要的”。你已看到过其中的一些,像 intString。我们称这些类为值类型(value type),它们的实例依赖(depend)在某个特定的实体上。这些类型的实例没有它们自己的标识(identity),也不能在实体间被共享(比如,两个 person 不能引用同一个 firstname 对象,即使他们有相同的 first name)。当然,值类型并不仅仅在 JDK 中存在(事实上,在一个 Hibernate 应用程序中,所有的 JDK 类都被视为值类型),而且你也可以编写你自己的依赖类,例如 AddressMonetaryAmount。 " #. Tag: para #, no-c-format -msgid "" -"You can also design a collection of value types. This is conceptually " -"different from a collection of references to other entities, but looks " -"almost the same in Java." -msgstr "" -"你也可以设计一个值类型的集合,这在概念上与引用其它实体的集合有很大的不同,但" -"是在 Java 里面看起来几乎是一样的。 " +msgid "You can also design a collection of value types. This is conceptually different from a collection of references to other entities, but looks almost the same in Java." +msgstr "你也可以设计一个值类型的集合,这在概念上与引用其它实体的集合有很大的不同,但是在 Java 里面看起来几乎是一样的。 " #. Tag: title #, no-c-format @@ -1168,14 +497,8 @@ msgstr "值类型的集合" #. Tag: para #, no-c-format -msgid "" -"Let's add a collection of email addresses to the Person " -"entity. This will be represented as a java.util.Set of java.lang.String instances:" -msgstr "" -"让我们在 Person 实体里添加一个电子邮件的集合。这将以 " -"java.lang.String 实例的 java.util.Set 出现:" +msgid "Let's add a collection of email addresses to the Person entity. This will be represented as a java.util.Set of java.lang.String instances:" +msgstr "让我们在 Person 实体里添加一个电子邮件的集合。这将以 java.lang.String 实例的 java.util.Set 出现:" #. Tag: para #, no-c-format @@ -1184,26 +507,8 @@ msgstr "这个 Set 的映射如下:" #. Tag: para #, no-c-format -msgid "" -"The difference compared with the earlier mapping is the use of the " -"element part which tells Hibernate that the collection " -"does not contain references to another entity, but is rather a collection " -"whose elements are values types, here specifically of type string. The lowercase name tells you it is a Hibernate mapping type/" -"converter. 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 email " -"address values will actually be stored." -msgstr "" -"比较这次和此前映射的差别,主要在于 element 部分,这次并没" -"有包含对其它实体引用的集合,而是元素类型为 String 的集合" -"(在映射中使用小写的名字”string“是向你表明它是一个 Hibernate 的映射类型或者类" -"型转换器)。和之前一样,set 元素的 table 属性决定了用于集合的表名。key 元素定义了在集合表" -"中外键的字段名。element 元素的 column " -"属性定义用于实际保存 String 值的字段名。 " +msgid "The difference compared with the earlier mapping is the use of the element part which tells Hibernate that the collection does not contain references to another entity, but is rather a collection whose elements are values types, here specifically of type string. The lowercase name tells you it is a Hibernate mapping type/converter. 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 email address values will actually be stored." +msgstr "比较这次和此前映射的差别,主要在于 element 部分,这次并没有包含对其它实体引用的集合,而是元素类型为 String 的集合(在映射中使用小写的名字”string“是向你表明它是一个 Hibernate 的映射类型或者类型转换器)。和之前一样,set 元素的 table 属性决定了用于集合的表名。key 元素定义了在集合表中外键的字段名。element 元素的 column 属性定义用于实际保存 String 值的字段名。 " #. Tag: para #, no-c-format @@ -1212,35 +517,18 @@ msgstr "看一下修改后的数据库 schema。 " #. Tag: para #, no-c-format -msgid "" -"You can see that the primary key of the collection table is in fact a " -"composite key that uses both columns. This also implies that there cannot be " -"duplicate email addresses per person, which is exactly the semantics we need " -"for a set in Java." -msgstr "" -"你可以看到集合表的主键实际上是个复合主键,同时使用了两个字段。这也暗示了对于" -"同一个 person 不能有重复的 email 地址,这正是 Java 里面使用 Set 时候所需要的" -"语义(Set 里元素不能重复)。" +msgid "You can see that the primary key of the collection table is in fact a composite key that uses both columns. This also implies that there cannot be duplicate email addresses per person, which is exactly the semantics we need for a set in Java." +msgstr "你可以看到集合表的主键实际上是个复合主键,同时使用了两个字段。这也暗示了对于同一个 person 不能有重复的 email 地址,这正是 Java 里面使用 Set 时候所需要的语义(Set 里元素不能重复)。" #. Tag: para #, no-c-format -msgid "" -"You can now try to add elements to this collection, just like we did before " -"by linking persons and events. It is the same code in Java:" -msgstr "" -"你现在可以试着把元素加入到这个集合,就像我们在之前关联 person 和 event 的那" -"样。其实现的 Java 代码是相同的: " +msgid "You can now try to add elements to this collection, just like we did before by linking persons and events. It is the same code in Java:" +msgstr "你现在可以试着把元素加入到这个集合,就像我们在之前关联 person 和 event 的那样。其实现的 Java 代码是相同的: " #. Tag: para #, no-c-format -msgid "" -"This time we did not use a fetch query to initialize " -"the collection. Monitor the SQL log and try to optimize this with an eager " -"fetch." -msgstr "" -"这次我们没有使用 fetch 查询来初始化集合。因此,调用其 " -"getter 方法会触发另一附加的 select 来初始化集合,这样我们才能把元素添加进去。" -"检查 SQL log,试着通过预先抓取来优化它。 " +msgid "This time we did not use a fetch query to initialize the collection. Monitor the SQL log and try to optimize this with an eager fetch." +msgstr "这次我们没有使用 fetch 查询来初始化集合。因此,调用其 getter 方法会触发另一附加的 select 来初始化集合,这样我们才能把元素添加进去。检查 SQL log,试着通过预先抓取来优化它。 " #. Tag: title #, no-c-format @@ -1249,68 +537,33 @@ msgstr "双向关联" #. Tag: para #, no-c-format -msgid "" -"Next you will map a bi-directional association. You will make the " -"association between person and event work from both sides in Java. The " -"database schema does not change, so you will still have many-to-many " -"multiplicity." -msgstr "" -"接下来我们将映射双向关联(bi-directional association)— 在 Java 里让 person " -"和 event 可以从关联的任何一端访问另一端。当然,数据库 schema 没有改变,我们仍" -"然需要多对多的阶数。一个关系型数据库要比网络编程语言更加灵活,所以它并不需要" -"任何像导航方向(navigation direction)的东西 — 数据可以用任何可能的方式进行查" -"看和获取。 " +msgid "Next you will map a bi-directional association. You will make the association between person and event work from both sides in Java. The database schema does not change, so you will still have many-to-many multiplicity." +msgstr "接下来我们将映射双向关联(bi-directional association)— 在 Java 里让 person 和 event 可以从关联的任何一端访问另一端。当然,数据库 schema 没有改变,我们仍然需要多对多的阶数。一个关系型数据库要比网络编程语言更加灵活,所以它并不需要任何像导航方向(navigation direction)的东西 — 数据可以用任何可能的方式进行查看和获取。 " #. Tag: para #, no-c-format -msgid "" -"A relational database is more flexible than a network programming language, " -"in that it does not need a navigation direction; data can be viewed and " -"retrieved in any possible way." -msgstr "" -"关系型数据库比网络编程语言更为灵活,因为它不需要方向导航,其数据可以用任何可" -"能的方式进行查看和提取。" +msgid "A relational database is more flexible than a network programming language, in that it does not need a navigation direction; data can be viewed and retrieved in any possible way." +msgstr "关系型数据库比网络编程语言更为灵活,因为它不需要方向导航,其数据可以用任何可能的方式进行查看和提取。" #. Tag: para #, no-c-format -msgid "" -"First, add a collection of participants to the Event " -"class:" -msgstr "" -"首先,把一个参与者(person)的集合加入 Event 类中: " +msgid "First, add a collection of participants to the Event class:" +msgstr "首先,把一个参与者(person)的集合加入 Event 类中: " #. Tag: para #, no-c-format -msgid "" -"Now map this side of the association in Event.hbm.xml." +msgid "Now map this side of the association in Event.hbm.xml." msgstr "在 Event.hbm.xml 里面也映射这个关联。 " #. Tag: para #, no-c-format -msgid "" -"These are normal set mappings in both mapping documents. " -"Notice that the column names in key and many-to-" -"many swap 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\" 属性。 " +msgid "These are normal set mappings in both mapping documents. Notice that the column names in key and many-to-many swap 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\" 属性。 " #. Tag: para #, 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 " -"类得到两个实体间关联的信息。这将会极大地帮助你理解双向关联是如何在两个实体间" -"被创建的。 " +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 #, no-c-format @@ -1319,73 +572,23 @@ msgstr "使双向连起来" #. Tag: para #, 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? You add an instance " -"of Event to the collection of event references, of an " -"instance of Person. If you want to make this link bi-" -"directional, you have to do the same on the other side by adding a " -"Person reference to the collection in an Event. This process of \"setting the link on both sides\" is absolutely " -"necessary with bi-directional links." -msgstr "" -"首先请记住,Hibernate 并不影响通常的 Java 语义。 在单向关联的例子中,我们是怎" -"样在 PersonEvent 之间创建联系的?我" -"们把 Event 实例添加到 Person 实例内的 " -"event 引用集合里。因此很显然,如果我们要让这个关联可以双向地工作,我们需要在" -"另外一端做同样的事情 - 把 Person 实例加入 " -"Event 类内的 Person 引用集合。这“在关联的两端设置联系”是完" -"全必要的而且你都得这么做。 " +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? You add an instance of Event to the collection of event references, of an instance of Person. If you want to make this link bi-directional, you have to do the same on the other side by adding a Person reference to the collection in an Event. This process of \"setting the link on both sides\" is absolutely necessary with bi-directional links." +msgstr "首先请记住,Hibernate 并不影响通常的 Java 语义。 在单向关联的例子中,我们是怎样在 PersonEvent 之间创建联系的?我们把 Event 实例添加到 Person 实例内的 event 引用集合里。因此很显然,如果我们要让这个关联可以双向地工作,我们需要在另外一端做同样的事情 - 把 Person 实例加入 Event 类内的 Person 引用集合。这“在关联的两端设置联系”是完全必要的而且你都得这么做。 " #. Tag: para #, no-c-format -msgid "" -"Many developers program defensively and create link management methods to " -"correctly set both sides (for example, in Person):" -msgstr "" -"许多开发人员防御式地编程,创建管理关联的方法来保证正确的设置了关联的两端,比" -"如在 Person 里: " +msgid "Many developers program defensively and create link management methods to correctly set both sides (for example, in Person):" +msgstr "许多开发人员防御式地编程,创建管理关联的方法来保证正确的设置了关联的两端,比如在 Person 里: " #. Tag: para #, no-c-format -msgid "" -"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 altering the collections directly. Repeat the " -"steps for the collection on the other side." -msgstr "" -"注意现在对于集合的 get 和 set 方法的访问级别是 protected — 这允许在位于同一个" -"包(package)中的类以及继承自这个类的子类可以访问这些方法,但禁止其他任何人的" -"直接访问,避免了集合内容的混乱。你应尽可能地在另一端也把集合的访问级别设成 " -"protected。 " +msgid "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 altering the collections directly. Repeat the steps for the collection on the other side." +msgstr "注意现在对于集合的 get 和 set 方法的访问级别是 protected — 这允许在位于同一个包(package)中的类以及继承自这个类的子类可以访问这些方法,但禁止其他任何人的直接访问,避免了集合内容的混乱。你应尽可能地在另一端也把集合的访问级别设成 protected。 " #. Tag: para #, 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, does not have enough " -"information to correctly arrange SQL INSERT and " -"UPDATE statements (to avoid constraint violations). " -"Making one side of the association inverse tells " -"Hibernate to consider it a mirror of the other side. " -"That is all that is necessary for Hibernate to resolve any issues that arise " -"when transforming a directional navigation model to a SQL database schema. " -"The rules are straightforward: all bi-directional associations need one side " -"as inverse. In a one-to-many association it has to be the " -"many-side, and in many-to-many association you can select either side." -msgstr "" -"inverse 映射属性究竟表示什么呢?对于你和 Java 来说,一个双" -"向关联仅仅是在两端简单地正确设置引用。然而,Hibernate 并没有足够的信息去正确" -"地执行 INSERTUPDATE 语句(以避免违" -"反数据库约束),所以它需要一些帮助来正确的处理双向关联。把关联的一端设置为 " -"inverse 将告诉 Hibernate 忽略关联的这一端,把这端看成是另" -"外一端的一个镜象(mirror)。这就是所需的全部信息," -"Hibernate 利用这些信息来处理把一个有向导航模型转移到数据库 schema 时的所有问" -"题。你只需要记住这个直观的规则:所有的双向关联需要有一端被设置为 " -"inverse。在一对多关联中它必须是代表多(many)的那端。而在" -"多对多(many-to-many)关联中,你可以任意选取一端,因为两端之间并没有差别。 " +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, does not have enough information to correctly arrange SQL INSERT and UPDATE statements (to avoid constraint violations). Making one side of the association inverse tells Hibernate to consider it a mirror of the other side. That is all that is necessary for Hibernate to resolve any issues that arise when transforming a directional navigation model to a SQL database schema. The rules are straightforward: all bi-directional associations need one side as inverse. In a one-to-many association it has to be the many-side, and in many-to-many association you can select either side." +msgstr "inverse 映射属性究竟表示什么呢?对于你和 Java 来说,一个双向关联仅仅是在两端简单地正确设置引用。然而,Hibernate 并没有足够的信息去正确地执行 INSERTUPDATE 语句(以避免违反数据库约束),所以它需要一些帮助来正确的处理双向关联。把关联的一端设置为 inverse 将告诉 Hibernate 忽略关联的这一端,把这端看成是另外一端的一个镜象(mirror)。这就是所需的全部信息,Hibernate 利用这些信息来处理把一个有向导航模型转移到数据库 schema 时的所有问题。你只需要记住这个直观的规则:所有的双向关联需要有一端被设置为 inverse。在一对多关联中它必须是代表多(many)的那端。而在多对多(many-to-many)关联中,你可以任意选取一端,因为两端之间并没有差别。 " #. Tag: title #, no-c-format @@ -1394,18 +597,8 @@ msgstr "第三部分 - EventManager web 应用程序" #. Tag: para #, no-c-format -msgid "" -"A Hibernate web application uses Session and " -"Transaction almost like a standalone application. " -"However, some common patterns are useful. You can 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 应用程序使用 Session 和 " -"Transaction 的方式几乎和独立应用程序是一样的。但是,有一些" -"常见的模式(pattern)非常有用。现在我们编写一个 " -"EventManagerServlet。这个 servlet 可以列出数据库中保存的所" -"有的 events,还提供一个 HTML 表单来增加新的 events。 " +msgid "A Hibernate web application uses Session and Transaction almost like a standalone application. However, some common patterns are useful. You can 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。 " #. Tag: title #, no-c-format @@ -1414,80 +607,33 @@ msgstr "编写基本的 servlet" #. Tag: para #, no-c-format -msgid "" -"First we need create our basic processing servlet. Since our servlet only " -"handles HTTP GET requests, we will only implement the " -"doGet() method:" -msgstr "" -"这个 servlet 只处理 HTTP GET 请求,因此,我们要实现的是 " -"doGet() 方法: " +msgid "First we need create our basic processing servlet. Since our servlet only handles HTTP GET requests, we will only implement the doGet() method:" +msgstr "这个 servlet 只处理 HTTP GET 请求,因此,我们要实现的是 doGet() 方法: " #. Tag: para #, no-c-format -msgid "" -"Save this servlet as src/main/java/org/hibernate/tutorial/web/" -"EventManagerServlet.java" -msgstr "" -"把这个 servlet 保存为 src/main/java/org/hibernate/tutorial/web/" -"EventManagerServlet.java。" +msgid "Save this servlet as src/main/java/org/hibernate/tutorial/web/EventManagerServlet.java" +msgstr "把这个 servlet 保存为 src/main/java/org/hibernate/tutorial/web/EventManagerServlet.java。" #. Tag: para #, no-c-format -msgid "" -"The pattern applied 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. A database transaction is then " -"started. All data access occurs inside a transaction irrespective of whether " -"the data is read or written. Do not use the auto-commit mode in applications." -msgstr "" -"我们称这里应用的模式为每次请求一个 session(session-per-request)。当有请求到达这个 servlet 的时候,通过对 SessionFactory 的第一次调用,打开一个新的 Hibernate Session。然" -"后启动一个数据库事务 — 所有的数据访问都是在事务中进行,不管是读还是写(我们在" -"应用程序中不使用 auto-commit 模式)。 " +msgid "The pattern applied 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. A database transaction is then started. All data access occurs inside a transaction irrespective of whether the data is read or written. Do not use the auto-commit mode in applications." +msgstr "我们称这里应用的模式为每次请求一个 session(session-per-request)。当有请求到达这个 servlet 的时候,通过对 SessionFactory 的第一次调用,打开一个新的 Hibernate Session。然后启动一个数据库事务 — 所有的数据访问都是在事务中进行,不管是读还是写(我们在应用程序中不使用 auto-commit 模式)。 " #. Tag: para #, 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 "" -"不要为每次数据库操作都使用一个新的 Hibernate " -"Session。将 Hibernate Session 的范围设" -"置为整个请求。要用 getCurrentSession(),这样它自动会绑定到" -"当前 Java 线程。" +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 "不要为每次数据库操作都使用一个新的 Hibernate Session。将 Hibernate Session 的范围设置为整个请求。要用 getCurrentSession(),这样它自动会绑定到当前 Java 线程。" #. Tag: para #, no-c-format -msgid "" -"Next, the possible actions of the request are processed and the response " -"HTML is rendered. We will get to that part soon." -msgstr "" -"下一步,对请求的可能动作进行处理,渲染出反馈的 HTML。我们很快就会涉及到那部" -"分。 " +msgid "Next, the possible actions of the request are processed and the response HTML is rendered. We will get to that part soon." +msgstr "下一步,对请求的可能动作进行处理,渲染出反馈的 HTML。我们很快就会涉及到那部分。 " #. Tag: para #, no-c-format -msgid "" -"Finally, the unit of work ends when processing and rendering are complete. " -"If any problems occurred 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 will need it as soon " -"as you consider rendering your view in JSP, not in a servlet." -msgstr "" -"最后,当处理与渲染都结束的时候,这个工作单元就结束了。假若在处理或渲染的时候" -"有任何错误发生,会抛出一个异常,回滚数据库事务。这样,session-per-" -"request 模式就完成了。为了避免在每个 servlet 中都编写事务边界界定的" -"代码,可以考虑写一个 servlet 过滤器(filter)来更好地解决。关于这一模式的更多" -"信息,请参阅 Hibernate 网站和 Wiki,这一模式叫做 Open Session in " -"View — 只要你考虑用JSP来渲染你的视图(view),而不是在servlet中," -"你就会很快用到它。 " +msgid "Finally, the unit of work ends when processing and rendering are complete. If any problems occurred 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 will need it as soon as you consider rendering your view in JSP, not in a servlet." +msgstr "最后,当处理与渲染都结束的时候,这个工作单元就结束了。假若在处理或渲染的时候有任何错误发生,会抛出一个异常,回滚数据库事务。这样,session-per-request 模式就完成了。为了避免在每个 servlet 中都编写事务边界界定的代码,可以考虑写一个 servlet 过滤器(filter)来更好地解决。关于这一模式的更多信息,请参阅 Hibernate 网站和 Wiki,这一模式叫做 Open Session in View — 只要你考虑用JSP来渲染你的视图(view),而不是在servlet中,你就会很快用到它。 " #. Tag: title #, no-c-format @@ -1496,63 +642,28 @@ msgstr "处理与渲染" #. Tag: para #, no-c-format -msgid "" -"Now you can implement the processing of the request and the rendering of the " -"page." +msgid "Now you can implement the processing of the request and the rendering of the page." msgstr "我们来实现处理请求以及渲染页面的工作。 " #. Tag: para #, no-c-format -msgid "" -"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 "" -"必须承认,这种编码风格把 Java 和 HTML 混在一起,在更复杂的应用程序里不应该大" -"量使用 — 记住,在本章里我们仅仅是展示了 Hibernate 的基本概念。这段代码打印出" -"了 HTML 页眉和页脚,在这个页面里,还打印了一个输入 events 条目的表单单并列出" -"了数据库里的有的 events。第一个方法微不足道,仅仅是输出 HTML:" +msgid "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 "必须承认,这种编码风格把 Java 和 HTML 混在一起,在更复杂的应用程序里不应该大量使用 — 记住,在本章里我们仅仅是展示了 Hibernate 的基本概念。这段代码打印出了 HTML 页眉和页脚,在这个页面里,还打印了一个输入 events 条目的表单单并列出了数据库里的有的 events。第一个方法微不足道,仅仅是输出 HTML:" #. Tag: para #, no-c-format -msgid "" -"The listEvents() method uses the Hibernate " -"Session bound to the current thread to execute a query:" -msgstr "" -"listEvents() 方法使用绑定到当前线程的 Hibernate " -"Session 来执行查询:" +msgid "The listEvents() method uses the Hibernate Session bound to the current thread to execute a query:" +msgstr "listEvents() 方法使用绑定到当前线程的 Hibernate Session 来执行查询:" #. Tag: para #, 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:" +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: para #, no-c-format -msgid "" -"The servlet is now 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 objects 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 would 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 会在单一的 SessionTransaction 中处理到达的 servlet 请求。如同在" -"前面的独立应用程序中那样,Hibernate 可以自动的把这些对象绑定到当前运行的线程" -"中。这给了你用任何你喜欢的方式来对代码分层及访问 SessionFactory 的自由。通常,你会用更加完备的设计,把数据访问代码转移到数据访问对象" -"中(DAO 模式)。请参见 Hibernate Wiki,那里有更多的例子。 " +msgid "The servlet is now 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 objects 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 would 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 会在单一的 SessionTransaction 中处理到达的 servlet 请求。如同在前面的独立应用程序中那样,Hibernate 可以自动的把这些对象绑定到当前运行的线程中。这给了你用任何你喜欢的方式来对代码分层及访问 SessionFactory 的自由。通常,你会用更加完备的设计,把数据访问代码转移到数据访问对象中(DAO 模式)。请参见 Hibernate Wiki,那里有更多的例子。 " #. Tag: title #, no-c-format @@ -1561,51 +672,23 @@ msgstr "部署与测试" #. Tag: para #, no-c-format -msgid "" -"To deploy this application for testing we must create a Web ARchive (WAR). " -"First we must define the WAR descriptor as src/main/webapp/WEB-INF/" -"web.xml" -msgstr "" -"要部署这个应用程序以进行测试,我们必须出具一个 Web ARchive (WAR)。首先我们必" -"须定义 WAR 描述符为 src/main/webapp/WEB-INF/web.xml。" +msgid "To deploy this application for testing we must create a Web ARchive (WAR). First we must define the WAR descriptor as src/main/webapp/WEB-INF/web.xml" +msgstr "要部署这个应用程序以进行测试,我们必须出具一个 Web ARchive (WAR)。首先我们必须定义 WAR 描述符为 src/main/webapp/WEB-INF/web.xml。" #. Tag: para #, no-c-format -msgid "" -"To build and deploy call mvn package in your project " -"directory and copy the hibernate-tutorial.war file into " -"your Tomcat webapps directory." -msgstr "" -"在你的开发目录中,调用 ant war 来构建、打包,然后把 " -"hibernate-tutorial.war 文件拷贝到你的 tomcat 的 " -"webapps 目录下。假若你还没安装 Tomcat,就去下载一个,按照" -"指南来安装。对此应用的发布,你不需要修改任何 Tomcat 的配置。 " - -#. Tag: para -#, fuzzy, no-c-format -msgid "" -"If you do not have Tomcat installed, download it from and follow the installation instructions. Our " -"application requires no changes to the standard Tomcat configuration." -msgstr "" -"如果你还没有安装 Tomcat,请从 下" -"载并按照安装说明进行安装。我们的应用程序不需要对标准的 Tomcat 配置进行修改。" +msgid "To build and deploy call mvn package in your project directory and copy the hibernate-tutorial.war file into your Tomcat webapps directory." +msgstr "在你的开发目录中,调用 ant war 来构建、打包,然后把 hibernate-tutorial.war 文件拷贝到你的 tomcat 的 webapps 目录下。假若你还没安装 Tomcat,就去下载一个,按照指南来安装。对此应用的发布,你不需要修改任何 Tomcat 的配置。 " #. Tag: para #, 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 的静态初始化器被调用),假若有任何异常抛" -"出,也可以看到详细的输出。" +msgid "If you do not have Tomcat installed, download it from and follow the installation instructions. Our application requires no changes to the standard Tomcat configuration." +msgstr "如果你还没有安装 Tomcat,请从 下载并按照安装说明进行安装。我们的应用程序不需要对标准的 Tomcat 配置进行修改。 " + +#. Tag: para +#, 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 #, no-c-format @@ -1614,14 +697,8 @@ msgstr "总结" #. Tag: para #, no-c-format -msgid "" -"This tutorial covered the basics of writing a simple standalone Hibernate " -"application and a small web application. More tutorials are available from " -"the Hibernate website." -msgstr "" -"本章覆盖了如何编写一个简单独立的 Hibernate 命令行应用程序及小型的 Hibernate " -"web 应用程序的基本要素。更多的教程可以在 website 上找到。" +msgid "This tutorial covered the basics of writing a simple standalone Hibernate application and a small web application. More tutorials are available from the Hibernate website." +msgstr "本章覆盖了如何编写一个简单独立的 Hibernate 命令行应用程序及小型的 Hibernate web 应用程序的基本要素。更多的教程可以在 website 上找到。" #~ msgid "" #~ "\n" #~ "\n" #~ "]]>" - #~ msgid "" #~ "" - #~ msgid "" #~ "\n" #~ "\n" #~ "[...]\n" #~ "]]>" - #~ msgid "" #~ "\n" #~ "\n" @@ -1830,7 +904,6 @@ msgstr "" #~ " \n" #~ "\n" #~ "]]>" - #~ msgid "" #~ "\n" #~ "\n" @@ -1851,7 +924,6 @@ msgstr "" #~ " \n" #~ "\n" #~ "]]>" - #~ msgid "" #~ "\n" @@ -1880,7 +952,6 @@ msgstr "" #~ " \n" #~ "\n" #~ "]]>" - #~ msgid "" #~ "\n" #~ "\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -20,13 +20,9 @@ msgid "XML Mapping" msgstr "XML 映射" #. Tag: para -#, fuzzy, no-c-format -msgid "" -" XML Mapping is an experimental feature in Hibernate 3.0 and is " -"currently under active development. " -msgstr "" -"注意 XML 映射只是 Hibernate 3.0 的一个实验性的特性。这一特性仍在积" -"极开发中。" +#, no-c-format +msgid " XML Mapping is an experimental feature in Hibernate 3.0 and is currently under active development. " +msgstr "注意 XML 映射只是 Hibernate 3.0 的一个实验性的特性。这一特性仍在积极开发中。 " #. Tag: title #, no-c-format @@ -35,51 +31,23 @@ msgstr "用 XML 数据进行工作" #. Tag: para #, no-c-format -msgid "" -"Hibernate allows you to work with persistent XML data in much the same way " -"you work with persistent POJOs. A parsed XML tree can be thought of as " -"another way of representing the relational data at the object level, instead " -"of POJOs." -msgstr "" -"Hibernate 使得你可以用 XML 数据来进行工作,恰如你用持久化的 POJO 进行工作那" -"样。解析过的 XML 树 可以被认为是代替 POJO 的另外一种在对象层面上表示关系型数" -"据的途径。" +msgid "Hibernate allows you to work with persistent XML data in much the same way you work with persistent POJOs. A parsed XML tree can be thought of as another way of representing the relational data at the object level, instead of POJOs." +msgstr "Hibernate 使得你可以用 XML 数据来进行工作,恰如你用持久化的 POJO 进行工作那样。解析过的 XML 树 可以被认为是代替 POJO 的另外一种在对象层面上表示关系型数据的途径。" #. Tag: para #, 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()目前还不支持)。" +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()目前还不支持)。" #. Tag: para #, 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 的报表。" +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 的报表。" #. Tag: para #, no-c-format -msgid "" -"A single mapping can 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 can be used to map just the XML." -msgstr "" -"一个单一的映射就可以将类的属性和 XML 文档的节点同时映射到数据库。如果不需要映" -"射类,它也可以用来只映射 XML 文档。 " +msgid "A single mapping can 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 can be used to map just the XML." +msgstr "一个单一的映射就可以将类的属性和 XML 文档的节点同时映射到数据库。如果不需要映射类,它也可以用来只映射 XML 文档。 " #. Tag: title #, no-c-format @@ -103,14 +71,8 @@ msgstr "这是一个不映射 POJO 的例子:" #. Tag: para #, 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 or java Maps. The property " -"names are purely logical constructs that can be referred to in HQL queries." -msgstr "" -"这个映射使得你既可以把数据作为一棵 dom4j 树那样访问,又可以作为由属性键值对" -"(java Map)组成的图那样访问。属性名字纯粹是逻辑上的结构," -"你可以在 HQL 查询中引用它。" +msgid "This mapping allows you to access the data as a dom4j tree, or as a graph of property name/value pairs or java Maps. The property names are purely logical constructs that can be referred to in HQL queries." +msgstr "这个映射使得你既可以把数据作为一棵 dom4j 树那样访问,又可以作为由属性键值对(java Map)组成的图那样访问。属性名字纯粹是逻辑上的结构,你可以在 HQL 查询中引用它。" #. Tag: title #, no-c-format @@ -119,15 +81,8 @@ msgstr "XML 映射元数据" #. Tag: para #, no-c-format -msgid "" -"A range of Hibernate mapping elements accept the node " -"attribute. This lets 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 属性必须是下列" -"格式之一: " +msgid "A range of Hibernate mapping elements accept the node attribute. This lets 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 属性必须是下列格式之一: " #. Tag: para #, no-c-format @@ -146,47 +101,23 @@ msgstr "\".\":映射为父元素" #. Tag: para #, no-c-format -msgid "" -"\"element-name/@attribute-name\": map to the named " -"attribute of the named element" -msgstr "" -"\"element-name/@attribute-name\":映射为指定元素的指定属性" +msgid "\"element-name/@attribute-name\": map to the named attribute of the named element" +msgstr "\"element-name/@attribute-name\":映射为指定元素的指定属性" #. Tag: para #, 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 not appear at all." -msgstr "" -"对于集合和单值的关联,有一个额外的 embed-xml 属性可用。这" -"个属性的缺省值是真(embed-xml=\"true\")。如果 " -"embed-xml=\"true\",则对应于被关联实体或值类型的集合的XML" -"树将直接嵌入拥有这些关联的实体的 XML 树中。否则,如果 embed-xml=" -"\"false\",那么对于单值的关联,仅被引用的实体的标识符出现在 XML 树" -"中(被引用实体本身不出现),而集合则根本不出现。" +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 not appear at all." +msgstr "对于集合和单值的关联,有一个额外的 embed-xml 属性可用。这个属性的缺省值是真(embed-xml=\"true\")。如果 embed-xml=\"true\",则对应于被关联实体或值类型的集合的XML树将直接嵌入拥有这些关联的实体的 XML 树中。否则,如果 embed-xml=\"false\",那么对于单值的关联,仅被引用的实体的标识符出现在 XML 树中(被引用实体本身不出现),而集合则根本不出现。" #. Tag: para #, no-c-format -msgid "" -"Do not leave embed-xml=\"true\" for too many " -"associations, since XML does not deal well with circularity." -msgstr "" -"你应该小心,不要让太多关联的 embed-xml 属性为真(embed-xml=\"true" -"\"),因为 XML 不能很好地处理循环引用。" +msgid "Do not leave embed-xml=\"true\" for too many associations, since XML does not deal well with circularity." +msgstr "你应该小心,不要让太多关联的 embed-xml 属性为真(embed-xml=\"true\"),因为 XML 不能很好地处理循环引用。" #. Tag: para #, no-c-format -msgid "" -"In this case, the collection of account ids is embedded, but not the actual " -"account data. The following HQL query:" -msgstr "" -"在这个例子中,我们决定嵌入帐目号码(account id)的集合,但不嵌入实际的帐目数" -"据。下面的 HQL 查询: " +msgid "In this case, the collection of account ids is embedded, but not the actual account data. The following HQL query:" +msgstr "在这个例子中,我们决定嵌入帐目号码(account id)的集合,但不嵌入实际的帐目数据。下面的 HQL 查询: " #. Tag: para #, no-c-format @@ -195,12 +126,8 @@ msgstr "返回的数据集将是这样: " #. Tag: para #, no-c-format -msgid "" -"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\"),则数据看上去就像这样:" +msgid "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: title #, no-c-format @@ -209,21 +136,13 @@ msgstr "操作 XML 数据" #. Tag: para #, no-c-format -msgid "" -"You can also re-read and update XML documents in the application. You can do " -"this by obtaining a dom4j session:" -msgstr "" -"你也可以重新读入和更新应用程序中的 XML 文档。通过获取一个 dom4j 会话可以做到" -"这一点:" +msgid "You can also re-read and update XML documents in the application. You can do this by obtaining a dom4j session:" +msgstr "你也可以重新读入和更新应用程序中的 XML 文档。通过获取一个 dom4j 会话可以做到这一点:" #. Tag: para #, no-c-format -msgid "" -"When implementing XML-based data import/export, it is useful to combine this " -"feature with Hibernate's replicate() operation." -msgstr "" -"将这一特色与 Hibernate 的 replicate() 操作结合起来对于实现" -"的基于 XML 的数据导入/导出将非常有用。" +msgid "When implementing XML-based data import/export, it is useful to combine this feature with Hibernate's replicate() operation." +msgstr "将这一特色与 Hibernate 的 replicate() 操作结合起来对于实现的基于 XML 的数据导入/导出将非常有用。" #~ msgid "" #~ "]]>" - #~ msgid "" #~ "]]>" - #~ msgid "" #~ "]]>" - #~ msgid "" #~ "" #~ msgstr "" #~ "" - #~ msgid "" #~ "\n" #~ " 987632567\n" @@ -417,7 +332,6 @@ msgstr "" #~ " \n" #~ " ...\n" #~ "]]>" - #~ msgid "" #~ "\n" #~ " \n" @@ -452,7 +366,6 @@ msgstr "" #~ " \n" #~ " ...\n" #~ "]]>" - #~ msgid "" #~ "" - #~ msgid "" #~ "" + diff --git a/documentation/manual/src/main/docbook/zh-CN/fallback_content/Conventions.po b/documentation/manual/src/main/docbook/zh-CN/fallback_content/Conventions.po index 1760ea3c20..8215fa2bb1 100644 --- a/documentation/manual/src/main/docbook/zh-CN/fallback_content/Conventions.po +++ b/documentation/manual/src/main/docbook/zh-CN/fallback_content/Conventions.po @@ -5,210 +5,210 @@ msgid "" msgstr "" "Project-Id-Version: 0\n" "POT-Creation-Date: 2010-02-04T04:51:23\n" -"PO-Revision-Date: 2010-02-04T04:51:23\n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2010-03-16 11:39+1000\n" +"Last-Translator: Xi HUANG \n" "Language-Team: None\n" "MIME-Version: 1.0\n" -"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. Tag: title #, no-c-format msgid "Document Conventions" -msgstr "" +msgstr "文档规则" #. Tag: para #, no-c-format msgid "This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information." -msgstr "" +msgstr "本手册使用了几种规则来突出某些文字和短语以及某些信息。" #. Tag: para #, no-c-format msgid "In PDF and paper editions, this manual uses typefaces drawn from the Liberation Fonts set. The Liberation Fonts set is also used in HTML editions if the set is installed on your system. If not, alternative but equivalent typefaces are displayed. Note: Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default." -msgstr "" +msgstr "在 PDF 版本里,本手册使用 Liberation Fonts 集里抽取的 typefaces。如果你安装了 Liberation Fonts 集,它也会用在 HTML 版本里。如果没有安装,则会使用其他相等的 typefaces。请注意,红帽企业版 Linux 5 和之后的版本缺省都包含了 Liberation Fonts 集。" #. Tag: title #, no-c-format msgid "Typographic Conventions" -msgstr "" +msgstr "印刷规则" #. Tag: para #, no-c-format msgid "Four typographic conventions are used to call attention to specific words and phrases. These conventions, and the circumstances they apply to, are as follows." -msgstr "" +msgstr "我们使用了四种印刷规则来突出特殊的文字和短语。下面是这些规则以及其适用的情况。" #. Tag: para #, no-c-format msgid "Mono-spaced Bold" -msgstr "" +msgstr "Mono-spaced Bold" #. Tag: para #, no-c-format msgid "Used to highlight system input, including shell commands, file names and paths. Also used to highlight keycaps and key combinations. For example:" -msgstr "" +msgstr "用来高亮显示系统输入,包括 shell 命令、文件名和路径。它也用于高亮显示键和键组合。例如:" #. Tag: para #, no-c-format msgid "To see the contents of the file my_next_bestselling_novel in your current working directory, enter the cat my_next_bestselling_novel command at the shell prompt and press Enter to execute the command." -msgstr "" +msgstr "要查看当前工作目录里的 my_next_bestselling_novel 的内容,请在 shell 提示符下输入 cat my_next_bestselling_novel 并按Enter 来执行命令。" #. Tag: para #, no-c-format msgid "The above includes a file name, a shell command and a keycap, all presented in mono-spaced bold and all distinguishable thanks to context." -msgstr "" +msgstr "上面包括了一个文件名、一个 shell 命令和键,它们都以 mono-spaced bold 出现并和上下文区分。" #. Tag: para #, no-c-format msgid "Key combinations can be distinguished from keycaps by the hyphen connecting each part of a key combination. For example:" -msgstr "" +msgstr "键组合可以通过连字符和键来区分。例如:" #. Tag: para #, no-c-format msgid "Press Enter to execute the command." -msgstr "" +msgstr "按 Enter 来执行这个命令。" #. Tag: para #, no-c-format msgid "Press CtrlAltF1 to switch to the first virtual terminal. Press CtrlAltF7 to return to your X-Windows session." -msgstr "" +msgstr "按 CtrlAltF1 切换至第一个虚拟终端。按 CtrlAltF7 返回到 X-Windows 会话。" #. Tag: para #, no-c-format msgid "The first paragraph highlights the particular keycap to press. The second highlights two key combinations (each a set of three keycaps with each set pressed simultaneously)." -msgstr "" +msgstr "第一段高亮显示了特殊的键。第二段高亮显示了两个键组合(每个都由三个同时按住的键构成)。" #. Tag: para #, no-c-format msgid "If source code is discussed, class names, methods, functions, variable names and returned values mentioned within a paragraph will be presented as above, in mono-spaced bold. For example:" -msgstr "" +msgstr "在源码中提及的类名、方法、函数、变量和返回值都将以 mono-spaced bold 出现。例如:" #. Tag: para #, no-c-format msgid "File-related classes include filesystem for file systems, file for files, and dir for directories. Each class has its own associated set of permissions." -msgstr "" +msgstr "文件相关的类包括用于文件系统的 filesystem、用于文件的 file 和用于目录的 dir。每个类都有自己的一套权限。" #. Tag: para #, no-c-format msgid "Proportional Bold" -msgstr "" +msgstr "Proportional Bold" #. Tag: para #, no-c-format msgid "This denotes words or phrases encountered on a system, including application names; dialog box text; labeled buttons; check-box and radio button labels; menu titles and sub-menu titles. For example:" -msgstr "" +msgstr "它表示系统里的文字或短语,包括程序名、对话框文本、标签按钮、复选框和单选框、菜单和子菜单标题。例如:" #. Tag: para #, no-c-format msgid "Choose SystemPreferencesMouse from the main menu bar to launch Mouse Preferences. In the Buttons tab, click the Left-handed mouse check box and click Close to switch the primary mouse button from the left to the right (making the mouse suitable for use in the left hand)." -msgstr "" +msgstr "从主菜单选择 SystemPreferencesMouse 来启动 Mouse Preferences。在 Buttons 标签页里,点击 Left-handed mouse 复选框并点击 Close 来把鼠标主按钮从左切换到右(适合于习惯用左手的人)。" #. Tag: para #, no-c-format msgid "To insert a special character into a gedit file, choose ApplicationsAccessoriesCharacter Map from the main menu bar. Next, choose SearchFind… from the Character Map menu bar, type the name of the character in the Search field and click Next. The character you sought will be highlighted in the Character Table. Double-click this highlighted character to place it in the Text to copy field and then click the Copy button. Now switch back to your document and choose EditPaste from the gedit menu bar." -msgstr "" +msgstr "要在 gedit 文件里插入特殊字符,从主菜单里选择 ApplicationsAccessoriesCharacter Map。然后,从 Character Map 菜单条里选择 SearchFind…,在 Search字段里输入字符并点击 Next。你要搜索的字符会在 Character Table 里高亮显示。双击这个高亮显示的字符并放入 Text to copy 字段里,然后点击 Copy 按钮。现在切换回你的文档并从 gedit 菜单条里选择EditPaste。" #. Tag: para #, no-c-format msgid "The above text includes application names; system-wide menu names and items; application-specific menu names; and buttons and text found within a GUI interface, all presented in proportional bold and all distinguishable by context." -msgstr "" +msgstr "上面的内容包括了程序名称、系统级的菜单名和条目、程序专有的菜单名、图形界面里的按钮和文本,它们都以 proportional bold 出现并和其他内容区分。" #. Tag: para #, no-c-format msgid "Mono-spaced Bold Italic or Proportional Bold Italic" -msgstr "" +msgstr "Mono-spaced Bold ItalicProportional Bold Italic" #. Tag: para #, no-c-format msgid "Whether mono-spaced bold or proportional bold, the addition of italics indicates replaceable or variable text. Italics denotes text you do not input literally or displayed text that changes depending on circumstance. For example:" -msgstr "" +msgstr "无论是 mono-spaced bold 还是 proportional bold,斜体都表示可替换的或可变的文本。斜体表示非输入的文本,它根据周围的内容而变化。例如:" #. Tag: para #, no-c-format msgid "To connect to a remote machine using ssh, type ssh username@domain.name at a shell prompt. If the remote machine is example.com and your username on that machine is john, type ssh john@example.com." -msgstr "" +msgstr "要用 ssh 连接到远程机器,在 shell 提示下输入 ssh username@domain.name。如果这个远程主机是 example.com 且你的用户名是 john,请输入 ssh john@example.com。" #. Tag: para #, no-c-format msgid "The mount -o remount file-system command remounts the named file system. For example, to remount the /home file system, the command is mount -o remount /home." -msgstr "" +msgstr "mount -o remount file-system 命令重新挂载文件系统。例如,要重新挂载 /home,命令是 mount -o remount /home。" #. Tag: para #, no-c-format msgid "To see the version of a currently installed package, use the rpm -q package command. It will return a result as follows: package-version-release." -msgstr "" +msgstr "要查看当前安装的软件包的版本,你可以使用 rpm -q package 命令。它将返回这样的结果集:package-version-release。" #. Tag: para #, no-c-format msgid "Note the words in bold italics above — username, domain.name, file-system, package, version and release. Each word is a placeholder, either for text you enter when issuing a command or for text displayed by the system." -msgstr "" +msgstr "请注意上面字体为粗斜体的文字 — username, domain.name, file-system, package, version 和 release。无论是你输入的命令还是系统显示的文本,每个文字都是一个占位符。" #. Tag: para #, no-c-format msgid "Aside from standard usage for presenting the title of a work, italics denotes the first use of a new and important term. For example:" -msgstr "" +msgstr "除了表示标题的标准用法之外,斜体表示新的和重要的术语的第一次使用。例如:" #. Tag: para #, no-c-format msgid "Publican is a DocBook publishing system." -msgstr "" +msgstr "Publican 是一个基于 DocBook 的发布系统。" #. Tag: title #, no-c-format msgid "Pull-quote Conventions" -msgstr "" +msgstr "副标题规则" #. Tag: para #, no-c-format msgid "Terminal output and source code listings are set off visually from the surrounding text." -msgstr "" +msgstr "终端输出和源代码列表由周围的文本来烘托。" #. Tag: para #, no-c-format msgid "Output sent to a terminal is set in mono-spaced roman and presented thus:" -msgstr "" +msgstr "发送到终端的输出在 mono-spaced roman 设置且以这种形式出现:" #. Tag: para #, no-c-format msgid "Source-code listings are also set in mono-spaced roman but add syntax highlighting as follows:" -msgstr "" +msgstr "源码列表也在 mono-spaced roman 里设置但添加了如下的语法高亮显示:" #. Tag: title #, no-c-format msgid "Notes and Warnings" -msgstr "" +msgstr "注意和警告" #. Tag: para #, no-c-format msgid "Finally, we use three visual styles to draw attention to information that might otherwise be overlooked." -msgstr "" +msgstr "最后,我们使用三章可视风格来引起对可能被忽视的信息的注意。" #. Tag: title #, no-c-format msgid "Note" -msgstr "" +msgstr "注意" #. Tag: para #, no-c-format msgid "Notes are tips, shortcuts or alternative approaches to the task at hand. Ignoring a note should have no negative consequences, but you might miss out on a trick that makes your life easier." -msgstr "" +msgstr "注意是完成手中任务的提示、快捷方式或其他方法。忽略”注意“不会产生负面影响,但你可能会错失使你受益的技巧。" #. Tag: title #, no-c-format msgid "Important" -msgstr "" +msgstr "重要信息" #. Tag: para #, no-c-format msgid "Important boxes detail things that are easily missed: configuration changes that only apply to the current session, or services that need restarting before an update will apply. Ignoring a box labeled 'Important' won't cause data loss but may cause irritation and frustration." -msgstr "" +msgstr "重要信息显示容易被错过的信息:只适用于当前会话的配置改动、或需要重启来生效的服务。忽略标记为”重要信息“的对话框不会导致数据丢失但会引发问题。" #. Tag: title #, no-c-format msgid "Warning" -msgstr "" +msgstr "警告" #. Tag: para #, no-c-format msgid "Warnings should not be ignored. Ignoring warnings will most likely cause data loss." -msgstr "" +msgstr "警告不应该被忽略。忽略警告将导致数据丢失。" diff --git a/documentation/manual/src/main/docbook/zh-CN/fallback_content/Feedback.po b/documentation/manual/src/main/docbook/zh-CN/fallback_content/Feedback.po index 1ff600c47f..728abbf528 100644 --- a/documentation/manual/src/main/docbook/zh-CN/fallback_content/Feedback.po +++ b/documentation/manual/src/main/docbook/zh-CN/fallback_content/Feedback.po @@ -5,19 +5,20 @@ msgid "" msgstr "" "Project-Id-Version: 0\n" "POT-Creation-Date: 2010-03-12T00:03:48\n" -"PO-Revision-Date: 2010-02-04T04:51:23\n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2010-03-16 10:17+1000\n" +"Last-Translator: Xi HUANG \n" "Language-Team: None\n" "MIME-Version: 1.0\n" -"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. Tag: title #, no-c-format msgid "We Need Feedback!" -msgstr "" +msgstr "我们需要你的反馈!" #. Tag: para #, no-c-format msgid "You should over ride this by creating your own local Feedback.xml file." -msgstr "" +msgstr "用自己的 Feedback.xml 文件覆盖本段内容。" + diff --git a/documentation/manual/src/main/docbook/zh-CN/fallback_content/Legal_Notice.po b/documentation/manual/src/main/docbook/zh-CN/fallback_content/Legal_Notice.po index 8bba6fc990..05820aea6c 100644 --- a/documentation/manual/src/main/docbook/zh-CN/fallback_content/Legal_Notice.po +++ b/documentation/manual/src/main/docbook/zh-CN/fallback_content/Legal_Notice.po @@ -5,15 +5,15 @@ msgid "" msgstr "" "Project-Id-Version: 0\n" "POT-Creation-Date: 2010-02-04T04:51:23\n" -"PO-Revision-Date: 2010-02-04T04:51:23\n" -"Last-Translator: Automatically generated\n" +"PO-Revision-Date: 2010-03-16 10:18+1000\n" +"Last-Translator: Xi HUANG \n" "Language-Team: None\n" "MIME-Version: 1.0\n" -"Content-Type: application/x-publican; charset=UTF-8\n" +"Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. Tag: para #, no-c-format msgid "Copyright &YEAR; &HOLDER; This material may only be distributed subject to the terms and conditions set forth in the GNU Free Documentation License (GFDL), V1.2 or later (the latest version is presently available at http://www.gnu.org/licenses/fdl.txt)." -msgstr "" +msgstr "Copyright &YEAR; &HOLDER; 本文档只可以按照 GNU Free Documentation License (GFDL), V1.2 或更新协议进行分发(GNU 的最新版本请参考 http://www.gnu.org/licenses/fdl.txt)。"