📄 example_mappings.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#: example_mappings.xml:29#, no-c-formatmsgid "Example: Various Mappings"msgstr ""#. Tag: para#: example_mappings.xml:31#, no-c-formatmsgid "This chapters shows off some more complex association mappings."msgstr ""#. Tag: title#: example_mappings.xml:36#, no-c-formatmsgid "Employer/Employee"msgstr ""#. Tag: para#: example_mappings.xml:38#, no-c-formatmsgid "The following model of the relationship between <literal>Employer</literal> and <literal>Employee</literal> uses an actual entity class (<literal>Employment</literal>) to represent the association. This is done because there might be more than one period of employment for the same two parties. Components are used to model monetary values and employee names."msgstr ""#. Tag: para#: example_mappings.xml:55#, no-c-formatmsgid "Heres a possible mapping document:"msgstr ""#. Tag: programlisting#: example_mappings.xml:59#, no-c-formatmsgid "" "<![CDATA[<hibernate-mapping>\n" " \n" " <class name=\"Employer\" table=\"employers\">\n" " <id name=\"id\">\n" " <generator class=\"sequence\">\n" " <param name=\"sequence\">employer_id_seq</param>\n" " </generator>\n" " </id>\n" " <property name=\"name\"/>\n" " </class>\n" "\n" " <class name=\"Employment\" table=\"employment_periods\">\n" "\n" " <id name=\"id\">\n" " <generator class=\"sequence\">\n" " <param name=\"sequence\">employment_id_seq</param>\n" " </generator>\n" " </id>\n" " <property name=\"startDate\" column=\"start_date\"/>\n" " <property name=\"endDate\" column=\"end_date\"/>\n" "\n" " <component name=\"hourlyRate\" class=\"MonetaryAmount\">\n" " <property name=\"amount\">\n" " <column name=\"hourly_rate\" sql-type=\"NUMERIC(12, 2)\"/>\n" " </property>\n" " <property name=\"currency\" length=\"12\"/>\n" " </component>\n" "\n" " <many-to-one name=\"employer\" column=\"employer_id\" not-null=\"true\"/>\n" " <many-to-one name=\"employee\" column=\"employee_id\" not-null=\"true\"/>\n" "\n" " </class>\n" "\n" " <class name=\"Employee\" table=\"employees\">\n" " <id name=\"id\">\n" " <generator class=\"sequence\">\n" " <param name=\"sequence\">employee_id_seq</param>\n" " </generator>\n" " </id>\n" " <property name=\"taxfileNumber\"/>\n" " <component name=\"name\" class=\"Name\">\n" " <property name=\"firstName\"/>\n" " <property name=\"initial\"/>\n" " <property name=\"lastName\"/>\n" " </component>\n" " </class>\n" "\n" "</hibernate-mapping>]]>"msgstr ""#. Tag: para#: example_mappings.xml:61#, no-c-formatmsgid "And heres the table schema generated by <literal>SchemaExport</literal>."msgstr ""#. Tag: programlisting#: example_mappings.xml:65#, no-c-formatmsgid "" "<![CDATA[create table employers (\n" " id BIGINT not null, \n" " name VARCHAR(255), \n" " primary key (id)\n" ")\n" "\n" "create table employment_periods (\n" " id BIGINT not null,\n" " hourly_rate NUMERIC(12, 2),\n" " currency VARCHAR(12), \n" " employee_id BIGINT not null, \n" " employer_id BIGINT not null, \n" " end_date TIMESTAMP, \n" " start_date TIMESTAMP, \n" " primary key (id)\n" ")\n" "\n" "create table employees (\n" " id BIGINT not null, \n" " firstName VARCHAR(255), \n" " initial CHAR(1), \n" " lastName VARCHAR(255), \n" " taxfileNumber VARCHAR(255), \n" " primary key (id)\n" ")\n" "\n" "alter table employment_periods \n" " add constraint employment_periodsFK0 foreign key (employer_id) references employers\n" "alter table employment_periods \n" " add constraint employment_periodsFK1 foreign key (employee_id) references employees\n" "create sequence employee_id_seq\n" "create sequence employment_id_seq\n" "create sequence employer_id_seq]]>"msgstr ""#. Tag: title#: example_mappings.xml:70#, no-c-formatmsgid "Author/Work"msgstr ""#. Tag: para#: example_mappings.xml:72#, no-c-formatmsgid "Consider the following model of the relationships between <literal>Work</literal>, <literal>Author</literal> and <literal>Person</literal>. We represent the relationship between <literal>Work</literal> and <literal>Author</literal> as a many-to-many association. We choose to represent the relationship between <literal>Author</literal> and <literal>Person</literal> as one-to-one association. Another possibility would be to have <literal>Author</literal> extend <literal>Person</literal>."msgstr ""#. Tag: para#: example_mappings.xml:90#, no-c-formatmsgid "The following mapping document correctly represents these relationships:"msgstr ""#. Tag: programlisting#: example_mappings.xml:94#, no-c-formatmsgid "" "<![CDATA[<hibernate-mapping>\n" "\n" " <class name=\"Work\" table=\"works\" discriminator-value=\"W\">\n" "\n" " <id name=\"id\" column=\"id\">\n" " <generator class=\"native\"/>\n" " </id>\n" " <discriminator column=\"type\" type=\"character\"/>\n" "\n" " <property name=\"title\"/>\n" " <set name=\"authors\" table=\"author_work\">\n" " <key column name=\"work_id\"/>\n" " <many-to-many class=\"Author\" column name=\"author_id\"/>\n" " </set>\n" "\n" " <subclass name=\"Book\" discriminator-value=\"B\">\n" " <property name=\"text\"/>\n" " </subclass>\n" "\n" " <subclass name=\"Song\" discriminator-value=\"S\">\n" " <property name=\"tempo\"/>\n" " <property name=\"genre\"/>\n" " </subclass>\n" "\n" " </class>\n" "\n" " <class name=\"Author\" table=\"authors\">\n" "\n" " <id name=\"id\" column=\"id\">\n" " <!-- The Author must have the same identifier as the Person -->\n" " <generator class=\"assigned\"/> \n" " </id>\n" "\n" " <property name=\"alias\"/>\n" " <one-to-one name=\"person\" constrained=\"true\"/>\n" "\n" " <set name=\"works\" table=\"author_work\" inverse=\"true\">\n" " <key column=\"author_id\"/>\n" " <many-to-many class=\"Work\" column=\"work_id\"/>\n" " </set>\n" "\n" " </class>\n" "\n" " <class name=\"Person\" table=\"persons\">\n" " <id name=\"id\" column=\"id\">\n" " <generator class=\"native\"/>\n" " </id>\n" " <property name=\"name\"/>\n" " </class>\n" "\n" "</hibernate-mapping>]]>"msgstr ""#. Tag: para#: example_mappings.xml:96#, no-c-formatmsgid "There are four tables in this mapping. <literal>works</literal>, <literal>authors</literal> and <literal>persons</literal> hold work, author and person data respectively. <literal>author_work</literal> is an association table linking authors to works. Heres the table schema, as generated by <literal>SchemaExport</literal>."msgstr ""#. Tag: programlisting#: example_mappings.xml:104#, no-c-formatmsgid "" "<![CDATA[create table works (\n" " id BIGINT not null generated by default as identity, \n" " tempo FLOAT, \n" " genre VARCHAR(255), \n" " text INTEGER, \n" " title VARCHAR(255), \n" " type CHAR(1) not null, \n" " primary key (id)\n" ")\n" "\n" "create table author_work (\n" " author_id BIGINT not null, \n" " work_id BIGINT not null, \n" " primary key (work_id, author_id)\n" ")\n" "\n" "create table authors (\n" " id BIGINT not null generated by default as identity, \n" " alias VARCHAR(255), \n" " primary key (id)\n" ")\n" "\n" "create table persons (\n" " id BIGINT not null generated by default as identity, \n" " name VARCHAR(255), \n" " primary key (id)\n" ")\n" "\n" "alter table authors \n" " add constraint authorsFK0 foreign key (id) references persons\n" "alter table author_work \n" " add constraint author_workFK0 foreign key (author_id) references authors\n" "alter table author_work\n" " add constraint author_workFK1 foreign key (work_id) references works]]>"msgstr ""#. Tag: title#: example_mappings.xml:109#, no-c-formatmsgid "Customer/Order/Product"msgstr ""#. Tag: para#: example_mappings.xml:111#, no-c-formatmsgid "Now consider a model of the relationships between <literal>Customer</literal>, <literal>Order</literal> and <literal>LineItem</literal> and <literal>Product</literal>. There is a one-to-many association between <literal>Customer</literal> and <literal>Order</literal>, but how should we represent <literal>Order</literal> / <literal>LineItem</literal> / <literal>Product</literal>? I've chosen to map <literal>LineItem</literal> as an association class representing the many-to-many association between <literal>Order</literal> and <literal>Product</literal>. In Hibernate, this is called a composite element."msgstr ""#. Tag: para#: example_mappings.xml:131#, no-c-formatmsgid "The mapping document:"msgstr ""#. Tag: programlisting#: example_mappings.xml:135#, no-c-formatmsgid "" "<![CDATA[<hibernate-mapping>\n" "\n" " <class name=\"Customer\" table=\"customers\">\n" " <id name=\"id\">\n" " <generator class=\"native\"/>\n" " </id>\n" " <property name=\"name\"/>\n" " <set name=\"orders\" inverse=\"true\">\n" " <key column=\"customer_id\"/>\n" " <one-to-many class=\"Order\"/>\n" " </set>\n" " </class>\n" "\n" " <class name=\"Order\" table=\"orders\">\n" " <id name=\"id\">\n" " <generator class=\"native\"/>\n" " </id>\n" " <property name=\"date\"/>\n" " <many-to-one name=\"customer\" column=\"customer_id\"/>\n" " <list name=\"lineItems\" table=\"line_items\">\n" " <key column=\"order_id\"/>\n" " <list-index column=\"line_number\"/>\n" " <composite-element class=\"LineItem\">\n" " <property name=\"quantity\"/>\n" " <many-to-one name=\"product\" column=\"product_id\"/>\n" " </composite-element>\n" " </list>\n" " </class>\n" "\n" " <class name=\"Product\" table=\"products\">\n" " <id name=\"id\">\n" " <generator class=\"native\"/>\n" " </id>\n" " <property name=\"serialNumber\"/>\n" " </class>\n" "\n" "</hibernate-mapping>]]>"msgstr ""#. Tag: para#: example_mappings.xml:137#, no-c-formatmsgid "<literal>customers</literal>, <literal>orders</literal>, <literal>line_items</literal> and <literal>products</literal> hold customer, order, order line item and product data respectively. <literal>line_items</literal> also acts as an association table linking orders with products."msgstr ""#. Tag: programlisting#: example_mappings.xml:144#, no-c-formatmsgid "" "<![CDATA[create table customers (\n" " id BIGINT not null generated by default as identity, \n" " name VARCHAR(255), \n" " primary key (id)\n" ")\n" "\n" "create table orders (\n" " id BIGINT not null generated by default as identity, \n" " customer_id BIGINT, \n" " date TIMESTAMP, \n" " primary key (id)\n" ")\n" "\n" "create table line_items (\n" " line_number INTEGER not null, \n" " order_id BIGINT not null, \n" " product_id BIGINT, \n" " quantity INTEGER, \n" " primary key (order_id, line_number)\n" ")\n" "\n" "create table products (\n" " id BIGINT not null generated by default as identity, \n" " serialNumber VARCHAR(255), \n" " primary key (id)\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -