⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inheritance_mapping.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 2 页
字号:
msgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""Report-Msgid-Bugs-To: http://bugs.kde.org\n""POT-Creation-Date: 2008-08-14 15:28+0000\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <LL@li.org>\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"#. Tag: title#: inheritance_mapping.xml:29#, no-c-formatmsgid "Inheritance Mapping"msgstr "继承映射(Inheritance Mappings)"#. Tag: title#: inheritance_mapping.xml:32#, no-c-formatmsgid "The Three Strategies"msgstr "三种策略"#. Tag: para#: inheritance_mapping.xml:34#, no-c-formatmsgid "Hibernate supports the three basic inheritance mapping strategies:"msgstr "Hibernate支持三种基本的继承映射策略:"#. Tag: para#: inheritance_mapping.xml:40#, no-c-formatmsgid "table per class hierarchy"msgstr "每个类分层结构一张表(table per class hierarchy)"#. Tag: para#: inheritance_mapping.xml:45#, fuzzy, no-c-formatmsgid "<para>table per subclass</para>"msgstr """#-#-#-#-#  - (PACKAGE VERSION)  #-#-#-#-#\n""每个子类一张表(table per subclass)\n""#-#-#-#-#  - (PACKAGE VERSION)  #-#-#-#-#\n""每个子类一张表"#. Tag: para#: inheritance_mapping.xml:50#, no-c-formatmsgid "table per concrete class"msgstr "每个具体类一张表(table per concrete class)"#. Tag: para#: inheritance_mapping.xml:56#, no-c-formatmsgid """In addition, Hibernate supports a fourth, slightly different kind of ""polymorphism:"msgstr "此外,Hibernate还支持第四种稍有不同的多态映射策略:"#. Tag: para#: inheritance_mapping.xml:63#, no-c-formatmsgid "implicit polymorphism"msgstr "隐式多态(implicit polymorphism)"#. Tag: para#: inheritance_mapping.xml:69#, no-c-formatmsgid """It is possible to use different mapping strategies for different branches of ""the same inheritance hierarchy, and then make use of implicit polymorphism ""to achieve polymorphism across the whole hierarchy. However, Hibernate does ""not support mixing <literal>&lt;subclass&gt;</literal>, and <literal>&lt;""joined-subclass&gt;</literal> and <literal>&lt;union-subclass&gt;</literal> ""mappings under the same root <literal>&lt;class&gt;</literal> element. It is ""possible to mix together the table per hierarchy and table per subclass ""strategies, under the the same <literal>&lt;class&gt;</literal> element, by ""combining the <literal>&lt;subclass&gt;</literal> and <literal>&lt;join&gt;</""literal> elements (see below)."msgstr """对于同一个继承层次内的不同分支,可以采用不同的映射策略,然后用隐式多 态来完成""跨越整个层次的多态。但是在同一个<literal>&lt;class&gt;</literal>根元素 下,""Hibernate不支持混合了元素<literal>&lt;subclass&gt;</literal>、 <literal>&lt;""joined-subclass&gt;</literal>和<literal>&lt;union-subclass&gt;</literal> 的映""射。在同一个<literal>&lt;class&gt;</literal>元素下,可以混合使用 “每个类分层""结构一张表”(table per hierarchy) 和“每个子类一张表”(table per subclass) ""这两种映射策略,这是通过结合元素<literal>&lt;subclass&gt;</literal>和 ""<literal>&lt;join&gt;</literal>来实现的(见后)。"#. Tag: para#: inheritance_mapping.xml:83#, no-c-formatmsgid """It is possible to define <literal>subclass</literal>, <literal>union-""subclass</literal>, and <literal>joined-subclass</literal> mappings in ""separate mapping documents, directly beneath <literal>hibernate-mapping</""literal>. This allows you to extend a class hierachy just by adding a new ""mapping file. You must specify an <literal>extends</literal> attribute in ""the subclass mapping, naming a previously mapped superclass. Note: ""Previously this feature made the ordering of the mapping documents ""important. Since Hibernate3, the ordering of mapping files does not matter ""when using the extends keyword. The ordering inside a single mapping file ""still needs to be defined as superclasses before subclasses."msgstr """在多个映射文件中,可以直接在<literal>hibernate-mapping</literal>根下定义""<literal>subclass</literal>,<literal>union-subclass</literal>和""<literal>joined-subclass</literal>。也就是说,你可以仅加入一个新的映射文件来""扩展类层次。你必须在subclass的映射中指明<literal>extends</literal>属性,给出""一个之前定义的超类的名字。注意,在以前,这一功能对映射文件的顺序有严格的要""求,从Hibernate 3开始,使用extends关键字的时侯,对映射文件的顺序不再有要求;""但在每个映射文件里,超类必须在子类之前定义。"#. Tag: programlisting#: inheritance_mapping.xml:94#, no-c-formatmsgid """<![CDATA[\n"" <hibernate-mapping>\n""     <subclass name=\"DomesticCat\" extends=\"Cat\" discriminator-value=\"D""\">\n""          <property name=\"name\" type=\"string\"/>\n""     </subclass>\n"" </hibernate-mapping>]]>"msgstr ""#. Tag: title#: inheritance_mapping.xml:98#, no-c-formatmsgid "Table per class hierarchy"msgstr "每个类分层结构一张表(Table per class hierarchy)"#. Tag: para#: inheritance_mapping.xml:100#, no-c-formatmsgid """Suppose we have an interface <literal>Payment</literal>, with implementors ""<literal>CreditCardPayment</literal>, <literal>CashPayment</literal>, ""<literal>ChequePayment</literal>. The table per hierarchy mapping would look ""like:"msgstr """假设我们有接口<literal>Payment</literal>和它的几个实现类: ""<literal>CreditCardPayment</literal>, <literal>CashPayment</literal>, 和""<literal>ChequePayment</literal>。则“每个类分层结构一张表”(Table per class ""hierarchy)的映射代码如下所示:"#. Tag: programlisting#: inheritance_mapping.xml:107#, no-c-formatmsgid """<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n""    <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n""    <property name=\"amount\" column=\"AMOUNT\"/>\n""    ...\n""    <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n""        <property name=\"creditCardType\" column=\"CCTYPE\"/>\n""        ...\n""    </subclass>\n""    <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n""        ...\n""    </subclass>\n""    <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n""        ...\n""    </subclass>\n""</class>]]>"msgstr ""#. Tag: para#: inheritance_mapping.xml:109#, no-c-formatmsgid """Exactly one table is required. There is one big limitation of this mapping ""strategy: columns declared by the subclasses, such as <literal>CCTYPE</""literal>, may not have <literal>NOT NULL</literal> constraints."msgstr """采用这种策略只需要一张表即可。它有一个很大的限制:要求那些由子类定义的字段, ""如<literal>CCTYPE</literal>,不能有<literal>非空(NOT NULL)</literal>约束。"#. Tag: title#: inheritance_mapping.xml:118#, no-c-formatmsgid "Table per subclass"msgstr "每个子类一张表(Table per subclass)"#. Tag: para#: inheritance_mapping.xml:120#, no-c-formatmsgid "A table per subclass mapping would look like:"msgstr "对于上例中的几个类而言,采用“每个子类一张表”的映射策略,代码如下所示:"#. Tag: programlisting#: inheritance_mapping.xml:124#, no-c-formatmsgid """<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n""    <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <property name=\"amount\" column=\"AMOUNT\"/>\n""    ...\n""    <joined-subclass name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n""        <key column=\"PAYMENT_ID\"/>\n""        <property name=\"creditCardType\" column=\"CCTYPE\"/>\n""        ...\n""    </joined-subclass>\n""    <joined-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n""        <key column=\"PAYMENT_ID\"/>\n""        ...\n""    </joined-subclass>\n""    <joined-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n""        <key column=\"PAYMENT_ID\"/>\n""        ...\n""    </joined-subclass>\n""</class>]]>"msgstr ""#. Tag: para#: inheritance_mapping.xml:126#, no-c-formatmsgid """Four tables are required. The three subclass tables have primary key ""associations to the superclass table (so the relational model is actually a ""one-to-one association)."msgstr """需要四张表。三个子类表通过主键关联到超类表(因而关系模型实际上是一对一关联)。"#. Tag: title#: inheritance_mapping.xml:135#, no-c-formatmsgid "Table per subclass, using a discriminator"msgstr "每个子类一张表(Table per subclass),使用辨别标志(Discriminator)"#. Tag: para#: inheritance_mapping.xml:137#, no-c-formatmsgid """Note that Hibernate's implementation of table per subclass requires no ""discriminator column. Other object/relational mappers use a different ""implementation of table per subclass which requires a type discriminator ""column in the superclass table. The approach taken by Hibernate is much more ""difficult to implement but arguably more correct from a relational point of ""view. If you would like to use a discriminator column with the table per ""subclass strategy, you may combine the use of <literal>&lt;subclass&gt;</""literal> and <literal>&lt;join&gt;</literal>, as follow:"msgstr """注意,对“每个子类一张表”的映射策略,Hibernate的实现不需要辨别字段,而其他 的""对象/关系映射工具使用了一种不同于Hibernate的实现方法,该方法要求在超类 表中有""一个类型辨别字段(type discriminator column)。Hibernate采用的方法更 难实现,但""从关系(数据库)的角度来看,按理说它更正确。若你愿意使用带有辨别字 段的“每个""子类一张表”的策略,你可以结合使用<literal>&lt;subclass&gt;</literal> 与""<literal>&lt;join&gt;</literal>,如下所示:"#. Tag: programlisting#: inheritance_mapping.xml:149#, no-c-formatmsgid """<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n""    <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n""    <property name=\"amount\" column=\"AMOUNT\"/>\n""    ...\n""    <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n""        <join table=\"CREDIT_PAYMENT\">\n""            <key column=\"PAYMENT_ID\"/>\n""            <property name=\"creditCardType\" column=\"CCTYPE\"/>\n""            ...\n""        </join>\n""    </subclass>\n""    <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n""        <join table=\"CASH_PAYMENT\">\n""            <key column=\"PAYMENT_ID\"/>\n""            ...\n""        </join>\n""    </subclass>\n""    <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n""        <join table=\"CHEQUE_PAYMENT\" fetch=\"select\">\n""            <key column=\"PAYMENT_ID\"/>\n""            ...\n""        </join>\n""    </subclass>\n""</class>]]>"msgstr ""#. Tag: para#: inheritance_mapping.xml:151#, no-c-formatmsgid """The optional <literal>fetch=\"select\"</literal> declaration tells Hibernate ""not to fetch the <literal>ChequePayment</literal> subclass data using an ""outer join when querying the superclass."msgstr """可选的声明<literal>fetch=\"select\"</literal>,是用来告诉Hibernate,在查询超""类时, 不要使用外部连接(outer join)来抓取子类<literal>ChequePayment</literal>""的数据。"#. Tag: title#: inheritance_mapping.xml:160#, no-c-formatmsgid "Mixing table per class hierarchy with table per subclass"msgstr "混合使用“每个类分层结构一张表”和“每个子类一张表”"#. Tag: para#: inheritance_mapping.xml:162#, no-c-formatmsgid """You may even mix the table per hierarchy and table per subclass strategies ""using this approach:"msgstr """你甚至可以采取如下方法混和使用“每个类分层结构一张表”和“每个子类一张表”这两种""策略:"#. Tag: programlisting#: inheritance_mapping.xml:167#, no-c-formatmsgid """<![CDATA[<class name=\"Payment\" table=\"PAYMENT\">\n""    <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <discriminator column=\"PAYMENT_TYPE\" type=\"string\"/>\n""    <property name=\"amount\" column=\"AMOUNT\"/>\n""    ...\n""    <subclass name=\"CreditCardPayment\" discriminator-value=\"CREDIT\">\n""        <join table=\"CREDIT_PAYMENT\">\n""            <property name=\"creditCardType\" column=\"CCTYPE\"/>\n""            ...\n""        </join>\n""    </subclass>\n""    <subclass name=\"CashPayment\" discriminator-value=\"CASH\">\n""        ...\n""    </subclass>\n""    <subclass name=\"ChequePayment\" discriminator-value=\"CHEQUE\">\n""        ...\n""    </subclass>\n""</class>]]>"msgstr ""#. Tag: para#: inheritance_mapping.xml:169#, no-c-formatmsgid """For any of these mapping strategies, a polymorphic association to the root ""<literal>Payment</literal> class is mapped using <literal>&lt;many-to-one&gt;""</literal>."msgstr """对上述任何一种映射策略而言,指向根类<literal>Payment</literal>的 关联是使用""<literal>&lt;many-to-one&gt;</literal>进行映射的。"#. Tag: programlisting#: inheritance_mapping.xml:175#, no-c-formatmsgid """<![CDATA[<many-to-one name=\"payment\" column=\"PAYMENT_ID\" class=\"Payment""\"/>]]>"msgstr ""#. Tag: title#: inheritance_mapping.xml:180#, no-c-formatmsgid "Table per concrete class"msgstr "每个具体类一张表(Table per concrete class)"#. Tag: para#: inheritance_mapping.xml:182#, no-c-formatmsgid """There are two ways we could go about mapping the table per concrete class ""strategy. The first is to use <literal>&lt;union-subclass&gt;</literal>."msgstr """对于“每个具体类一张表”的映射策略,可以采用两种方法。第一种方法是使用 ""<literal>&lt;union-subclass&gt;</literal>。"#. Tag: programlisting#: inheritance_mapping.xml:187#, no-c-formatmsgid """<![CDATA[<class name=\"Payment\">\n""    <id name=\"id\" type=\"long\" column=\"PAYMENT_ID\">\n""        <generator class=\"sequence\"/>\n""    </id>\n""    <property name=\"amount\" column=\"AMOUNT\"/>\n""    ...\n""    <union-subclass name=\"CreditCardPayment\" table=\"CREDIT_PAYMENT\">\n""        <property name=\"creditCardType\" column=\"CCTYPE\"/>\n""        ...\n""    </union-subclass>\n""    <union-subclass name=\"CashPayment\" table=\"CASH_PAYMENT\">\n""        ...\n""    </union-subclass>\n""    <union-subclass name=\"ChequePayment\" table=\"CHEQUE_PAYMENT\">\n""        ...\n""    </union-subclass>\n""</class>]]>"msgstr ""#. Tag: para#: inheritance_mapping.xml:189#, no-c-formatmsgid """Three tables are involved for the subclasses. Each table defines columns for ""all properties of the class, including inherited properties."msgstr """这里涉及三张与子类相关的表。每张表为对应类的所有属性(包括从超类继承的属性)""定义相应字段。"#. Tag: para

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -