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

📄 collection_mapping.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 5 页
字号:
"        <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 ""#. Tag: para#: collection_mapping.xml:766#, no-c-formatmsgid """Note that in this mapping, the collection-valued end of the association is ""responsible for updates to the foreign key. TODO: Does this really result in ""some unnecessary update statements?"msgstr """Notez que dans ce mapping, l'extrémité de l'association contenant la ""collection est responsable des mises à jour de la clef étrangère. À faire : ""cela entraîne-t-il réellement des expressions updates inutiles ?"#. Tag: title#: collection_mapping.xml:774#, no-c-formatmsgid "Ternary associations"msgstr "Associations ternaires"#. Tag: para#: collection_mapping.xml:776#, no-c-formatmsgid """There are three possible approaches to mapping a ternary association. One is ""to use a <literal>Map</literal> with an association as its index:"msgstr """Il y a trois approches possibles pour mapper une association ternaire. L'une ""est d'utiliser une <literal>Map</literal> avec une association en tant ""qu'index :"#. Tag: programlisting#: collection_mapping.xml:781#, no-c-formatmsgid """<![CDATA[<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: programlisting#: collection_mapping.xml:783#, no-c-formatmsgid """<![CDATA[<map name=\"connections\">\n""    <key column=\"incoming_node_id\"/>\n""    <map-key-many-to-many column=\"outgoing_node_id\" class=\"Node\"/>\n""    <many-to-many column=\"connection_id\" class=\"Connection\"/>\n""</map>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:785#, no-c-formatmsgid """A second approach is to simply remodel the association as an entity class. ""This is the approach we use most commonly."msgstr """Une seconde approche est simplement de remodeler l'association comme une ""classe d'entité. C'est l'approche la plus commune."#. Tag: para#: collection_mapping.xml:790#, no-c-formatmsgid """A final alternative is to use composite elements, which we will discuss ""later."msgstr """Une alternative finale est d'utiliser des éléments composites, dont nous ""discuterons plus tard."#. Tag: literal#: collection_mapping.xml:797#, no-c-formatmsgid "Using an &lt;idbag&gt;"msgstr "Utiliser un <literal>&lt;idbag&gt;</literal>"#. Tag: para#: collection_mapping.xml:799#, no-c-formatmsgid """If you've fully embraced our view that composite keys are a bad thing and ""that entities should have synthetic identifiers (surrogate keys), then you ""might find it a bit odd that the many to many associations and collections ""of values that we've shown so far all map to tables with composite keys! ""Now, this point is quite arguable; a pure association table doesn't seem to ""benefit much from a surrogate key (though a collection of composite values ""<emphasis>might</emphasis>). Nevertheless, Hibernate provides a feature that ""allows you to map many to many associations and collections of values to a ""table with a surrogate key."msgstr """Si vous embrassez pleinement notre vue que les clefs composées sont une ""mauvaise chose et que des entités devraient avoir des identifiants ""artificiels (des clefs subrogées), alors vous pourriez trouver un peu ""curieux que les associations plusieurs-vers-plusieurs et les collections de ""valeurs que nous avons montré jusqu'ici mappent toutes des tables avec des ""clefs composées ! Maintenant, ce point est assez discutable ; une table ""d'association pure ne semble pas beaucoup bénéficier d'une clef subrogée ""(bien qu'une collection de valeur composées le <emphasis>pourrait</""emphasis>). Néanmoins, Hibernate fournit une foncionnalité qui vous permet ""de mapper des associations plusieurs-vers-plusieurs et des collections de ""valeurs vers une table avec une clef subrogée."#. Tag: para#: collection_mapping.xml:810#, no-c-formatmsgid """The <literal>&lt;idbag&gt;</literal> element lets you map a <literal>List</""literal> (or <literal>Collection</literal>) with bag semantics."msgstr """L'élément <literal>&lt;idbag&gt;</literal> vous laisse mapper une ""<literal>List</literal> (ou une <literal>Collection</literal>) avec une ""sémantique de sac."#. Tag: programlisting#: collection_mapping.xml:815#, no-c-formatmsgid """<![CDATA[<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 ""#. Tag: para#: collection_mapping.xml:817#, no-c-formatmsgid """As you can see, an <literal>&lt;idbag&gt;</literal> has a synthetic id ""generator, just like an entity class! A different surrogate key is assigned ""to each collection row. Hibernate does not provide any mechanism to discover ""the surrogate key value of a particular row, however."msgstr """Comme vous pouvez voir, un <literal>&lt;idbag&gt;</literal> a un généréteur ""d'id artificiel, comme une classe d'entité ! Une clef subrogée différente ""est assignée à chaque ligne de la collection. Cependant, Hibernate ne ""fournit pas de mécanisme pour découvrir la valeur d'une clef subrogée d'une ""ligne particulière."#. Tag: para#: collection_mapping.xml:824#, no-c-formatmsgid """Note that the update performance of an <literal>&lt;idbag&gt;</literal> is ""<emphasis>much</emphasis> better than a regular <literal>&lt;bag&gt;</""literal>! Hibernate can locate individual rows efficiently and update or ""delete them individually, just like a list, map or set."msgstr """Notez que les performances de la mise à jour d'un <literal>&lt;idbag&gt;</""literal> sont <emphasis>bien</emphasis> meilleures qu'un <literal>&lt;bag&gt;""</literal> ordinaire ! Hibernate peut localiser des lignes individuelles ""efficacement et les mettre à jour ou les effacer individuellement, comme une ""liste, une map ou un ensemble."#. Tag: para#: collection_mapping.xml:831#, no-c-formatmsgid """In the current implementation, the <literal>native</literal> identifier ""generation strategy is not supported for <literal>&lt;idbag&gt;</literal> ""collection identifiers."msgstr """Dans l'implémentation actuelle, la stratégie de la génération de ""l'identifiant <literal>native</literal> n'est pas supportée pour les ""identifiants de collection <literal>&lt;idbag&gt;</literal>."#. Tag: title#: collection_mapping.xml:855#, no-c-formatmsgid "Collection examples"msgstr "Exemples de collections"#. Tag: para#: collection_mapping.xml:857#, no-c-formatmsgid """The previous sections are pretty confusing. So lets look at an example. This ""class:"msgstr """Les sections précédentes sont assez confuses. Donc prenons un exemple. Cette ""classe :"#. Tag: programlisting#: collection_mapping.xml:862#, no-c-formatmsgid """<![CDATA[package eg;\n""import java.util.Set;\n""\n""public class Parent {\n""    private long id;\n""    private Set children;\n""\n""    public long getId() { return id; }\n""    private void setId(long id) { this.id=id; }\n""\n""    private Set getChildren() { return children; }\n""    private void setChildren(Set children) { this.children=children; }\n""\n""    ....\n""    ....\n""}]]>"msgstr ""#. Tag: para#: collection_mapping.xml:864#, no-c-formatmsgid """has a collection of <literal>Child</literal> instances. If each child has at ""most one parent, the most natural mapping is a one-to-many association:"msgstr """a une collection d'instances de <literal>Child</literal>. Si chaque enfant a ""au plus un parent, le mapping le plus naturel est une association un-vers-""plusieurs :"#. Tag: programlisting#: collection_mapping.xml:870#, no-c-formatmsgid """<![CDATA[<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 ""#. Tag: para#: collection_mapping.xml:872#, no-c-formatmsgid "This maps to the following table definitions:"msgstr "Ceci mappe les définitions de tables suivantes :"#. Tag: programlisting#: collection_mapping.xml:876#, no-c-formatmsgid """<![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]]>"msgstr ""#. Tag: para#: collection_mapping.xml:878#, no-c-formatmsgid """If the parent is <emphasis>required</emphasis>, use a bidirectional one-to-""many association:"msgstr """Si le parent est <emphasis>requis</emphasis>, utilisez une association un-""vers-plusieurs unidirectionnelle :"#. Tag: programlisting#: collection_mapping.xml:883#, no-c-formatmsgid """<![CDATA[<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 ""#. Tag: para#: collection_mapping.xml:885#, no-c-formatmsgid "Notice the <literal>NOT NULL</literal> constraint:"msgstr "Notez la contrainte <literal>NOT NULL</literal> :"#. Tag: programlisting#: collection_mapping.xml:889#, no-c-formatmsgid """<![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]]>"msgstr ""#. Tag: para#: collection_mapping.xml:891#, no-c-formatmsgid """Alternatively, if you absolutely insist that this association should be ""unidirectional, you can declare the <literal>NOT NULL</literal> constraint ""on the <li

⌨️ 快捷键说明

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