|
Hibernate example source code file (association_mapping.po)
This example Hibernate source code file (association_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 association_mapping.po source code
# translation of association_mapping.po to
# Xi Huang <xhuang@redhat.com>, 2006.
# Xi HUANG <xhuang@redhat.com>, 2007, 2009.
# translation of Collection_Mapping.po to
msgid ""
msgstr ""
"Project-Id-Version: association_mapping\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-02-10T07:25:34\n"
"PO-Revision-Date: 2009-11-03 11:04+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 "Association Mappings"
msgstr "关联关系映射"
#. Tag: title
#, no-c-format
msgid "Introduction"
msgstr "介绍"
#. Tag: para
#, no-c-format
msgid ""
"Association mappings are often the most difficult thing to implement "
"correctly. In this section we examine some canonical cases one by one, "
"starting with unidirectional mappings and then bidirectional cases. We will "
"use <literal>Person and Address in all the "
"examples."
msgstr ""
"关联关系映射通常情况是最难配置正确的。在这个部分中,我们从单向关系映射开始,"
"然后考虑双向关系映射,逐步讲解典型的案例。在所有的例子中,我们都使将用 "
"<literal>Person 和 Address。"
#. Tag: para
#, no-c-format
msgid ""
"Associations will be classified by multiplicity and whether or not they map "
"to an intervening join table."
msgstr ""
"我们根据映射关系是否涉及连接表以及多样性(multiplicity)来划分关联类型。 "
#. Tag: para
#, no-c-format
msgid ""
"Nullable foreign keys are not considered to be good practice in traditional "
"data modelling, so our examples do not use nullable foreign keys. This is "
"not a requirement of Hibernate, and the mappings will work if you drop the "
"nullability constraints."
msgstr ""
"在传统的数据建模中,允许为 Null 值的外键被认为是一种不好的实践,因此我们所有"
"的例子中都使用不允许为 Null 的外键。这并不是 Hibernate的 要求,即使你删除掉不"
"允许为 Null 的约束,Hibernate 映射一样可以工作的很好。 "
#. Tag: title
#, no-c-format
msgid "Unidirectional associations"
msgstr "单向关联(Unidirectional associations)"
#. Tag: title
#, no-c-format
msgid "Many-to-one"
msgstr "多对一(many-to-one) "
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>unidirectional many-to-one association is the most "
"common kind of unidirectional association."
msgstr "<emphasis>单向 many-to-one 关联是最常见的单向关联关系。"
#. Tag: title
#, no-c-format
msgid "One-to-one"
msgstr "一对一(One-to-one)"
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-one association on a foreign key"
"emphasis> is almost identical. The only difference is the column unique "
"constraint."
msgstr ""
"<emphasis>基于外键关联的单向一对一关联和单向多对一关联"
"emphasis>几乎是一样的。唯一的不同就是单向一对一关联中的外键字段具有唯一性约"
"束。"
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-one association on a primary key"
"emphasis> usually uses a special id generator In this example, however, we "
"have reversed the direction of the association:"
msgstr ""
"<emphasis>基于主键关联的单向一对一关联通常使用一个特定的 id 生成"
"器,然而在这个例子中我们掉换了关联的方向:"
#. Tag: title
#, no-c-format
msgid "One-to-many"
msgstr "一对多(one-to-many) "
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-many association on a foreign key"
"emphasis> is an unusual case, and is not recommended."
msgstr ""
"<emphasis>基于外键关联的单向一对多关联是一种很少见的情况,我们不推"
"荐使用它。"
#. Tag: para
#, no-c-format
msgid "You should instead use a join table for this kind of association."
msgstr "我们认为对于这种关联关系最好使用连接表。 "
#. Tag: title
#, no-c-format
msgid "Unidirectional associations with join tables"
msgstr "使用连接表的单向关联(Unidirectional associations with join tables)"
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-many association on a join table"
"emphasis> is the preferred option. Specifying <literal>unique=\"true\""
"literal>, changes the multiplicity from many-to-many to one-to-many."
msgstr ""
"<emphasis>基于连接表的单向一对多关联 应该优先被采用。请注意,通过"
"指定<literal>unique=\"true\",我们可以把多样性从多对多改变为一对"
"多。"
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>unidirectional many-to-one association on a join table"
"emphasis> is common when the association is optional. For example:"
msgstr ""
"<emphasis>基于连接表的单向多对一关联在关联关系可选的情况下应用也很"
"普遍。例如:"
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>unidirectional one-to-one association on a join table "
"is possible, but extremely unusual."
msgstr ""
"<emphasis>基于连接表的单向一对一关联也是可行的,但非常少见。"
#. Tag: title
#, no-c-format
msgid "Many-to-many"
msgstr "多对多(many-to-many) "
#. Tag: para
#, no-c-format
msgid ""
"Finally, here is an example of a <emphasis>unidirectional many-to-many "
"association</emphasis>."
msgstr "最后,这里是一个<emphasis>单向多对多关联的例子。"
#. Tag: title
#, no-c-format
msgid "Bidirectional associations"
msgstr "双向关联(Bidirectional associations)"
#. Tag: title
#, no-c-format
msgid "one-to-many / many-to-one"
msgstr "一对多(one to many)/多对一(many to one) "
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>bidirectional many-to-one association is the most "
"common kind of association. The following example illustrates the standard "
"parent/child relationship."
msgstr ""
"<emphasis>双向多对一关联 是最常见的关联关系。下面的例子解释了这种"
"标准的父/子关联关系。"
#. Tag: para
#, no-c-format
msgid ""
"If you use a <literal>List, or other indexed collection, set the "
"<literal>key column of the foreign key to not null"
"literal>. Hibernate will manage the association from the collections side to "
"maintain the index of each element, making the other side virtually inverse "
"by setting <literal>update=\"false\" and insert=\"false"
"\"</literal>:"
msgstr ""
"如果你使用 <literal>List(或者其他有序集合类),你需要设置外键对应"
"的 <literal>key 列为 not null。Hibernate 将从集"
"合端管理关联,维护每个元素的索引,并通过设置 <literal>update=\"false\""
"literal> 和 <literal>insert=\"false\" 来对另一端反向操作。"
#. Tag: para
#, no-c-format
msgid ""
"If the underlying foreign key column is <literal>NOT NULL, it is "
"important that you define <literal>not-null=\"true\" on the "
"<literal><key> element of the collection mapping. Do not "
"only declare <literal>not-null=\"true\" on a possible nested "
"<literal><column> element, but on the <key>"
"literal> element."
msgstr ""
"假若集合映射的 <literal><key> 元素对应的底层外键字段是 "
"<literal>NOT NULL 的,那么为这一 key 元素定义 not-null="
"\"true\"</literal> 是很重要的。不要仅仅为可能的嵌套 <column>"
"literal>元素定义 <literal>not-null=\"true\",<key>"
"literal> 元素也是需要的。 "
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>bidirectional one-to-one association on a foreign key "
"is common:"
msgstr "<emphasis>基于外键关联的双向一对一关联也很常见。 "
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>bidirectional one-to-one association on a primary key "
"uses the special id generator:"
msgstr ""
"<emphasis>基于主键关联的一对一关联需要使用特定的 id 生成器:"
#. Tag: title
#, no-c-format
msgid "Bidirectional associations with join tables"
msgstr "使用连接表的双向关联(Bidirectional associations with join tables)"
#. Tag: para
#, no-c-format
msgid ""
"The following is an example of a <emphasis>bidirectional one-to-many "
"association on a join table</emphasis>. The inverse=\"true\""
"literal> can go on either end of the association, on the collection, or on "
"the join."
msgstr ""
"下面是一个<emphasis>基于连接表的双向一对多关联的例子。注意 "
"<literal>inverse=\"true\" 可以出现在关联的任意一端,即 collection "
"端或者 join 端。"
#. Tag: title
#, no-c-format
msgid "one to one"
msgstr "一对一(one to one)"
#. Tag: para
#, no-c-format
msgid ""
"A <emphasis>bidirectional one-to-one association on a join table "
"is possible, but extremely unusual."
msgstr ""
"<emphasis>基于连接表的双向一对一关联也是可行的,但极为罕见。"
#. Tag: para
#, no-c-format
msgid ""
"Here is an example of a <emphasis>bidirectional many-to-many association"
"emphasis>."
msgstr "下面是一个<emphasis>双向多对多关联的例子。"
#. Tag: title
#, no-c-format
msgid "More complex association mappings"
msgstr "更复杂的关联映射"
#. Tag: para
#, no-c-format
msgid ""
"More complex association joins are <emphasis>extremely rare. "
"Hibernate handles more complex situations by using SQL fragments embedded in "
"the mapping document. For example, if a table with historical account "
"information data defines <literal>accountNumber, "
"<literal>effectiveEndDate and effectiveStartDate"
"literal>columns, it would be mapped as follows:"
msgstr ""
"更复杂的关联连接<emphasis>极为罕见。通过在映射文档中嵌入 SQL 片"
"断,Hibernate 也可以处理更为复杂的情况。比如,假若包含历史帐户数据的表定义了 "
"<literal>accountNumber、effectiveEndDate 和 "
"<literal>effectiveStartDate 字段,按照下面映射:"
#. Tag: para
#, no-c-format
msgid ""
"You can then map an association to the <emphasis>current "
"instance, the one with null <literal>effectiveEndDate, by using:"
msgstr ""
"那么我们可以对<emphasis>目前(current)实例(其 "
"<literal>effectiveEndDate 为 null)使用这样的关联映射: "
#. Tag: para
#, no-c-format
msgid ""
"In a more complex example, imagine that the association between "
"<literal>Employee and Organization is "
"maintained in an <literal>Employment table full of historical "
"employment data. An association to the employee's <emphasis>most recent"
"emphasis> employer, the one with the most recent <literal>startDate"
"literal>, could be mapped in the following way:"
msgstr ""
"在更复杂的例子中,假想 <literal>Employee 和 Organization"
"literal> 之间的关联是通过一个 <literal>Employment 中间表维护的,而"
"中间表中填充了很多历史雇员数据。那“雇员的<emphasis>最新雇主”这个关"
"联(最新雇主就是具有最新的 <literal>startDate 的那个)可以这样映"
"射:"
#. Tag: para
#, no-c-format
msgid ""
"This functionality allows a degree of creativity and flexibility, but it is "
"more practical to handle these kinds of cases using HQL or a criteria query."
msgstr ""
"使用这一功能时可以充满创意和灵活性,但通常更加实用的是用 HQL 或条件查询来处理"
"这些情况。"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key, addressId "
#~ "bigint not null )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key, addressId "
#~ "bigint not null )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key, addressId "
#~ "bigint not null unique )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key, addressId "
#~ "bigint not null unique )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgid ""
#~ "<![CDATA[\n"
#~ " </generator>\n"
#~ " </id>\n"
#~ " <one-to-one name=\"person\" constrained=\"true\"/>\n"
#~ "</class>]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ " </generator>\n"
#~ " </id>\n"
#~ " <one-to-one name=\"person\" constrained=\"true\"/>\n"
#~ "</class>]]>"
#~ msgid ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table Address ( personId bigint not null primary key )\n"
#~ " ]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table Address ( personId bigint not null primary key )\n"
#~ " ]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table Address ( addressId bigint not null primary key, personId "
#~ "bigint not null )\n"
#~ " ]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table Address ( addressId bigint not null primary key, personId "
#~ "bigint not null )\n"
#~ " ]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId not null, addressId bigint not null "
#~ "primary key )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId not null, addressId bigint not null "
#~ "primary key )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId bigint not null primary key, "
#~ "addressId bigint not null )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId bigint not null primary key, "
#~ "addressId bigint not null )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId bigint not null primary key, "
#~ "addressId bigint not null unique )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId bigint not null primary key, "
#~ "addressId bigint not null unique )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId bigint not null, addressId bigint "
#~ "not null, primary key (personId, addressId) )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId bigint not null, addressId bigint "
#~ "not null, primary key (personId, addressId) )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ " </generator>\n"
#~ " </id>\n"
#~ " <one-to-one name=\"person\" \n"
#~ " constrained=\"true\"/>\n"
#~ "</class>]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ " </generator>\n"
#~ " </id>\n"
#~ " <one-to-one name=\"person\" \n"
#~ " constrained=\"true\"/>\n"
#~ "</class>]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId bigint not null, addressId bigint "
#~ "not null primary key )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "create table Person ( personId bigint not null primary key )\n"
#~ "create table PersonAddress ( personId bigint not null, addressId bigint "
#~ "not null primary key )\n"
#~ "create table Address ( addressId bigint not null primary key )\n"
#~ " ]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[\n"
#~ "</many-to-one>]]>"
#~ msgstr ""
#~ "<![CDATA[\n"
#~ "</many-to-one>]]>"
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
Other Hibernate examples (source code examples)
Here is a short list of links related to this Hibernate association_mapping.po source code file:
|