📄 example_mappings.po
字号:
msgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""Report-Msgid-Bugs-To: http://bugs.kde.org\n""POT-Creation-Date: 2007-10-25 01:01+0000\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <LL@li.org>\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"#. Tag: title#: example_mappings.xml:20#, no-c-formatmsgid "Example: Various Mappings"msgstr "示例:复杂映射实例"#. Tag: para#: example_mappings.xml:22#, no-c-formatmsgid "This chapters shows off some more complex association mappings."msgstr "本章展示了一些较为复杂的关系映射。"#. Tag: title#: example_mappings.xml:27#, no-c-formatmsgid "Employer/Employee"msgstr "Employer(雇主)/Employee(雇员)"#. Tag: para#: example_mappings.xml:29#, 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 """下面关于<literal>Employer</literal> 和 <literal>Employee</literal>的关系模型""使用了一个真实的实体类 (<literal>Employment</literal>)来表述,这是因为对于相""同的雇员和雇主可能会有多个雇佣时间段。 对于金额和雇员姓名,用Components建模。"#. Tag: para#: example_mappings.xml:46#, no-c-formatmsgid "Heres a possible mapping document:"msgstr "映射文件可能是这样:"#. Tag: programlisting#: example_mappings.xml:50#, 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:52#, no-c-formatmsgid """And heres the table schema generated by <literal>SchemaExport</literal>."msgstr "用<literal>SchemaExport</literal>生成表结构。"#. Tag: programlisting#: example_mappings.xml:56#, 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:61#, no-c-formatmsgid "Author/Work"msgstr "Author(作家)/Work(作品)"#. Tag: para#: example_mappings.xml:63#, 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 """考虑下面的<literal>Work</literal>,<literal>Author</literal> 和 ""<literal>Person</literal>模型的关系。 我们用多对多关系来描述<literal>Work</""literal> 和 <literal>Author</literal>, 用一对一关系来描述<literal>Author</""literal> 和 <literal>Person</literal>, 另一种可能性是<literal>Author</""literal>继承<literal>Person</literal>。"#. Tag: para#: example_mappings.xml:81#, no-c-formatmsgid """The following mapping document correctly represents these relationships:"msgstr "下面的映射文件正确的描述了这些关系:"#. Tag: programlisting#: example_mappings.xml:85#, 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:87#, 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 """映射中有4个表。<literal>works</literal>, <literal>authors</literal> 和 ""<literal>persons</literal> 分别保存着work,author和person的数据。""<literal>author_work</literal>是authors和works的关联表。 表结构是由""<literal>SchemaExport</literal>生成的。"#. Tag: programlisting#: example_mappings.xml:95#, 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:100#, no-c-formatmsgid "Customer/Order/Product"msgstr "Customer(客户)/Order(订单)/Product(产品)"#. Tag: para#: example_mappings.xml:102#, 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 """现在来考虑<literal>Customer</literal>,<literal>Order</literal> , ""<literal>LineItem</literal> 和 <literal>Product</literal>关系的模型。""<literal>Customer</literal> 和 <literal>Order</literal>之间 是一对多的关系,""但是我们怎么来描述<literal>Order</literal> / <literal>LineItem</literal> / ""<literal>Product</literal>呢? 我可以把<literal>LineItem</literal>作为描述""<literal>Order</literal> 和 <literal>Product</literal> 多对多关系的关联类,在""Hibernate,这叫做组合元素。"#. Tag: para#: example_mappings.xml:122#, no-c-formatmsgid "The mapping document:"msgstr "映射文件如下:"#. Tag: programlisting#: example_mappings.xml:126#, 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:128#, 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 """<literal>customers</literal>, <literal>orders</literal>, ""<literal>line_items</literal> 和 <literal>products</literal> 分别保存着""customer, order, order line item 和 product的数据。 <literal>line_items</""literal>也作为连接orders 和 products的关联表。"#. Tag: programlisting#: example_mappings.xml:135#, no-c-formatmsgid ""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -