|
Hibernate example source code file (collection_mapping.po)
This example Hibernate source code file (collection_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 collection_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-07-20 21:02+0000\n"
"PO-Revision-Date: 2010-03-15 08:59+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
#: collection_mapping.xml:31
#, no-c-format
msgid "Collection mapping"
msgstr "集åˆæ˜ 射(Collection mappings)"
#. Tag: title
#: collection_mapping.xml:34
#, no-c-format
msgid "Persistent collections"
msgstr "æŒä¹…化集åˆç±»ï¼ˆPersistent collections)"
#. Tag: para
#: collection_mapping.xml:36
#, fuzzy, no-c-format
msgid ""
"Naturally Hibernate also allows to persist collections. These persistent "
"collections can contain almost any other Hibernate type, including: basic "
"types, custom types, components and references to other entities. The "
"distinction between value and reference semantics is in this context very "
"important. An object in a collection might be handled with \"value\" "
"semantics (its life cycle fully depends on the collection owner), or it "
"might be a reference to another entity with its own life cycle. In the "
"latter case, only the \"link\" between the two objects is considered to be a "
"state held by the collection."
msgstr ""
"集åˆå‡ 乎å¯ä»¥åŒ…å«ä»»ä½•å…¶ä»–çš„ Hibernate 类型,包括所有的基本类型ã€è‡ªå®šä¹‰ç±»åž‹ã€ç»„"
"件,当然还有对其他实体的引用。å˜åœ¨ä¸€ä¸ªé‡è¦çš„区别:ä½äºŽé›†åˆä¸çš„对象å¯èƒ½æ˜¯æ ¹"
"æ®â€œå€¼â€è¯ä¹‰æ¥æ“作(其声明周期完全ä¾èµ–于集åˆæŒæœ‰è€…),或者它å¯èƒ½æ˜¯æŒ‡å‘å¦ä¸€ä¸ªå®ž"
"体的引用,具有其自己的生命周期。在åŽè€…的情况下,被作为集åˆæŒæœ‰çš„状æ€è€ƒè™‘的,"
"åªæœ‰ä¸¤ä¸ªå¯¹è±¡ä¹‹é—´çš„“连接â€ã€‚ "
#. Tag: para
#: collection_mapping.xml:46
#, fuzzy, no-c-format
msgid ""
"As a requirement persistent collection-valued fields must be declared as an "
"interface type (see <xref linkend=\"example.collection.mapping.annotations\"/"
">). The actual interface might be <literal>java.util.Set, "
"<literal>java.util.Collection, java.util.List, "
"<literal>java.util.Map, java.util.SortedSet, "
"<literal>java.util.SortedMap or anything you like (\"anything you "
"like\" means you will have to write an implementation of <literal>org."
"hibernate.usertype.UserCollectionType</literal>)."
msgstr ""
"实际的接å£å¯èƒ½æ˜¯ <literal>java.util.Setã€java.util."
"Collection</literal>ã€java.util.Listã€java.util."
"Map</literal>ã€java.util.SortedSetã€java.util."
"SortedMap</literal> æˆ–è€…ä»»ä½•ä½ å–œæ¬¢çš„ç±»åž‹ï¼ˆ\"ä»»ä½•ä½ å–œæ¬¢çš„ç±»åž‹\" ä»£è¡¨ä½ éœ€è¦ç¼–"
"写 <literal>org.hibernate.usertype.UserCollectionType 的实现)。"
#. Tag: para
#: collection_mapping.xml:57
#, fuzzy, no-c-format
msgid ""
"Notice how in <xref linkend=\"example.collection.mapping.annotations\"/> the "
"instance variable <literal>parts was initialized with an instance "
"of <literal>HashSet. This is the best way to initialize collection "
"valued properties of newly instantiated (non-persistent) instances. When you "
"make the instance persistent, by calling <literal>persist(), "
"Hibernate will actually replace the <literal>HashSet with an "
"instance of Hibernate's own implementation of <literal>Set. Be "
"aware of the following error:"
msgstr ""
"注æ„我们是如何用一个 <literal>HashSet 实例æ¥åˆå§‹åŒ–实例å˜é‡çš„。这是"
"用于åˆå§‹åŒ–新创建(尚未æŒä¹…化)的类实例ä¸é›†åˆå€¼å±žæ€§çš„æœ€ä½³æ–¹æ³•ã€‚å½“ä½ æŒä¹…化这个"
"实例时 — 比如通过调用 <literal>persist() — Hibernate 会自动把 "
"<literal>HashSet 替æ¢ä¸º Hibernate 自己的 Set 实"
"现。注æ„下é¢çš„错误:"
#. Tag: title
#: collection_mapping.xml:68
#, no-c-format
msgid "Hibernate uses its own collection implementations"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:70
#, fuzzy, no-c-format
msgid ""
"Cat cat = new DomesticCat();\n"
"Cat kitten = new DomesticCat();\n"
"....\n"
"Set kittens = new HashSet();\n"
"kittens.add(kitten);\n"
"cat.setKittens(kittens);\n"
"session.persist(cat);\n"
"\n"
"kittens = cat.getKittens(); // Okay, kittens collection is a Set\n"
"(HashSet) cat.getKittens(); // Error!"
msgstr ""
"<![CDATA[Cat cat = new DomesticCat();\n"
"Cat kitten = new DomesticCat();\n"
"....\n"
"Set kittens = new HashSet();\n"
"kittens.add(kitten);\n"
"cat.setKittens(kittens);\n"
"session.persist(cat);\n"
"kittens = cat.getKittens(); // Okay, kittens collection is a Set\n"
"(HashSet) cat.getKittens(); // Error!]]>"
#. Tag: para
#: collection_mapping.xml:73
#, no-c-format
msgid ""
"The persistent collections injected by Hibernate behave like "
"<literal>HashMap, HashSet, TreeMapTreeSet or ArrayList, "
"depending on the interface type."
msgstr ""
"æ ¹æ®ä¸åŒçš„接å£ç±»åž‹ï¼Œè¢« Hibernate 注射的æŒä¹…化集åˆç±»çš„表现类似 "
"<literal>HashMapã€HashSetã€TreeMapTreeSet 或 ArrayList。"
#. Tag: para
#: collection_mapping.xml:78
#, no-c-format
msgid ""
"Collections instances have the usual behavior of value types. They are "
"automatically persisted when referenced by a persistent object and are "
"automatically deleted when unreferenced. If a collection is passed from one "
"persistent object to another, its elements might be moved from one table to "
"another. Two entities cannot share a reference to the same collection "
"instance. Due to the underlying relational model, collection-valued "
"properties do not support null value semantics. Hibernate does not "
"distinguish between a null collection reference and an empty collection."
msgstr ""
"集åˆç±»å®žä¾‹å…·æœ‰å€¼ç±»åž‹çš„通常行为。当被æŒä¹…化对象引用åŽï¼Œä»–们会自动被æŒä¹…化,当"
"ä¸å†è¢«å¼•ç”¨åŽï¼Œè‡ªåŠ¨è¢«åˆ 除。å‡è‹¥å®žä¾‹è¢«ä»Žä¸€ä¸ªæŒä¹…åŒ–å¯¹è±¡ä¼ é€’åˆ°å¦ä¸€ä¸ªï¼Œå®ƒçš„å…ƒç´ å¯"
"能从一个表转移到å¦ä¸€ä¸ªè¡¨ã€‚两个实体ä¸èƒ½å…±äº«åŒä¸€ä¸ªé›†åˆç±»å®žä¾‹çš„å¼•ç”¨ã€‚å› ä¸ºåº•å±‚å…³"
"系数æ®åº“æ¨¡åž‹çš„åŽŸå› ï¼Œé›†åˆå€¼å±žæ€§æ— 法支æŒç©ºå€¼è¯ä¹‰ï¼›Hibernate 对空的集åˆå¼•ç”¨å’Œç©º"
"集åˆä¸åŠ 区别。 "
#. Tag: para
#: collection_mapping.xml:89
#, fuzzy, no-c-format
msgid ""
"Use persistent collections the same way you use ordinary Java collections. "
"However, ensure you understand the semantics of bidirectional associations "
"(see <xref linkend=\"collections-bidirectional\"/>)."
msgstr ""
"ä½ ä¸éœ€è¦è¿‡å¤šçš„为æ¤æ‹…心。就如åŒä½ 平时使用普通的 Java 集åˆç±»ä¸€æ ·æ¥ä½¿ç”¨æŒä¹…化集"
"åˆç±»ã€‚åªæ˜¯è¦ç¡®è®¤ä½ ç†è§£äº†åŒå‘å…³è”çš„è¯ä¹‰ï¼ˆåŽæ–‡å°†è¿›è¡Œè®¨è®ºï¼‰ã€‚"
#. Tag: title
#: collection_mapping.xml:97
#, fuzzy, no-c-format
msgid "How to map collections"
msgstr "有åºé›†åˆï¼ˆSorted collections)"
#. Tag: para
#: collection_mapping.xml:99
#, no-c-format
msgid ""
"Using annotations you can map <classname>Collections, "
"<classname>Lists, Maps and "
"<classname>Sets of associated entities using @OneToMany and "
"@ManyToMany. For collections of a basic or embeddable type use "
"@ElementCollection. In the simplest case a collection mapping looks like "
"this:"
msgstr ""
#. Tag: title
#: collection_mapping.xml:107
#, no-c-format
msgid "Collection mapping using @OneToMany and @JoinColumn"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:109
#, fuzzy, no-c-format
msgid ""
"@Entity\n"
"public class Product {\n"
"\n"
" private String serialNumber;\n"
" private Set<Part> parts = new HashSet<Part>();\n"
"\n"
" @Id\n"
" public String getSerialNumber() { return serialNumber; }\n"
" void setSerialNumber(String sn) { serialNumber = sn; }\n"
" \n"
" @OneToMany\n"
" @JoinColumn(name=\"PART_ID\")\n"
" public Set<Part> getParts() { return parts; }\n"
" void setParts(Set parts) { this.parts = parts; }\n"
"}\n"
"\n"
"\n"
"@Entity\n"
"public class Part {\n"
" ...\n"
"}"
msgstr ""
"<![CDATA[public class Product {\n"
" private String serialNumber;\n"
" private Set parts = new HashSet();\n"
" \n"
" public Set getParts() { return parts; }\n"
" void setParts(Set parts) { this.parts = parts; }\n"
" public String getSerialNumber() { return serialNumber; }\n"
" void setSerialNumber(String sn) { serialNumber = sn; }\n"
"}]]>"
#. Tag: para
#: collection_mapping.xml:112
#, no-c-format
msgid ""
"Product describes a unidirectional relationship with Part using the join "
"column PART_ID. In this unidirectional one to many scenario you can also use "
"a join table as seen in <xref linkend=\"example-one-to-many-with-join-table"
"\"/>."
msgstr ""
#. Tag: title
#: collection_mapping.xml:118
#, no-c-format
msgid "Collection mapping using @OneToMany and @JoinTable"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:121
#, no-c-format
msgid ""
"@Entity\n"
"public class Product {\n"
"\n"
" private String serialNumber;\n"
" private Set<Part> parts = new HashSet<Part>();\n"
"\n"
" @Id\n"
" public String getSerialNumber() { return serialNumber; }\n"
" void setSerialNumber(String sn) { serialNumber = sn; }\n"
" \n"
" @OneToMany\n"
" @JoinTable(\n"
" name=\"PRODUCT_PARTS\",\n"
" joinColumns = @JoinColumn( name=\"PRODUCT_ID\"),\n"
" inverseJoinColumns = @JoinColumn( name=\"PART_ID\")\n"
" )\n"
" public Set<Part> getParts() { return parts; }\n"
" void setParts(Set parts) { this.parts = parts; }\n"
"}\n"
"\n"
"\n"
"@Entity\n"
"public class Part {\n"
" ...\n"
"}"
msgstr ""
#. Tag: para
#: collection_mapping.xml:124
#, no-c-format
msgid ""
"Without describing any physical mapping (no <classname>@JoinColumn@JoinTable), a unidirectional one to "
"many with join table is used. The table name is the concatenation of the "
"owner table name, _, and the other side table name. The foreign key name(s) "
"referencing the owner table is the concatenation of the owner table, _, and "
"the owner primary key column(s) name. The foreign key name(s) referencing "
"the other side is the concatenation of the owner property name, _, and the "
"other side primary key column(s) name. A unique constraint is added to the "
"foreign key referencing the other side table to reflect the one to many."
msgstr ""
#. Tag: para
#: collection_mapping.xml:135
#, fuzzy, no-c-format
msgid ""
"Lets have a look now how collections are mapped using Hibernate mapping "
"files. In this case the first step is to chose the right mapping element. It "
"depends on the type of interface. For example, a <literal><set>SetSet 类型的属性。 "
#. Tag: title
#: collection_mapping.xml:142
#, no-c-format
msgid "Mapping a Set using <set>"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:144
#, fuzzy, no-c-format
msgid ""
"<class name=\"Product\">\n"
" <id name=\"serialNumber\" column=\"productSerialNumber\"/>\n"
" <set name=\"parts\">\n"
" <key column=\"productSerialNumber\" not-null=\"true\"/>\n"
" <one-to-many class=\"Part\"/>\n"
" </set>\n"
"</class>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:147
#, fuzzy, no-c-format
msgid ""
"In <xref linkend=\"example.collections.set\"/> a one-to-many "
"association</emphasis> links the Product and "
"<literal>Part entities. This association requires the existence of "
"a foreign key column and possibly an index column to the <literal>Part 到 Part çš„å…³è”需è¦å…³é”®å—"
"å—段,å¯èƒ½è¿˜æœ‰ä¸€ä¸ªç´¢å¼•å—æ®µæŒ‡å‘ <literal>Part 所对应的表。"
"<literal><one-to-many> æ ‡è®°æŒ‡æ˜Žäº†ä¸€ä¸ªä¸€å¯¹å¤šçš„å…³è”。 "
#. Tag: para
#: collection_mapping.xml:156
#, no-c-format
msgid ""
"An instance of the contained entity class cannot belong to more than one "
"instance of the collection."
msgstr "一个被包å«çš„实体的实例åªèƒ½è¢«åŒ…å«åœ¨ä¸€ä¸ªé›†åˆçš„实例ä¸ã€‚"
#. Tag: para
#: collection_mapping.xml:161
#, no-c-format
msgid ""
"An instance of the contained entity class cannot appear at more than one "
"value of the collection index."
msgstr "一个被包å«çš„实体的实例åªèƒ½å¯¹åº”于集åˆç´¢å¼•çš„一个值ä¸ã€‚"
#. Tag: para
#: collection_mapping.xml:166
#, no-c-format
msgid ""
"Looking closer at the used <literal><one-to-many> tag we see "
"that it has the following options."
msgstr ""
#. Tag: title
#: collection_mapping.xml:170
#, no-c-format
msgid "options of <one-to-many> element"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:181
#, fuzzy, no-c-format
msgid ""
"<one-to-many\n"
" class=\"ClassName\"\n"
" not-found=\"ignore|exception\"\n"
" entity-name=\"EntityName\"\n"
" node=\"element-name\"\n"
" embed-xml=\"true|false\"\n"
" />"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:185
#, no-c-format
msgid "<literal>class (required): the name of the associated class."
msgstr "<literal>class(必需):被关è”类的å称。 "
#. Tag: para
#: collection_mapping.xml:190
#, no-c-format
msgid ""
"<literal>not-found (optional - defaults to exception will treat a missing row as a null "
"association."
msgstr ""
"<literal>not-found(å¯é€‰ - 默认为exception):指"
"明若缓å˜çš„æ ‡ç¤ºå€¼å…³è”的行缺失,该如何处ç†ï¼š<literal>ignore 会把缺失"
"的行作为一个空关è”处ç†ã€‚ "
#. Tag: para
#: collection_mapping.xml:198
#, no-c-format
msgid ""
"<literal>entity-name (optional): the entity name of the associated "
"class, as an alternative to <literal>class."
msgstr ""
"<literal>entity-name(å¯é€‰ï¼‰ï¼šè¢«å…³è”的类的实体å,作为 "
"<literal>class 的替代。 "
#. Tag: para
#: collection_mapping.xml:206
#, no-c-format
msgid ""
"The <literal><one-to-many> element does not need to declare "
"any columns. Nor is it necessary to specify the <literal>table "
"name anywhere."
msgstr ""
"注æ„:<literal><one-to-many> å…ƒç´ ä¸éœ€è¦å®šä¹‰ä»»ä½•å—段。也ä¸éœ€è¦"
"指定表å。 "
#. Tag: para
#: collection_mapping.xml:211
#, fuzzy, no-c-format
msgid ""
"If the foreign key column of a <literal><one-to-many> "
"association is declared <literal>NOT NULL, you must declare the "
"<literal><key> mapping not-null=\"true\" "
"or <emphasis>use a bidirectional association with the collection "
"mapping marked <literal>inverse=\"true\". See :如果一对多关è”ä¸çš„外键å—段"
"å®šä¹‰æˆ <literal>NOT NULLï¼Œä½ å¿…é¡»æŠŠ <key> "
"æ˜ å°„å£°æ˜Žä¸º <literal>not-null=\"true\",或者使用åŒå‘å…³è”inverse=\"true\"。å‚é˜…æœ¬ç« åŽé¢å…³äºŽåŒå‘"
"å…³è”的讨论。 "
#. Tag: para
#: collection_mapping.xml:221
#, fuzzy, no-c-format
msgid ""
"Apart from the <literal><set> tag as shown in <list><map>, <bag>, "
"<literal><array> and <primitive-array><map> element is "
"representative:"
msgstr ""
"除了 <literal><set>,还有<list>,"
"<literal><map>,<bag>,<"
"array></literal> å’Œ <primitive-array> æ˜ å°„å…ƒç´ ã€‚"
"<literal><map> 具有代表性:"
#. Tag: title
#: collection_mapping.xml:229
#, no-c-format
msgid "Elements of the <map> mapping"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:262
#, fuzzy, no-c-format
msgid ""
"<map\n"
" name=\"propertyName\"\n"
" table=\"table_name\"\n"
" schema=\"schema_name\"\n"
" lazy=\"true|extra|false\"\n"
" inverse=\"true|false\"\n"
" cascade=\"all|none|save-update|delete|all-delete-orphan|delete-orphan\"\n"
" sort=\"unsorted|natural|comparatorClass\"\n"
" order-by=\"column_name asc|desc\"\n"
" where=\"arbitrary sql where condition\"\n"
" fetch=\"join|select|subselect\"\n"
" batch-size=\"N\"\n"
" access=\"field|property|ClassName\"\n"
" optimistic-lock=\"true|false\"\n"
" mutable=\"true|false\"\n"
" node=\"element-name|.\"\n"
" embed-xml=\"true|false\"\n"
">\n"
"\n"
" <key .... />\n"
" <map-key .... />\n"
" <element .... />\n"
"</map>"
msgstr ""
"<![CDATA[, or columns, of the "
"collection table. The collection key column is mapped by the "
"<literal>@JoinColumn annotation respectively the <"
"key></literal> XML element."
msgstr ""
"集åˆå®žä¾‹åœ¨æ•°æ®åº“ä¸ä¾é æŒæœ‰é›†åˆçš„å®žä½“çš„å¤–é”®åŠ ä»¥è¾¨åˆ«ã€‚æ¤å¤–键作为<emphasis>集åˆ"
"关键å—段(collection key column)</emphasis>(或多个å—æ®µï¼‰åŠ ä»¥å¼•ç”¨ã€‚é›†åˆå…³é”®"
"å—段通过 <literal><key> å…ƒç´ æ˜ å°„ã€‚ "
#. Tag: para
#: collection_mapping.xml:374
#, fuzzy, no-c-format
msgid ""
"There can be a nullability constraint on the foreign key column. For most "
"collections, this is implied. For unidirectional one-to-many associations, "
"the foreign key column is nullable by default, so you may need to specify"
msgstr ""
"在外键å—段上å¯èƒ½å…·æœ‰éžç©ºçº¦æŸã€‚对于大多数集åˆæ¥è¯´ï¼Œè¿™æ˜¯éšå«çš„。对å•å‘一对多关"
"è”æ¥è¯´ï¼Œå¤–é”®å—段默认是å¯ä»¥ä¸ºç©ºçš„ï¼Œå› æ¤ä½ å¯èƒ½éœ€è¦æŒ‡æ˜Ž <literal>not-null=\"true"
"\"</literal>。 "
#. Tag: programlisting
#: collection_mapping.xml:379
#, no-c-format
msgid "@JoinColumn(nullable=false)"
msgstr ""
#. Tag: para
#: collection_mapping.xml:381
#, no-c-format
msgid "<para>or"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:383
#, fuzzy, no-c-format
msgid "<key column=\"productSerialNumber\" not-null=\"true\"/>"
msgstr "<![CDATA["
#. Tag: para
#: collection_mapping.xml:385
#, fuzzy, no-c-format
msgid ""
"The foreign key constraint can use <literal>ON DELETE CASCADE. In "
"XML this can be expressed via:"
msgstr "外键约æŸå¯ä»¥ä½¿ç”¨ <literal>ON DELETE CASCADE。 "
#. Tag: programlisting
#: collection_mapping.xml:388
#, fuzzy, no-c-format
msgid "<key column=\"productSerialNumber\" on-delete=\"cascade\"/>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:390
#, no-c-format
msgid ""
"In annotations the Hibernate specific annotation @OnDelete has to be used."
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:393
#, no-c-format
msgid "@OnDelete(action=OnDeleteAction.CASCADE)"
msgstr ""
#. Tag: para
#: collection_mapping.xml:395
#, fuzzy, no-c-format
msgid ""
"See <xref lang=\"\" linkend=\"section.key\"/> for more information about the "
"<literal><key> element."
msgstr "对 <literal><key> å…ƒç´ çš„å®Œæ•´å®šä¹‰ï¼Œè¯·å‚阅å‰é¢çš„ç« èŠ‚ã€‚"
#. Tag: title
#: collection_mapping.xml:400
#, no-c-format
msgid "Indexed collections"
msgstr "索引集åˆç±»ï¼ˆIndexed collections)"
#. Tag: para
#: collection_mapping.xml:402
#, no-c-format
msgid ""
"In the following paragraphs we have a closer at the indexed collections "
"<classname>List and Map how the their "
"index can be mapped in Hibernate."
msgstr ""
#. Tag: title
#: collection_mapping.xml:407
#, no-c-format
msgid "Lists"
msgstr ""
#. Tag: para
#: collection_mapping.xml:409
#, no-c-format
msgid "Lists can be mapped in two different ways:"
msgstr ""
#. Tag: para
#: collection_mapping.xml:413
#, no-c-format
msgid "as ordered lists, where the order is not materialized in the database"
msgstr ""
#. Tag: para
#: collection_mapping.xml:418
#, no-c-format
msgid "as indexed lists, where the order is materialized in the database"
msgstr ""
#. Tag: para
#: collection_mapping.xml:423
#, no-c-format
msgid ""
"To order lists in memory, add <literal>@javax.persistence.OrderBy "
"to your property. This annotation takes as parameter a list of comma "
"separated properties (of the target entity) and orders the collection "
"accordingly (eg <code>firstname asc, age desc), if the string is "
"empty, the collection will be ordered by the primary key of the target "
"entity."
msgstr ""
#. Tag: title
#: collection_mapping.xml:432
#, no-c-format
msgid "Ordered lists using <classname>@OrderBy"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:434
#, no-c-format
msgid ""
"@Entity\n"
"public class Customer {\n"
" @Id @GeneratedValue public Integer getId() { return id; }\n"
" public void setId(Integer id) { this.id = id; }\n"
" private Integer id;\n"
"\n"
" @OneToMany(mappedBy=\"customer\")\n"
" @OrderBy(\"number\")\n"
" public List<Order> getOrders() { return orders; }\n"
" public void setOrders(List<Order> orders) { this.orders = "
"orders; }\n"
" private List<Order> orders;\n"
"}\n"
"\n"
"@Entity\n"
"public class Order {\n"
" @Id @GeneratedValue public Integer getId() { return id; }\n"
" public void setId(Integer id) { this.id = id; }\n"
" private Integer id;\n"
"\n"
" public String getNumber() { return number; }\n"
" public void setNumber(String number) { this.number = number; }\n"
" private String number;\n"
"\n"
" @ManyToOne\n"
" public Customer getCustomer() { return customer; }\n"
" public void setCustomer(Customer customer) { this.customer = customer; }\n"
" private Customer number;\n"
"}\n"
"\n"
"-- Table schema\n"
"|-------------| |----------|\n"
"| Order | | Customer |\n"
"|-------------| |----------|\n"
"| id | | id |\n"
"| number | |----------| \n"
"| customer_id |\n"
"|-------------|"
msgstr ""
#. Tag: para
#: collection_mapping.xml:437
#, no-c-format
msgid ""
"To store the index value in a dedicated column, use the <classname>@javax."
"persistence.OrderColumn</classname> annotation on your property. This "
"annotations describes the column name and attributes of the column keeping "
"the index value. This column is hosted on the table containing the "
"association foreign key. If the column name is not specified, the default is "
"the name of the referencing property, followed by underscore, followed by "
"<literal>ORDER (in the following example, it would be "
"<literal>orders_ORDER)."
msgstr ""
#. Tag: title
#: collection_mapping.xml:448
#, no-c-format
msgid "Explicit index column using <classname>@OrderColumn"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:451
#, no-c-format
msgid ""
"@Entity\n"
"public class Customer {\n"
" @Id @GeneratedValue public Integer getId() { return id; }\n"
" public void setId(Integer id) { this.id = id; }\n"
" private Integer id;\n"
"\n"
" @OneToMany(mappedBy=\"customer\")\n"
" @OrderColumn(name=\"orders_index\")\n"
" public List<Order> getOrders() { return orders; }\n"
" public void setOrders(List<Order> orders) { this.orders = "
"orders; }\n"
" private List<Order> orders;\n"
"}\n"
"\n"
"@Entity\n"
"public class Order {\n"
" @Id @GeneratedValue public Integer getId() { return id; }\n"
" public void setId(Integer id) { this.id = id; }\n"
" private Integer id;\n"
"\n"
" public String getNumber() { return number; }\n"
" public void setNumber(String number) { this.number = number; }\n"
" private String number;\n"
"\n"
" @ManyToOne\n"
" public Customer getCustomer() { return customer; }\n"
" public void setCustomer(Customer customer) { this.customer = customer; }\n"
" private Customer number;\n"
"}\n"
"\n"
"-- Table schema\n"
"|--------------| |----------|\n"
"| Order | | Customer |\n"
"|--------------| |----------|\n"
"| id | | id |\n"
"| number | |----------| \n"
"| customer_id |\n"
"| orders_order |\n"
"|--------------|"
msgstr ""
#. Tag: para
#: collection_mapping.xml:455
#, no-c-format
msgid ""
"We recommend you to convert <classname>the legacy @org.hibernate.annotations."
"IndexColumn</classname> usages to @OrderColumn unless "
"you are making use of the base property. The <literal>base "
"property lets you define the index value of the first element (aka as base "
"index). The usual value is <literal>0 or 1. The "
"default is 0 like in Java."
msgstr ""
#. Tag: para
#: collection_mapping.xml:464
#, no-c-format
msgid ""
"Looking again at the Hibernate mapping file equivalent, the index of an "
"array or list is always of type <literal>integer and is mapped "
"using the <literal><list-index> element. The mapped column "
"contains sequential integers that are numbered from zero by default."
msgstr ""
#. Tag: title
#: collection_mapping.xml:471
#, no-c-format
msgid "index-list element for indexed collections in xml mapping"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:481
#, no-c-format
msgid ""
"<list-index\n"
" column=\"column_name\"\n"
" base=\"0|1|...\"/>"
msgstr ""
#. Tag: para
#: collection_mapping.xml:485
#, no-c-format
msgid ""
"<literal>column_name (required): the name of the column holding "
"the collection index values."
msgstr "<literal>column_name(必需):æŒæœ‰é›†åˆç´¢å¼•å€¼çš„å—段的å称。 "
#. Tag: para
#: collection_mapping.xml:490
#, no-c-format
msgid ""
"<literal>base (optional - defaults to 0): the "
"value of the index column that corresponds to the first element of the list "
"or array."
msgstr ""
"<literal>base(å¯é€‰ — 默认为 0)对应列表或队列的"
"ç¬¬ä¸€ä¸ªå…ƒç´ çš„ç´¢å¼•å—段的值。"
#. Tag: para
#: collection_mapping.xml:498
#, no-c-format
msgid ""
"If your table does not have an index column, and you still wish to use "
"<literal>List as the property type, you can map the property as a "
"Hibernate <emphasis><bag>. A bag does not retain its order "
"when it is retrieved from the database, but it can be optionally sorted or "
"ordered."
msgstr ""
"å‡è‹¥ä½ 的表没有一个索引å—æ®µï¼Œå½“ä½ ä»ç„¶å¸Œæœ›ä½¿ç”¨ <literal>List 作为属性"
"ç±»åž‹ï¼Œä½ åº”è¯¥æŠŠæ¤å±žæ€§æ˜ 射为 Hibernate <emphasis><bag>。从数æ®"
"库ä¸èŽ·å–的时候,bag ä¸ç»´æŠ¤å…¶é¡ºåºï¼Œä½†ä¹Ÿå¯é€‰æ‹©æ€§çš„进行排åºã€‚ "
#. Tag: title
#: collection_mapping.xml:506
#, no-c-format
msgid "Maps"
msgstr ""
#. Tag: para
#: collection_mapping.xml:508
#, no-c-format
msgid ""
"The question with <classname>Maps is where the key value is "
"stored. There are everal options. Maps can borrow their keys from one of the "
"associated entity properties or have dedicated columns to store an explicit "
"key."
msgstr ""
#. Tag: para
#: collection_mapping.xml:513
#, no-c-format
msgid ""
"To use one of the target entity property as a key of the map, use "
"<literal>@MapKey(name=\"myProperty\"), where myProperty without the name attribuate, the target entity "
"primary key is used. The map key uses the same column as the property "
"pointed out. There is no additional column defined to hold the map key, "
"because the map key represent a target property. Be aware that once loaded, "
"the key is no longer kept in sync with the property. In other words, if you "
"change the property value, the key will not change automatically in your "
"Java model."
msgstr ""
#. Tag: title
#: collection_mapping.xml:525
#, no-c-format
msgid ""
"Use of target entity property as map key via <classname>@MapKey"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:528
#, no-c-format
msgid ""
"@Entity\n"
"public class Customer {\n"
" @Id @GeneratedValue public Integer getId() { return id; }\n"
" public void setId(Integer id) { this.id = id; }\n"
" private Integer id;\n"
"\n"
" @OneToMany(mappedBy=\"customer\")\n"
" @MapKey(name=\"number\")\n"
" public Map<String,Order> getOrders() { return orders; }\n"
" public void setOrders(Map<String,Order> order) { this.orders = "
"orders; }\n"
" private Map<String,Order> orders;\n"
"}\n"
"\n"
"@Entity\n"
"public class Order {\n"
" @Id @GeneratedValue public Integer getId() { return id; }\n"
" public void setId(Integer id) { this.id = id; }\n"
" private Integer id;\n"
"\n"
" public String getNumber() { return number; }\n"
" public void setNumber(String number) { this.number = number; }\n"
" private String number;\n"
"\n"
" @ManyToOne\n"
" public Customer getCustomer() { return customer; }\n"
" public void setCustomer(Customer customer) { this.customer = customer; }\n"
" private Customer number;\n"
"}\n"
"\n"
"-- Table schema\n"
"|-------------| |----------|\n"
"| Order | | Customer |\n"
"|-------------| |----------|\n"
"| id | | id |\n"
"| number | |----------| \n"
"| customer_id |\n"
"|-------------|"
msgstr ""
#. Tag: para
#: collection_mapping.xml:531
#, no-c-format
msgid ""
"Alternatively the map key is mapped to a dedicated column or columns. In "
"order to customize the mapping use one of the following annotations:"
msgstr ""
#. Tag: para
#: collection_mapping.xml:537
#, no-c-format
msgid ""
"@<classname>MapKeyColumn if the map key is a basic type. If you "
"don't specify the column name, the name of the property followed by "
"underscore followed by <literal>KEY is used (for example "
"<literal>orders_KEY)."
msgstr ""
#. Tag: para
#: collection_mapping.xml:544
#, no-c-format
msgid ""
"<classname>@MapKeyEnumerated / @MapKeyTemporalDate/@MapKeyJoinColumns/@AttributeOverrideskey. to define the type of "
"the key if you don't use generics."
msgstr ""
#. Tag: title
#: collection_mapping.xml:566
#, no-c-format
msgid "Map key as basic type using <classname>@MapKeyColumn"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:569
#, no-c-format
msgid ""
"@Entity\n"
"public class Customer {\n"
" @Id @GeneratedValue public Integer getId() { return id; }\n"
" public void setId(Integer id) { this.id = id; }\n"
" private Integer id;\n"
"\n"
" @OneToMany @JoinTable(name=\"Cust_Order\")\n"
" @MapKeyColumn(name=\"orders_number\")\n"
" public Map<String,Order> getOrders() { return orders; }\n"
" public void setOrders(Map<String,Order> orders) { this.orders = "
"orders; }\n"
" private Map<String,Order> orders;\n"
"}\n"
"\n"
"@Entity\n"
"public class Order {\n"
" @Id @GeneratedValue public Integer getId() { return id; }\n"
" public void setId(Integer id) { this.id = id; }\n"
" private Integer id;\n"
"\n"
" public String getNumber() { return number; }\n"
" public void setNumber(String number) { this.number = number; }\n"
" private String number;\n"
"\n"
" @ManyToOne\n"
" public Customer getCustomer() { return customer; }\n"
" public void setCustomer(Customer customer) { this.customer = customer; }\n"
" private Customer number;\n"
"}\n"
"\n"
"-- Table schema\n"
"|-------------| |----------| |---------------|\n"
"| Order | | Customer | | Cust_Order |\n"
"|-------------| |----------| |---------------|\n"
"| id | | id | | customer_id |\n"
"| number | |----------| | order_id |\n"
"| customer_id | | orders_number |\n"
"|-------------| |---------------|"
msgstr ""
#. Tag: para
#: collection_mapping.xml:573
#, no-c-format
msgid ""
"We recommend you to migrate from <classname>@org.hibernate.annotations."
"MapKey</classname> / @org.hibernate.annotation.MapKeyManyToMany, "
"<literal><map-key-many-to-many> and <composite-"
"map-key></literal>. <map-key> is used for any "
"basic type, <literal><map-key-many-to-many> for an entity "
"reference and <literal><composite-map-key> for a composite "
"type."
msgstr ""
"除了 <literal><set>,还有<list>,"
"<literal><map>,<bag>,<"
"array></literal> å’Œ <primitive-array> æ˜ å°„å…ƒç´ ã€‚"
"<literal><map> 具有代表性:"
#. Tag: title
#: collection_mapping.xml:590
#, no-c-format
msgid "map-key xml mapping element"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:601
#, no-c-format
msgid ""
"<map-key\n"
" column=\"column_name\"\n"
" formula=\"any SQL expression\"\n"
" type=\"type_name\"\n"
" node=\"@attribute-name\"\n"
" length=\"N\"/>"
msgstr ""
#. Tag: para
#: collection_mapping.xml:605
#, no-c-format
msgid ""
"<literal>column (optional): the name of the column holding the "
"collection index values."
msgstr "<literal>column(å¯é€‰ï¼‰ï¼šæŒæœ‰é›†åˆç´¢å¼•å€¼çš„å—段的å称。"
#. Tag: para
#: collection_mapping.xml:610
#, no-c-format
msgid ""
"<literal>formula (optional): a SQL formula used to evaluate the "
"key of the map."
msgstr "<literal>formula(å¯é€‰ï¼‰ï¼šç”¨äºŽå¯¹è¡¨é”®æ±‚值的 SQL å…¬å¼ã€‚"
#. Tag: para
#: collection_mapping.xml:615
#, no-c-format
msgid "<literal>type (required): the type of the map keys."
msgstr "<literal>typeï¼ˆå¿…éœ€ï¼‰ï¼šæ˜ å°„é”®çš„ç±»åž‹ã€‚ "
#. Tag: title
#: collection_mapping.xml:623
#, fuzzy, no-c-format
msgid "map-key-many-to-many"
msgstr "多对多(many-to-many)"
#. Tag: programlisting
#: collection_mapping.xml:634
#, no-c-format
msgid ""
"<map-key-many-to-many\n"
" column=\"column_name\"\n"
" formula=\"any SQL expression\"\n"
" class=\"ClassName\"\n"
"/>"
msgstr ""
#. Tag: para
#: collection_mapping.xml:638
#, no-c-format
msgid ""
"<literal>column (optional): the name of the foreign key column for "
"the collection index values."
msgstr "<literal>column(å¯é€‰ï¼‰ï¼šç”¨äºŽé›†åˆç´¢å¼•å€¼çš„外键å—段的å称。"
#. Tag: para
#: collection_mapping.xml:643
#, no-c-format
msgid ""
"<literal>formula (optional): a SQ formula used to evaluate the "
"foreign key of the map key."
msgstr ""
"<literal>formula(å¯é€‰ï¼‰ï¼šç”¨äºŽå¯¹æ˜ 射键的外键求值的 SQL å…¬å¼ã€‚"
#. Tag: para
#: collection_mapping.xml:648
#, no-c-format
msgid ""
"<literal>class (required): the entity class used as the map key."
msgstr "<literal>classï¼ˆå¿…éœ€ï¼‰ï¼šç”¨ä½œæ˜ å°„é”®çš„å®žä½“ç±»çš„å称。 "
#. Tag: title
#: collection_mapping.xml:658
#, fuzzy, no-c-format
msgid "Collections of basic types and embeddable objects"
msgstr ""
"值集åˆäºŽå¤šå¯¹å¤šå…³è”(Collections of values and many-to-many associations)"
#. Tag: para
#: collection_mapping.xml:660
#, no-c-format
msgid ""
"In some situations you don't need to associate two entities but simply "
"create a collection of basic types or embeddable objects. Use the "
"<classname>@ElementCollection for this case."
msgstr ""
#. Tag: title
#: collection_mapping.xml:665
#, no-c-format
msgid ""
"Collection of basic types mapped via <classname>@ElementCollection annotation. If omitted the "
"collection table name defaults to the concatenation of the name of the "
"containing entity and the name of the collection attribute, separated by an "
"underscore. In our example, it would be <literal>User_nicknames."
msgstr ""
#. Tag: para
#: collection_mapping.xml:678
#, no-c-format
msgid ""
"The column holding the basic type is set using the <classname>@Column."
msgstr ""
#. Tag: para
#: collection_mapping.xml:683
#, no-c-format
msgid ""
"But you are not limited to basic types, the collection type can be any "
"embeddable object. To override the columns of the embeddable object in the "
"collection table, use the <classname>@AttributeOverride "
"annotation."
msgstr ""
#. Tag: title
#: collection_mapping.xml:689
#, no-c-format
msgid "@ElementCollection for embeddable objects"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:691
#, no-c-format
msgid ""
"@Entity\n"
"public class User {\n"
" [...]\n"
" public String getLastname() { ...}\n"
"\n"
" @ElementCollection\n"
" @CollectionTable(name=\"Addresses\", joinColumns=@JoinColumn(name="
"\"user_id\"))\n"
" @AttributeOverrides({\n"
" @AttributeOverride(name=\"street1\", column=@Column(name=\"fld_street"
"\"))\n"
" })\n"
" public Set<Address> getAddresses() { ... } \n"
"}\n"
"\n"
"@Embeddable\n"
"public class Address {\n"
" public String getStreet1() {...}\n"
" [...]\n"
"}"
msgstr ""
#. Tag: para
#: collection_mapping.xml:694
#, no-c-format
msgid "Such an embeddable object cannot contains a collection itself."
msgstr ""
#. Tag: para
#: collection_mapping.xml:698
#, no-c-format
msgid ""
"in <classname>@AttributeOverride, you must use the "
"<literal>value. prefix to override properties of the embeddable "
"object used in the map value and the <literal>key. prefix to "
"override properties of the embeddable object used in the map key."
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:704
#, no-c-format
msgid ""
"@Entity\n"
"public class User {\n"
" @ElementCollection\n"
" @AttributeOverrides({\n"
" @AttributeOverride(name=\"key.street1\", column=@Column(name="
"\"fld_street\")),\n"
" @AttributeOverride(name=\"value.stars\", column=@Column(name=\"fld_note"
"\"))\n"
" })\n"
" public Map<Address,Rating> getFavHomes() { ... }"
msgstr ""
#. Tag: para
#: collection_mapping.xml:708
#, no-c-format
msgid ""
"We recommend you to migrate from <classname>@org.hibernate.annotations."
"CollectionOfElements</classname> to the new @ElementCollection tag. For example:"
msgstr ""
"对于一个值集åˆï¼Œæˆ‘们使用 <literal><element> æ ‡ç¾ã€‚例如:"
#. Tag: title
#: collection_mapping.xml:718
#, no-c-format
msgid "<element> tag for collection values using mapping files"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:730
#, no-c-format
msgid ""
"<element\n"
" column=\"column_name\"\n"
" formula=\"any SQL expression\"\n"
" type=\"typename\"\n"
" length=\"L\"\n"
" precision=\"P\"\n"
" scale=\"S\"\n"
" not-null=\"true|false\"\n"
" unique=\"true|false\"\n"
" node=\"element-name\"\n"
"/>"
msgstr ""
#. Tag: para
#: collection_mapping.xml:734
#, no-c-format
msgid ""
"<literal>column (optional): the name of the column holding the "
"collection element values."
msgstr "<literal>column(å¯é€‰ï¼‰ï¼šæŒæœ‰é›†åˆå…ƒç´ 值的å—段的å称。"
#. Tag: para
#: collection_mapping.xml:739
#, no-c-format
msgid ""
"<literal>formula (optional): an SQL formula used to evaluate the "
"element."
msgstr "<literal>formula(å¯é€‰ï¼‰ï¼šç”¨äºŽå¯¹å…ƒç´ 求值的 SQL å…¬å¼ã€‚"
#. Tag: para
#: collection_mapping.xml:744
#, no-c-format
msgid "<literal>type (required): the type of the collection element."
msgstr "<literal>type(必需):集åˆå…ƒç´ 的类型。 "
#. Tag: title
#: collection_mapping.xml:754
#, no-c-format
msgid "Advanced collection mappings"
msgstr "高级集åˆæ˜ 射(Advanced collection mappings)"
#. Tag: title
#: collection_mapping.xml:757
#, no-c-format
msgid "Sorted collections"
msgstr "有åºé›†åˆï¼ˆSorted collections)"
#. Tag: para
#: collection_mapping.xml:759
#, no-c-format
msgid ""
"Hibernate supports collections implementing <literal>java.util.SortedMapjava.util.SortedSet. With annotations you "
"declare a sort comparator using <literal>@Sort. You chose between "
"the comparator types unsorted, natural or custom. If you want to use your "
"own comparator implementation, you'll also have to specify the "
"implementation class using the <literal>comparator attribute. Note "
"that you need to use either a <classname>SortedSet or a "
"<classname>SortedMap interface."
msgstr ""
#. Tag: title
#: collection_mapping.xml:770
#, fuzzy, no-c-format
msgid "Sorted collection with @Sort"
msgstr "有åºé›†åˆï¼ˆSorted collections)"
#. Tag: programlisting
#: collection_mapping.xml:772
#, no-c-format
msgid ""
"@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)\n"
"@JoinColumn(name=\"CUST_ID\")\n"
"@Sort(type = SortType.COMPARATOR, comparator = TicketComparator.class)\n"
"public SortedSet<Ticket> getTickets() {\n"
" return tickets;\n"
"}"
msgstr ""
#. Tag: para
#: collection_mapping.xml:775
#, no-c-format
msgid ""
"Using Hibernate mapping files you specify a comparator in the mapping file "
"with <literal><sort>:"
msgstr ""
#. Tag: title
#: collection_mapping.xml:779
#, fuzzy, no-c-format
msgid "Sorted collection using xml mapping"
msgstr "有åºé›†åˆï¼ˆSorted collections)"
#. Tag: programlisting
#: collection_mapping.xml:781
#, fuzzy, no-c-format
msgid ""
"<set name=\"aliases\"\n"
" table=\"person_aliases\" \n"
" sort=\"natural\">\n"
" <key column=\"person\"/>\n"
" <element column=\"name\" type=\"string\"/>\n"
"</set>\n"
"\n"
"<map name=\"holidays\" sort=\"my.custom.HolidayComparator\">\n"
" <key column=\"year_id\"/>\n"
" <map-key column=\"hol_name\" type=\"string\"/>\n"
" <element column=\"hol_date\" type=\"date\"/>\n"
"</map>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:784
#, no-c-format
msgid ""
"Allowed values of the <literal>sort attribute are "
"<literal>unsorted, natural and the name of a "
"class implementing <literal>java.util.Comparator."
msgstr ""
"<literal>sort 属性ä¸å…许的值包括 unsorted,"
"<literal>natural å’ŒæŸä¸ªå®žçŽ°äº† java.util.Comparator "
"or <literal>java.util.TreeMap."
msgstr ""
"分类集åˆçš„行为事实上象 <literal>java.util.TreeSet 或者 "
"<literal>java.util.TreeMap。"
#. Tag: para
#: collection_mapping.xml:794
#, fuzzy, no-c-format
msgid ""
"If you want the database itself to order the collection elements, use the "
"<literal>order-by attribute of set, "
"<literal>bag or map mappings. This solution is "
"implemented using <literal>LinkedHashSet or "
"<literal>LinkedHashMap and performs the ordering in the SQL query "
"and not in the memory."
msgstr ""
"å¦‚æžœä½ å¸Œæœ›æ•°æ®åº“自己对集åˆå…ƒç´ 排åºï¼Œå¯ä»¥åˆ©ç”¨ <literal>set,"
"<literal>bag 或者 map æ˜ å°„ä¸çš„ order-"
"by</literal> 属性。这个解决方案åªèƒ½åœ¨ jdk1.4 或者更高的 jdk 版本ä¸æ‰å¯ä»¥å®žçŽ°"
"(通过 LinkedHashSet 或者 LinkedHashMap 实现)。它是在 SQL 查询ä¸å®ŒæˆæŽ’åºï¼Œè€Œ"
"ä¸æ˜¯åœ¨å†…å˜ä¸ã€‚ "
#. Tag: title
#: collection_mapping.xml:802
#, no-c-format
msgid "Sorting in database using order-by"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:804
#, fuzzy, no-c-format
msgid ""
"<set name=\"aliases\" table=\"person_aliases\" order-by=\"lower(name) asc"
"\">\n"
" <key column=\"person\"/>\n"
" <element column=\"name\" type=\"string\"/>\n"
"</set>\n"
"\n"
"<map name=\"holidays\" order-by=\"hol_date, hol_name\">\n"
" <key column=\"year_id\"/>\n"
" <map-key column=\"hol_name\" type=\"string\"/>\n"
" <element column=\"hol_date type=\"date\"/>\n"
"</map>"
msgstr ""
"<![CDATA["
#. Tag: title
#: collection_mapping.xml:808
#, no-c-format
msgid "Note"
msgstr "注æ„"
#. Tag: para
#: collection_mapping.xml:810
#, no-c-format
msgid ""
"The value of the <literal>order-by attribute is an SQL ordering, "
"not an HQL ordering."
msgstr ""
"注æ„:这个 <literal>order-by 属性的值是一个 SQL 排åºåå¥è€Œä¸æ˜¯ HQL "
"的。"
#. Tag: para
#: collection_mapping.xml:814
#, no-c-format
msgid ""
"Associations can even be sorted by arbitrary criteria at runtime using a "
"collection <literal>filter():"
msgstr ""
"å…³è”还å¯ä»¥åœ¨è¿è¡Œæ—¶ä½¿ç”¨é›†åˆ <literal>filter() æ ¹æ®ä»»æ„çš„æ¡ä»¶æ¥æŽ’åºï¼š"
#. Tag: title
#: collection_mapping.xml:818
#, no-c-format
msgid "Sorting via a query filter"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:820
#, fuzzy, no-c-format
msgid ""
"sortedUsers = s.createFilter( group.getUsers(), \"order by this.name\" ).list"
"();"
msgstr ""
"<![CDATA[sortedUsers = s.createFilter( group.getUsers(), \"order by this.name"
"\" ).list();]]>"
#. Tag: title
#: collection_mapping.xml:825
#, no-c-format
msgid "Bidirectional associations"
msgstr "åŒå‘å…³è”(Bidirectional associations)"
#. Tag: para
#: collection_mapping.xml:827
#, no-c-format
msgid ""
"A <emphasis>bidirectional association allows navigation from both "
"\"ends\" of the association. Two kinds of bidirectional association are "
"supported:"
msgstr ""
"<emphasis>åŒå‘å…³è”å…许通过关è”的任一端访问å¦å¤–一端。在 Hibernate "
"ä¸ï¼Œæ”¯æŒä¸¤ç§ç±»åž‹çš„åŒå‘å…³è”: "
#. Tag: term
#: collection_mapping.xml:831
#, no-c-format
msgid "one-to-many"
msgstr "一对多(one-to-many)"
#. Tag: para
#: collection_mapping.xml:834
#, no-c-format
msgid "set or bag valued at one end and single-valued at the other"
msgstr "Set 或者 bag 值在一端,å•ç‹¬å€¼ï¼ˆéžé›†åˆï¼‰åœ¨å¦å¤–一端 "
#. Tag: term
#: collection_mapping.xml:840
#, no-c-format
msgid "many-to-many"
msgstr "多对多(many-to-many)"
#. Tag: para
#: collection_mapping.xml:843
#, no-c-format
msgid "set or bag valued at both ends"
msgstr "两端都是 set 或 bag 值"
#. Tag: para
#: collection_mapping.xml:848
#, no-c-format
msgid ""
"Often there exists a many to one association which is the owner side of a "
"bidirectional relationship. The corresponding one to many association is in "
"this case annotated by <literal>@OneToMany(mappedBy=...)"
msgstr ""
#. Tag: title
#: collection_mapping.xml:854
#, no-c-format
msgid "Bidirectional one to many with many to one side as association owner"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:857
#, no-c-format
msgid ""
"@Entity\n"
"public class Troop {\n"
" @OneToMany(mappedBy=\"troop\")\n"
" public Set<Soldier> getSoldiers() {\n"
" ...\n"
"}\n"
"\n"
"@Entity\n"
"public class Soldier {\n"
" @ManyToOne\n"
" @JoinColumn(name=\"troop_fk\")\n"
" public Troop getTroop() {\n"
" ...\n"
"}"
msgstr ""
#. Tag: para
#: collection_mapping.xml:860
#, no-c-format
msgid ""
"<classname>Troop has a bidirectional one to many relationship "
"with <literal>Soldier through the troop "
"property. You don't have to (must not) define any physical mapping in the "
"<literal>mappedBy side."
msgstr ""
#. Tag: para
#: collection_mapping.xml:865
#, no-c-format
msgid ""
"To map a bidirectional one to many, with the one-to-many side as the owning "
"side, you have to remove the <literal>mappedBy element and set the "
"many to one <literal>@JoinColumn as insertable and updatable to "
"false. This solution is not optimized and will produce additional UPDATE "
"statements."
msgstr ""
#. Tag: title
#: collection_mapping.xml:872
#, fuzzy, no-c-format
msgid "Bidirectional associtaion with one to many side as owner"
msgstr "åŒå‘å…³è”,涉åŠæœ‰åºé›†åˆç±»"
#. Tag: programlisting
#: collection_mapping.xml:875
#, no-c-format
msgid ""
"@Entity\n"
"public class Troop {\n"
" @OneToMany\n"
" @JoinColumn(name=\"troop_fk\") //we need to duplicate the physical "
"information\n"
" public Set<Soldier> getSoldiers() {\n"
" ...\n"
"}\n"
"\n"
"@Entity\n"
"public class Soldier {\n"
" @ManyToOne\n"
" @JoinColumn(name=\"troop_fk\", insertable=false, updatable=false)\n"
" public Troop getTroop() {\n"
" ...\n"
"}"
msgstr ""
#. Tag: para
#: collection_mapping.xml:878
#, fuzzy, no-c-format
msgid ""
"How does the mappping of a bidirectional mapping look like in Hibernate "
"mapping xml? There you define a bidirectional one-to-many association by "
"mapping a one-to-many association to the same table column(s) as a many-to-"
"one association and declaring the many-valued end <literal>inverse=\"true\""
#. Tag: para
#: collection_mapping.xml:890
#, no-c-format
msgid ""
"Mapping one end of an association with <literal>inverse=\"true\" "
"does not affect the operation of cascades as these are orthogonal concepts."
msgstr ""
"在“一â€è¿™ä¸€ç«¯å®šä¹‰ <literal>inverse=\"true\" ä¸ä¼šå½±å“级è”æ“作,二者是"
"æ£äº¤çš„概念。"
#. Tag: para
#: collection_mapping.xml:894
#, no-c-format
msgid ""
"A many-to-many association is defined logically using the "
"<literal>@ManyToMany annotation. You also have to describe the "
"association table and the join conditions using the <literal>@JoinTable defines a name primary key (the \"other side\"). As seen "
"previously, the other side don't have to (must not) describe the physical "
"mapping: a simple <literal>mappedBy argument containing the owner "
"side property name bind the two."
msgstr ""
#. Tag: para
#: collection_mapping.xml:919
#, no-c-format
msgid ""
"As any other annotations, most values are guessed in a many to many "
"relationship. Without describing any physical mapping in a unidirectional "
"many to many the following rules applied. The table name is the "
"concatenation of the owner table name, <keycap>_ and the other side "
"table name. The foreign key name(s) referencing the owner table is the "
"concatenation of the owner table name, <keycap>_ and the owner "
"primary key column(s). The foreign key name(s) referencing the other side is "
"the concatenation of the owner property name, <keycap>_, and the "
"other side primary key column(s). These are the same rules used for a "
"unidirectional one to many relationship."
msgstr ""
#. Tag: title
#: collection_mapping.xml:932
#, no-c-format
msgid "Default values for <classname>@ManyToMany (uni-directional)"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:935
#, no-c-format
msgid ""
"@Entity\n"
"public class Store {\n"
" @ManyToMany(cascade = CascadeType.PERSIST)\n"
" public Set<City> getImplantedIn() {\n"
" ...\n"
" }\n"
"}\n"
"\n"
"@Entity\n"
"public class City {\n"
" ... //no bidirectional relationship\n"
"}"
msgstr ""
#. Tag: para
#: collection_mapping.xml:938
#, no-c-format
msgid ""
"A <literal>Store_City is used as the join table. The "
"<literal>Store_id column is a foreign key to the StoreimplantedIn_id column is a foreign "
"key to the <literal>City table."
msgstr ""
#. Tag: para
#: collection_mapping.xml:943
#, no-c-format
msgid ""
"Without describing any physical mapping in a bidirectional many to many the "
"following rules applied. The table name is the concatenation of the owner "
"table name, <keycap>_ and the other side table name. The foreign "
"key name(s) referencing the owner table is the concatenation of the other "
"side property name, <keycap>_, and the owner primary key column(s). "
"The foreign key name(s) referencing the other side is the concatenation of "
"the owner property name, <keycap>_, and the other side primary key "
"column(s). These are the same rules used for a unidirectional one to many "
"relationship."
msgstr ""
#. Tag: title
#: collection_mapping.xml:955
#, no-c-format
msgid "Default values for <classname>@ManyToMany (bi-directional)"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:958
#, no-c-format
msgid ""
"@Entity\n"
"public class Store {\n"
" @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})\n"
" public Set<Customer> getCustomers() {\n"
" ...\n"
" }\n"
"}\n"
"\n"
"@Entity\n"
"public class Customer {\n"
" @ManyToMany(mappedBy=\"customers\")\n"
" public Set<Store> getStores() {\n"
" ...\n"
" }\n"
"}"
msgstr ""
#. Tag: para
#: collection_mapping.xml:961
#, no-c-format
msgid ""
"A <literal>Store_Customer is used as the join table. The "
"<literal>stores_id column is a foreign key to the Storecustomers_id column is a foreign key "
"to the <literal>Customer table."
msgstr ""
#. Tag: para
#: collection_mapping.xml:966
#, fuzzy, no-c-format
msgid ""
"Using Hibernate mapping files you can map a bidirectional many-to-many "
"association by mapping two many-to-many associations to the same database "
"table and declaring one end as <emphasis>inverse."
msgstr ""
"è¦å»ºç«‹ä¸€ä¸ªåŒå‘的多对多关è”,åªéœ€è¦æ˜ 射两个 many-to-many å…³è”到åŒä¸€ä¸ªæ•°æ®åº“表"
"ä¸ï¼Œå¹¶å†å®šä¹‰å…¶ä¸çš„一端为 <emphasis>inverse(使用哪一端è¦æ ¹æ®ä½ 的选"
"择,但它ä¸èƒ½æ˜¯ä¸€ä¸ªç´¢å¼•é›†åˆï¼‰ã€‚ "
#. Tag: para
#: collection_mapping.xml:970
#, no-c-format
msgid "You cannot select an indexed collection."
msgstr ""
#. Tag: para
#: collection_mapping.xml:973
#, fuzzy, no-c-format
msgid ""
"shows a bidirectional many-to-many association that illustrates how each "
"category can have many items and each item can be in many categories:"
msgstr ""
"这里有一个 many-to-many çš„åŒå‘å…³è”的例å;æ¯ä¸€ä¸ª category 都å¯ä»¥æœ‰å¾ˆå¤š items,"
"æ¯ä¸€ä¸ª items å¯ä»¥å±žäºŽå¾ˆå¤š categories: "
#. Tag: title
#: collection_mapping.xml:979
#, no-c-format
msgid "Many to many association using Hibernate mapping files"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:981
#, fuzzy, no-c-format
msgid ""
"<class name=\"Category\">\n"
" <id name=\"id\" column=\"CATEGORY_ID\"/>\n"
" ...\n"
" <bag name=\"items\" table=\"CATEGORY_ITEM\">\n"
" <key column=\"CATEGORY_ID\"/>\n"
" <many-to-many class=\"Item\" column=\"ITEM_ID\"/>\n"
" </bag>\n"
"</class>\n"
"\n"
"<class name=\"Item\">\n"
" <id name=\"id\" column=\"ITEM_ID\"/>\n"
" ...\n"
"\n"
" <!-- inverse end -->\n"
" <bag name=\"categories\" table=\"CATEGORY_ITEM\" inverse=\"true"
"\">\n"
" <key column=\"ITEM_ID\"/>\n"
" <many-to-many class=\"Category\" column=\"CATEGORY_ID\"/>\n"
" </bag>\n"
"</class>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:984
#, no-c-format
msgid ""
"Changes made only to the inverse end of the association are <emphasis>not被æŒä¹…化。 "
"这表示 Hibernate 为æ¯ä¸ªåŒå‘å…³è”在内å˜ä¸å˜åœ¨ä¸¤æ¬¡è¡¨çŽ°ï¼Œä¸€ä¸ªä»Ž A 连接到 B,å¦ä¸€"
"个从 B 连接到 Aã€‚å¦‚æžœä½ å›žæƒ³ä¸€ä¸‹ Java 对象模型,我们是如何在 Java ä¸åˆ›å»ºå¤šå¯¹å¤š"
"关系的,这å¯ä»¥è®©ä½ 更容易ç†è§£ï¼š "
#. Tag: title
#: collection_mapping.xml:992
#, fuzzy, no-c-format
msgid "Effect of inverse vs. non-inverse side of many to many associations"
msgstr ""
"值集åˆäºŽå¤šå¯¹å¤šå…³è”(Collections of values and many-to-many associations)"
#. Tag: programlisting
#: collection_mapping.xml:995
#, fuzzy, no-c-format
msgid ""
"category.getItems().add(item); // The category now \"knows\" about "
"the relationship\n"
"item.getCategories().add(category); // The item now \"knows\" about the "
"relationship\n"
"\n"
"session.persist(item); // The relationship won't be "
"saved!\n"
"session.persist(category); // The relationship will be saved"
msgstr ""
"<![CDATA[\n"
"category.getItems().add(item); // The category now \"knows\" about "
"the relationship\n"
"item.getCategories().add(category); // The item now \"knows\" about the "
"relationship\n"
"\n"
"session.persist(item); // The relationship won't be "
"saved!\n"
"session.persist(category); // The relationship will be saved]]>"
#. Tag: para
#: collection_mapping.xml:998
#, no-c-format
msgid ""
"The non-inverse side is used to save the in-memory representation to the "
"database."
msgstr "éžåå‘端用于把内å˜ä¸çš„表示ä¿å˜åˆ°æ•°æ®åº“ä¸ã€‚"
#. Tag: title
#: collection_mapping.xml:1003
#, no-c-format
msgid "Bidirectional associations with indexed collections"
msgstr "åŒå‘å…³è”,涉åŠæœ‰åºé›†åˆç±»"
#. Tag: para
#: collection_mapping.xml:1005
#, fuzzy, no-c-format
msgid ""
"There are some additional considerations for bidirectional mappings with "
"indexed collections (where one end is represented as a <literal><list>"
"</literal> or <map>) when using Hibernate mapping "
"files. If there is a property of the child class that maps to the index "
"column you can use <literal>inverse=\"true\" on the collection "
"mapping:"
msgstr ""
"对于有一端是 <literal><list> 或者 <map>: "
#. Tag: title
#: collection_mapping.xml:1013
#, fuzzy, no-c-format
msgid "Bidirectional association with indexed collection"
msgstr "åŒå‘å…³è”,涉åŠæœ‰åºé›†åˆç±»"
#. Tag: programlisting
#: collection_mapping.xml:1015
#, fuzzy, no-c-format
msgid ""
"<class name=\"Parent\">\n"
" <id name=\"id\" column=\"parent_id\"/>\n"
" ....\n"
" <map name=\"children\" inverse=\"true\">\n"
" <key column=\"parent_id\"/>\n"
" <map-key column=\"name\" \n"
" type=\"string\"/>\n"
" <one-to-many class=\"Child\"/>\n"
" </map>\n"
"</class>\n"
"\n"
"<class name=\"Child\">\n"
" <id name=\"id\" column=\"child_id\"/>\n"
" ....\n"
" <property name=\"name\" \n"
" not-null=\"true\"/>\n"
" <many-to-one name=\"parent\" \n"
" class=\"Parent\" \n"
" column=\"parent_id\"\n"
" not-null=\"true\"/>\n"
"</class>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:1018
#, no-c-format
msgid ""
"If there is no such property on the child class, the association cannot be "
"considered truly bidirectional. That is, there is information available at "
"one end of the association that is not available at the other end. In this "
"case, you cannot map the collection <literal>inverse=\"true\". "
"Instead, you could use the following mapping:"
msgstr ""
"但是,å‡è‹¥åç±»ä¸æ²¡æœ‰è¿™æ ·çš„属性å˜åœ¨ï¼Œæˆ‘们ä¸èƒ½è®¤ä¸ºè¿™ä¸ªå…³è”是真æ£çš„åŒå‘å…³è”(信"
"æ¯ä¸å¯¹ç§°ï¼Œåœ¨å…³è”的一端有一些å¦å¤–一端没有的信æ¯ï¼‰ã€‚在这ç§æƒ…况下,我们ä¸èƒ½ä½¿ç”¨ "
"<literal>inverse=\"true\"。我们需è¦è¿™æ ·ç”¨ï¼š "
#. Tag: title
#: collection_mapping.xml:1026
#, fuzzy, no-c-format
msgid "Bidirectional association with indexed collection, but no index column"
msgstr "åŒå‘å…³è”,涉åŠæœ‰åºé›†åˆç±»"
#. Tag: programlisting
#: collection_mapping.xml:1029
#, fuzzy, no-c-format
msgid ""
"<class name=\"Parent\">\n"
" <id name=\"id\" column=\"parent_id\"/>\n"
" ....\n"
" <map name=\"children\">\n"
" <key column=\"parent_id\"\n"
" not-null=\"true\"/>\n"
" <map-key column=\"name\" \n"
" type=\"string\"/>\n"
" <one-to-many class=\"Child\"/>\n"
" </map>\n"
"</class>\n"
"\n"
"<class name=\"Child\">\n"
" <id name=\"id\" column=\"child_id\"/>\n"
" ....\n"
" <many-to-one name=\"parent\" \n"
" class=\"Parent\" \n"
" column=\"parent_id\"\n"
" insert=\"false\"\n"
" update=\"false\"\n"
" not-null=\"true\"/>\n"
"</class>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:1032
#, no-c-format
msgid ""
"Note that in this mapping, the collection-valued end of the association is "
"responsible for updates to the foreign key."
msgstr "注æ„åœ¨è¿™ä¸ªæ˜ å°„ä¸ï¼Œå…³è”ä¸é›†åˆç±»\"值\"一端负责æ¥æ›´æ–°å¤–键。"
#. Tag: title
#: collection_mapping.xml:1037
#, no-c-format
msgid "Ternary associations"
msgstr "三é‡å…³è”(Ternary associations)"
#. Tag: para
#: collection_mapping.xml:1039
#, no-c-format
msgid ""
"There are three possible approaches to mapping a ternary association. One "
"approach is to use a <literal>Map with an association as its index:"
msgstr ""
"有三ç§å¯èƒ½çš„途径æ¥æ˜ 射一个三é‡å…³è”。第一ç§æ˜¯ä½¿ç”¨ä¸€ä¸ª <literal>Map,"
"把一个关è”作为其索引: "
#. Tag: title
#: collection_mapping.xml:1044
#, fuzzy, no-c-format
msgid "Ternary association mapping"
msgstr "三é‡å…³è”(Ternary associations)"
#. Tag: programlisting
#: collection_mapping.xml:1046
#, no-c-format
msgid ""
"@Entity\n"
"public class Company {\n"
" @Id \n"
" int id;\n"
" ...\n"
" @OneToMany // unidirectional\n"
" @MapKeyJoinColumn(name=\"employee_id\")\n"
" Map<Employee, Contract> contracts;\n"
"}\n"
"\n"
"// or\n"
"\n"
"<map name=\"contracts\">\n"
" <key column=\"employer_id\" not-null=\"true\"/>\n"
" <map-key-many-to-many column=\"employee_id\" class=\"Employee\"/>\n"
" <one-to-many class=\"Contract\"/>\n"
"</map>"
msgstr ""
#. Tag: para
#: collection_mapping.xml:1049
#, fuzzy, no-c-format
msgid ""
"A second approach is to remodel the association as an entity class. This is "
"the most common approach. A final alternative is to use composite elements, "
"which will be discussed later."
msgstr ""
"第二ç§æ–¹æ³•æ˜¯ç®€å•çš„把关è”é‡æ–°å»ºæ¨¡ä¸ºä¸€ä¸ªå®žä½“类。这使我们最ç»å¸¸ä½¿ç”¨çš„方法。 "
#. Tag: literal
#: collection_mapping.xml:1055
#, fuzzy, no-c-format
msgid "Using an <idbag>"
msgstr "<literal>使用 an <idbag> "
#. Tag: para
#: collection_mapping.xml:1057
#, fuzzy, no-c-format
msgid ""
"The majority of the many-to-many associations and collections of values "
"shown previously all map to tables with composite keys, even though it has "
"been suggested that entities should have synthetic identifiers (surrogate "
"keys). A pure association table does not seem to benefit much from a "
"surrogate key, although a collection of composite values <emphasis>might会获得一点好处)。ä¸è¿‡ï¼Œ"
"Hibernate æä¾›äº†ä¸€ä¸ªï¼ˆä¸€ç‚¹ç‚¹è¯•éªŒæ€§è´¨çš„ï¼‰åŠŸèƒ½ï¼Œè®©ä½ æŠŠå¤šå¯¹å¤šå…³è”和值集åˆåº”得到"
"ä¸€ä¸ªä½¿ç”¨ä»£ç”¨æ ‡è¯†ç¬¦çš„è¡¨åŽ»ã€‚ "
#. Tag: para
#: collection_mapping.xml:1066
#, no-c-format
msgid ""
"The <literal><idbag> element lets you map a ListCollection) with bag semantics. For example:"
msgstr ""
"<literal><idbag> å±žæ€§è®©ä½ ä½¿ç”¨ bag è¯ä¹‰æ¥æ˜ 射一个 "
"<literal>List (或 Collection)。 "
#. Tag: programlisting
#: collection_mapping.xml:1070
#, fuzzy, no-c-format
msgid ""
"<idbag name=\"lovers\" table=\"LOVERS\">\n"
" <collection-id column=\"ID\" type=\"long\">\n"
" <generator class=\"sequence\"/>\n"
" </collection-id>\n"
" <key column=\"PERSON1\"/>\n"
" <many-to-many column=\"PERSON2\" class=\"Person\" fetch=\"join\"/"
">\n"
"</idbag>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:1072
#, no-c-format
msgid ""
"An <literal><idbag> has a synthetic id generator, just like "
"an entity class. A different surrogate key is assigned to each collection "
"row. Hibernate does not, however, provide any mechanism for discovering the "
"surrogate key value of a particular row."
msgstr ""
"ä½ å¯ä»¥ç†è§£ï¼Œ<literal><idbag> 人工的 id 生æˆå™¨ï¼Œå°±å¥½åƒæ˜¯å®žä½“ç±»"
"ä¸€æ ·ï¼é›†åˆçš„æ¯ä¸€è¡Œéƒ½æœ‰ä¸€ä¸ªä¸åŒçš„äººé€ å…³é”®å—。但是,Hibernate 没有æ供任何机制"
"æ¥è®©ä½ å–å¾—æŸä¸ªç‰¹å®šè¡Œçš„äººé€ å…³é”®å—。 "
#. Tag: para
#: collection_mapping.xml:1077
#, no-c-format
msgid ""
"The update performance of an <literal><idbag> supersedes a "
"regular <literal><bag>. Hibernate can locate individual rows "
"efficiently and update or delete them individually, similar to a list, map "
"or set."
msgstr ""
"æ³¨æ„ <literal><idbag> 的更新性能è¦æ¯”普通的 <"
"bag></literal> 高得多ï¼Hibernate å¯ä»¥æœ‰æ•ˆçš„定ä½åˆ°ä¸åŒçš„行,分别进行更新或"
"åˆ é™¤å·¥ä½œï¼Œå°±å¦‚åŒå¤„ç†ä¸€ä¸ª list,map 或者 set ä¸€æ ·ã€‚ "
#. Tag: para
#: collection_mapping.xml:1082
#, no-c-format
msgid ""
"In the current implementation, the <literal>native identifier "
"generation strategy is not supported for <literal><idbag> "
"collection identifiers."
msgstr ""
"在目å‰çš„实现ä¸ï¼Œè¿˜ä¸æ”¯æŒä½¿ç”¨ <literal>identity æ ‡è¯†ç¬¦ç”Ÿæˆå™¨ç–ç•¥æ¥ç”Ÿ"
"æˆ <literal><idbag> 集åˆçš„æ ‡è¯†ç¬¦ã€‚"
#. Tag: title
#: collection_mapping.xml:1103
#, no-c-format
msgid "Collection examples"
msgstr "集åˆä¾‹å(Collection example)"
#. Tag: para
#: collection_mapping.xml:1105
#, no-c-format
msgid "This section covers collection examples."
msgstr "集åˆä¾‹å(Collection example)。"
#. Tag: para
#: collection_mapping.xml:1107
#, no-c-format
msgid ""
"The following class has a collection of <literal>Child instances:"
msgstr "下é¢çš„代ç 是用æ¥æ·»åŠ 一个新的 <literal>Child:"
#. Tag: title
#: collection_mapping.xml:1111
#, no-c-format
msgid ""
"Example classes <classname>Parent and Child 的实例集åˆã€‚如果æ¯ä¸€ä¸ªå实例至多有一个"
"çˆ¶å®žä¾‹ï¼Œé‚£ä¹ˆæœ€è‡ªç„¶çš„æ˜ å°„æ˜¯ä¸€ä¸ª one-to-many çš„å…³è”关系: "
#. Tag: title
#: collection_mapping.xml:1121
#, no-c-format
msgid ""
"One to many unidirectional <classname>Parent-Child relationship "
"using annotations"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1124
#, no-c-format
msgid ""
"public class Parent {\n"
" @Id\n"
" @GeneratedValue\n"
" private long id;\n"
"\n"
" @OneToMany\n"
" private Set<Child> children;\n"
"\n"
" // getter/setter\n"
" ...\n"
"}\n"
"\n"
"\n"
"public class Child {\n"
" @Id\n"
" @GeneratedValue\n"
" private long id;\n"
" private String name;\n"
"\n"
" \n"
" // getter/setter\n"
" ...\n"
"}"
msgstr ""
#. Tag: title
#: collection_mapping.xml:1128
#, no-c-format
msgid ""
"One to many unidirectional <classname>Parent-Child relationship "
"using mapping files"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1131
#, fuzzy, no-c-format
msgid ""
"<hibernate-mapping>\n"
"\n"
" <class name=\"Parent\">\n"
" <id name=\"id\">\n"
" <generator class=\"sequence\"/>\n"
" </id>\n"
" <set name=\"children\">\n"
" <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n"
" </set>\n"
" </class>\n"
"\n"
" <class name=\"Child\">\n"
" <id name=\"id\">\n"
" <generator class=\"sequence\"/>\n"
" </id>\n"
" <property name=\"name\"/>\n"
" </class>\n"
"\n"
"</hibernate-mapping>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:1134
#, no-c-format
msgid "This maps to the following table definitions:"
msgstr "在以下的表定义ä¸ååº”äº†è¿™ä¸ªæ˜ å°„å…³ç³»ï¼š"
#. Tag: title
#: collection_mapping.xml:1137
#, no-c-format
msgid ""
"Table definitions for unidirectional <classname>Parent-"
"<classname>Child relationship"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1141
#, fuzzy, no-c-format
msgid ""
"create table parent ( id bigint not null primary key )\n"
"create table child ( id bigint not null primary key, name varchar(255), "
"parent_id bigint )\n"
"alter table child add constraint childfk0 (parent_id) references parent"
msgstr ""
"<![CDATA[create table parent ( id bigint not null primary key )\n"
"create table child ( id bigint not null primary key, name varchar(255), "
"parent_id bigint )\n"
"alter table child add constraint childfk0 (parent_id) references parent]]>"
#. Tag: para
#: collection_mapping.xml:1144
#, no-c-format
msgid ""
"If the parent is <emphasis>required, use a bidirectional one-to-"
"many association:"
msgstr ""
"如果父亲是<emphasis>必须的,那么就å¯ä»¥ä½¿ç”¨åŒå‘ one-to-many çš„å…³è”"
"了:"
#. Tag: title
#: collection_mapping.xml:1148
#, no-c-format
msgid ""
"One to many bidirectional <classname>Parent-Child relationship "
"using annotations"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1151
#, no-c-format
msgid ""
"public class Parent {\n"
" @Id\n"
" @GeneratedValue\n"
" private long id;\n"
"\n"
" @OneToMany(mappedBy=\"parent\")\n"
" private Set<Child> children;\n"
"\n"
" // getter/setter\n"
" ...\n"
"}\n"
"\n"
"\n"
"public class Child {\n"
" @Id\n"
" @GeneratedValue\n"
" private long id;\n"
"\n"
" private String name;\n"
" \n"
" @ManyToOne\n"
" private Parent parent;\n"
"\n"
" \n"
" // getter/setter\n"
" ...\n"
"}"
msgstr ""
#. Tag: title
#: collection_mapping.xml:1155
#, no-c-format
msgid ""
"One to many bidirectional <classname>Parent-Child relationship "
"using mapping files"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1158
#, fuzzy, no-c-format
msgid ""
"<hibernate-mapping>\n"
"\n"
" <class name=\"Parent\">\n"
" <id name=\"id\">\n"
" <generator class=\"sequence\"/>\n"
" </id>\n"
" <set name=\"children\" inverse=\"true\">\n"
" <key column=\"parent_id\"/>\n"
" <one-to-many class=\"Child\"/>\n"
" </set>\n"
" </class>\n"
"\n"
" <class name=\"Child\">\n"
" <id name=\"id\">\n"
" <generator class=\"sequence\"/>\n"
" </id>\n"
" <property name=\"name\"/>\n"
" <many-to-one name=\"parent\" class=\"Parent\" column=\"parent_id"
"\" not-null=\"true\"/>\n"
" </class>\n"
"\n"
"</hibernate-mapping>"
msgstr ""
"<![CDATA[\n"" "<="" hibernate-mapping>]]="">"
#. Tag: para
#: collection_mapping.xml:1161
#, no-c-format
msgid "Notice the <literal>NOT NULL constraint:"
msgstr "è¯·æ³¨æ„ <literal>NOT NULL 的约æŸ:"
#. Tag: title
#: collection_mapping.xml:1164
#, no-c-format
msgid ""
"Table definitions for bidirectional <classname>Parent-"
"<classname>Child relationship"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1168
#, fuzzy, no-c-format
msgid ""
"create table parent ( id bigint not null primary key )\n"
"create table child ( id bigint not null\n"
" primary key,\n"
" name varchar(255),\n"
" parent_id bigint not null )\n"
"alter table child add constraint childfk0 (parent_id) references parent"
msgstr ""
"<![CDATA[create table parent ( id bigint not null primary key )\n"
"create table child ( id bigint not null\n"
" primary key,\n"
" name varchar(255),\n"
" parent_id bigint not null )\n"
"alter table child add constraint childfk0 (parent_id) references parent]]>"
#. Tag: para
#: collection_mapping.xml:1171
#, fuzzy, no-c-format
msgid ""
"Alternatively, if this association must be unidirectional you can enforce "
"the <literal>NOT NULL constraint."
msgstr ""
"å¦å¤–ï¼Œå¦‚æžœä½ ç»å¯¹åšæŒè¿™ä¸ªå…³è”应该是å•å‘çš„ï¼Œä½ å¯ä»¥å¯¹ <literal><key>NOT NULL 约æŸï¼š "
#. Tag: title
#: collection_mapping.xml:1175
#, no-c-format
msgid ""
"Enforcing NOT NULL constraint in unidirectional relation using annotations"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1178
#, no-c-format
msgid ""
"public class Parent {\n"
" @Id\n"
" @GeneratedValue\n"
" private long id;\n"
"\n"
" @OneToMany(optional=false)\n"
" private Set<Child> children;\n"
"\n"
" // getter/setter\n"
" ...\n"
"}\n"
"\n"
"\n"
"public class Child {\n"
" @Id\n"
" @GeneratedValue\n"
" private long id;\n"
" private String name;\n"
"\n"
" \n"
" // getter/setter\n"
" ...\n"
"}"
msgstr ""
#. Tag: title
#: collection_mapping.xml:1182
#, no-c-format
msgid ""
"Enforcing NOT NULL constraint in unidirectional relation using mapping files"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1185
#, fuzzy, no-c-format
msgid ""
"<hibernate-mapping>\n"
"\n"
" <class name=\"Parent\">\n"
" <id name=\"id\">\n"
" <generator class=\"sequence\"/>\n"
" </id>\n"
" <set name=\"children\">\n"
" <key column=\"parent_id\" not-null=\"true\"/>\n"
" <one-to-many class=\"Child\"/>\n"
" </set>\n"
" </class>\n"
"\n"
" <class name=\"Child\">\n"
" <id name=\"id\">\n"
" <generator class=\"sequence\"/>\n"
" </id>\n"
" <property name=\"name\"/>\n"
" </class>\n"
"\n"
"</hibernate-mapping>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:1188
#, fuzzy, no-c-format
msgid ""
"On the other hand, if a child has multiple parents, a many-to-many "
"association is appropriate."
msgstr ""
"å¦å¤–一方é¢ï¼Œå¦‚果一个å实例å¯èƒ½æœ‰å¤šä¸ªçˆ¶å®žä¾‹ï¼Œé‚£ä¹ˆå°±åº”该使用 many-to-many å…³"
"è”: "
#. Tag: title
#: collection_mapping.xml:1192
#, no-c-format
msgid ""
"Many to many <classname>Parent-Child relationship using "
"annotations"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1195
#, no-c-format
msgid ""
"public class Parent {\n"
" @Id\n"
" @GeneratedValue\n"
" private long id;\n"
"\n"
" @ManyToMany\n"
" private Set<Child> children;\n"
"\n"
" // getter/setter\n"
" ...\n"
"}\n"
"\n"
"\n"
"public class Child {\n"
" @Id\n"
" @GeneratedValue\n"
" private long id;\n"
"\n"
" private String name;\n"
"\n"
" \n"
" // getter/setter\n"
" ...\n"
"}"
msgstr ""
#. Tag: title
#: collection_mapping.xml:1199
#, no-c-format
msgid ""
"Many to many <classname>Parent-Child relationship using mapping "
"files"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1202
#, fuzzy, no-c-format
msgid ""
"<hibernate-mapping>\n"
"\n"
" <class name=\"Parent\">\n"
" <id name=\"id\">\n"
" <generator class=\"sequence\"/>\n"
" </id>\n"
" <set name=\"children\" table=\"childset\">\n"
" <key column=\"parent_id\"/>\n"
" <many-to-many class=\"Child\" column=\"child_id\"/>\n"
" </set>\n"
" </class>\n"
"\n"
" <class name=\"Child\">\n"
" <id name=\"id\">\n"
" <generator class=\"sequence\"/>\n"
" </id>\n"
" <property name=\"name\"/>\n"
" </class>\n"
"\n"
"</hibernate-mapping>"
msgstr ""
"<![CDATA["
#. Tag: para
#: collection_mapping.xml:1205
#, no-c-format
msgid "Table definitions:"
msgstr "表定义:"
#. Tag: title
#: collection_mapping.xml:1208
#, no-c-format
msgid "Table definitions for many to many releationship"
msgstr ""
#. Tag: programlisting
#: collection_mapping.xml:1210
#, fuzzy, no-c-format
msgid ""
"create table parent ( id bigint not null primary key )\n"
"create table child ( id bigint not null primary key, name varchar(255) )\n"
"create table childset ( parent_id bigint not null,\n"
" child_id bigint not null,\n"
" primary key ( parent_id, child_id ) )\n"
"alter table childset add constraint childsetfk0 (parent_id) references "
"parent\n"
"alter table childset add constraint childsetfk1 (child_id) references child"
msgstr ""
"<![CDATA[create table parent ( id bigint not null primary key )\n"
"create table child ( id bigint not null primary key, name varchar(255) )\n"
"create table childset ( parent_id bigint not null,\n"
" child_id bigint not null,\n"
" primary key ( parent_id, child_id ) )\n"
"alter table childset add constraint childsetfk0 (parent_id) references "
"parent\n"
"alter table childset add constraint childsetfk1 (child_id) references child]]"
">"
#. Tag: para
#: collection_mapping.xml:1213
#, fuzzy, no-c-format
msgid ""
"For more examples and a complete explanation of a parent/child relationship "
"mapping, see <xref linkend=\"example-parentchild\"/> for more information. "
"Even more complex association mappings are covered in the next chapter."
msgstr ""
"更多的例å,以åŠä¸€ä¸ªå®Œæ•´çš„父/åå…³ç³»æ˜ å°„çš„æŽ’ç»ƒï¼Œè¯·å‚阅 <xref linkend="
"\"example-parentchild\" />。 "
#~ msgid ""
#~ "Hibernate requires that persistent collection-valued fields be declared "
#~ "as an interface type. For example:"
#~ msgstr ""
#~ "ï¼ˆè¯‘è€…æ³¨ï¼šåœ¨é˜…è¯»æœ¬ç« çš„æ—¶å€™ï¼Œä»¥åŽæ•´ä¸ªæ‰‹å†Œçš„阅读过程ä¸ï¼Œæˆ‘们都会é¢ä¸´ä¸€ä¸ªåè¯"
#~ "æ–¹é¢çš„问题,那就是“集åˆâ€ã€‚\"Collections\" å’Œ \"Set\" 在ä¸æ–‡é‡Œå¯¹åº”都被翻译"
#~ "为“集åˆâ€ï¼Œä½†æ˜¯ä»–们的å«ä¹‰å¾ˆä¸ä¸€æ ·ã€‚Collections 是一个超集,Set 是其ä¸çš„一"
#~ "ç§ã€‚大部分情况下,本译稿ä¸æ³›æŒ‡çš„æœªåŠ è‹±æ–‡æ³¨æ˜Žçš„â€œé›†åˆâ€ï¼Œéƒ½åº”当ç†è§£"
#~ "为“Collectionsâ€ã€‚在有些二者åŒæ—¶å‡ºçŽ°ï¼Œå¯èƒ½é€ æˆæ··æ·†çš„地方,我们用“集åˆç±»â€æ¥"
#~ "特指“Collecionsâ€ï¼Œâ€œé›†åˆï¼ˆSet)â€æ¥æŒ‡ \"Set\",一般都会在åŽé¢çš„括å·ä¸ç»™å‡ºè‹±"
#~ "文。希望大家在阅读时è”系上下文ç†è§£ï¼Œä¸è¦é€ æˆè¯¯è§£ã€‚ 与æ¤åŒæ—¶ï¼Œâ€œå…ƒç´ â€ä¸€è¯å¯¹"
#~ "应的英文“elementâ€ï¼Œä¹Ÿæœ‰ä¸¤ä¸ªä¸åŒçš„å«ä¹‰ã€‚其一为集åˆçš„å…ƒç´ ï¼Œæ˜¯å†…å˜ä¸çš„一个å˜"
#~ "é‡ï¼›å¦ä¸€å«ä¹‰åˆ™æ˜¯ XML 文档ä¸çš„ä¸€ä¸ªæ ‡ç¾æ‰€ä»£è¡¨çš„å…ƒç´ ã€‚ä¹Ÿè¯·æ³¨æ„åŒºåˆ«ã€‚æœ¬ç« ä¸ï¼Œ"
#~ "特别是åŽåŠéƒ¨åˆ†æ˜¯éœ€è¦åå¤é˜…读æ‰èƒ½ç†è§£æ¸…楚的。如果é‡åˆ°ä»»ä½•ç–‘问,请记ä½ï¼Œè‹±æ–‡"
#~ "版本的 reference æ˜¯æƒŸä¸€æ ‡å‡†çš„å‚考资料。) Hibernate è¦æ±‚æŒä¹…化集åˆå€¼å—段必"
#~ "须声明为接å£ï¼Œä¾‹å¦‚:"
#~ msgid "Collection mappings"
#~ msgstr "集åˆæ˜ 射( Collection mappings )"
#~ msgid ""
#~ "There are quite a range of mappings that can be generated for collections "
#~ "that cover many common relational models. We suggest you experiment with "
#~ "the schema generation tool so that you understand how various mapping "
#~ "declarations translate to database tables."
#~ msgstr ""
#~ "从集åˆç±»å¯ä»¥äº§ç”Ÿå¾ˆå¤§ä¸€éƒ¨åˆ†æ˜ 射,覆盖了很多常è§çš„å…³ç³»æ¨¡åž‹ã€‚æˆ‘ä»¬å»ºè®®ä½ è¯•éªŒ "
#~ "schema 生æˆå·¥å…·ï¼Œæ¥ä½“会一下ä¸åŒçš„æ˜ å°„å£°æ˜Žæ˜¯å¦‚ä½•è¢«ç¿»è¯‘ä¸ºæ•°æ®åº“表的。 "
#~ msgid "Collection elements"
#~ msgstr "集åˆå…ƒç´ (Collection elements)"
#~ msgid ""
#~ "The contained type is referred to as the <emphasis>collection element "
#~ "type</emphasis>. Collection elements are mapped by <"
#~ "element></literal> or <composite-element>, or "
#~ "in the case of entity references, with <literal><one-to-many><many-to-many>. The first two map "
#~ "elements with value semantics, the next two are used to map entity "
#~ "associations."
#~ msgstr ""
#~ "被包容的类型被称为<emphasis>集åˆå…ƒç´ 类型(collection element type)<element> 或 "
#~ "<literal><composite-element> æ˜ å°„ï¼Œæˆ–åœ¨å…¶æ˜¯å®žä½“å¼•ç”¨çš„æ—¶"
#~ "候,通过 <literal><one-to-many> 或 <many-to-"
#~ "many></literal> æ˜ å°„ã€‚å‰ä¸¤ç§ç”¨äºŽä½¿ç”¨å€¼è¯ä¹‰æ˜ å°„å…ƒç´ ï¼ŒåŽä¸¤ç§ç”¨äºŽæ˜ 射实体"
#~ "å…³è”。"
#~ msgid ""
#~ "All collection mappings, except those with set and bag semantics, need an "
#~ "<emphasis>index column in the collection table. An index "
#~ "column is a column that maps to an array index, or <literal>ListMap key. The index of a "
#~ "<literal>Map may be of any basic type, mapped with <"
#~ "map-key></literal>. It can be an entity reference mapped with "
#~ "<literal><map-key-many-to-many>, or it can be a composite "
#~ "type mapped with <literal><composite-map-key>. The index "
#~ "of an array or list is always of type <literal>integer and is "
#~ "mapped using the <literal><list-index> element. The "
#~ "mapped column contains sequential integers that are numbered from zero by "
#~ "default."
#~ msgstr ""
#~ "所有的集åˆæ˜ 射,除了 set å’Œ bag è¯ä¹‰çš„以外,都需è¦æŒ‡å®šä¸€ä¸ªé›†åˆè¡¨çš„"
#~ "<emphasis>索引å—段(index column) — 用于对应到数组索引,或者 "
#~ "<literal>List 的索引,或者 Map 的关键å—。通"
#~ "过 <literal><map-key>,Map 的索引å¯ä»¥æ˜¯"
#~ "任何基础类型;若通过 <literal><map-key-many-to-many>,它也"
#~ "å¯ä»¥æ˜¯ä¸€ä¸ªå®žä½“引用;若通过 <literal><composite-map-key>,"
#~ "它还å¯ä»¥æ˜¯ä¸€ä¸ªç»„åˆç±»åž‹ã€‚数组或列表的索引必须是 <literal>integer "
#~ "类型,并且使用 <literal><list-index> å…ƒç´ å®šä¹‰æ˜ å°„ã€‚è¢«æ˜ å°„"
#~ "çš„å—段包å«æœ‰é¡ºåºæŽ’列的整数(默认从 0 开始)。 "
#~ msgid ""
#~ "Any collection of values or many-to-many associations requires a "
#~ "dedicated <emphasis>collection table with a foreign key column "
#~ "or columns, <emphasis>collection element column or columns, "
#~ "and possibly an index column or columns."
#~ msgstr ""
#~ "任何值集åˆæˆ–者多对多关è”需è¦ä¸“用的具有一个或多个外键å—段的 "
#~ "<emphasis>collection tableã€ä¸€ä¸ªæˆ–多个 collection "
#~ "element column</emphasis>,以åŠè¿˜å¯èƒ½æœ‰ä¸€ä¸ªæˆ–多个索引å—段。 "
#~ msgid ""
#~ "A <emphasis>many-to-many association is specified using the "
#~ "<literal><many-to-many> element."
#~ msgstr ""
#~ "用 <literal><many-to-many> å…ƒç´ æŒ‡å®š many-to-"
#~ "many association</emphasis>。"
#~ msgid ""
#~ "<literal>column (optional): the name of the element foreign key "
#~ "column."
#~ msgstr "<literal>columnï¼ˆå¿…éœ€ï¼‰ï¼šå…ƒç´ å¤–é”®å—段的å称。 "
#~ msgid ""
#~ "<literal>formula (optional): an SQL formula used to evaluate "
#~ "the element foreign key value."
#~ msgstr ""
#~ "<literal>formula(å¯é€‰ï¼‰ï¼šç”¨äºŽå¯¹å…ƒç´ 外键值求值的 SQL å…¬å¼ã€‚"
#~ msgid ""
#~ "<literal>fetch (optional - defaults to join of an entity and its many-to-many relationships "
#~ "to other entities, you would enable <literal>join fetching,not "
#~ "only of the collection itself, but also with this attribute on the "
#~ "<literal><many-to-many> nested element."
#~ msgstr ""
#~ "<literal>fetch(å¯é€‰ - 缺çœä¸º join): 为这个"
#~ "å…³è”å¯ç”¨å¤–连接或åºåˆ—性选择抓å–。这是一个特例。对于在å•ä¸ª <literal>SELECT<many-to-many>"
#~ "</literal> n用多对多关è”ï¼Œä½ å¯ä»¥å¯ç”¨ join fetching,这"
#~ "ä¸ä»…是对于集åˆæœ¬èº«ï¼Œä¹Ÿå¯¹ <literal><many-to-many> åµŒå¥—å…ƒç´ "
#~ "的属性。"
#~ msgid ""
#~ "<literal>unique (optional): enables the DDL generation of a "
#~ "unique constraint for the foreign-key column. This makes the association "
#~ "multiplicity effectively one-to-many."
#~ msgstr ""
#~ "<literal>unique(å¯é€‰ï¼‰ï¼šæœªå¤–é”®å—段å¯ç”¨å”¯ä¸€çº¦æŸçš„ DDL 生æˆã€‚这使"
#~ "å¾—å…³è”ä¸€å¯¹å¤šçš„å¤šæ ·æ€§æ›´ä¸ºæœ‰æ•ˆã€‚"
#~ msgid ""
#~ "<literal>not-found (optional - defaults to exception will treat a missing row as a null "
#~ "association."
#~ msgstr ""
#~ "<literal>not-found(å¯é€‰ - 默认为 exceptionignore (optional): the name of a property of the "
#~ "associated class that is joined to this foreign key. If not specified, "
#~ "the primary key of the associated class is used."
#~ msgstr ""
#~ "<literal>property-ref(å¯é€‰ï¼‰ï¼šè¿žæŽ¥è‡³è¿™ä¸ªå¤–键的关è”类的属性å"
#~ "称。如果未指定,关è”类的主键将被使用。"
#~ msgid "Here are some examples."
#~ msgstr "下é¢æ˜¯ä¸€äº›ä¾‹å:"
#~ msgid "A set of strings:"
#~ msgstr "一系列å—符串:"
#~ msgid ""
#~ "A bag containing integers with an iteration order determined by the "
#~ "<literal>order-by attribute:"
#~ msgstr ""
#~ "包å«ä¸€ç»„æ•´æ•°çš„ bag(还设置了 <literal>order-by å‚数指定了è¿ä»£çš„"
#~ "顺åºï¼‰ï¼š "
#~ msgid "An array of entities, in this case, a many-to-many association:"
#~ msgstr ""
#~ "一个实体数组,在这个案例ä¸æ˜¯ä¸€ä¸ªå¤šå¯¹å¤šçš„å…³è”(注æ„这里的实体是自动管ç†ç”Ÿå‘½"
#~ "周期的对象(lifecycle objects),<literal>cascade=\"all\"): "
#~ msgid "A map from string indices to dates:"
#~ msgstr "一个 map,通过å—符串的索引æ¥æŒ‡æ˜Žæ—¥æœŸï¼š"
#~ msgid "A list of components (this is discussed in the next chapter):"
#~ msgstr "ä¸€ä¸ªç»„ä»¶çš„åˆ—è¡¨ï¼šï¼ˆå°†åœ¨ä¸‹ä¸€ç« è®¨è®ºï¼‰"
#~ msgid "One-to-many associations"
#~ msgstr "一对多关è”(One-to-many Associations)"
#~ msgid ""
#~ "A <emphasis>one-to-many association links the tables of two "
#~ "classes via a foreign key with no intervening collection table. This "
#~ "mapping loses certain semantics of normal Java collections:"
#~ msgstr ""
#~ "<emphasis>一对多关è”通过外键连接两个类对应"
#~ "的表,而没有ä¸é—´é›†åˆè¡¨ã€‚ 这个关系模型失去了一些 Java 集åˆçš„è¯ä¹‰ï¼š"
#~ msgid ""
#~ "The following example shows a map of <literal>Part entities by "
#~ "name, where <literal>partName is a persistent property of "
#~ "<literal>Part. Notice the use of a formula-based index:"
#~ msgstr ""
#~ "下é¢çš„例å展示一个 <literal>Part 实体的 map,把 name 作为关键"
#~ "å—。( <literal>partName 是 Part çš„æŒä¹…化属"
#~ "性)。注æ„å…¶ä¸çš„基于公å¼çš„索引的用法。 "
#~ msgid ""
#~ "Hibernate supports collections implementing <literal>java.util.SortedMapjava.util.SortedSet. You must specify a "
#~ "comparator in the mapping file:"
#~ msgstr ""
#~ "Hibernate 支æŒå®žçŽ° <literal>java.util.SortedMap å’Œ "
#~ "<literal>java.util.SortedSet 的集åˆã€‚ä½ å¿…é¡»åœ¨æ˜ å°„æ–‡ä»¶ä¸æŒ‡å®šä¸€ä¸ª"
#~ "比较器:"
#~ msgid ""
#~ "A final alternative is to use composite elements, which will be discussed "
#~ "later."
#~ msgstr "最åŽä¸€ç§é€‰æ‹©æ˜¯ä½¿ç”¨å¤åˆå…ƒç´ ,我们会在åŽé¢è®¨è®ºã€‚"
#~ msgid ""
#~ "Even more complex association mappings are covered in the next chapter."
#~ msgstr "甚至å¯èƒ½å‡ºçŽ°æ›´åŠ å¤æ‚çš„å…³è”æ˜ å°„ï¼Œæˆ‘ä»¬ä¼šåœ¨ä¸‹ä¸€ç« ä¸åˆ—出所有å¯èƒ½æ€§ã€‚ "
#~ msgid ""
#~ "<programlistingco> </programlisting> " <para=""> column_name (required): "
#~ "the name of the column holding the collection index values. </para> base "
#~ "(optional - defaults to <literal>0): the value of the index "
#~ "column that corresponds to the first element of the list or array. </"
#~ "para> </callout> "
#~ "<areaspec> "
#~ "<programlisting></programlisting> " <para=""> column (optional): the "
#~ "name of the column holding the collection index values. </para> formula "
#~ "(optional): a SQL formula used to evaluate the key of the map. </para> type "
#~ "(required): the type of the map keys. </para> </programlisting> column (optional): the name of the foreign "
#~ "key column for the collection index values. </para> " <para=""> formula "
#~ "(optional): a SQ formula used to evaluate the foreign key of the map key. "
#~ "</para> "
#~ "<literal>class (required): the entity class used as the map "
#~ "key. </para> "
#~ msgstr ""
#~ "<programlistingco> </programlisting> " <para=""> column_name (required): "
#~ "the name of the column holding the collection index values. </para> base "
#~ "(optional - defaults to <literal>0): the value of the index "
#~ "column that corresponds to the first element of the list or array. </"
#~ "para> </callout> "
#~ "<areaspec> "
#~ "<programlisting></programlisting> " <para=""> column (optional): the "
#~ "name of the column holding the collection index values. </para> formula "
#~ "(optional): a SQL formula used to evaluate the key of the map. </para> type "
#~ "(required): the type of the map keys. </para> </programlisting> column (optional): the name of the foreign "
#~ "key column for the collection index values. </para> " <para=""> formula "
#~ "(optional): a SQ formula used to evaluate the foreign key of the map key. "
#~ "</para> "
#~ "<literal>class (required): the entity class used as the map "
#~ "key. </para> "
#~ msgid ""
#~ "<programlistingco> "
#~ "<area id=\"element2b\" coords=\"3 50\"/> </programlisting> "
#~ "<para> column (optional): the name of the column "
#~ "holding the collection element values. </para> " <para=""> formula (optional): an "
#~ "SQL formula used to evaluate the element. </para> " <para=""> type (required): the "
#~ "type of the collection element. </para> A many-to-many association "
#~ "is specified using the <literal><many-to-many> element. </programlisting> column (optional): the name of the element "
#~ "foreign key column. </para> "
#~ "<para> formula (optional): an SQL formula used to "
#~ "evaluate the element foreign key value. </para> " <para=""> class (required): the "
#~ "name of the associated class. </para> fetch (optional - defaults to "
#~ "<literal>join): enables outer-join or sequential select "
#~ "fetching for this association. This is a special case; for full eager "
#~ "fetching in a single <literal>SELECT of an entity and its many-"
#~ "to-many relationships to other entities, you would enable <literal>join nested element. "
#~ "</para> "
#~ "<literal>unique (optional): enables the DDL generation of a "
#~ "unique constraint for the foreign-key column. This makes the association "
#~ "multiplicity effectively one-to-many. </para> " <para=""> not-found (optional - "
#~ "defaults to <literal>exception): specifies how foreign keys "
#~ "that reference missing rows will be handled: <literal>ignore "
#~ "will treat a missing row as a null association. </para> "
#~ "<callout arearefs=\"manytomany7\"> entity-name "
#~ "(optional): the entity name of the associated class, as an alternative to "
#~ "<literal>class. property-ref (optional): the "
#~ "name of a property of the associated class that is joined to this foreign "
#~ "key. If not specified, the primary key of the associated class is used. </"
#~ "para> </callout> "
#~ msgstr ""
#~ "<programlistingco> "
#~ "<area id=\"element2b\" coords=\"3 50\"/> </programlisting> "
#~ "<para> column (optional): the name of the column "
#~ "holding the collection element values. </para> " <para=""> formula (optional): an "
#~ "SQL formula used to evaluate the element. </para> " <para=""> type (required): the "
#~ "type of the collection element. </para> A many-to-many association "
#~ "is specified using the <literal><many-to-many> element. </programlisting> column (optional): the name of the element "
#~ "foreign key column. </para> "
#~ "<para> formula (optional): an SQL formula used to "
#~ "evaluate the element foreign key value. </para> " <para=""> class (required): the "
#~ "name of the associated class. </para> fetch (optional - defaults to "
#~ "<literal>join): enables outer-join or sequential select "
#~ "fetching for this association. This is a special case; for full eager "
#~ "fetching in a single <literal>SELECT of an entity and its many-"
#~ "to-many relationships to other entities, you would enable <literal>join nested element. "
#~ "</para> "
#~ "<literal>unique (optional): enables the DDL generation of a "
#~ "unique constraint for the foreign-key column. This makes the association "
#~ "multiplicity effectively one-to-many. </para> " <para=""> not-found (optional - "
#~ "defaults to <literal>exception): specifies how foreign keys "
#~ "that reference missing rows will be handled: <literal>ignore "
#~ "will treat a missing row as a null association. </para> "
#~ "<callout arearefs=\"manytomany7\"> entity-name "
#~ "(optional): the entity name of the associated class, as an alternative to "
#~ "<literal>class. property-ref (optional): the "
#~ "name of a property of the associated class that is joined to this foreign "
#~ "key. If not specified, the primary key of the associated class is used. </"
#~ "para> </callout> "
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA["
#~ msgstr ""
#~ "<![CDATA["
#~ msgid ""
#~ "<![CDATA[
Other Hibernate examples (source code examples)
Here is a short list of links related to this Hibernate collection_mapping.po source code file:
|