|
Hibernate example source code file (component_mapping.po)
This example Hibernate source code file (component_mapping.po) is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.
The Hibernate component_mapping.po source code
# translation of Collection_Mapping.po to
# Xi Huang <xhuang@redhat.com>, 2006.
# Xi HUANG <xhuang@redhat.com>, 2007.
msgid ""
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-03-15 09:01+1000\n"
"Last-Translator: Xi HUANG <xhuang@redhat.com>\n"
"Language-Team: <en@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"
#. Tag: title
#, no-c-format
msgid "Component Mapping"
msgstr "组件(Component)映射"
#. Tag: para
#, no-c-format
msgid "The notion of a <emphasis>component is re-used in several different contexts and purposes throughout Hibernate."
msgstr "<emphasis>组件(Component)这个概念在 Hibernate 中几处不同的地方为了不同的目的被重复使用。"
#. Tag: title
#, no-c-format
msgid "Dependent objects"
msgstr "依赖对象(Dependent objects)"
#. Tag: para
#, no-c-format
msgid "A component is a contained object that is persisted as a value type and not an entity reference. The term \"component\" refers to the object-oriented notion of composition and not to architecture-level components. For example, you can model a person like this:"
msgstr "组件(Component)是一个被包含的对象,在持久化的过程中,它被当作值类型,而并非一个实体的引用。在这篇文档中,组件这一术语指的是面向对象的合成概念(而并不是系统构架层次上的组件的概念)。举个例子,你对人(Person)这个概念可以像下面这样来建模: "
#. Tag: para
#, no-c-format
msgid "Now <literal>Name can be persisted as a component of Person. Name defines getter and setter methods for its persistent properties, but it does not need to declare any interfaces or identifier properties."
msgstr "在持久化的过程中,<literal>姓名(Name)可以作为人(Person)的一个组件。需要注意的是:你应该为姓名的持久化属性定义 getter 和 setter 方法,但是你不需要实现任何的接口或申明标识符字段。 "
#. Tag: para
#, no-c-format
msgid "Our Hibernate mapping would look like this:"
msgstr "以下是这个例子的 Hibernate 映射文件: "
#. Tag: para
#, no-c-format
msgid "The person table would have the columns <literal>pid, birthday, initial, first and last."
msgstr "人员(Person)表中将包括 <literal>pid,birthday,initial,first和 last 等字段。"
#. Tag: para
#, no-c-format
msgid "Like value types, components do not support shared references. In other words, two persons could have the same name, but the two person objects would contain two independent name objects that were only \"the same\" by value. The null value semantics of a component are <emphasis>ad hoc. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This is suitable for most purposes."
msgstr "就像所有的值类型一样,组件不支持共享引用。换句话说,两个人可能重名,但是两个 Person 对象应该包含两个独立的 Name 对象,只不过这两个 Name 对象具有“同样”的值。组件的值可以为空,其定义如下。 每当 Hibernate 重新加载一个包含组件的对象,如果该组件的所有字段为空,Hibernate 将假定整个组件为空。在大多数情况下,这样假定应该是没有问题的。"
#. Tag: para
#, no-c-format
msgid "The properties of a component can be of any Hibernate type (collections, many-to-one associations, other components, etc). Nested components should <emphasis>not be considered an exotic usage. Hibernate is intended to support a fine-grained object model."
msgstr "组件的属性可以是任意一种 Hibernate 类型(包括集合,多对多关联,以及其它组件等等)。嵌套组件不应该被当作一种特殊的应用(Nested components should not be considered an exotic usage)。Hibernate 倾向于支持细颗粒度的(fine-grained)对象模型。"
#. Tag: para
#, no-c-format
msgid "The <literal><component> element allows a <parent> subelement that maps a property of the component class as a reference back to the containing entity."
msgstr "<literal><component> 元素允许加入一个 <parent> 子元素,在组件类内部就可以有一个指向其容器的实体的反向引用。"
#. Tag: title
#, no-c-format
msgid "Collections of dependent objects"
msgstr "在集合中出现的依赖对象(Collections of dependent objects)"
#. Tag: para
#, no-c-format
msgid "Collections of components are supported (e.g. an array of type <literal>Name). Declare your component collection by replacing the <element> tag with a <composite-element> tag:"
msgstr "Hibernate 支持组件的集合(例如:一个元素是姓名 <literal>Name 这种类型的数组)。你可以使用 <composite-element> 标签替代 <element> 标签来定义你的组件集合。"
#. Tag: para
#, no-c-format
msgid "If you define a <literal>Set of composite elements, it is important to implement equals() and hashCode() correctly."
msgstr "注意,如果你定义的 Set 包含组合元素(composite-element),正确地实现 <literal>equals() 和 hashCode() 是非常重要的。 "
#. Tag: para
#, no-c-format
msgid "Composite elements can contain components but not collections. If your composite element contains components, use the <literal><nested-composite-element> tag. This case is a collection of components which themselves have components. You may want to consider if a one-to-many association is more appropriate. Remodel the composite element as an entity, but be aware that even though the Java model is the same, the relational model and persistence semantics are still slightly different."
msgstr "组合元素可以包含组件,但是不能包含集合。如果你的组合元素自身包含组件,你必须使用 <literal><nested-composite-element> 标签。这是一个相当特殊的案例 — 在一个组件的集合里,那些组件本身又可以包含其他的组件。这个时候你就应该考虑一下使用 one-to-many 关联是否会更恰当。尝试对这个组合元素重新建模为一个实体 — 但是需要注意的是,虽然 Java 模型和重新建模前是一样的,关系模型和持久性语义会有细微的变化。 "
#. Tag: para
#, no-c-format
msgid "A composite element mapping does not support null-able properties if you are using a <literal><set>. There is no separate primary key column in the composite element table. Hibernate uses each column's value to identify a record when deleting objects, which is not possible with null values. You have to either use only not-null properties in a composite-element or choose a <list>, <map>, <bag> or <idbag>."
msgstr "请注意如果你使用 <literal><set> 标签,一个组合元素的映射不支持可能为空的属性. 当删除对象时,Hibernate 必须使用每一个字段的值来确定一条记录(在组合元素表中,没有单独的关键字段),如果有为 null 的字段,这样做就不可能了。你必须作出一个选择,要么在组合元素中使用不能为空的属性,要么选择使用 <list>,<map>,<bag> 或者 <idbag> 而不是 <set>。 "
#. Tag: para
#, no-c-format
msgid "A special case of a composite element is a composite element with a nested <literal><many-to-one> element. This mapping allows you to map extra columns of a many-to-many association table to the composite element class. The following is a many-to-many association from Order to Item, where purchaseDate, price and quantity are properties of the association:"
msgstr "组合元素有个特别的用法是它可以包含一个<literal><many-to-one>元素。类似这样的映射允许你将一个 many-to-many 关联表的额外字段映射为组合元素类。接下来的的例子是从 Order 到 Item 的一个多对多的关联关系,关联属性是 purchaseDate,price 和 quantity 。 "
#. Tag: para
#, no-c-format
msgid "There cannot be a reference to the purchase on the other side for bidirectional association navigation. Components are value types and do not allow shared references. A single <literal>Purchase can be in the set of an Order, but it cannot be referenced by the Item at the same time."
msgstr "当然,当你定义 Item 时,你无法引用这些 purchase,因此你无法实现双向关联查询。记住组件是值类型,并且不允许共享引用。某一个特定的 <literal>Purchase 可以放在 Order 的集合中,但它不能同时被 Item 所引用。 "
#. Tag: para
#, no-c-format
msgid "Even ternary (or quaternary, etc) associations are possible:"
msgstr "其实组合元素的这个用法可以扩展到三重或多重关联:"
#. Tag: para
#, no-c-format
msgid "Composite elements can appear in queries using the same syntax as associations to other entities."
msgstr "在查询中,表达组合元素的语法和关联到其他实体的语法是一样的。 "
#. Tag: title
#, no-c-format
msgid "Components as Map indices"
msgstr "组件作为 Map 的索引(Components as Map indices )"
#. Tag: para
#, no-c-format
msgid "The <literal><composite-map-key> element allows you to map a component class as the key of a Map. Ensure that you override hashCode() and equals() correctly on the component class."
msgstr "<literal><composite-map-key> 元素允许你映射一个组件类作为一个 Map 的 key,前提是你必须正确的在这个类中重写了 hashCode() 和 equals() 方法。 "
#. Tag: title
#, no-c-format
msgid "Components as composite identifiers"
msgstr "组件作为联合标识符(Components as composite identifiers)"
#. Tag: para
#, no-c-format
msgid "You can use a component as an identifier of an entity class. Your component class must satisfy certain requirements:"
msgstr "你可以使用一个组件作为一个实体类的标识符。你的组件类必须满足以下要求: "
#. Tag: para
#, no-c-format
msgid "It must implement <literal>java.io.Serializable."
msgstr "它必须实现 <literal>java.io.Serializable 接口"
#. Tag: para
#, no-c-format
msgid "It must re-implement <literal>equals() and hashCode() consistently with the database's notion of composite key equality."
msgstr "它必须重新实现 <literal>equals() 和 hashCode() 方法,始终和组合关键字在数据库中的概念保持一致 "
#. Tag: title
#, no-c-format
msgid "Note"
msgstr "注意"
#. Tag: para
#, no-c-format
msgid "In Hibernate3, although the second requirement is not an absolutely hard requirement of Hibernate, it is recommended."
msgstr "注意:在 Hibernate3 中,第二个要求并非是 Hibernate 强制必须的。但最好这样做。 "
#. Tag: para
#, no-c-format
msgid "You cannot use an <literal>IdentifierGenerator to generate composite keys. Instead the application must assign its own identifiers."
msgstr "你不能使用一个 <literal>IdentifierGenerator 产生组合关键字。一个应用程序必须分配它自己的标识符。 "
#. Tag: para
#, no-c-format
msgid "Use the <literal><composite-id> tag, with nested <key-property> elements, in place of the usual <id> declaration. For example, the OrderLine class has a primary key that depends upon the (composite) primary key of Order."
msgstr "使用 <literal><composite-id> 标签(并且内嵌 <key-property> 元素)代替通常的 <id> 标签。比如,OrderLine 类具有一个主键,这个主键依赖于 Order 的(联合)主键。 "
#. Tag: para
#, no-c-format
msgid "Any foreign keys referencing the <literal>OrderLine table are now composite. Declare this in your mappings for other classes. An association to OrderLine is mapped like this:"
msgstr "现在,任何指向 <literal>OrderLine 的外键都是复合的。在你的映射文件中,必须为其他类也这样声明。例如,一个指向 OrderLine 的关联可能被这样映射: "
#. Tag: para
#, no-c-format
msgid "The <literal>column element is an alternative to the column attribute everywhere. Using the column element just gives more declaration options, which are mostly useful when utilizing hbm2ddl"
msgstr "注意在各个地方 <literal>column 标签都是 column 属性的替代写法。使用 column 元素只是给出一个更详细的选项,在使用 hbm2ddl 时会更有用。"
#. Tag: para
#, no-c-format
msgid "A <literal>many-to-many association to OrderLine also uses the composite foreign key:"
msgstr "指向 <literal>OrderLine 的多对多关联也使用联合外键:"
#. Tag: para
#, no-c-format
msgid "The collection of <literal>OrderLines in Order would use:"
msgstr "在 <literal>Order 中,OrderLine 的集合则是这样: "
#. Tag: para
#, no-c-format
msgid "The <literal><one-to-many> element declares no columns."
msgstr "与通常一样,<literal><one-to-many> 元素不声明任何列。"
#. Tag: para
#, no-c-format
msgid "If <literal>OrderLine itself owns a collection, it also has a composite foreign key."
msgstr "假若 <literal>OrderLine 本身拥有一个集合,它也具有组合外键。"
#. Tag: title
#, no-c-format
msgid "Dynamic components"
msgstr "动态组件(Dynamic components)"
#. Tag: para
#, no-c-format
msgid "You can also map a property of type <literal>Map:"
msgstr "你甚至可以映射 <literal>Map 类型的属性: "
#. Tag: para
#, no-c-format
msgid "The semantics of a <literal><dynamic-component> mapping are identical to <component>. The advantage of this kind of mapping is the ability to determine the actual properties of the bean at deployment time just by editing the mapping document. Runtime manipulation of the mapping document is also possible, using a DOM parser. You can also access, and change, Hibernate's configuration-time metamodel via the Configuration object."
msgstr "从 <literal><dynamic-component> 映射的语义上来讲,它和 <component> 是相同的。这种映射类型的优点在于通过修改映射文件,就可以具有在部署时检测真实属性的能力。利用一个 DOM 解析器,也可以在程序运行时操作映射文件。更好的是,你可以通过 Configuration 对象来访问(或者修改)Hibernate 的运行时元模型。 "
#~ msgid ""
#~ "<![CDATA[public class Person {\n"
#~ " private java.util.Date birthday;\n"
#~ " private Name name;\n"
#~ " private String key;\n"
#~ " public String getKey() {\n"
#~ " return key;\n"
#~ " }\n"
#~ " private void setKey(String key) {\n"
#~ " this.key=key;\n"
#~ " }\n"
#~ " public java.util.Date getBirthday() {\n"
#~ " return birthday;\n"
#~ " }\n"
#~ " public void setBirthday(java.util.Date birthday) {\n"
#~ " this.birthday = birthday;\n"
#~ " }\n"
#~ " public Name getName() {\n"
#~ " return name;\n"
#~ " }\n"
#~ " public void setName(Name name) {\n"
#~ " this.name = name;\n"
#~ " }\n"
#~ " ......\n"
#~ " ......\n"
#~ "}]]>"
#~ msgstr ""
#~ "<![CDATA[public class Person {\n"
#~ " private java.util.Date birthday;\n"
#~ " private Name name;\n"
#~ " private String key;\n"
#~ " public String getKey() {\n"
#~ " return key;\n"
#~ " }\n"
#~ " private void setKey(String key) {\n"
#~ " this.key=key;\n"
#~ " }\n"
#~ " public java.util.Date getBirthday() {\n"
#~ " return birthday;\n"
#~ " }\n"
#~ " public void setBirthday(java.util.Date birthday) {\n"
#~ " this.birthday = birthday;\n"
#~ " }\n"
#~ " public Name getName() {\n"
#~ " return name;\n"
#~ " }\n"
#~ " public void setName(Name name) {\n"
#~ " this.name = name;\n"
#~ " }\n"
#~ " ......\n"
#~ " ......\n"
#~ "}]]>"
#~ msgid ""
#~ "<![CDATA[public class Name {\n"
#~ " char initial;\n"
#~ " String first;\n"
#~ " String last;\n"
#~ " public String getFirst() {\n"
#~ " return first;\n"
#~ " }\n"
#~ " void setFirst(String first) {\n"
#~ " this.first = first;\n"
#~ " }\n"
#~ " public String getLast() {\n"
#~ " return last;\n"
#~ " }\n"
#~ " void setLast(String last) {\n"
#~ " this.last = last;\n"
#~ " }\n"
#~ " public char getInitial() {\n"
#~ " return initial;\n"
#~ " }\n"
#~ " void setInitial(char initial) {\n"
#~ " this.initial = initial;\n"
#~ " }\n"
#~ "}]]>"
#~ msgstr ""
#~ "<![CDATA[public class Name {\n"
#~ " char initial;\n"
#~ " String first;\n"
#~ " String last;\n"
#~ " public String getFirst() {\n"
#~ " return first;\n"
#~ " }\n"
#~ " void setFirst(String first) {\n"
#~ " this.first = first;\n"
#~ " }\n"
#~ " public String getLast() {\n"
#~ " return last;\n"
#~ " }\n"
#~ " void setLast(String last) {\n"
#~ " this.last = last;\n"
#~ " }\n"
#~ " public char getInitial() {\n"
#~ " return initial;\n"
#~ " }\n"
#~ " void setInitial(char initial) {\n"
#~ " this.initial = initial;\n"
#~ " }\n"
#~ "}]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#, fuzzy
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<class name=\"eg.Order\" .... >\n"
#~ " ....\n"
#~ " <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true"
#~ "\">\n"
#~ " <key column=\"order_id\">\n"
#~ " <composite-element class=\"eg.Purchase\">\n"
#~ " <property name=\"purchaseDate\"/>\n"
#~ " <property name=\"price\"/>\n"
#~ " <property name=\"quantity\"/>\n"
#~ " <many-to-one name=\"item\" class=\"eg.Item\"/> <!-- "
#~ "class attribute is optional -->\n"
#~ " </composite-element>\n"
#~ " </set>\n"
#~ "</class>"
#, fuzzy
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<class name=\"eg.Order\" .... >\n"
#~ " ....\n"
#~ " <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true"
#~ "\">\n"
#~ " <key column=\"order_id\">\n"
#~ " <composite-element class=\"eg.OrderLine\">\n"
#~ " <many-to-one name=\"purchaseDetails class=\"eg.Purchase\"/"
#~ ">\n"
#~ " <many-to-one name=\"item\" class=\"eg.Item\"/>\n"
#~ " </composite-element>\n"
#~ " </set>\n"
#~ "</class>"
#, fuzzy
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<class name=\"OrderLine\">\n"
#~ " \n"
#~ " <composite-id name=\"id\" class=\"OrderLineId\">\n"
#~ " <key-property name=\"lineId\"/>\n"
#~ " <key-property name=\"orderId\"/>\n"
#~ " <key-property name=\"customerId\"/>\n"
#~ " </composite-id>\n"
#~ " \n"
#~ " <property name=\"name\"/>\n"
#~ " \n"
#~ " <many-to-one name=\"order\" class=\"Order\"\n"
#~ " insert=\"false\" update=\"false\">\n"
#~ " <column name=\"orderId\"/>\n"
#~ " <column name=\"customerId\"/>\n"
#~ " </many-to-one>\n"
#~ " ....\n"
#~ " \n"
#~ "</class>"
#, fuzzy
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<many-to-one name=\"orderLine\" class=\"OrderLine\">\n"
#~ "<!-- the \"class\" attribute is optional, as usual -->\n"
#~ " <column name=\"lineId\"/>\n"
#~ " <column name=\"orderId\"/>\n"
#~ " <column name=\"customerId\"/>\n"
#~ "</many-to-one>"
#, fuzzy
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<set name=\"undeliveredOrderLines\">\n"
#~ " <key column name=\"warehouseId\"/>\n"
#~ " <many-to-many class=\"OrderLine\">\n"
#~ " <column name=\"lineId\"/>\n"
#~ " <column name=\"orderId\"/>\n"
#~ " <column name=\"customerId\"/>\n"
#~ " </many-to-many>\n"
#~ "</set>"
#, fuzzy
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<set name=\"orderLines\" inverse=\"true\">\n"
#~ " <key>\n"
#~ " <column name=\"orderId\"/>\n"
#~ " <column name=\"customerId\"/>\n"
#~ " </key>\n"
#~ " <one-to-many class=\"OrderLine\"/>\n"
#~ "</set>"
#, fuzzy
#~ msgid ""
#~ "<![CDATA[\n"
#~ " <column name=\"lineId\"/>\n"
#~ " <column name=\"orderId\"/>\n"
#~ " <column name=\"customerId\"/>\n"
#~ " </key>\n"
#~ " <list-index column=\"attemptId\" base=\"1\"/>\n"
#~ " <composite-element class=\"DeliveryAttempt\">\n"
#~ " ...\n"
#~ " </composite-element>\n"
#~ " </set>\n"
#~ "</class>]]>"
#~ msgstr ""
#~ "<class name=\"OrderLine\">\n"
#~ " ....\n"
#~ " ....\n"
#~ " <list name=\"deliveryAttempts\">\n"
#~ " <key> <!-- a collection inherits the composite key "
#~ "type -->\n"
#~ " <column name=\"lineId\"/>\n"
#~ " <column name=\"orderId\"/>\n"
#~ " <column name=\"customerId\"/>\n"
#~ " </key>\n"
#~ " <list-index column=\"attemptId\" base=\"1\"/>\n"
#~ " <composite-element class=\"DeliveryAttempt\">\n"
#~ " ...\n"
#~ " </composite-element>\n"
#~ " </set>\n"
#~ "</class>"
#, fuzzy
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<dynamic-component name=\"userAttributes\">\n"
#~ " <property name=\"foo\" column=\"FOO\" type=\"string\"/>\n"
#~ " <property name=\"bar\" column=\"BAR\" type=\"integer\"/>\n"
#~ " <many-to-one name=\"baz\" class=\"Baz\" column=\"BAZ_ID\"/>\n"
#~ "</dynamic-component>"
Other Hibernate examples (source code examples)
Here is a short list of links related to this Hibernate component_mapping.po source code file:
|