📄 collection_mapping.po
字号:
"</set>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:486#, no-c-formatmsgid """A bag containing integers (with an iteration order determined by the ""<literal>order-by</literal> attribute):"msgstr """一个实体数组,在这个案例中是一个多对多的关联(注意这里的实体是自动管理生命周期""的对象(life cycle objects),<literal>cascade=\"all\"</literal>):"#. Tag: programlisting#: collection_mapping.xml:491#, no-c-formatmsgid """<![CDATA[<bag name=\"sizes\" \n"" table=\"item_sizes\" \n"" order-by=\"size asc\">\n"" <key column=\"item_id\"/>\n"" <element column=\"size\" type=\"integer\"/>\n""</bag>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:493#, no-c-formatmsgid "An array of entities - in this case, a many to many association:"msgstr "一个map,通过字符串的索引来指明日期:"#. Tag: programlisting#: collection_mapping.xml:497#, no-c-formatmsgid """<![CDATA[<array name=\"addresses\" \n"" table=\"PersonAddress\" \n"" cascade=\"persist\">\n"" <key column=\"personId\"/>\n"" <list-index column=\"sortOrder\"/>\n"" <many-to-many column=\"addressId\" class=\"Address\"/>\n""</array>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:499#, no-c-formatmsgid "A map from string indices to dates:"msgstr "一个组件的列表:(下一章讨论)"#. Tag: programlisting#: collection_mapping.xml:503#, no-c-formatmsgid """<![CDATA[<map name=\"holidays\" \n"" table=\"holidays\" \n"" schema=\"dbo\" \n"" order-by=\"hol_name asc\">\n"" <key column=\"id\"/>\n"" <map-key column=\"hol_name\" type=\"string\"/>\n"" <element column=\"hol_date\" type=\"date\"/>\n""</map>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:505#, no-c-formatmsgid "A list of components (discussed in the next chapter):"msgstr "一对多关联(One-to-many Associations)"#. Tag: programlisting#: collection_mapping.xml:509#, no-c-formatmsgid """<![CDATA[<list name=\"carComponents\" \n"" table=\"CarComponents\">\n"" <key column=\"carId\"/>\n"" <list-index column=\"sortOrder\"/>\n"" <composite-element class=\"CarComponent\">\n"" <property name=\"price\"/>\n"" <property name=\"type\"/>\n"" <property name=\"serialNumber\" column=\"serialNum\"/>\n"" </composite-element>\n""</list>]]>"msgstr ""#. Tag: title#: collection_mapping.xml:514#, no-c-formatmsgid "One-to-many associations"msgstr """<emphasis>一对多关联</emphasis><emphasis>通过外键</emphasis>连接两个类对应的""表,而没有中间集合表。 这个关系模型失去了一些Java集合的语义:"#. Tag: para#: collection_mapping.xml:516#, no-c-formatmsgid """A <emphasis>one to many association</emphasis> links the tables of two ""classes via a foreign key, with no intervening collection table. This ""mapping loses certain semantics of normal Java collections:"msgstr "一个被包含的实体的实例只能被包含在一个集合的实例中"#. Tag: para#: collection_mapping.xml:524#, no-c-formatmsgid """An instance of the contained entity class may not belong to more than one ""instance of the collection"msgstr "一个被包含的实体的实例只能对应于集合索引的一个值中"#. Tag: para#: collection_mapping.xml:530#, no-c-formatmsgid """An instance of the contained entity class may not appear at more than one ""value of the collection index"msgstr """一个从<literal>Product</literal>到<literal>Part</literal>的关联需要关键字字""段,可能还有一个索引字段指向<literal>Part</literal>所对应的表。 <literal><""one-to-many></literal>标记指明了一个一对多的关联。"#. Tag: para#: collection_mapping.xml:537#, no-c-formatmsgid """An association from <literal>Product</literal> to <literal>Part</literal> ""requires existence of a foreign key column and possibly an index column to ""the <literal>Part</literal> table. A <literal><one-to-many></literal> ""tag indicates that this is a one to many association."msgstr "<literal>class</literal>(必须):被关联类的名称。"#. Tag: programlisting#: collection_mapping.xml:550#, no-c-formatmsgid """<![CDATA[<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 ""#. Tag: para#: collection_mapping.xml:553#, fuzzy, no-c-formatmsgid "<literal>class</literal> (required): The name of the associated class."msgstr """#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n""为此关联打开外连接抓取或者后续select抓取。这是特殊情况;对于一个实体及其指向""其他实体的多对多关联进全预先抓取(使用一条单独的<literal>SELECT</literal>),""你不仅需要对集合自身打开<literal>join</literal>,也需要对<literal><many-""to-many></literal>这个内嵌元素打开此属性。\n""#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n""<literal>not-found</literal> (可选 - 默认为<literal>exception</literal>): 指""明若缓存的标示值关联的行缺失,该如何处理: <literal>ignore</literal> 会把缺失的""行作为一个空关联处理。"#. Tag: para#: collection_mapping.xml:558#, no-c-formatmsgid """<literal>not-found</literal> (optional - defaults to <literal>exception</""literal>): Specifies how cached identifiers that reference missing rows will ""be handled: <literal>ignore</literal> will treat a missing row as a null ""association."msgstr """<literal>entity-name</literal> (可选): 被关联的类的实体名,作为""<literal>class</literal>的替代。"#. Tag: para#: collection_mapping.xml:565#, fuzzy, no-c-formatmsgid """<literal>entity-name</literal> (optional): The entity name of the associated ""class, as an alternative to <literal>class</literal>."msgstr """#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n""<literal>property-ref</literal>: (可选) 被关联到此外键(foreign key)的类中的对""应属性的名字。若未指定,使用被关联类的主键。\n""#-#-#-#-# - (PACKAGE VERSION) #-#-#-#-#\n""例子"#. Tag: para#: collection_mapping.xml:573#, no-c-formatmsgid """Notice that the <literal><one-to-many></literal> element does not need ""to declare any columns. Nor is it necessary to specify the <literal>table</""literal> name anywhere."msgstr """注意:<literal><one-to-many></literal>元素不需要定义任何字段。 也不需要""指定表名。"#. Tag: para#: collection_mapping.xml:579#, no-c-formatmsgid """<emphasis>Very important note:</emphasis> If the foreign key column of a ""<literal><one-to-many></literal> association is declared <literal>NOT ""NULL</literal>, you must declare the <literal><key></literal> mapping ""<literal>not-null=\"true\"</literal> or <emphasis>use a bidirectional ""association</emphasis> with the collection mapping marked <literal>inverse=""\"true\"</literal>. See the discussion of bidirectional associations later ""in this chapter."msgstr """<emphasis>重要提示</emphasis>:如果<literal>一对多</literal>关联中的外键字段定""义成<literal>NOT NULL</literal>,你必须把<literal><key></literal>映射声""明为<literal>not-null=\"true\"</literal>,或者使用<emphasis>双向关联</""emphasis>,并且标明<literal>inverse=\"true\"</literal>。参阅本章后面关于双向""关联的讨论。"#. Tag: para#: collection_mapping.xml:588#, no-c-formatmsgid """This example shows a map of <literal>Part</literal> entities by name (where ""<literal>partName</literal> is a persistent property of <literal>Part</""literal>). Notice the use of a formula-based index."msgstr """下面的例子展示一个<literal>Part</literal>实体的map,把name作为关键字。""( <literal>partName</literal> 是<literal>Part</literal>的持久化属性)。注意其""中的基于公式的索引的用法。"#. Tag: programlisting#: collection_mapping.xml:594#, no-c-formatmsgid """<![CDATA[<map name=\"parts\"\n"" cascade=\"all\">\n"" <key column=\"productId\" not-null=\"true\"/>\n"" <map-key formula=\"partName\"/>\n"" <one-to-many class=\"Part\"/>\n""</map>]]>"msgstr ""#. Tag: title#: collection_mapping.xml:600#, no-c-formatmsgid "Advanced collection mappings"msgstr "高级集合映射(Advanced collection mappings)"#. Tag: title#: collection_mapping.xml:603#, no-c-formatmsgid "Sorted collections"msgstr "有序集合(Sorted collections)"#. Tag: para#: collection_mapping.xml:605#, no-c-formatmsgid """Hibernate supports collections implementing <literal>java.util.SortedMap</""literal> and <literal>java.util.SortedSet</literal>. You must specify a ""comparator in the mapping file:"msgstr """Hibernate支持实现<literal>java.util.SortedMap</literal>和<literal>java.util.""SortedSet</literal>的集合。 你必须在映射文件中指定一个比较器:"#. Tag: programlisting#: collection_mapping.xml:610#, no-c-formatmsgid """<![CDATA[<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 ""#. Tag: para#: collection_mapping.xml:612#, no-c-formatmsgid """Allowed values of the <literal>sort</literal> attribute are ""<literal>unsorted</literal>, <literal>natural</literal> and the name of a ""class implementing <literal>java.util.Comparator</literal>."msgstr """<literal>sort</literal>属性中允许的值包括<literal>unsorted</literal>,""<literal>natural</literal>和某个实现了<literal>java.util.Comparator</literal>""的类的名称。"#. Tag: para#: collection_mapping.xml:618#, no-c-formatmsgid """Sorted collections actually behave like <literal>java.util.TreeSet</literal> ""or <literal>java.util.TreeMap</literal>."msgstr """分类集合的行为事实上象<literal>java.util.TreeSet</literal>或者<literal>java.""util.TreeMap</literal>。"#. Tag: para#: collection_mapping.xml:623#, no-c-formatmsgid """If you want the database itself to order the collection elements use the ""<literal>order-by</literal> attribute of <literal>set</literal>, ""<literal>bag</literal> or <literal>map</literal> mappings. This solution is ""only available under JDK 1.4 or higher (it is implemented using ""<literal>LinkedHashSet</literal> or <literal>LinkedHashMap</literal>). This ""performs the ordering in the SQL query, not in memory."msgstr """如果你希望数据库自己对集合元素排序,可以利用<literal>set</literal>,""<literal>bag</literal>或者<literal>map</literal>映射中的<literal>order-by</""literal>属性。这个解决方案只能在jdk1.4或者更高的jdk版本中才可以实现(通过""LinkedHashSet或者 LinkedHashMap实现)。 它是在SQL查询中完成排序,而不是在内存""中。"#. Tag: programlisting#: collection_mapping.xml:632#, no-c-formatmsgid """<![CDATA[<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 ""#. Tag: para#: collection_mapping.xml:634#, no-c-formatmsgid """Note that the value of the <literal>order-by</literal> attribute is an SQL ""ordering, not a HQL ordering!"msgstr """注意: 这个<literal>order-by</literal>属性的值是一个SQL排序子句而不是HQL的!"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -