📄 collection_mapping.po
字号:
"片側が <literal><list></literal> や <literal><map></literal> であ""る 双方向関連は、特によく考える必要があります。 インデックスカラムにマップさ""れる子クラスのプロパティがある場合は、問題ないです。 コレクションのマッピング""で <literal>inverse=\"true\"</literal> を使い続けられます。"#. Tag: programlisting#: collection_mapping.xml:729#, no-c-formatmsgid """<![CDATA[<class name=\"Parent\">\n"" <id name=\"id\" column=\"parent_id\"/>\n"" ....\n"" <map name=\"children\" inverse=\"true\">\n"" <key column=\"parent_id\"/>\n"" <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"" <property name=\"name\" \n"" not-null=\"true\"/>\n"" <many-to-one name=\"parent\" \n"" class=\"Parent\" \n"" column=\"parent_id\"\n"" not-null=\"true\"/>\n""</class>]]>"msgstr ""#. Tag: para#: collection_mapping.xml:731#, no-c-formatmsgid """But, if there is no such property on the child class, we can't think of the ""association as truly bidirectional (there is information available at one ""end of the association that is not available at the other end). In this ""case, we can't map the collection <literal>inverse=\"true\"</literal>. ""Instead, we could use the following mapping:"msgstr """しかし、子クラスにそのようなプロパティがない場合は、 関連を真に双方向であると""考えることができません (関連の片側に利用できる情報がありますが、もう一方には""ありません)。 この場合は、コレクションに <literal>inverse=\"true\"</""literal> をマッピングできません。 代わりに、次のようなマッピングが使えます。"#. Tag: programlisting#: collection_mapping.xml:738#, no-c-formatmsgid """<![CDATA[<class name=\"Parent\">\n"" <id name=\"id\" column=\"parent_id\"/>\n"" ....\n"" <map name=\"children\">\n"" <key column=\"parent_id\"\n"" not-null=\"true\"/>\n"" <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:740#, 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 """注意: このマッピングでは、関連のコレクション値の側は、 外部キーをアップデー""トする責任があります。"#. Tag: title#: collection_mapping.xml:748#, no-c-formatmsgid "Ternary associations"msgstr "3項関連"#. Tag: para#: collection_mapping.xml:750#, 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 """3項関連のマッピングには3つのアプローチがあります。 1つ目は関連をインデックス""として <literal>Map</literal> を使用するアプローチです。"#. Tag: programlisting#: collection_mapping.xml:755#, 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:757#, 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:759#, 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 """2つ目は単純に関連をエンティティ・クラスとしてモデルを作り直すアプローチで、 頻""繁に使われます。"#. Tag: para#: collection_mapping.xml:764#, no-c-formatmsgid """A final alternative is to use composite elements, which we will discuss ""later."msgstr """最後はcomposite要素を使うアプローチです。これに関する議論は後ほど行います。"#. Tag: literal#: collection_mapping.xml:771#, no-c-formatmsgid "Using an <idbag>"msgstr "<literal><idbag></literal>の使用"#. Tag: para#: collection_mapping.xml:773#, 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 """複合キーは悪いもので、エンティティは人工の識別子(代理キー)を持つべきであると""いう考え方からは、 多対多関連と値のコレクションを複合キーを用いたテーブルへ""マッピングするのは少し奇妙に感じるかもしれません! 確かにこの考え方には議論の""余地があります。 純粋な関連テーブルは代理キーを使っても利益を得られないように""思えるからです (合成値のコレクションは利益がある <emphasis>かも</emphasis> ""しれませんが)。 とはいえ、Hibernateは代理キーを持つテーブルへ多対多関連と値""のコレクションを マッピングする機能も備えています。"#. Tag: para#: collection_mapping.xml:784#, no-c-formatmsgid """The <literal><idbag></literal> element lets you map a <literal>List</""literal> (or <literal>Collection</literal>) with bag semantics."msgstr """bagのセマンティックスを持った <literal>List</literal>(または ""<literal>Collection</literal>)を <literal><idbag></literal> 要素にマッ""ピングできます。"#. Tag: programlisting#: collection_mapping.xml:789#, 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:791#, no-c-formatmsgid """As you can see, an <literal><idbag></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 """ご存知のように <literal><idbag></literal> はエンティティ・クラスのよう""に 人工的なidジェネレータを持っています! 異なる代理キーをそれぞれのコレク""ションの列に割り当てます。 しかしながら、Hibernateはある行の代理キーの値を見""つけ出す機構を持っていません。"#. Tag: para#: collection_mapping.xml:798#, no-c-formatmsgid """Note that the update performance of an <literal><idbag></literal> is ""<emphasis>much</emphasis> better than a regular <literal><bag></""literal>! Hibernate can locate individual rows efficiently and update or ""delete them individually, just like a list, map or set."msgstr """<literal><idbag></literal> を更新するパフォーマンスは 通常の ""<literal><bag></literal> よりも良いことに注目してください! Hibernateは""個々の行を効果的に見つけることができ、 listやmap、setのように個別にその行を更""新、削除できます。"#. Tag: para#: collection_mapping.xml:805#, no-c-formatmsgid """In the current implementation, the <literal>native</literal> identifier ""generation strategy is not supported for <literal><idbag></literal> ""collection identifiers."msgstr """現在の実装では、<literal>native</literal> というid生成戦略を <literal><""idbag></literal> コレクションの識別子に対して使えません。"#. Tag: title#: collection_mapping.xml:829#, no-c-formatmsgid "Collection examples"msgstr "コレクションの例"#. Tag: para#: collection_mapping.xml:831#, no-c-formatmsgid """The previous sections are pretty confusing. So lets look at an example. This ""class:"msgstr "これまでの節の説明では理解しにくいので、以下の例を見てください。"#. Tag: programlisting#: collection_mapping.xml:836#, 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:838#, 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 """このクラスは <literal>Child</literal> インスタンスのコレクションを持っていま""す。 もし各々のchildが最大でも一つのparentを持っているならば、最も自然なマッ""ピングは一対多関連です。"#. Tag: programlisting#: collection_mapping.xml:844#, 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:846#, no-c-formatmsgid "This maps to the following table definitions:"msgstr "これは以下のテーブル定義にマッピングします。"#. Tag: programlisting#: collection_mapping.xml:850#, no-c-formatmsgid """<![CDATA[create table parent ( id bigint not null primary ke
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -