📄 association_mapping.pot
字号:
# 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#: association_mapping.xml:30#, no-c-formatmsgid "Association Mappings"msgstr ""#. Tag: title#: association_mapping.xml:33#, no-c-formatmsgid "Introduction"msgstr ""#. Tag: para#: association_mapping.xml:35#, no-c-formatmsgid "Association mappings are the often most difficult thing to get right. In this section we'll go through the canonical cases one by one, starting with unidirectional mappings, and then considering the bidirectional cases. We'll use <literal>Person</literal> and <literal>Address</literal> in all the examples."msgstr ""#. Tag: para#: association_mapping.xml:43#, no-c-formatmsgid "We'll classify associations by whether or not they map to an intervening join table, and by multiplicity."msgstr ""#. Tag: para#: association_mapping.xml:48#, no-c-formatmsgid "Nullable foreign keys are not considered good practice in traditional data modelling, so all our examples use not null foreign keys. This is not a requirement of Hibernate, and the mappings will all work if you drop the nullability constraints."msgstr ""#. Tag: title#: association_mapping.xml:58#, no-c-formatmsgid "Unidirectional associations"msgstr ""#. Tag: title#: association_mapping.xml:61 association_mapping.xml:132#, no-c-formatmsgid "many to one"msgstr ""#. Tag: para#: association_mapping.xml:63#, no-c-formatmsgid "A <emphasis>unidirectional many-to-one association</emphasis> is the most common kind of unidirectional association."msgstr ""#. Tag: programlisting#: association_mapping.xml:68#, 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" "</class>]]>"msgstr ""#. Tag: programlisting#: association_mapping.xml:69 association_mapping.xml:185#, no-c-formatmsgid "" "<![CDATA[\n" "create table Person ( personId bigint not null primary key, addressId bigint not null )\n" "create table Address ( addressId bigint not null primary key )\n" " ]]>"msgstr ""#. Tag: title#: association_mapping.xml:74 association_mapping.xml:145 association_mapping.xml:209 association_mapping.xml:249#, no-c-formatmsgid "one to one"msgstr ""#. Tag: para#: association_mapping.xml:76#, no-c-formatmsgid "A <emphasis>unidirectional one-to-one association on a foreign key</emphasis> is almost identical. The only difference is the column unique constraint."msgstr ""#. Tag: programlisting#: association_mapping.xml:81#, 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" "</class>]]>"msgstr ""#. Tag: programlisting#: association_mapping.xml:82 association_mapping.xml:217#, no-c-formatmsgid "" "<![CDATA[\n" "create table Person ( personId bigint not null primary key, addressId bigint not null unique )\n" "create table Address ( addressId bigint not null primary key )\n" " ]]>"msgstr ""#. Tag: para#: association_mapping.xml:84#, no-c-formatmsgid "A <emphasis>unidirectional one-to-one association on a primary key</emphasis> usually uses a special id generator. (Notice that we've reversed the direction of the association in this example.)"msgstr ""#. Tag: programlisting#: association_mapping.xml:90#, no-c-formatmsgid "" "<![CDATA[<class name=\"Person\">\n" " <id name=\"id\" column=\"personId\">\n" " <generator class=\"native\"/>\n" " </id>\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\" constrained=\"true\"/>\n" "</class>]]>"msgstr ""#. Tag: programlisting#: association_mapping.xml:91 association_mapping.xml:225#, no-c-formatmsgid "" "<![CDATA[\n" "create table Person ( personId bigint not null primary key )\n" "create table Address ( personId bigint not null primary key )\n" " ]]>"msgstr ""#. Tag: title#: association_mapping.xml:96 association_mapping.xml:118#, no-c-formatmsgid "one to many"msgstr ""#. Tag: para#: association_mapping.xml:98#, no-c-formatmsgid "A <emphasis>unidirectional one-to-many association on a foreign key</emphasis> is a very unusual case, and is not really recommended."msgstr ""#. Tag: programlisting#: association_mapping.xml:103#, no-c-formatmsgid "" "<![CDATA[<class name=\"Person\">\n" " <id name=\"id\" column=\"personId\">\n" " <generator class=\"native\"/>\n" " </id>\n" " <set name=\"addresses\">\n" " <key column=\"personId\" \n" " not-null=\"true\"/>\n" " <one-to-many 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:104#, no-c-formatmsgid "" "<![CDATA[\n" "create table Person ( personId bigint not null primary key )\n" "create table Address ( addressId bigint not null primary key, personId bigint not null )\n" " ]]>"msgstr ""#. Tag: para#: association_mapping.xml:106#, no-c-formatmsgid "We think it's better to use a join table for this kind of association."msgstr ""#. Tag: title#: association_mapping.xml:115#, no-c-formatmsgid "Unidirectional associations with join tables"msgstr ""#. Tag: para#: association_mapping.xml:120#, no-c-formatmsgid "A <emphasis>unidirectional one-to-many association on a join table</emphasis> is much preferred. Notice that by specifying <literal>unique=\"true\"</literal>, we have changed the multiplicity from many-to-many to one-to-many."msgstr ""#. Tag: programlisting#: association_mapping.xml:126#, 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" " 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" "</class>]]>"msgstr ""#. Tag: programlisting#: association_mapping.xml:127#, no-c-formatmsgid "" "<![CDATA[\n" "create table Person ( personId bigint not null primary key )\n" "create table PersonAddress ( personId 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:134#, no-c-formatmsgid "A <emphasis>unidirectional many-to-one association on a join table</emphasis> is quite common when the association is optional."msgstr ""#. Tag: programlisting#: association_mapping.xml:139#, 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\" unique=\"true\"/>\n" " <many-to-one name=\"address\"\n" " column=\"addressId\" \n" " not-null=\"true\"/>\n" " </join>\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:140#, no-c-formatmsgid "" "<![CDATA[\n" "create table Person ( personId bigint not null primary key )\n" "create table PersonAddress ( personId bigint not null primary key, addressId bigint not null )\n" "create table Address ( addressId bigint not null primary key )\n" " ]]>"msgstr ""#. Tag: para#: association_mapping.xml:147#, no-c-formatmsgid "A <emphasis>unidirectional one-to-one association on a join table</emphasis> is extremely unusual, but possible."msgstr ""#. Tag: programlisting#: association_mapping.xml:152#, 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" "</class>]]>"msgstr ""#. Tag: programlisting#: association_mapping.xml:153 association_mapping.xml:257#, no-c-formatmsgid "" "<![CDATA[\n" "create table Person ( personId bigint not null primary key )\n" "create table PersonAddress ( personId bigint not null primary key, addressId bigint not null unique )\n" "create table Address ( addressId bigint not null primary key )\n" " ]]>"msgstr ""#. Tag: title#: association_mapping.xml:158 association_mapping.xml:262#, no-c-formatmsgid "many to many"msgstr ""#. Tag: para#: association_mapping.xml:160#, no-c-formatmsgid "Finally, we have a <emphasis>unidirectional many-to-many association</emphasis>."msgstr ""#. Tag: programlisting#: association_mapping.xml:164#, no-c-formatmsgid "" "<![CDATA[<class name=\"Person\">\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -