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

📄 association_mapping.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 2 页
字号:
"        <generator class=\"native\"/>\n""    </id>\n""    <set name=\"addresses\" table=\"PersonAddress\">\n""        <key column=\"personId\"/>\n""        <many-to-many column=\"addressId\"\n""            class=\"Address\"/>\n""    </set>\n""</class>\n""\n""<class name=\"Address\">\n""    <id name=\"id\" column=\"addressId\">\n""        <generator class=\"native\"/>\n""    </id>\n""</class>]]>"msgstr ""#. Tag: programlisting#: association_mapping.xml:165 association_mapping.xml:270#, no-c-formatmsgid """<![CDATA[\n""create table Person ( personId bigint not null primary key )\n""create table PersonAddress ( personId bigint not null, addressId bigint not ""null, primary key (personId, addressId) )\n""create table Address ( addressId bigint not null primary key )\n""        ]]>"msgstr ""#. Tag: title#: association_mapping.xml:172#, no-c-formatmsgid "Bidirectional associations"msgstr "Associations bidirectionnelles"#. Tag: title#: association_mapping.xml:175 association_mapping.xml:235#, no-c-formatmsgid "one to many / many to one"msgstr "un à plusieurs / plusieurs à un"#. Tag: para#: association_mapping.xml:177#, no-c-formatmsgid """A <emphasis>bidirectional many-to-one association</emphasis> is the most ""common kind of association. (This is the standard parent/child relationship.)"msgstr """Une <emphasis>association bidirectionnelle plusieurs à un (many-to-one)</""emphasis> est le type d'association que l'on rencontre le plus souvent. ""(c'est la façon standard de créer des relations parents/enfants.)"#. Tag: programlisting#: association_mapping.xml:183#, no-c-formatmsgid """<![CDATA[<class name=\"Person\">\n""    <id name=\"id\" column=\"personId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <many-to-one name=\"address\" \n""        column=\"addressId\"\n""        not-null=\"true\"/>\n""</class>\n""\n""<class name=\"Address\">\n""    <id name=\"id\" column=\"addressId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <set name=\"people\" inverse=\"true\">\n""        <key column=\"addressId\"/>\n""        <one-to-many class=\"Person\"/>\n""    </set>\n""</class>]]>"msgstr ""#. Tag: para#: association_mapping.xml:187#, no-c-formatmsgid """If you use a <literal>List</literal> (or other indexed collection) you need ""to set the <literal>key</literal> column of the foreign key to <literal>not ""null</literal>, and let Hibernate manage the association from the ""collections side to maintain the index of each element (making the other ""side virtually inverse by setting <literal>update=\"false\"</literal> and ""<literal>insert=\"false\"</literal>):"msgstr """Si vous utilisez une <literal>List</literal> (ou toute autre collection ""indexée) vous devez paramétrer la colonne <literal>key</literal> de la clé ""étrangère à <literal>not null</literal>, et laisser Hibernate gérer ""l'association depuis l'extrémité collection pour maintenir l'index de chaque ""élément (rendant l'autre extrémité virtuellement inverse en paramétrant ""<literal>update=\"false\"</literal> et <literal>insert=\"false\"</literal>):"#. Tag: programlisting#: association_mapping.xml:195#, no-c-formatmsgid """<![CDATA[<class name=\"Person\">\n""   <id name=\"id\"/>\n""   ...\n""   <many-to-one name=\"address\"\n""      column=\"addressId\"\n""      not-null=\"true\"\n""      insert=\"false\"\n""      update=\"false\"/>\n""</class>\n""\n""<class name=\"Address\">\n""   <id name=\"id\"/>\n""   ...\n""   <list name=\"people\">\n""      <key column=\"addressId\" not-null=\"true\"/>\n""      <list-index column=\"peopleIdx\"/>\n""      <one-to-many class=\"Person\"/>\n""   </list>\n""</class>]]>"msgstr ""#. Tag: para#: association_mapping.xml:197#, no-c-formatmsgid """It is important that you define <literal>not-null=\"true\"</literal> on the ""<literal>&lt;key&gt;</literal> element of the collection mapping if the ""underlying foreign key column is <literal>NOT NULL</literal>. Don't only ""declare <literal>not-null=\"true\"</literal> on a possible nested ""<literal>&lt;column&gt;</literal> element, but on the <literal>&lt;key&gt;</""literal> element."msgstr """It is important that you define <literal>not-null=\"true\"</literal> on the ""<literal>&lt;key&gt;</literal> element of the collection mapping if the ""underlying foreign key column is <literal>NOT NULL</literal>. Don't only ""declare <literal>not-null=\"true\"</literal> on a possible nested ""<literal>&lt;column&gt;</literal> element, but on the <literal>&lt;key&gt;</""literal> element."#. Tag: para#: association_mapping.xml:211#, no-c-formatmsgid """A <emphasis>bidirectional one-to-one association on a foreign key</emphasis> ""is quite common."msgstr """Une <emphasis>association bidirectionnelle un à un (one-to-one) sur une clé ""étrangère</emphasis> est aussi très fréquente."#. Tag: programlisting#: association_mapping.xml:216#, no-c-formatmsgid """<![CDATA[<class name=\"Person\">\n""    <id name=\"id\" column=\"personId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <many-to-one name=\"address\" \n""        column=\"addressId\" \n""        unique=\"true\"\n""        not-null=\"true\"/>\n""</class>\n""\n""<class name=\"Address\">\n""    <id name=\"id\" column=\"addressId\">\n""        <generator class=\"native\"/>\n""    </id>\n""   <one-to-one name=\"person\" \n""        property-ref=\"address\"/>\n""</class>]]>"msgstr ""#. Tag: para#: association_mapping.xml:219#, no-c-formatmsgid """A <emphasis>bidirectional one-to-one association on a primary key</emphasis> ""uses the special id generator."msgstr """Une <emphasis>association bidirectionnelle un-à-un (one-to-one) sur une clé ""primaire</emphasis> utilise un générateur particulier d'id."#. Tag: programlisting#: association_mapping.xml:224#, no-c-formatmsgid """<![CDATA[<class name=\"Person\">\n""    <id name=\"id\" column=\"personId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <one-to-one name=\"address\"/>\n""</class>\n""\n""<class name=\"Address\">\n""    <id name=\"id\" column=\"personId\">\n""        <generator class=\"foreign\">\n""            <param name=\"property\">person</param>\n""        </generator>\n""    </id>\n""    <one-to-one name=\"person\" \n""        constrained=\"true\"/>\n""</class>]]>"msgstr ""#. Tag: title#: association_mapping.xml:232#, no-c-formatmsgid "Bidirectional associations with join tables"msgstr "Associations bidirectionnelles avec table de jointure"#. Tag: para#: association_mapping.xml:237#, no-c-formatmsgid """A <emphasis>bidirectional one-to-many association on a join table</""emphasis>. Note that the <literal>inverse=\"true\"</literal> can go on ""either end of the association, on the collection, or on the join."msgstr """Une <emphasis>association bidirectionnelle un-à-plusieurs (one-to-many) sur ""une table de jointure </emphasis>. Remarquez que <literal>inverse=\"true\"</""literal> peut s'appliquer sur les deux extrémités de l' association, sur la ""collection, ou sur la jointure."#. Tag: programlisting#: association_mapping.xml:243#, no-c-formatmsgid """<![CDATA[<class name=\"Person\">\n""    <id name=\"id\" column=\"personId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <set name=\"addresses\" \n""        table=\"PersonAddress\">\n""        <key column=\"personId\"/>\n""        <many-to-many column=\"addressId\"\n""            unique=\"true\"\n""            class=\"Address\"/>\n""    </set>\n""</class>\n""\n""<class name=\"Address\">\n""    <id name=\"id\" column=\"addressId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <join table=\"PersonAddress\" \n""        inverse=\"true\" \n""        optional=\"true\">\n""        <key column=\"addressId\"/>\n""        <many-to-one name=\"person\"\n""            column=\"personId\"\n""            not-null=\"true\"/>\n""    </join>\n""</class>]]>"msgstr ""#. Tag: programlisting#: association_mapping.xml:244#, no-c-formatmsgid """<![CDATA[\n""create table Person ( personId bigint not null primary key )\n""create table PersonAddress ( personId bigint not null, addressId bigint not ""null primary key )\n""create table Address ( addressId bigint not null primary key )\n""        ]]>"msgstr ""#. Tag: para#: association_mapping.xml:251#, no-c-formatmsgid """A <emphasis>bidirectional one-to-one association on a join table</emphasis> ""is extremely unusual, but possible."msgstr """Une <emphasis>association bidirectionnelle un-à-un (one-to-one) sur une ""table de jointure</emphasis> est extrèmement rare mais envisageable."#. Tag: programlisting#: association_mapping.xml:256#, no-c-formatmsgid """<![CDATA[<class name=\"Person\">\n""    <id name=\"id\" column=\"personId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <join table=\"PersonAddress\" \n""        optional=\"true\">\n""        <key column=\"personId\" \n""            unique=\"true\"/>\n""        <many-to-one name=\"address\"\n""            column=\"addressId\" \n""            not-null=\"true\"\n""            unique=\"true\"/>\n""    </join>\n""</class>\n""\n""<class name=\"Address\">\n""    <id name=\"id\" column=\"addressId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <join table=\"PersonAddress\" \n""        optional=\"true\"\n""        inverse=\"true\">\n""        <key column=\"addressId\" \n""            unique=\"true\"/>\n""        <many-to-one name=\"person\"\n""            column=\"personId\" \n""            not-null=\"true\"\n""            unique=\"true\"/>\n""    </join>\n""</class>]]>"msgstr ""#. Tag: para#: association_mapping.xml:264#, no-c-formatmsgid """Finally, we have a <emphasis>bidirectional many-to-many association</""emphasis>."msgstr """Finallement nous avons <emphasis>l'association bidirectionnelle plusieurs à ""plusieurs</emphasis>."#. Tag: programlisting#: association_mapping.xml:268#, no-c-formatmsgid """<![CDATA[<class name=\"Person\">\n""    <id name=\"id\" column=\"personId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <set name=\"addresses\" table=\"PersonAddress\">\n""        <key column=\"personId\"/>\n""        <many-to-many column=\"addressId\"\n""            class=\"Address\"/>\n""    </set>\n""</class>\n""\n""<class name=\"Address\">\n""    <id name=\"id\" column=\"addressId\">\n""        <generator class=\"native\"/>\n""    </id>\n""    <set name=\"people\" inverse=\"true\" table=\"PersonAddress\">\n""        <key column=\"addressId\"/>\n""        <many-to-many column=\"personId\"\n""            class=\"Person\"/>\n""    </set>\n""</class>]]>"msgstr ""#. Tag: title#: association_mapping.xml:277#, no-c-formatmsgid "More complex association mappings"msgstr "Des mappings plus complexes"#. Tag: para#: association_mapping.xml:279#, no-c-formatmsgid """More complex association joins are <emphasis>extremely</emphasis> rare. ""Hibernate makes it possible to handle more complex situations using SQL ""fragments embedded in the mapping document. For example, if a table with ""historical account information data defines <literal>accountNumber</""literal>, <literal>effectiveEndDate</literal> and ""<literal>effectiveStartDate</literal>columns, mapped as follows:"msgstr """Des associations encore plus complexes sont <emphasis>extrêmement</emphasis> ""rares. Hibernate permet de gérer des situations plus complexes en utilisant ""des parties SQL dans les fichiers de mapping. Par exemple, si une table avec ""l'historiques des informations d'un compte définit les colonnes ""<literal>accountNumber</literal>, <literal>effectiveEndDate</literal> et ""<literal>effectiveStartDate</literal>, mappées de telle sorte:"#. Tag: programlisting#: association_mapping.xml:288#, no-c-formatmsgid """<![CDATA[<properties name=\"currentAccountKey\">\n""    <property name=\"accountNumber\" type=\"string\" not-null=\"true\"/>\n""    <property name=\"currentAccount\" type=\"boolean\">\n""        <formula>case when effectiveEndDate is null then 1 else 0 end</""formula>\n""    </property>\n""</properties>\n""<property name=\"effectiveEndDate\" type=\"date\"/>\n""<property name=\"effectiveStateDate\" type=\"date\" not-null=\"true\"/>]]>"msgstr ""#. Tag: para#: association_mapping.xml:290#, no-c-formatmsgid """Then we can map an association to the <emphasis>current</emphasis> instance ""(the one with null <literal>effectiveEndDate</literal>) using:"msgstr """alors nous pouvons mapper une association à l'instance <emphasis>courante</""emphasis> (celle avec une <literal>effectiveEndDate</literal>) nulle en ""utilisant:"#. Tag: programlisting#: association_mapping.xml:295#, no-c-formatmsgid """<![CDATA[<many-to-one name=\"currentAccountInfo\" \n""        property-ref=\"currentAccountKey\"\n""        class=\"AccountInfo\">\n""    <column name=\"accountNumber\"/>\n""    <formula>'1'</formula>\n""</many-to-one>]]>"msgstr ""#. Tag: para#: association_mapping.xml:297#, no-c-formatmsgid """In a more complex example, imagine that the association between ""<literal>Employee</literal> and <literal>Organization</literal> is ""maintained in an <literal>Employment</literal> table full of historical ""employment data. Then an association to the employee's <emphasis>most ""recent</emphasis> employer (the one with the most recent <literal>startDate</""literal>) might be mapped this way:"msgstr """Dans un exemple plus complexe, imaginez qu'une association entre ""<literal>Employee</literal> et <literal>Organization</literal> est gérée ""dans une table <literal>Employment</literal> pleines de données historiques. ""Dans ce cas, une association vers l'employeur <emphasis>le plus récent</""emphasis> (celui avec la <literal>startDate</literal> la plus récente) ""pourrait être mappée comme cela:"#. Tag: programlisting#: association_mapping.xml:305#, no-c-formatmsgid """<![CDATA[<join>\n""    <key column=\"employeeId\"/>\n""    <subselect>\n""        select employeeId, orgId \n""        from Employments \n""        group by orgId \n""        having startDate = max(startDate)\n""    </subselect>\n""    <many-to-one name=\"mostRecentEmployer\" \n""            class=\"Organization\" \n""            column=\"orgId\"/>\n""</join>]]>"msgstr ""#. Tag: para#: association_mapping.xml:307#, no-c-formatmsgid """You can get quite creative with this functionality, but it is usually more ""practical to handle these kinds of cases using HQL or a criteria query."msgstr """Vous pouvez être créatif grace à ces possibilités, mais il est généralement ""plus pratique d'utiliser des requêtes HQL ou criteria dans ce genre de ""situation."

⌨️ 快捷键说明

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