📄 performance.po
字号:
#, no-c-formatmsgid "Tuning fetch strategies"msgstr "フェッチ戦略のチューニング"#. Tag: para#: performance.xml:172#, no-c-formatmsgid """Select fetching (the default) is extremely vulnerable to N+1 selects ""problems, so we might want to enable join fetching in the mapping document:"msgstr """セレクトフェッチ(デフォルト)はN+1セレクト問題という大きな弱点があるため、 ""マッピング定義で結合フェッチを有効にすることができます。"#. Tag: programlisting#: performance.xml:177#, no-c-formatmsgid """<![CDATA[<set name=\"permissions\" \n"" fetch=\"join\">\n"" <key column=\"userId\"/>\n"" <one-to-many class=\"Permission\"/>\n""</set]]>"msgstr ""#. Tag: programlisting#: performance.xml:179#, no-c-formatmsgid "<![CDATA[<many-to-one name=\"mother\" class=\"Cat\" fetch=\"join\"/>]]>"msgstr ""#. Tag: para#: performance.xml:181#, no-c-formatmsgid """The <literal>fetch</literal> strategy defined in the mapping document ""affects:"msgstr """マッピング定義で定義した <literal>フェッチ</literal> 戦略は次のものに影響しま""す。"#. Tag: para#: performance.xml:187#, no-c-formatmsgid "retrieval via <literal>get()</literal> or <literal>load()</literal>"msgstr "<literal>get()</literal> や <literal>load()</literal> による復元"#. Tag: para#: performance.xml:192#, no-c-formatmsgid "retrieval that happens implicitly when an association is navigated"msgstr "関連にナビゲートしたときに発生する暗黙的な復元"#. Tag: para#: performance.xml:197#, no-c-formatmsgid "<literal>Criteria</literal> queries"msgstr "<literal>Criteria</literal> クエリ"#. Tag: para#: performance.xml:202#, no-c-formatmsgid "HQL queries if <literal>subselect</literal> fetching is used"msgstr "<literal>サブセレクト</literal> フェッチを使うHQLクエリ"#. Tag: para#: performance.xml:208#, no-c-formatmsgid """No matter what fetching strategy you use, the defined non-lazy graph is ""guaranteed to be loaded into memory. Note that this might result in several ""immediate selects being used to execute a particular HQL query."msgstr """たとえどんなフェッチ戦略を使ったとしても、遅延ではないグラフはメモリに読み込""まれることが 保証されます。つまり、特定のHQLクエリを実行するためにいくつかの""SELECT文が即時実行される ことがあるので注意してください。"#. Tag: para#: performance.xml:214#, no-c-formatmsgid """Usually, we don't use the mapping document to customize fetching. Instead, ""we keep the default behavior, and override it for a particular transaction, ""using <literal>left join fetch</literal> in HQL. This tells Hibernate to ""fetch the association eagerly in the first select, using an outer join. In ""the <literal>Criteria</literal> query API, you would use ""<literal>setFetchMode(FetchMode.JOIN)</literal>."msgstr """通常は、マッピング定義でフェッチのカスタマイズは行いません。 代わりに、デフォ""ルトの動作のままにしておいて、HQLで <literal>left join fetch</literal> を 指""定することで特定のトランザクションで動作をオーバーライドします。 これは""Hibernateに初回のセレクトで外部結合を使って関連を先にフェッチするように指定し""ています。 <literal>Criteria</literal> クエリのAPIでは、 ""<literal>setFetchMode(FetchMode.JOIN)</literal> を使うことが出来ます。"#. Tag: para#: performance.xml:223#, no-c-formatmsgid """If you ever feel like you wish you could change the fetching strategy used ""by <literal>get()</literal> or <literal>load()</literal>, simply use a ""<literal>Criteria</literal> query, for example:"msgstr """もし <literal>get()</literal> や <literal>load()</literal> で使われる フェッ""チ戦略を変えたいと感じたときには、単純に <literal>Criteria</literal> クエリを""使ってください。例:"#. Tag: programlisting#: performance.xml:229#, no-c-formatmsgid """<![CDATA[User user = (User) session.createCriteria(User.class)\n"" .setFetchMode(\"permissions\", FetchMode.JOIN)\n"" .add( Restrictions.idEq(userId) )\n"" .uniqueResult();]]>"msgstr ""#. Tag: para#: performance.xml:231#, no-c-formatmsgid """(This is Hibernate's equivalent of what some ORM solutions call a \"fetch ""plan\".)"msgstr """(これはいくつかのORMソリューションが\"fetch plan\"と呼んでいるものと同じで""す。)"#. Tag: para#: performance.xml:235#, no-c-formatmsgid """A completely different way to avoid problems with N+1 selects is to use the ""second-level cache."msgstr """N+1セレクト問題を避けるためのまったく違う方法は、第2レベルキャッシュを使うこ""とです。"#. Tag: title#: performance.xml:243#, no-c-formatmsgid "Single-ended association proxies"msgstr "単一端関連プロキシ"#. Tag: para#: performance.xml:245#, no-c-formatmsgid """Lazy fetching for collections is implemented using Hibernate's own ""implementation of persistent collections. However, a different mechanism is ""needed for lazy behavior in single-ended associations. The target entity of ""the association must be proxied. Hibernate implements lazy initializing ""proxies for persistent objects using runtime bytecode enhancement (via the ""excellent CGLIB library)."msgstr """コレクションの遅延フェッチは、Hibernate自身の実装による永続コレクションを使っ""て 実現しています。しかし、単一端関連における遅延処理では、違う仕組みが 必要""です。対象の関連エンティティはプロキシでなければなりません。Hibernateは (す""ばらしいCGLIBライブラリによる)実行時のバイトコード拡張を 使って永続オブジェ""クトの遅延初期化プロキシを実現しています。"#. Tag: para#: performance.xml:253#, no-c-formatmsgid """By default, Hibernate3 generates proxies (at startup) for all persistent ""classes and uses them to enable lazy fetching of <literal>many-to-one</""literal> and <literal>one-to-one</literal> associations."msgstr """デフォルトでは、Hibernate3は(開始時に)すべての永続クラスのプロキシを生成""し、 それらを使って、 <literal>many-to-one</literal> や <literal>one-to-one</""literal> 関連の 遅延フェッチを可能にしています。"#. Tag: para#: performance.xml:259#, no-c-formatmsgid """The mapping file may declare an interface to use as the proxy interface for ""that class, with the <literal>proxy</literal> attribute. By default, ""Hibernate uses a subclass of the class. <emphasis>Note that the proxied ""class must implement a default constructor with at least package visibility. ""We recommend this constructor for all persistent classes!</emphasis>"msgstr """マッピングファイルで <literal>proxy</literal> 属性によって、クラスのプロキシ""インターフェイスとして 使うインターフェイスを宣言できます。デフォルトでは、""Hibernateはそのクラスのサブクラスを使います。 <emphasis>プロキシクラスは少な""くともパッケージ可視でデフォルトコンストラクタを実装しなければ ならないことに""注意してください。すべての永続クラスにこのコンストラクタを推奨します!</""emphasis>"#. Tag: para#: performance.xml:266#, no-c-formatmsgid """There are some gotchas to be aware of when extending this approach to ""polymorphic classes, eg."msgstr """ポリモーフィズムのクラスに対してこの方法を適用するときにいくつか考慮すること""があります。 例:"#. Tag: programlisting#: performance.xml:271#, no-c-formatmsgid """<![CDATA[<class name=\"Cat\" proxy=\"Cat\">\n"" ......\n"" <subclass name=\"DomesticCat\">\n"" .....\n"" </subclass>\n""</class>]]>"msgstr ""#. Tag: para#: performance.xml:273#, no-c-formatmsgid """Firstly, instances of <literal>Cat</literal> will never be castable to ""<literal>DomesticCat</literal>, even if the underlying instance is an ""instance of <literal>DomesticCat</literal>:"msgstr """第一に、 <literal>Cat</literal> のインスタンスは <literal>DomesticCat</""literal> にキャストできません。たとえ基となるインスタンスが ""<literal>DomesticCat</literal> であったとしてもです。"#. Tag: programlisting#: performance.xml:279#, no-c-formatmsgid """<![CDATA[Cat cat = (Cat) session.load(Cat.class, id); // instantiate a ""proxy (does not hit the db)\n""if ( cat.isDomesticCat() ) { // hit the db to initialize ""the proxy\n"" DomesticCat dc = (DomesticCat) cat; // Error!\n"" ....\n""}]]>"msgstr ""#. Tag: para#: performance.xml:281#, no-c-formatmsgid "Secondly, it is possible to break proxy <literal>==</literal>."msgstr "第二に、プロキシの <literal>==</literal> は成立しないことがあります。"#. Tag: programlisting#: performance.xml:285#, no-c-formatmsgid """<![CDATA[Cat cat = (Cat) session.load(Cat.class, id); // ""instantiate a Cat proxy\n""DomesticCat dc = \n"" (DomesticCat) session.load(DomesticCat.class, id); // acquire new ""DomesticCat proxy!\n""System.out.println(cat==dc); // false]]>"msgstr ""#. Tag: para#: performance.xml:287#, no-c-formatmsgid """However, the situation is not quite as bad as it looks. Even though we now ""have two references to different proxy objects, the underlying instance will ""still be the same object:"msgstr """しかし、これは見かけほど悪い状況というわけではありません。たとえ異なったプロ""キシオブジェクトへの 二つの参照があったとしても、基となるインスタンスは同じオ""ブジェクトです。"#. Tag: programlisting#: performance.xml:292#, no-c-formatmsgid """<![CDATA[cat.setWeight(11.0); // hit the db to initialize the proxy\n""System.out.println( dc.getWeight() ); // 11.0]]>"msgstr ""#. Tag: para#: performance.xml:294#, no-c-formatmsgid """Third, you may not use a CGLIB proxy for a <literal>final</literal> class or ""a class with any <literal>final</literal> methods."msgstr """第三に、 <literal>final</literal> クラスや <literal>final</literal> メソッド""を持つクラスに CGLIBプロキシを使えません。"#. Tag: para#: performance.xml:299#, no-c-formatmsgid """Finally, if your persistent object acquires any resources upon instantiation ""(eg. in initializers or default constructor), then those resources will also ""be acquired by the proxy. The proxy class is an actual subclass of the ""persistent class."msgstr """最後に、もし永続オブジェクトのインスタンス化時(例えば、初期化処理やデフォルト""コンストラクタの中で) になんらかのリソースが必要となるなら、そのリソースもま""たプロキシを通して取得されます。 実際には、プロキシクラスは永続クラスのサブク""ラスです。"#. Tag: para#: performance.xml:305#, no-c-formatmsgid """These problems are all due to fundamental limitations in Java's single ""inheritance model. If you wish to avoid these problems your persistent ""classes must each implement an interface that declares its business methods. ""You should specify these interfaces in the mapping file. eg."msgstr """これらの問題はJavaの単一継承モデルの原理上の制限のためです。もしこれらの問題""を避けたいのなら、 ビジネスメソッドを宣言したインターフェイスをそれぞれ永続ク""ラスで実装しなければなりません。 マッピングファイルでこれらのインターフェイス""を指定する必要があります。例:"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -