📄 session_api.po
字号:
#, no-c-formatmsgid "<![CDATA[Cat fritz = (Cat) sess.load(Cat.class, generatedId);]]>"msgstr ""#. Tag: programlisting#: session_api.xml:160#, no-c-formatmsgid """<![CDATA[// you need to wrap primitive identifiers\n""long id = 1234;\n""DomesticCat pk = (DomesticCat) sess.load( DomesticCat.class, new Long""(id) );]]>"msgstr ""#. Tag: para#: session_api.xml:162#, no-c-formatmsgid "Alternatively, you can load state into a given instance:"msgstr """あるいは、以下のように、既存のインスタンスに状態をロードすることもできます。"#. Tag: programlisting#: session_api.xml:166#, no-c-formatmsgid """<![CDATA[Cat cat = new DomesticCat();\n""// load pk's state into cat\n""sess.load( cat, new Long(pkId) );\n""Set kittens = cat.getKittens();]]>"msgstr ""#. Tag: para#: session_api.xml:168#, no-c-formatmsgid """Note that <literal>load()</literal> will throw an unrecoverable exception if ""there is no matching database row. If the class is mapped with a proxy, ""<literal>load()</literal> just returns an uninitialized proxy and does not ""actually hit the database until you invoke a method of the proxy. This ""behaviour is very useful if you wish to create an association to an object ""without actually loading it from the database. It also allows multiple ""instances to be loaded as a batch if <literal>batch-size</literal> is ""defined for the class mapping."msgstr """DBに該当する行が無い場合、 <literal>load()</literal> は回復不可能な例外を 投""げることに注意しましょう。 そのクラスがプロキシを使ってマッピングされている場""合、 <literal>load()</literal> は初期化されていないプロキシを返し、プロキシの""メソッドが呼ばれるまで実際には データベースにアクセスしません。 もし、実際に""データベースからロードせずに、オブジェクトに対する関連を作りたい場合、 この振""る舞いはとても役立ちます。 <literal>batch-size</literal> がクラスマッピングに""定義されているならば、 複数のインスタンスを一括でロードすることが可能です。"#. Tag: para#: session_api.xml:179#, no-c-formatmsgid """If you are not certain that a matching row exists, you should use the ""<literal>get()</literal> method, which hits the database immediately and ""returns null if there is no matching row."msgstr """該当する行が存在することを確信できない場合は、 <literal>get()</literal> メ""ソッドを使うべきです。 それは、データベースにすぐにアクセスし、該当する行が無""い場合はnullを返します。"#. Tag: programlisting#: session_api.xml:185#, no-c-formatmsgid """<![CDATA[Cat cat = (Cat) sess.get(Cat.class, id);\n""if (cat==null) {\n"" cat = new Cat();\n"" sess.save(cat, id);\n""}\n""return cat;]]>"msgstr ""#. Tag: para#: session_api.xml:187#, no-c-formatmsgid """You may even load an object using an SQL <literal>SELECT ... FOR UPDATE</""literal>, using a <literal>LockMode</literal>. See the API documentation for ""more information."msgstr """<literal>LockMode</literal> を使えば、 <literal>SELECT ... FOR UPDATE</""literal>というSQLを 使ってオブジェクトをロードすることができます。 詳細な情報""は、APIドキュメントを参照してください。"#. Tag: programlisting#: session_api.xml:192#, no-c-formatmsgid "<![CDATA[Cat cat = (Cat) sess.get(Cat.class, id, LockMode.UPGRADE);]]>"msgstr ""#. Tag: para#: session_api.xml:194#, no-c-formatmsgid """Note that any associated instances or contained collections are ""<emphasis>not</emphasis> selected <literal>FOR UPDATE</literal>, unless you ""decide to specify <literal>lock</literal> or <literal>all</literal> as a ""cascade style for the association."msgstr """関連に対するカスケード方法として <literal>lock</literal> や <literal>all</""literal> を 指定しない限り、関連するインスタンスや含まれるコレクションは ""<literal>FOR UPDATE</literal> で復元 <emphasis>されない</emphasis> ことに注意""しましょう。"#. Tag: para#: session_api.xml:201#, no-c-formatmsgid """It is possible to re-load an object and all its collections at any time, ""using the <literal>refresh()</literal> method. This is useful when database ""triggers are used to initialize some of the properties of the object."msgstr """<literal>refresh()</literal> メソッドを使うことで、どんなときでも、オブジェク""トやそのコレクションを リロードすることができます。 データベースのトリガが""テーブルを更新した際に、 そのテーブルに対応するオブジェクトのプロパティを同期""する場合、このメソッドが役に立ちます。"#. Tag: programlisting#: session_api.xml:207#, no-c-formatmsgid """<![CDATA[sess.save(cat);\n""sess.flush(); //force the SQL INSERT\n""sess.refresh(cat); //re-read the state (after the trigger executes)]]>"msgstr ""#. Tag: para#: session_api.xml:209#, no-c-formatmsgid """An important question usually appears at this point: How much does Hibernate ""load from the database and how many SQL <literal>SELECT</literal>s will it ""use? This depends on the <emphasis>fetching strategy</emphasis> and is ""explained in <xref linkend=\"performance-fetching\"/>."msgstr """大切な問題は、いつも次の点に関するものです。それは、Hibernateがデータベースか""ら、 どのくらいの量を復元するのかと、どのくらいの数のSQLの <literal>SELECT</""literal> 文が使われるのかです。 これは、 <emphasis>フェッチの戦略</emphasis> ""によります。これについては、<xref linkend=\"performance-fetching\"/> で説明し""ています。"#. Tag: title#: session_api.xml:219#, no-c-formatmsgid "Querying"msgstr "クエリ"#. Tag: para#: session_api.xml:221#, no-c-formatmsgid """If you don't know the identifiers of the objects you are looking for, you ""need a query. Hibernate supports an easy-to-use but powerful object oriented ""query language (HQL). For programmatic query creation, Hibernate supports a ""sophisticated Criteria and Example query feature (QBC and QBE). You may also ""express your query in the native SQL of your database, with optional support ""from Hibernate for result set conversion into objects."msgstr """探したいオブジェクトの識別子が分からない場合は、クエリが必要になります。 ""Hibernateは使いやすくて強力なオブジェクト指向のクエリ言語 (HQL)をサポートして""います。 プログラムによってクエリが作成できるように、Hibernateは洗練された""CriteriaとExampleクエリ機能(QBCとQBE)を サポートしています。ResultSetをオブ""ジェクトに変換するHibernateのオプション機能を使うことで、 データベースのネイ""ティブなSQLでクエリを表現することもできます。"#. Tag: title#: session_api.xml:231#, no-c-formatmsgid "Executing queries"msgstr "クエリの実行"#. Tag: para#: session_api.xml:233#, no-c-formatmsgid """HQL and native SQL queries are represented with an instance of <literal>org.""hibernate.Query</literal>. This interface offers methods for parameter ""binding, result set handling, and for the execution of the actual query. You ""always obtain a <literal>Query</literal> using the current <literal>Session</""literal>:"msgstr """HQLやネイティブなSQLクエリは、 <literal>org.hibernate.Query</literal> のイン""スタンスとして表現されます。 このインタフェースは、パラメータバインディングや""ResultSetのハンドリングや クエリの実行を行うメソッドを用意しています。 通""常、 <literal>Query</literal> は、以下に示すように、 その時点の ""<literal>Session</literal> を使って取得します。"#. Tag: programlisting#: session_api.xml:240#, no-c-formatmsgid """<![CDATA[List cats = session.createQuery(\n"" \"from Cat as cat where cat.birthdate < ?\")\n"" .setDate(0, date)\n"" .list();\n""\n""List mothers = session.createQuery(\n"" \"select mother from Cat as cat join cat.mother as mother where cat.name ""= ?\")\n"" .setString(0, name)\n"" .list();\n""\n""List kittens = session.createQuery(\n"" \"from Cat as cat where cat.mother = ?\")\n"" .setEntity(0, pk)\n"" .list();\n""\n""Cat mother = (Cat) session.createQuery(\n"" \"select cat.mother from Cat as cat where cat = ?\")\n"" .setEntity(0, izi)\n"" .uniqueResult();]]\n""\n""Query mothersWithKittens = (Cat) session.createQuery(\n"" \"select mother from Cat as mother left join fetch mother.kittens\");\n""Set uniqueMothers = new HashSet(mothersWithKittens.list());]]>"msgstr ""#. Tag: para#: session_api.xml:242#, no-c-formatmsgid """A query is usually executed by invoking <literal>list()</literal>, the ""result of the query will be loaded completely into a collection in memory. ""Entity instances retrieved by a query are in persistent state. The ""<literal>uniqueResult()</literal> method offers a shortcut if you know your ""query will only return a single object. Note that queries that make use of ""eager fetching of collections usually return duplicates of the root objects ""(but with their collections initialized). You can filter these duplicates ""simply through a <literal>Set</literal>."msgstr """クエリは、普通、 <literal>list()</literal> を呼び出すことによって実行されま""す。 クエリの結果は、メモリ上にあるコレクションにすべてロードされます。 クエ""リによって復元されたエンティティのインスタンスは、永続状態です。 もし、クエリ""がたった1個のインスタンスを返すと分かっているなら、 <literal>uniqueResult()</""literal> メソッドが手っ取り早い方法です。 即時フェッチを利用したクエリの場""合、ふつう、得られたコレクションには、 ルートのオブジェクトが重複して含まれて""います (しかし、ルートが持つコレクションは初期化(ロード)されています)。 こ""の重複は <literal>Set</literal> を使って取り除くことができます。"#. Tag: title#: session_api.xml:254#, no-c-formatmsgid "Iterating results"msgstr "結果をイテレートする"#. Tag: para#: session_api.xml:256#, no-c-formatmsgid """Occasionally, you might be able to achieve better performance by executing ""the query using the <literal>iterate()</literal> method. This will only ""usually be the case if you expect that the actual entity instances returned ""by the query will already be in the session or second-level cache. If they ""are not already cached, <literal>iterate()</literal> will be slower than ""<literal>list()</literal> and might require many database hits for a simple ""query, usually <emphasis>1</emphasis> for the initial select which only ""returns identifiers, and <emphasis>n</emphasis> additional selects to ""initialize the actual instances."msgstr """時々、 <literal>iterate()</literal> メソッドを使ってクエリを実行することで、 ""より良いパフォーマンスを得ることができます。 これは、通常、クエリによって得ら""れた実際のエンティティのインスタンスが、 すでにセッションまたは二次キャッシュ""に存在することが期待できる場合だけです。 それらが、まだキャッシュされていない""なら、 <literal>iterate()</literal> は、 <literal>list()</literal> よりも遅""く、簡単なクエリに対しても多くのデータベースアクセスを 必要とします。そのアク""セスとは、識別子だけを取得するための最初のselect1回と、 実際のインスタンスを""初期化するために後から行うn回のselectのことです。"#. Tag: programlisting#: session_api.xml:268#, no-c-formatmsgid """<![CDATA[// fetch ids\n""Iterator iter = sess.createQuery(\"from eg.Qux q order by q.likeliness\").""iterate();\n""while ( iter.hasNext() ) {\n"" Qux qux = (Qux) iter.next(); // fetch the object\n"" // something we couldnt express in the query\n"" if ( qux.calculateComplicatedAlgorithm() ) {\n"" // delete the current instance\n"" iter.remove();\n"" // dont need to process the rest\n"" break;\n"" }\n""}]]>"msgstr ""#. Tag: title#: session_api.xml:272#, no-c-formatmsgid "Queries that return tuples"msgstr "オブジェクトの組(tuple)を返すクエリ"#. Tag: para#: session_api.xml:274#, no-c-formatmsgid """Hibernate queries sometimes return tuples of objects, in which case each ""tuple is returned as an array:"msgstr """Hibernateのクエリでは、時々、オブジェクトの組を返すことがあります。 その場合""は、各タプルは配列として返されます。"#. Tag: programlisting#: session_api.xml:279#, no-c-formatmsgid """<![CDATA[Iterator kittensAndMothers = sess.createQuery(\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -