📄 persistent_classes.po
字号:
"す。"#. 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 """finalではないクラスで <literal>public final</literal> メソッドを定義すること""も避けるべきです。 <literal>public final</literal> メソッドを持つクラスを使い""たければ、 <literal>lazy=\"false\"</literal> と設定して明示的にプロキシを無効""にしなければなりません。"#. Tag: title#: persistent_classes.xml:115#, no-c-formatmsgid "Declare accessors and mutators for persistent fields (optional)"msgstr "永続フィールドに対するアクセサとミューテータを定義する(オプション)"#. 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> ではすべての永続フィールドに対してアクセサメソッドを定""義しています。 他の多くのORMツールは、永続インスタンス変数を直接永続化しま""す。 私たちはリレーショナルスキーマとクラスの内部構造を分離する方が良いと信じ""ています。 デフォルトでは、HibernateはJavaBeanスタイルのプロパティを永続化""し、 <literal>getFoo</literal>, <literal>isFoo</literal>, <literal>setFoo</""literal> 形式のメソッド名を認識します。 しかし必要なら、特定のプロパティに対""して、直接のフィールドアクセスに切り替えることは可能です。"#. 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 """プロパティはpublicで宣言する必要は <emphasis>ありません</emphasis> 。 ""Hibernateはデフォルト、<literal>protected</literal> もしくは ""<literal>private</literal> のget / setのペアを持つプロパティを永続化すること""ができます。"#. Tag: title#: persistent_classes.xml:138#, no-c-formatmsgid "Implementing inheritance"msgstr "継承の実装"#. 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 """サブクラスも1番目と2番目のルールを守らなければなりません。 サブクラスはスー""パークラス <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 "<literal>equals()</literal> と <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 """以下の条件の場合、 <literal>equals()</literal> と <literal>hashCode()</""literal> メソッドをオーバーライドしなければなりません、"#. 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 """永続クラスのインスタンスを <literal>Set</literal> に置く場合。 (これは多値の""関連を表現するおすすめの方法です) <emphasis>そして同時に</emphasis>"#. Tag: para#: persistent_classes.xml:164#, no-c-formatmsgid "intend to use reattachment of detached instances"msgstr "分離インスタンスをセッションへ再追加する場合。"#. 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は、永続ID(データベースの行)と、特定のセッションスコープ内に 限定""ですがJavaIDとが等価であることを保証します。 ですから異なるセッションで検索し""たインスタンスを組み合わせる場合、 <literal>Set</literal> に意味のあるセマン""ティクスを持たせようと思っているなら すぐに<literal>equals()</literal> と ""<literal>hashCode()</literal> を実装しなければなりません。"#. 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 """最も明白な方法は、両方のオブジェクトの識別子の値の比較によって ""<literal>equals()</literal>と <literal>hashCode()</literal> を実装する方法で""す。 値が同じなら、両者はデータベースの同じ行でなければならないため等しくなり""ます。 (両者が <literal>Set</literal> に追加されても、 <literal>Set</""literal> には1個の要素しかないことになります) 残念なことに、生成された識別子""にはこのアプローチを使うことができません。 Hibernateは永続化されたオブジェク""トへ識別子の値を代入するだけであり、 新しく作成されたインスタンスはどのような""識別子の値も持っていません。 さらに、インスタンスがセーブされておらず、現在 ""<literal>Set</literal> の中にあれば、 セーブするとオブジェクトへ識別子の値を""代入することになります。 もし <literal>equals()</literal> と ""<literal>hashCode()</literal> が識別子の値に基づいているなら、 ハッシュコード""が変更されると <literal>Set</literal> の規約が破られます。 この問題についての""完全な議論は、Hibernateのウェブサイトを見てください。 これはHibernateの問題で""はなく、オブジェクトの同一性と等価性についての、 通常のJavaのセマンティクスで""あることに注意してください。"#. 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 """<emphasis>ビジネスキーの等価性</emphasis> を使って、 <literal>equals()</""literal> と <literal>hashCode()</literal> を実装することをお勧めします。 ビジ""ネスキーの等価性とは、<literal>equals()</literal> メソッドが、ビジネスキー、 ""つまり現実の世界においてインスタンスを特定するキー(<emphasis>自然</""emphasis> 候補キー) を形成するプロパティだけを比較することを意味します。"#. 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 """ビジネスキーはデータベースの主キー候補ほど安定である必要はないことに注意して""ください (<xref linkend=\"transactions-basics-identity\"/> を見てくださ""い)。 更新不可なプロパティやユニークなプロパティは、通常ビジネスキーのよい候""補です。"#. Tag: title#: persistent_classes.xml:212#, no-c-formatmsgid "Dynamic models"msgstr "動的モデル"#. 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 """以下の機能は現在実験段階にあると見なされており、 近い将来変更される可能性があ""ることに注意してください。"#. 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 """永続エンティティは、必ずしも実行時にPOJOクラスやJavaBeanオブジェクトで表現す""る必要はありません。 Hibernateは(実行時に <literal>Map</literal> の ""<literal>Map</literal> を使う)動的モデルと、 DOM4Jツリーとしてのエンティティ""の表現もサポートします。 このアプローチを使うと永続クラスを書かず、マッピング""ファイルだけを書くことになります。"#. 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 """デフォルトでは、Hibernateは通常のPOJOモードで動作します。 ""<literal>default_entity_mode</literal> 設定オプションを使って、 特定の ""<literal>SessionFactory</literal> に対するデフォルトのエンティティ表現モード""を設定することができます (<xref linkend=\"configuration-optional-properties""\"/> を見てください)。"#. Tag: para#: persistent_classes.xml:234#, no-c-formatmsgid ""
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -