📄 association_mapping.po
字号:
" <id name=\"id\" column=\"addressId\">\n"" <generator class=\"native\"/>\n"" </id>\n""</class>]]>"msgstr ""#. Tag: programlisting#: association_mapping.xml:141 association_mapping.xml:246#, 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:148#, no-c-formatmsgid "Bidirectional associations"msgstr "双方向関連"#. Tag: title#: association_mapping.xml:151 association_mapping.xml:211#, no-c-formatmsgid "one to many / many to one"msgstr "一対多/多対一"#. Tag: para#: association_mapping.xml:153#, 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 """<emphasis>双方向多対一関連</emphasis> は最も一般的な関連です。 (標準的な親子""関係です)"#. Tag: programlisting#: association_mapping.xml:159#, 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:163#, 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 """<literal>List</literal> (または他のインデックス付きのコレクション)を使うな""ら、 外部キーの <literal>key</literal> カラムを <literal>not null</literal> ""に設定し、 コレクション側が各要素のインデックスをメンテナンスするように、 関""連を扱う必要があります (<literal>update=\"false\"</literal> かつ ""<literal>insert=\"false\"</literal> と設定して、反対側を仮想的にinverseにしま""す):"#. Tag: programlisting#: association_mapping.xml:171#, 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:173#, no-c-formatmsgid """It is important that you define <literal>not-null=\"true\"</literal> on the ""<literal><key></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><column></literal> element, but on the <literal><key></""literal> element."msgstr """もし外部キーカラムが <literal>NOT NULL</literal> であるならば、 コレクション""マッピングの <literal><key></literal> 要素を <literal>not-null=\"true""\"</literal> にすることは重要です。 入れ子になった <literal><column></""literal> 要素だけではなく、 <literal><key></literal> 要素も ""<literal>not-null=\"true\"</literal> と定義しないようにしてください。"#. Tag: para#: association_mapping.xml:187#, no-c-formatmsgid """A <emphasis>bidirectional one-to-one association on a foreign key</emphasis> ""is quite common."msgstr "<emphasis>外部キーの双方向一対一関連</emphasis> は非常に一般的です。"#. Tag: programlisting#: association_mapping.xml:192#, 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:195#, no-c-formatmsgid """A <emphasis>bidirectional one-to-one association on a primary key</emphasis> ""uses the special id generator."msgstr """<emphasis>主キーの双方向一対一関連</emphasis> は特殊なIDジェネレータを使いま""す。"#. Tag: programlisting#: association_mapping.xml:200#, 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:208#, no-c-formatmsgid "Bidirectional associations with join tables"msgstr "結合テーブルを使った双方向関連"#. Tag: para#: association_mapping.xml:213#, 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 """<emphasis>結合テーブルの双方向一対多関連</emphasis> です。 <literal>inverse=""\"true\"</literal> が関連端、コレクション、結合のいずれかに 設定できることに""注意してください。"#. Tag: programlisting#: association_mapping.xml:219#, 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:220#, 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:227#, no-c-formatmsgid """A <emphasis>bidirectional one-to-one association on a join table</emphasis> ""is extremely unusual, but possible."msgstr """<emphasis>結合テーブルの双方向一対一関連</emphasis> は非常に特殊ですが、可能""です。"#. Tag: programlisting#: association_mapping.xml:232#, 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:240#, no-c-formatmsgid """Finally, we have a <emphasis>bidirectional many-to-many association</""emphasis>."msgstr "最後に、<emphasis>双方向多対多関連</emphasis> を示します。"#. Tag: programlisting#: association_mapping.xml:244#, 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:253#, no-c-formatmsgid "More complex association mappings"msgstr "より複雑な関連マッピング"#. Tag: para#: association_mapping.xml:255#, 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 """より複雑な関連結合は <emphasis>極めて</emphasis> 稀です。 マッピングドキュメ""ントにSQL文を埋め込むことで、 さらに複雑な状況を扱うことができます。 例えば、""<literal>accountNumber</literal>, <literal>effectiveEndDate</literal>, ""<literal>effectiveStartDate</literal> カラムを持つaccount(口座)情報の履歴を""扱うテーブルは、 以下のようにマッピングします。"#. Tag: programlisting#: association_mapping.xml:264#, 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:266#, no-c-formatmsgid """Then we can map an association to the <emphasis>current</emphasis> instance ""(the one with null <literal>effectiveEndDate</literal>) using:"msgstr """そして、関連を <emphasis>現時点の</emphasis> インスタンス ""(<literal>effectiveEndDate</literal> がnullであるもの)にマッピングします。 ""以下のようになります:"#. Tag: programlisting#: association_mapping.xml:271#, 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:273#, 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 """さらに複雑な例では、<literal>Employee(従業員)</literal> と ""<literal>Organization(組織)</literal> 間の関連が <literal>Employment(雇""用)</literal> テーブルで保持される場合を想像してください。 このテーブルには""雇用データの履歴がすべて含まれます。 すると従業員の <emphasis>最も最近の</""emphasis> 雇用者を表す関連 (最も最近の <literal>startDate</literal> を持つも""の)は、このようにマッピングできます:"#. Tag: programlisting#: association_mapping.xml:281#, 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:283#, 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 """この機能は非常に強力です。 しかしこのような場合、普通はHQLやcriteriaクエリを""使う方がより実践的です。"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -