📄 component_mapping.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#: component_mapping.xml:5#, no-c-formatmsgid "Component Mapping"msgstr "组件(Component)映射"#. Tag: para#: component_mapping.xml:7#, no-c-formatmsgid """The notion of a <emphasis>component</emphasis> is re-used in several ""different contexts, for different purposes, throughout Hibernate."msgstr """<emphasis>组件</emphasis>(Component)这个概念在Hibernate中几处不同的地方为了不""同的目的被重复使用."#. Tag: title#: component_mapping.xml:13#, no-c-formatmsgid "Dependent objects"msgstr "依赖对象(Dependent objects)"#. Tag: para#: component_mapping.xml:15#, no-c-formatmsgid """A component is a contained object that is persisted as a value type, not an ""entity reference. The term \"component\" refers to the object-oriented ""notion of composition (not to architecture-level components). For example, ""you might model a person like this:"msgstr """组件(Component)是一个被包含的对象,在持久化的过程中,它被当作值类型,而并非一""个实体的引用。在这篇文档中,组件这一术语指的是面向对象的合成概念(而并不是系""统构架层次上的组件的概念)。举个例子, 你对人(Person)这个概念可以像下面这样来""建模:"#. Tag: programlisting#: component_mapping.xml:21#, no-c-formatmsgid """<![CDATA[public class Person {\n"" private java.util.Date birthday;\n"" private Name name;\n"" private String key;\n"" public String getKey() {\n"" return key;\n"" }\n"" private void setKey(String key) {\n"" this.key=key;\n"" }\n"" public java.util.Date getBirthday() {\n"" return birthday;\n"" }\n"" public void setBirthday(java.util.Date birthday) {\n"" this.birthday = birthday;\n"" }\n"" public Name getName() {\n"" return name;\n"" }\n"" public void setName(Name name) {\n"" this.name = name;\n"" }\n"" ......\n"" ......\n""}]]>"msgstr ""#. Tag: programlisting#: component_mapping.xml:23#, no-c-formatmsgid """<![CDATA[public class Name {\n"" char initial;\n"" String first;\n"" String last;\n"" public String getFirst() {\n"" return first;\n"" }\n"" void setFirst(String first) {\n"" this.first = first;\n"" }\n"" public String getLast() {\n"" return last;\n"" }\n"" void setLast(String last) {\n"" this.last = last;\n"" }\n"" public char getInitial() {\n"" return initial;\n"" }\n"" void setInitial(char initial) {\n"" this.initial = initial;\n"" }\n""}]]>"msgstr ""#. Tag: para#: component_mapping.xml:25#, no-c-formatmsgid """Now <literal>Name</literal> may be persisted as a component of ""<literal>Person</literal>. Notice that <literal>Name</literal> defines ""getter and setter methods for its persistent properties, but doesn't need to ""declare any interfaces or identifier properties."msgstr """在持久化的过程中,<literal>姓名(Name)</literal>可以作为<literal>人(Person)</""literal>的一个组件。需要注意的是:你应该为<literal>姓名</literal>的持久化属性""定义getter和setter方法,但是你不需要实现任何的接口或申明标识符字段。"#. Tag: para#: component_mapping.xml:32#, no-c-formatmsgid "Our Hibernate mapping would look like:"msgstr "以下是这个例子的Hibernate映射文件:"#. Tag: programlisting#: component_mapping.xml:36#, no-c-formatmsgid """<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"" <id name=\"Key\" column=\"pid\" type=\"string\">\n"" <generator class=\"uuid\"/>\n"" </id>\n"" <property name=\"birthday\" type=\"date\"/>\n"" <component name=\"Name\" class=\"eg.Name\"> <!-- class attribute ""optional -->\n"" <property name=\"initial\"/>\n"" <property name=\"first\"/>\n"" <property name=\"last\"/>\n"" </component>\n""</class>]]>"msgstr ""#. Tag: para#: component_mapping.xml:38#, no-c-formatmsgid """The person table would have the columns <literal>pid</literal>, ""<literal>birthday</literal>, <literal>initial</literal>, <literal>first</""literal> and <literal>last</literal>."msgstr """人员(Person)表中将包括<literal>pid</literal>, <literal>birthday</literal>, ""<literal>initial</literal>, <literal>first</literal>和 <literal>last</""literal>等字段。"#. Tag: para#: component_mapping.xml:46#, no-c-formatmsgid """Like all value types, components do not support shared references. In other ""words, two persons could have the same name, but the two person objects ""would contain two independent name ojects, only \"the same\" by value. The ""null value semantics of a component are <emphasis>ad hoc</emphasis>. When ""reloading the containing object, Hibernate will assume that if all component ""columns are null, then the entire component is null. This should be okay for ""most purposes."msgstr """就像所有的值类型一样, 组件不支持共享引用。 换句话说,两个人可能重名,但是两个""Person对象应该包含两个独立的Name对象,只不过这两个Name对象具有“同样”的值。 组""件的值可以为空,其定义如下。 每当Hibernate重新加载一个包含组件的对象,如果该组""件的所有字段为空,Hibernate将假定整个组件为空。 在大多数情况下,这样假定应该是""没有问题的。"#. Tag: para#: component_mapping.xml:55#, no-c-formatmsgid """The properties of a component may be of any Hibernate type (collections, ""many-to-one associations, other components, etc). Nested components should ""<emphasis>not</emphasis> be considered an exotic usage. Hibernate is ""intended to support a very fine-grained object model."msgstr """组件的属性可以是任意一种Hibernate类型(包括集合, 多对多关联, 以及其它组件等""等)。嵌套组件不应该被当作一种特殊的应用(Nested components should not be ""considered an exotic usage)。 Hibernate倾向于支持细致的(fine-grained)对象模""型。"#. Tag: para#: component_mapping.xml:62#, no-c-formatmsgid """The <literal><component></literal> element allows a <literal><""parent></literal> subelement that maps a property of the component class ""as a reference back to the containing entity."msgstr """<literal><component></literal> 元素还允许有 <literal><parent></""literal>子元素,用来表明component类中的一个属性是指向包含它的实体的引用。"#. Tag: programlisting#: component_mapping.xml:68#, no-c-formatmsgid """<![CDATA[<class name=\"eg.Person\" table=\"person\">\n"" <id name=\"Key\" column=\"pid\" type=\"string\">\n"" <generator class=\"uuid\"/>\n"" </id>\n"" <property name=\"birthday\" type=\"date\"/>\n"" <component name=\"Name\" class=\"eg.Name\" unique=\"true\">\n"" <parent name=\"namedPerson\"/> <!-- reference back to the Person --"">\n"" <property name=\"initial\"/>\n"" <property name=\"first\"/>\n"" <property name=\"last\"/>\n"" </component>\n""</class>]]>"msgstr ""#. Tag: title#: component_mapping.xml:73#, no-c-formatmsgid "Collections of dependent objects"msgstr "在集合中出现的依赖对象 (Collections of dependent objects)"#. Tag: para#: component_mapping.xml:75#, no-c-formatmsgid """Collections of components are supported (eg. an array of type <literal>Name</""literal>). Declare your component collection by replacing the <literal><""element></literal> tag with a <literal><composite-element></""literal> tag."msgstr """Hibernate支持组件的集合(例如: 一个元素是姓名(Name)这种类型的数组)。 你可以使""用<literal><composite-element></literal>标签替代<literal><""element></literal>标签来定义你的组件集合。"#. Tag: programlisting#: component_mapping.xml:82#, no-c-formatmsgid """<![CDATA[<set name=\"someNames\" table=\"some_names\" lazy=\"true\">\n"" <key column=\"id\"/>\n"" <composite-element class=\"eg.Name\"> <!-- class attribute required -->\n"" <property name=\"initial\"/>\n"" <property name=\"first\"/>\n"" <property name=\"last\"/>\n"" </composite-element>\n""</set>]]>"msgstr ""#. Tag: para#: component_mapping.xml:84#, no-c-formatmsgid """Note: if you define a <literal>Set</literal> of composite elements, it is ""very important to implement <literal>equals()</literal> and <literal>hashCode""()</literal> correctly."msgstr """注意,如果你定义的Set包含组合元素(composite-element),正确地实现""<literal>equals()</literal>和<literal>hashCode()</literal>是非常重要的。"#. Tag: para#: component_mapping.xml:90#, no-c-formatmsgid """Composite elements may contain components but not collections. If your ""composite element itself contains components, use the <literal><nested-""composite-element></literal> tag. This is a pretty exotic case - a ""collection of components which themselves have components. By this stage you ""should be asking yourself if a one-to-many association is more appropriate. ""Try remodelling the composite element as an entity - but note that even ""though the Java model is the same, the relational model and persistence ""semantics are still slightly different."msgstr """组合元素可以包含组件,但是不能包含集合。如果你的组合元素自身包含组件, 你必须""使用<literal><nested-composite-element></literal>标签。这是一个相当特殊""的案例 - 在一个组件的集合里,那些组件本身又可以包含其他的组件。这个时候你就应""该考虑一下使用one-to-many关联是否会更恰当。 尝试对这个组合元素重新建模为一个""实体-但是需要注意的是,虽然Java模型和重新建模前是一样的,关系模型和持久性语""义会有细微的变化。"#. Tag: para#: component_mapping.xml:102#, no-c-formatmsgid """Please note that a composite element mapping doesn't support null-able ""properties if you're using a <literal><set></literal>. Hibernate has ""to use each columns value to identify a record when deleting objects (there ""is no separate primary key column in the composite element table), which is ""not possible with null values. You have to either use only not-null ""properties in a composite-element or choose a <literal><list></""literal>, <literal><map></literal>, <literal><bag></literal> or ""<literal><idbag></literal>."msgstr """请注意如果你使用<literal><set></literal>标签,一个组合元素的映射不支持可""能为空的属性. 当删除对象时, Hibernate必须使用每一个字段的值来确定一条记录(在""组合元素表中,没有单独的关键字段), 如果有为null的字段,这样做就不可能了。你""必须作出一个选择,要么在组合元素中使用不能为空的属性,要么选择使用""<literal><list></literal>,<literal><map></literal>,<literal><""bag></literal> 或者 <literal><idbag></literal>而不是 <literal><""set></literal>。"#. Tag: para#: component_mapping.xml:113#, no-c-formatmsgid """A special case of a composite element is a composite element with a nested ""<literal><many-to-one></literal> element. A mapping like this allows ""you to map extra columns of a many-to-many association table to the ""composite element class. The following is a many-to-many association from ""<literal>Order</literal> to <literal>Item</literal> where ""<literal>purchaseDate</literal>, <literal>price</literal> and ""<literal>quantity</literal> are properties of the association:"msgstr """组合元素有个特别的用法是它可以包含一个<literal><many-to-one></literal>""元素。类似这样的映射允许你将一个many-to-many关联表映射为组合元素的集合。(A ""mapping like this allows you to map extra columns of a many-to-many ""association table to the composite element class.) 接下来的的例子是从""<literal>Order</literal>到<literal>Item</literal>的一个多对多的关联关系, 关联""属性是 <literal>purchaseDate</literal>, <literal>price</literal> 和 ""<literal>quantity</literal> 。"#. Tag: programlisting#: component_mapping.xml:123#, no-c-format
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -