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

📄 component_mapping.pot

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 POT
📖 第 1 页 / 共 2 页
字号:
# SOME DESCRIPTIVE TITLE.# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.##, fuzzymsgid ""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 <kde-i18n-doc@kde.org>\n""MIME-Version: 1.0\n""Content-Type: application/x-xml2pot; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"#. Tag: title#: component_mapping.xml:29#, no-c-formatmsgid "Component Mapping"msgstr ""#. Tag: para#: component_mapping.xml:31#, no-c-formatmsgid "The notion of a <emphasis>component</emphasis> is re-used in several different contexts, for different purposes, throughout Hibernate."msgstr ""#. Tag: title#: component_mapping.xml:37#, no-c-formatmsgid "Dependent objects"msgstr ""#. Tag: para#: component_mapping.xml:39#, no-c-formatmsgid "A component is a contained object that is persisted as a value type, not an entity reference. The term \"component\" refers to the object-oriented notion of composition (not to architecture-level components). For example, you might model a person like this:"msgstr ""#. Tag: programlisting#: component_mapping.xml:45#, no-c-formatmsgid ""      "<![CDATA[public class Person {\n"      "    private java.util.Date birthday;\n"      "    private Name name;\n"      "    private String key;\n"      "    public String getKey() {\n"      "        return key;\n"      "    }\n"      "    private void setKey(String key) {\n"      "        this.key=key;\n"      "    }\n"      "    public java.util.Date getBirthday() {\n"      "        return birthday;\n"      "    }\n"      "    public void setBirthday(java.util.Date birthday) {\n"      "        this.birthday = birthday;\n"      "    }\n"      "    public Name getName() {\n"      "        return name;\n"      "    }\n"      "    public void setName(Name name) {\n"      "        this.name = name;\n"      "    }\n"      "    ......\n"      "    ......\n"      "}]]>"msgstr ""#. Tag: programlisting#: component_mapping.xml:47#, no-c-formatmsgid ""      "<![CDATA[public class Name {\n"      "    char initial;\n"      "    String first;\n"      "    String last;\n"      "    public String getFirst() {\n"      "        return first;\n"      "    }\n"      "    void setFirst(String first) {\n"      "        this.first = first;\n"      "    }\n"      "    public String getLast() {\n"      "        return last;\n"      "    }\n"      "    void setLast(String last) {\n"      "        this.last = last;\n"      "    }\n"      "    public char getInitial() {\n"      "        return initial;\n"      "    }\n"      "    void setInitial(char initial) {\n"      "        this.initial = initial;\n"      "    }\n"      "}]]>"msgstr ""#. Tag: para#: component_mapping.xml:49#, no-c-formatmsgid "Now <literal>Name</literal> may be persisted as a component of <literal>Person</literal>. Notice that <literal>Name</literal> defines getter and setter methods for its persistent properties, but doesn't need to declare any interfaces or identifier properties."msgstr ""#. Tag: para#: component_mapping.xml:56#, no-c-formatmsgid "Our Hibernate mapping would look like:"msgstr ""#. Tag: programlisting#: component_mapping.xml:60#, no-c-formatmsgid ""      "<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"      "    <id name=\"Key\" column=\"pid\" type=\"string\">\n"      "        <generator class=\"uuid\"/>\n"      "    </id>\n"      "    <property name=\"birthday\" type=\"date\"/>\n"      "    <component name=\"Name\" class=\"eg.Name\"> <!-- class attribute optional -->\n"      "        <property name=\"initial\"/>\n"      "        <property name=\"first\"/>\n"      "        <property name=\"last\"/>\n"      "    </component>\n"      "</class>]]>"msgstr ""#. Tag: para#: component_mapping.xml:62#, no-c-formatmsgid "The person table would have the columns <literal>pid</literal>, <literal>birthday</literal>, <literal>initial</literal>, <literal>first</literal> and <literal>last</literal>."msgstr ""#. Tag: para#: component_mapping.xml:70#, no-c-formatmsgid "Like all value types, components do not support shared references. In other words, two persons could have the same name, but the two person objects would contain two independent name ojects, only \"the same\" by value. The null value semantics of a component are <emphasis>ad hoc</emphasis>. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This should be okay for most purposes."msgstr ""#. Tag: para#: component_mapping.xml:79#, no-c-formatmsgid "The properties of a component may be of any Hibernate type (collections, many-to-one associations, other components, etc). Nested components should <emphasis>not</emphasis> be considered an exotic usage. Hibernate is intended to support a very fine-grained object model."msgstr ""#. Tag: para#: component_mapping.xml:86#, no-c-formatmsgid "The <literal>&lt;component&gt;</literal> element allows a <literal>&lt;parent&gt;</literal> subelement that maps a property of the component class as a reference back to the containing entity."msgstr ""#. Tag: programlisting#: component_mapping.xml:92#, no-c-formatmsgid ""      "<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"      "    <id name=\"Key\" column=\"pid\" type=\"string\">\n"      "        <generator class=\"uuid\"/>\n"      "    </id>\n"      "    <property name=\"birthday\" type=\"date\"/>\n"      "    <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n"      "        <parent name=\"namedPerson\"/> <!-- reference back to the Person -->\n"      "        <property name=\"initial\"/>\n"      "        <property name=\"first\"/>\n"      "        <property name=\"last\"/>\n"      "    </component>\n"      "</class>]]>"msgstr ""#. Tag: title#: component_mapping.xml:97#, no-c-formatmsgid "Collections of dependent objects"msgstr ""#. Tag: para#: component_mapping.xml:99#, no-c-formatmsgid "Collections of components are supported (eg. an array of type <literal>Name</literal>). Declare your component collection by replacing the <literal>&lt;element&gt;</literal> tag with a <literal>&lt;composite-element&gt;</literal> tag."msgstr ""#. Tag: programlisting#: component_mapping.xml:106#, no-c-formatmsgid ""      "<![CDATA[<set name=\"someNames\" table=\"some_names\" lazy=\"true\">\n"      "    <key column=\"id\"/>\n"      "    <composite-element class=\"eg.Name\"> <!-- class attribute required -->\n"      "        <property name=\"initial\"/>\n"      "        <property name=\"first\"/>\n"      "        <property name=\"last\"/>\n"      "    </composite-element>\n"      "</set>]]>"msgstr ""#. Tag: para#: component_mapping.xml:108#, no-c-formatmsgid "Note: if you define a <literal>Set</literal> of composite elements, it is very important to implement <literal>equals()</literal> and <literal>hashCode()</literal> correctly."msgstr ""#. Tag: para#: component_mapping.xml:114#, no-c-formatmsgid "Composite elements may contain components but not collections. If your composite element itself contains components, use the <literal>&lt;nested-composite-element&gt;</literal> tag. This is a pretty exotic case - a collection of components which themselves have components. By this stage you should be asking yourself if a one-to-many association is more appropriate. Try remodelling the composite element as an entity - but note that even though the Java model is the same, the relational model and persistence semantics are still slightly different."msgstr ""#. Tag: para#: component_mapping.xml:126#, no-c-formatmsgid "Please note that a composite element mapping doesn't support null-able properties if you're using a <literal>&lt;set&gt;</literal>. Hibernate has to use each columns value to identify a record when deleting objects (there is no separate primary key column in the composite element table), which is not possible with null values. You have to either use only not-null properties in a composite-element or choose a <literal>&lt;list&gt;</literal>, <literal>&lt;map&gt;</literal>, <literal>&lt;bag&gt;</literal> or <literal>&lt;idbag&gt;</literal>."msgstr ""#. Tag: para#: component_mapping.xml:137#, no-c-formatmsgid "A special case of a composite element is a composite element with a nested <literal>&lt;many-to-one&gt;</literal> element. A mapping like this allows you to map extra columns of a many-to-many association table to the composite element class. The following is a many-to-many association from <literal>Order</literal> to <literal>Item</literal> where <literal>purchaseDate</literal>, <literal>price</literal> and <literal>quantity</literal> are properties of the association:"msgstr ""#. Tag: programlisting#: component_mapping.xml:147#, no-c-formatmsgid ""      "<![CDATA[<class name=\"eg.Order\" .... >\n"      "    ....\n"      "    <set name=\"purchasedItems\" table=\"purchase_items\" lazy=\"true\">\n"      "        <key column=\"order_id\">\n"      "        <composite-element class=\"eg.Purchase\">\n"      "            <property name=\"purchaseDate\"/>\n"      "            <property name=\"price\"/>\n"      "            <property name=\"quantity\"/>\n"      "            <many-to-one name=\"item\" class=\"eg.Item\"/> <!-- class attribute is optional -->\n"      "        </composite-element>\n"      "    </set>\n"      "</class>]]>"msgstr ""

⌨️ 快捷键说明

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