⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 persistent_classes.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 3 页
字号:
#. Tag: para#: persistent_classes.xml:107#, no-c-formatmsgid """You should also avoid declaring <literal>public final</literal> methods on ""the non-final classes. If you want to use a class with a <literal>public ""final</literal> method, you must explicitly disable proxying by setting ""<literal>lazy=\"false\"</literal>."msgstr """You should also avoid declaring <literal>public final</literal> methods on ""the non-final classes. If you want to use a class with a <literal>public ""final</literal> method, you must explicitly disable proying by setting ""<literal>lazy=\"false\"</literal>."#. Tag: title#: persistent_classes.xml:115#, no-c-formatmsgid "Declare accessors and mutators for persistent fields (optional)"msgstr "Declare accessors and mutators for persistent fields (optional)"#. Tag: para#: persistent_classes.xml:117#, no-c-formatmsgid """<literal>Cat</literal> declares accessor methods for all its persistent ""fields. Many other ORM tools directly persist instance variables. We believe ""it is better to provide an indirection between the relational schema and ""internal data structures of the class. By default, Hibernate persists ""JavaBeans style properties, and recognizes method names of the form ""<literal>getFoo</literal>, <literal>isFoo</literal> and <literal>setFoo</""literal>. You may switch to direct field access for particular properties, ""if needed."msgstr """<literal>Cat</literal> declares accessor methods for all its persistent ""fields. Many other ORM tools directly persist instance variables. We believe ""it is better to provide an indirection between the relational schema and ""internal data structures of the class. By default, Hibernate persists ""JavaBeans style properties, and recognizes method names of the form ""<literal>getFoo</literal>, <literal>isFoo</literal> and <literal>setFoo</""literal>. You may switch to direct field access for particular properties, ""if needed."#. Tag: para#: persistent_classes.xml:127#, no-c-formatmsgid """Properties need <emphasis>not</emphasis> be declared public - Hibernate can ""persist a property with a default, <literal>protected</literal> or ""<literal>private</literal> get / set pair."msgstr """Properties need <emphasis>not</emphasis> be declared public - Hibernate can ""persist a property with a default, <literal>protected</literal> or ""<literal>private</literal> get / set pair."#. Tag: title#: persistent_classes.xml:138#, no-c-formatmsgid "Implementing inheritance"msgstr "Implementing inheritance"#. Tag: para#: persistent_classes.xml:140#, no-c-formatmsgid """A subclass must also observe the first and second rules. It inherits its ""identifier property from the superclass, <literal>Cat</literal>."msgstr """A subclass must also observe the first and second rules. It inherits its ""identifier property from the superclass, <literal>Cat</literal>."#. Tag: programlisting#: persistent_classes.xml:145#, no-c-formatmsgid """<![CDATA[package eg;\n""\n""public class DomesticCat extends Cat {\n""        private String name;\n""\n""        public String getName() {\n""                return name;\n""        }\n""        protected void setName(String name) {\n""                this.name=name;\n""        }\n""}]]>"msgstr ""#. Tag: title#: persistent_classes.xml:149#, no-c-formatmsgid """Implementing <literal>equals()</literal> and <literal>hashCode()</literal>"msgstr """Implementing <literal>equals()</literal> and <literal>hashCode()</literal>"#. Tag: para#: persistent_classes.xml:151#, no-c-formatmsgid """You have to override the <literal>equals()</literal> and <literal>hashCode()""</literal> methods if you"msgstr """You have to override the <literal>equals()</literal> and <literal>hashCode()""</literal> methods if you"#. Tag: para#: persistent_classes.xml:157#, no-c-formatmsgid """intend to put instances of persistent classes in a <literal>Set</literal> ""(the recommended way to represent many-valued associations) <emphasis>and</""emphasis>"msgstr """intend to put instances of persistent classes in a <literal>Set</literal> ""(the recommended way to represent many-valued associations) <emphasis>and</""emphasis>"#. Tag: para#: persistent_classes.xml:164#, no-c-formatmsgid "intend to use reattachment of detached instances"msgstr "intend to use reattachment of detached instances"#. Tag: para#: persistent_classes.xml:170#, no-c-formatmsgid """Hibernate guarantees equivalence of persistent identity (database row) and ""Java identity only inside a particular session scope. So as soon as we mix ""instances retrieved in different sessions, we must implement <literal>equals""()</literal> and <literal>hashCode()</literal> if we wish to have meaningful ""semantics for <literal>Set</literal>s."msgstr """Hibernate guarantees equivalence of persistent identity (database row) and ""Java identity only inside a particular session scope. So as soon as we mix ""instances retrieved in different sessions, we must implement <literal>equals""()</literal> and <literal>hashCode()</literal> if we wish to have meaningful ""semantics for <literal>Set</literal>s."#. Tag: para#: persistent_classes.xml:178#, no-c-formatmsgid """The most obvious way is to implement <literal>equals()</literal>/""<literal>hashCode()</literal> by comparing the identifier value of both ""objects. If the value is the same, both must be the same database row, they ""are therefore equal (if both are added to a <literal>Set</literal>, we will ""only have one element in the <literal>Set</literal>). Unfortunately, we ""can't use that approach with generated identifiers! Hibernate will only ""assign identifier values to objects that are persistent, a newly created ""instance will not have any identifier value! Furthermore, if an instance is ""unsaved and currently in a <literal>Set</literal>, saving it will assign an ""identifier value to the object. If <literal>equals()</literal> and ""<literal>hashCode()</literal> are based on the identifier value, the hash ""code would change, breaking the contract of the <literal>Set</literal>. See ""the Hibernate website for a full discussion of this problem. Note that this ""is not a Hibernate issue, but normal Java semantics of object identity and ""equality."msgstr """The most obvious way is to implement <literal>equals()</literal>/""<literal>hashCode()</literal> by comparing the identifier value of both ""objects. If the value is the same, both must be the same database row, they ""are therefore equal (if both are added to a <literal>Set</literal>, we will ""only have one element in the <literal>Set</literal>). Unfortunately, we ""can't use that approach with generated identifiers! Hibernate will only ""assign identifier values to objects that are persistent, a newly created ""instance will not have any identifier value! Furthermore, if an instance is ""unsaved and currently in a <literal>Set</literal>, saving it will assign an ""identifier value to the object. If <literal>equals()</literal> and ""<literal>hashCode()</literal> are based on the identifier value, the hash ""code would change, breaking the contract of the <literal>Set</literal>. See ""the Hibernate website for a full discussion of this problem. Note that this ""is not a Hibernate issue, but normal Java semantics of object identity and ""equality."#. Tag: para#: persistent_classes.xml:192#, no-c-formatmsgid """We recommend implementing <literal>equals()</literal> and <literal>hashCode()""</literal> using <emphasis>Business key equality</emphasis>. Business key ""equality means that the <literal>equals()</literal> method compares only the ""properties that form the business key, a key that would identify our ""instance in the real world (a <emphasis>natural</emphasis> candidate key):"msgstr """We recommend implementing <literal>equals()</literal> and <literal>hashCode()""</literal> using <emphasis>Business key equality</emphasis>. Business key ""equality means that the <literal>equals()</literal> method compares only the ""properties that form the business key, a key that would identify our ""instance in the real world (a <emphasis>natural</emphasis> candidate key):"#. Tag: programlisting#: persistent_classes.xml:200#, no-c-formatmsgid """<![CDATA[public class Cat {\n""\n""    ...\n""    public boolean equals(Object other) {\n""        if (this == other) return true;\n""        if ( !(other instanceof Cat) ) return false;\n""\n""        final Cat cat = (Cat) other;\n""\n""        if ( !cat.getLitterId().equals( getLitterId() ) ) return false;\n""        if ( !cat.getMother().equals( getMother() ) ) return false;\n""\n""        return true;\n""    }\n""\n""    public int hashCode() {\n""        int result;\n""        result = getMother().hashCode();\n""        result = 29 * result + getLitterId();\n""        return result;\n""    }\n""\n""}]]>"msgstr ""#. Tag: para#: persistent_classes.xml:202#, no-c-formatmsgid """Note that a business key does not have to be as solid as a database primary ""key candidate (see <xref linkend=\"transactions-basics-identity\"/>). ""Immutable or unique properties are usually good candidates for a business ""key."msgstr """Note that a business key does not have to be as solid as a database primary ""key candidate (see <xref linkend=\"transactions-basics-identity\"/>). ""Immutable or unique properties are usually good candidates for a business ""key."#. Tag: title#: persistent_classes.xml:212#, no-c-formatmsgid "Dynamic models"msgstr "Dynamic models"#. Tag: emphasis#: persistent_classes.xml:215#, no-c-formatmsgid """Note that the following features are currently considered experimental and ""may change in the near future."msgstr """Note that the following features are currently considered experimental and ""may change in the near future."#. Tag: para#: persistent_classes.xml:219#, no-c-formatmsgid """Persistent entities don't necessarily have to be represented as POJO classes ""or as JavaBean objects at runtime. Hibernate also supports dynamic models ""(using <literal>Map</literal>s of <literal>Map</literal>s at runtime) and ""the representation of entities as DOM4J trees. With this approach, you don't ""write persistent classes, only mapping files."msgstr """Persistent entities don't necessarily have to be represented as POJO classes ""or as JavaBean objects at runtime. Hibernate also supports dynamic models ""(using <literal>Map</literal>s of <literal>Map</literal>s at runtime) and ""the representation of entities as DOM4J trees. With this approach, you don't ""write persistent classes, only mapping files."#. Tag: para#: persistent_classes.xml:227#, no-c-formatmsgid """By default, Hibernate works in normal POJO mode. You may set a default ""entity representation mode for a particular <literal>SessionFactory</""literal> using the <literal>default_entity_mode</literal> configuration ""option (see <xref linkend=\"configuration-optional-properties\"/>."msgstr """By default, Hibernate works in normal POJO mode. You may set a default ""entity representation mode for a particular <literal>SessionFactory</""literal> using the <literal>default_entity_mode</literal> configuration ""option (see <xref linkend=\"configuration-optional-properties\"/>."#. Tag: para#: persistent_classes.xml:234#, no-c-formatmsgid """The following examples demonstrates the representation using <literal>Map</""literal>s. First, in the mapping file, an <literal>entity-name</literal> has "

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -