alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Hibernate example source code file (session_api.po)

This example Hibernate source code file (session_api.po) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Hibernate tags/keywords

api, cat, cat, domesticcat, hibernate, hibernate, if, list, sql, sql, tag, tag, the, this

The Hibernate session_api.po source code

# translation of Collection_Mapping.po to
# Xi HUANG <xhuang@redhat.com>, 2007, 2010.
msgid ""
msgstr ""
"Project-Id-Version: Collection_Mapping\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-07-21 05:43+0000\n"
"PO-Revision-Date: 2010-01-07 14:56+1000\n"
"Last-Translator: Xi HUANG <xhuang@redhat.com>\n"
"Language-Team:  <en@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"

#. Tag: title
#: session_api.xml:31
#, no-c-format
msgid "Working with objects"
msgstr "オブジェクトを扱う"

#. Tag: para
#: session_api.xml:33
#, no-c-format
msgid ""
"Hibernate is a full object/relational mapping solution that not only shields "
"the developer from the details of the underlying database management system, "
"but also offers <emphasis>state management of objects. This is, "
"contrary to the management of SQL <literal>statements in common "
"JDBC/SQL persistence layers, a natural object-oriented view of persistence "
"in Java applications."
msgstr ""
"Hibernate は完全なオブジェクト/リレーショナルマッピングソリューションであり、"
"データベース管理システムの詳細を開発者から隠蔽するだけでなく、オブジェクトの "
"<emphasis>状態管理 も行います。これは、 JDBC/SQL 永続層と同じよう"
"な SQL <literal>statements の管理とは異なり、 Java アプリケーション"
"における永続化に対する、とても自然なオブジェクト指向の考え方を提供します。"

#. Tag: para
#: session_api.xml:40
#, no-c-format
msgid ""
"In other words, Hibernate application developers should always think about "
"the <emphasis>state of their objects, and not necessarily about "
"the execution of SQL statements. This part is taken care of by Hibernate and "
"is only relevant for the application developer when tuning the performance "
"of the system."
msgstr ""
"言いかえれば、 Hibernate を用いるアプリケーション開発者は、オブジェクトの "
"<emphasis>状態 については常に意識すべきであり、 SQL 文の実行につい"
"ては必ずしもそうではありません。この部分は、通常、 Hibernate が処理し、システ"
"ムのパフォーマンスをチューニングするときにだけ、問題になってきます。"

#. Tag: title
#: session_api.xml:47
#, no-c-format
msgid "Hibernate object states"
msgstr "Hibernate におけるオブジェクトの状態"

#. Tag: para
#: session_api.xml:49
#, no-c-format
msgid "Hibernate defines and supports the following object states:"
msgstr "Hibernate は次のようなオブジェクトの状態を定義し、サポートしています:"

#. Tag: para
#: session_api.xml:53
#, no-c-format
msgid ""
"<emphasis>Transient - an object is transient if it has just been "
"instantiated using the <literal>new operator, and it is not "
"associated with a Hibernate <literal>Session. It has no persistent "
"representation in the database and no identifier value has been assigned. "
"Transient instances will be destroyed by the garbage collector if the "
"application does not hold a reference anymore. Use the Hibernate "
"<literal>Session to make an object persistent (and let Hibernate "
"take care of the SQL statements that need to be executed for this "
"transition)."
msgstr ""
"<emphasis>Transient - new 演算子を使ってインス"
"タンス化されただけで、 Hibernate の <literal>Session に関連付けられ"
"ていないオブジェクトは、 transient です。それは、データベースに永続的な表現を"
"持たず、識別子となる値は割り当てられていません。 Transient インスタンスは、ア"
"プリケーションがその参照をどこにも保持しない場合に、ガベージコレクタによって"
"破棄されます。オブジェクトを永続的 (persistent) な状態にするためには、 "
"Hibernate の <literal>Session を使いましょう(この状態遷移に必要と"
"なる SQL 文の発行は、 Hibernate に任せましょう)。"

#. Tag: para
#: session_api.xml:65
#, no-c-format
msgid ""
"<emphasis>Persistent - a persistent instance has a representation "
"in the database and an identifier value. It might just have been saved or "
"loaded, however, it is by definition in the scope of a <literal>Session "
"statements, or <literal>DELETE statements when an object should be "
"made transient."
msgstr ""
"<emphasis>永続的 (Persistent) - 永続的なインスタンスはデータベース"
"に永続的な表現を持ち、識別子となる値を持っています。それは、セーブされたり、"
"ロードされたりするかもしれませんが、定義上は、 <literal>Session の"
"スコープの中に存在しています。 Hibernate は、作業単位(Unit of Work)が完了し"
"たときに、永続状態のオブジェクトに加えられた変更を検出し、オブジェクトの状態"
"とデータベースを同期します。オブジェクトを transient にするときは、開発者は、"
"手作業で <literal>UPDATE 文や DELETE 文を実行し"
"ません。"

#. Tag: para
#: session_api.xml:77
#, no-c-format
msgid ""
"<emphasis>Detached - a detached instance is an object that has "
"been persistent, but its <literal>Session has been closed. The "
"reference to the object is still valid, of course, and the detached instance "
"might even be modified in this state. A detached instance can be reattached "
"to a new <literal>Session at a later point in time, making it (and "
"all the modifications) persistent again. This feature enables a programming "
"model for long running units of work that require user think-time. We call "
"them <emphasis>application transactions, i.e., a unit of work "
"from the point of view of the user."
msgstr ""
"<emphasis>Detached - detached インスタンスとは、永続化されている"
"が、それと関連付いていた <literal>Session がクローズされているオブ"
"ジェクトのことです。そのオブジェクトへの参照は、依然として有効です。そして、"
"もちろん、detached インスタンスはこの状態に修正することさえできます。 "
"detached インスタンスは、もう一度永続化したい(そして、すべての変更を永続化し"
"たい)ときに、新しい <literal>Session に再追加できます。この機能"
"は、ユーザーが考える時間を必要とするような、長期間に及ぶ作業単位に対するプロ"
"グラミングモデルを可能にします。我々は、これを <emphasis>アプリケーションのト"
"ランザクション(application transactions)</emphasis> と呼んでいます。すなわ"
"ち、ユーザーから見た作業単位だということです。"

#. Tag: para
#: session_api.xml:90
#, no-c-format
msgid ""
"We will now discuss the states and state transitions (and the Hibernate "
"methods that trigger a transition) in more detail."
msgstr ""
"これから、状態と状態遷移(そして、遷移のきっかけとなる Hibernate のメソッド)"
"について、詳細に述べます。"

#. Tag: title
#: session_api.xml:95
#, no-c-format
msgid "Making objects persistent"
msgstr "オブジェクトを永続状態にする"

#. Tag: para
#: session_api.xml:97
#, fuzzy, no-c-format
msgid ""
"Newly instantiated instances of a persistent class are considered "
"<emphasis>transient by Hibernate. We can make a transient "
"instance <emphasis>persistent by associating it with a session:"
msgstr ""
"新しくインスタンス化された永続クラスのインスタンスは、 Hibernate では "
"<emphasis>transient と見なされます。以下のように、セッションと関連"
"づけることで、 transient インスタンスを <emphasis>永続状態 (persistent) has a generated identifier, the identifier is "
"generated and assigned to the <literal>cat when save()Cat has an assigned instance before calling save()persist() instead of "
"<literal>save(), with the semantics defined in the EJB3 early "
"draft."
msgstr ""
"<literal>Cat クラスの識別子が自動生成されるのであれば、 "
"<literal>save() が呼ばれるときに、識別子が生成され、 catCat の識別子が "
"<literal>assigned 識別子を持つか、複合キーであるなら、 "
"<literal>save() を呼び出す前に、識別子を cat イ"
"ンスタンスを割り当てなければなりません。 <literal>save() の代わり"
"に、 EJB3 の初期ドラフトで定義された <literal>persist() を使うこと"
"も可能です。"

#. Tag: para
#: session_api.xml:115
#, no-c-format
msgid ""
"<literal>persist() makes a transient instance persistent. However, "
"it does not guarantee that the identifier value will be assigned to the "
"persistent instance immediately, the assignment might happen at flush time. "
"<literal>persist() also guarantees that it will not execute an "
"<literal>INSERT statement if it is called outside of transaction "
"boundaries. This is useful in long-running conversations with an extended "
"Session/persistence context."
msgstr ""

#. Tag: para
#: session_api.xml:126
#, no-c-format
msgid ""
"<literal>save() does guarantee to return an identifier. If an "
"INSERT has to be executed to get the identifier ( e.g. \"identity\" "
"generator, not \"sequence\"), this INSERT happens immediately, no matter if "
"you are inside or outside of a transaction. This is problematic in a long-"
"running conversation with an extended Session/persistence context."
msgstr ""

#. Tag: para
#: session_api.xml:135
#, fuzzy, no-c-format
msgid ""
"Alternatively, you can assign the identifier using an overloaded version of "
"<literal>save()."
msgstr ""
"代わりに、識別子を引数にとる <literal>save() メソッドを使って、識別"
"子を割り当てることもできます。"

#. Tag: programlisting
#: session_api.xml:138
#, fuzzy, no-c-format
msgid ""
"DomesticCat pk = new DomesticCat();\n"
"pk.setColor(Color.TABBY);\n"
"pk.setSex('F');\n"
"pk.setName(\"PK\");\n"
"pk.setKittens( new HashSet() );\n"
"pk.addKitten(fritz);\n"
"sess.save( pk, new Long(1234) );"
msgstr ""
"DomesticCat pk = new DomesticCat();\n"
"pk.setColor(Color.TABBY);\n"
"pk.setSex('F');\n"
"pk.setName(\"PK\");\n"
"pk.setKittens( new HashSet() );\n"
"pk.addKitten(fritz);\n"
"sess.save( pk, new Long(1234) );"

#. Tag: para
#: session_api.xml:140
#, no-c-format
msgid ""
"If the object you make persistent has associated objects (e.g. the "
"<literal>kittens collection in the previous example), these "
"objects can be made persistent in any order you like unless you have a "
"<literal>NOT NULL constraint upon a foreign key column. There is "
"never a risk of violating foreign key constraints. However, you might "
"violate a <literal>NOT NULL constraint if you save() コレクションのように)、外部キーカラムに、 "
"<literal>NOT NULL 制約をつけない限りは、これらの一連のオブジェクト"
"をどんな順番で永続化してもかまいません。外部キー制約を違反する恐れはありませ"
"ん。しかし、 <literal>NOT NULL 制約がある場合、間違った順番でオブ"
"ジェクトを <literal>save() してしまうと、制約に違反するかもしれませ"
"ん。"

#. Tag: para
#: session_api.xml:148
#, no-c-format
msgid ""
"Usually you do not bother with this detail, as you will normally use "
"Hibernate's <emphasis>transitive persistence feature to save the "
"associated objects automatically. Then, even <literal>NOT NULL "
"constraint violations do not occur - Hibernate will take care of everything. "
"Transitive persistence is discussed later in this chapter."
msgstr ""
"関連するオブジェクトを自動的に保存する、 Hibernate の <emphasis>遷移的な永続"
"化 (transitive persistence)</emphasis> 機能を使うつもりならば、そのような詳細"
"を気にする必要はありません。そして、 <literal>NOT NULL 制約の違反す"
"ら起こりません。 Hibernate がすべて面倒をみてくれます。遷移的な永続化は、この"
"章の後半に書かれています。"

#. Tag: title
#: session_api.xml:157
#, no-c-format
msgid "Loading an object"
msgstr "オブジェクトのロード"

#. Tag: para
#: session_api.xml:159
#, no-c-format
msgid ""
"The <literal>load() methods of Session provide "
"a way of retrieving a persistent instance if you know its identifier. "
"<literal>load() takes a class object and loads the state into a "
"newly instantiated instance of that class in a persistent state."
msgstr ""
"永続化されたインスタンスの識別子があらかじめ分かっているなら、 "
"<literal>Session の load() メソッドを使って、復"
"元できます。 <literal>load() は、 Class オブジェクトを引数にとり、"
"そのクラスのインスタンスを新たに生成し、状態をロードします。そのインスタンス"
"の状態は、永続 (persistent) 状態です。"

#. Tag: programlisting
#: session_api.xml:165
#, fuzzy, no-c-format
msgid "Cat fritz = (Cat) sess.load(Cat.class, generatedId);"
msgstr "Cat fritz = (Cat) sess.load(Cat.class, generatedId);"

#. Tag: programlisting
#: session_api.xml:167
#, fuzzy, no-c-format
msgid ""
"// you need to wrap primitive identifiers\n"
"long id = 1234;\n"
"DomesticCat pk = (DomesticCat) sess.load( DomesticCat.class, new Long(id) );"
msgstr ""
"// you need to wrap primitive identifiers\n"
"long id = 1234;\n"
"DomesticCat pk = (DomesticCat) sess.load( DomesticCat.class, new Long(id) );"

#. Tag: para
#: session_api.xml:169
#, no-c-format
msgid "Alternatively, you can load state into a given instance:"
msgstr ""
"あるいは、以下のように、既存のインスタンスに状態をロードすることもできます:"

#. Tag: programlisting
#: session_api.xml:171
#, fuzzy, no-c-format
msgid ""
"Cat cat = new DomesticCat();\n"
"// load pk's state into cat\n"
"sess.load( cat, new Long(pkId) );\n"
"Set kittens = cat.getKittens();"
msgstr ""
"Cat cat = new DomesticCat();\n"
"// load pk's state into cat\n"
"sess.load( cat, new Long(pkId) );\n"
"Set kittens = cat.getKittens();"

#. Tag: para
#: session_api.xml:173
#, no-c-format
msgid ""
"Be aware that <literal>load() will throw an unrecoverable "
"exception if there is no matching database row. If the class is mapped with "
"a proxy, <literal>load() just returns an uninitialized proxy and "
"does not actually hit the database until you invoke a method of the proxy. "
"This is 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 is defined for the "
"class mapping."
msgstr ""
"DB に該当する行が無い場合、 <literal>load() は回復不可能な例外を投"
"げることに注意しましょう。そのクラスがプロキシを使ってマッピングされている場"
"合、 <literal>load() は初期化されていないプロキシを返し、プロキシの"
"メソッドが呼ばれるまで実際にはデータベースにアクセスしません。もし、実際に"
"データベースからロードせずに、オブジェクトに対する関連を作りたい場合、この振"
"る舞いはとても役立ちます。 <literal>batch-size がクラスマッピングに"
"定義されているならば、複数のインスタンスを一括でロードすることが可能です。"

#. Tag: para
#: session_api.xml:182
#, no-c-format
msgid ""
"If you are not certain that a matching row exists, you should use the "
"<literal>get() method which hits the database immediately and "
"returns null if there is no matching row."
msgstr ""
"該当する行が存在することを確信できない場合は、 <literal>get() メ"
"ソッドを使うべきです。それは、データベースにすぐにアクセスし、該当する行が無"
"い場合は null を返します。"

#. Tag: programlisting
#: session_api.xml:186
#, fuzzy, no-c-format
msgid ""
"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 ""
"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;"

#. Tag: para
#: session_api.xml:188
#, no-c-format
msgid ""
"You can even load an object using an SQL <literal>SELECT ... FOR UPDATELockMode. See the API documentation for "
"more information."
msgstr ""
"<literal>LockMode を使えば、 SELECT ... FOR UPDATEFOR UPDATE, unless you decide to "
"specify <literal>lock or all as a cascade style "
"for the association."
msgstr ""
"関連に対するカスケード方法として <literal>lock や all で復元 されない ことに注意"
"しましょう。"

#. Tag: para
#: session_api.xml:199
#, no-c-format
msgid ""
"It is possible to re-load an object and all its collections at any time, "
"using the <literal>refresh() method. This is useful when database "
"triggers are used to initialize some of the properties of the object."
msgstr ""
"<literal>refresh() メソッドを使うことで、どんなときでも、オブジェク"
"トやそのコレクションをリロードすることができます。データベースのトリガがテー"
"ブルを更新した際に、そのテーブルに対応するオブジェクトのプロパティを同期する"
"場合、このメソッドが役に立ちます。"

#. Tag: programlisting
#: session_api.xml:204
#, fuzzy, no-c-format
msgid ""
"sess.save(cat);\n"
"sess.flush(); //force the SQL INSERT\n"
"sess.refresh(cat); //re-read the state (after the trigger executes)"
msgstr ""
"sess.save(cat);\n"
"sess.flush(); //force the SQL INSERT\n"
"sess.refresh(cat); //re-read the state (after the trigger executes)"

#. Tag: para
#: session_api.xml:206
#, fuzzy, no-c-format
msgid ""
"How much does Hibernate load from the database and how many SQL "
"<literal>SELECTs will it use? This depends on the "
"<emphasis>fetching strategy. This is explained in  文が使われるのかです。これは、 フェッチの"
"戦略</emphasis> によります。これについては、  using the current Session のイ"
"ンスタンスとして表現されます。このインタフェースは、パラメータバインディング"
"や ResultSet のハンドリングやクエリの実行を行うメソッドを用意しています。通"
"常、 <literal>Query は、以下に示すように、その時点の "
"<literal>Session を使って取得します。"

#. Tag: programlisting
#: session_api.xml:232
#, fuzzy, no-c-format
msgid ""
"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 ""
"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());"

#. Tag: para
#: session_api.xml:234
#, no-c-format
msgid ""
"A query is usually executed by invoking <literal>list(). The "
"result of the query will be loaded completely into a collection in memory. "
"Entity instances retrieved by a query are in a persistent state. The "
"<literal>uniqueResult() method offers a shortcut if you know your "
"query will only return a single object. 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 through "
"a <literal>Set."
msgstr ""
"クエリは、普通、 <literal>list() を呼び出すことによって実行されま"
"す。クエリの結果は、メモリ上にあるコレクションにすべてロードされます。クエリ"
"によって復元されたエンティティのインスタンスは、永続状態です。もし、クエリが"
"たった1個のインスタンスを返すと分かっているなら、 <literal>uniqueResult() を使って取り除くことができます。"

#. Tag: title
#: session_api.xml:244
#, no-c-format
msgid "Iterating results"
msgstr "結果をイテレートする"

#. Tag: para
#: session_api.xml:246
#, no-c-format
msgid ""
"Occasionally, you might be able to achieve better performance by executing "
"the query using the <literal>iterate() method. This will 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() will be slower than "
"<literal>list() and might require many database hits for a simple "
"query, usually <emphasis>1 for the initial select which only "
"returns identifiers, and <emphasis>n additional selects to "
"initialize the actual instances."
msgstr ""
"時々、 <literal>iterate() メソッドを使ってクエリを実行することで、"
"より良いパフォーマンスを得ることができます。これは、通常、クエリによって得ら"
"れた実際のエンティティのインスタンスが、すでにセッションまたは二次キャッシュ"
"に存在することが期待できる場合だけです。それらが、まだキャッシュされていない"
"なら、 <literal>iterate() は、 list() よりも遅"
"く、簡単なクエリに対しても多くのデータベースアクセスを必要とします。そのアク"
"セスとは、識別子だけを取得するための最初の select <emphasis>1回 "
"と、実際のインスタンスを初期化するために後から行う <emphasis>n回 "
"の select のことです。"

#. Tag: programlisting
#: session_api.xml:257
#, fuzzy, no-c-format
msgid ""
"// 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 ""
"// 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"
"}"

#. Tag: title
#: session_api.xml:261
#, no-c-format
msgid "Queries that return tuples"
msgstr "オブジェクトの組(tuple)を返すクエリ"

#. Tag: para
#: session_api.xml:263
#, no-c-format
msgid ""
"Hibernate queries sometimes return tuples of objects. Each tuple is returned "
"as an array:"
msgstr ""
"Hibernate のクエリでは、時々、オブジェクトの組を返すことがあります。その場合"
"は、各タプルは配列として返されます:"

#. Tag: programlisting
#: session_api.xml:266
#, fuzzy, no-c-format
msgid ""
"Iterator kittensAndMothers = sess.createQuery(\n"
"            \"select kitten, mother from Cat kitten join kitten.mother mother"
"\")\n"
"            .list()\n"
"            .iterator();\n"
"\n"
"while ( kittensAndMothers.hasNext() ) {\n"
"    Object[] tuple = (Object[]) kittensAndMothers.next();\n"
"    Cat kitten = (Cat) tuple[0];\n"
"    Cat mother = (Cat) tuple[1];\n"
"    ....\n"
"}"
msgstr ""
"Iterator kittensAndMothers = sess.createQuery(\n"
"            \"select kitten, mother from Cat kitten join kitten.mother mother"
"\")\n"
"            .list()\n"
"            .iterator();\n"
"\n"
"while ( kittensAndMothers.hasNext() ) {\n"
"    Object[] tuple = (Object[]) kittensAndMothers.next();\n"
"    Cat kitten  = tuple[0];\n"
"    Cat mother  = tuple[1];\n"
"    ....\n"
"}"

#. Tag: title
#: session_api.xml:270
#, no-c-format
msgid "Scalar results"
msgstr "スカラーの結果"

#. Tag: para
#: session_api.xml:272
#, no-c-format
msgid ""
"Queries can specify a property of a class in the <literal>select "
"clause. They can even call SQL aggregate functions. Properties or aggregates "
"are considered \"scalar\" results and not entities in persistent state."
msgstr ""
"クエリでは、 <literal>select 節でクラスのプロパティを指定できま"
"す。 SQL の集合関数を呼ぶこともできます。プロパティや集合関数は、(永続状態の"
"エンティティではなく)「スカラー値」であると見なされます。"

#. Tag: programlisting
#: session_api.xml:277
#, fuzzy, no-c-format
msgid ""
"Iterator results = sess.createQuery(\n"
"        \"select cat.color, min(cat.birthdate), count(cat) from Cat cat \" "
"+\n"
"        \"group by cat.color\")\n"
"        .list()\n"
"        .iterator();\n"
"\n"
"while ( results.hasNext() ) {\n"
"    Object[] row = (Object[]) results.next();\n"
"    Color type = (Color) row[0];\n"
"    Date oldest = (Date) row[1];\n"
"    Integer count = (Integer) row[2];\n"
"    .....\n"
"}"
msgstr ""
"Iterator results = sess.createQuery(\n"
"        \"select cat.color, min(cat.birthdate), count(cat) from Cat cat \" "
"+\n"
"        \"group by cat.color\")\n"
"        .list()\n"
"        .iterator();\n"
"\n"
"while ( results.hasNext() ) {\n"
"    Object[] row = (Object[]) results.next();\n"
"    Color type = (Color) row[0];\n"
"    Date oldest = (Date) row[1];\n"
"    Integer count = (Integer) row[2];\n"
"    .....\n"
"}"

#. Tag: title
#: session_api.xml:281
#, no-c-format
msgid "Bind parameters"
msgstr "パラメータのバインド"

#. Tag: para
#: session_api.xml:283
#, no-c-format
msgid ""
"Methods on <literal>Query are provided for binding values to named "
"parameters or JDBC-style <literal>? parameters. Contrary "
"to JDBC, Hibernate numbers parameters from zero.</emphasis> Named parameters "
"are identifiers of the form <literal>:name in the query string. "
"The advantages of named parameters are as follows:"
msgstr ""
"<literal>Query は、名前付きのパラメータや JDBC スタイルの "
"<literal>? パラメータに値をバインドするためのメソッドを持っていま"
"す。 <emphasis> JDBC とは違い、 Hibernate はパラメータにゼロから番号を振って"
"いきます。</emphasis>名前付きのパラメータとは、クエリ文字列のなかにある "
"<literal>:name 形式の識別子です。名前付きパラメータの利点は次の通り"
"です。"

#. Tag: para
#: session_api.xml:292
#, no-c-format
msgid ""
"named parameters are insensitive to the order they occur in the query string"
msgstr "名前付きパラメータは、クエリ文字列に登場する順番と無関係です"

#. Tag: para
#: session_api.xml:297
#, no-c-format
msgid "they can occur multiple times in the same query"
msgstr "同じクエリ内に複数回登場することができます"

#. Tag: para
#: session_api.xml:301
#, no-c-format
msgid "they are self-documenting"
msgstr "自分自身を説明します"

#. Tag: programlisting
#: session_api.xml:305
#, fuzzy, no-c-format
msgid ""
"//named parameter (preferred)\n"
"Query q = sess.createQuery(\"from DomesticCat cat where cat.name = :name"
"\");\n"
"q.setString(\"name\", \"Fritz\");\n"
"Iterator cats = q.iterate();"
msgstr ""
"//named parameter (preferred)\n"
"Query q = sess.createQuery(\"from DomesticCat cat where cat.name = :name"
"\");\n"
"q.setString(\"name\", \"Fritz\");\n"
"Iterator cats = q.iterate();"

#. Tag: programlisting
#: session_api.xml:307
#, fuzzy, no-c-format
msgid ""
"//positional parameter\n"
"Query q = sess.createQuery(\"from DomesticCat cat where cat.name = ?\");\n"
"q.setString(0, \"Izi\");\n"
"Iterator cats = q.iterate();"
msgstr ""
"//positional parameter\n"
"Query q = sess.createQuery(\"from DomesticCat cat where cat.name = ?\");\n"
"q.setString(0, \"Izi\");\n"
"Iterator cats = q.iterate();"

#. Tag: programlisting
#: session_api.xml:309
#, fuzzy, no-c-format
msgid ""
"//named parameter list\n"
"List names = new ArrayList();\n"
"names.add(\"Izi\");\n"
"names.add(\"Fritz\");\n"
"Query q = sess.createQuery(\"from DomesticCat cat where cat.name in (:"
"namesList)\");\n"
"q.setParameterList(\"namesList\", names);\n"
"List cats = q.list();"
msgstr ""
"//named parameter list\n"
"List names = new ArrayList();\n"
"names.add(\"Izi\");\n"
"names.add(\"Fritz\");\n"
"Query q = sess.createQuery(\"from DomesticCat cat where cat.name in (:"
"namesList)\");\n"
"q.setParameterList(\"namesList\", names);\n"
"List cats = q.list();"

#. Tag: title
#: session_api.xml:313
#, no-c-format
msgid "Pagination"
msgstr "ページ分け"

#. Tag: para
#: session_api.xml:315
#, no-c-format
msgid ""
"If you need to specify bounds upon your result set, that is, the maximum "
"number of rows you want to retrieve and/or the first row you want to "
"retrieve, you can use methods of the <literal>Query interface:"
msgstr ""
"ResultSet に制限(復元したい最大行数や復元したい最初の行)を加える必要があれ"
"ば、以下のように、 <literal>Query インターフェースのメソッドを使い"
"ます。"

#. Tag: programlisting
#: session_api.xml:320
#, fuzzy, no-c-format
msgid ""
"Query q = sess.createQuery(\"from DomesticCat cat\");\n"
"q.setFirstResult(20);\n"
"q.setMaxResults(10);\n"
"List cats = q.list();"
msgstr ""
"Query q = sess.createQuery(\"from DomesticCat cat\");\n"
"q.setFirstResult(20);\n"
"q.setMaxResults(10);\n"
"List cats = q.list();"

#. Tag: para
#: session_api.xml:322
#, no-c-format
msgid ""
"Hibernate knows how to translate this limit query into the native SQL of "
"your DBMS."
msgstr ""
"制限付きのクエリを DBMS のネイティブな SQL に変換する方法を、 Hibernate は"
"知っています。"

#. Tag: title
#: session_api.xml:327
#, no-c-format
msgid "Scrollable iteration"
msgstr "スクロール可能なイテレーション"

#. Tag: para
#: session_api.xml:329
#, no-c-format
msgid ""
"If your JDBC driver supports scrollable <literal>ResultSets, the "
"<literal>Query interface can be used to obtain a "
"<literal>ScrollableResults object that allows flexible navigation "
"of the query results."
msgstr ""
"JDBC ドライバがスクロール可能な <literal>ResultSet をサポートしてい"
"れば、 <literal>Query インターフェースを使って、 "
"<literal>ScrollableResults オブジェクトを取得できます。それを使う"
"と、クエリの結果に対して柔軟にナビゲーションできます。"

#. Tag: programlisting
#: session_api.xml:334
#, fuzzy, no-c-format
msgid ""
"Query q = sess.createQuery(\"select cat.name, cat from DomesticCat cat \" +\n"
"                            \"order by cat.name\");\n"
"ScrollableResults cats = q.scroll();\n"
"if ( cats.first() ) {\n"
"\n"
"    // find the first name on each page of an alphabetical list of cats by "
"name\n"
"    firstNamesOfPages = new ArrayList();\n"
"    do {\n"
"        String name = cats.getString(0);\n"
"        firstNamesOfPages.add(name);\n"
"    }\n"
"    while ( cats.scroll(PAGE_SIZE) );\n"
"\n"
"    // Now get the first page of cats\n"
"    pageOfCats = new ArrayList();\n"
"    cats.beforeFirst();\n"
"    int i=0;\n"
"    while( ( PAGE_SIZE > i++ ) && cats.next() ) pageOfCats.add"
"( cats.get(1) );\n"
"\n"
"}\n"
"cats.close()"
msgstr ""
"Query q = sess.createQuery(\"select cat.name, cat from DomesticCat cat \" +\n"
"                            \"order by cat.name\");\n"
"ScrollableResults cats = q.scroll();\n"
"if ( cats.first() ) {\n"
"\n"
"    // find the first name on each page of an alphabetical list of cats by "
"name\n"
"    firstNamesOfPages = new ArrayList();\n"
"    do {\n"
"        String name = cats.getString(0);\n"
"        firstNamesOfPages.add(name);\n"
"    }\n"
"    while ( cats.scroll(PAGE_SIZE) );\n"
"\n"
"    // Now get the first page of cats\n"
"    pageOfCats = new ArrayList();\n"
"    cats.beforeFirst();\n"
"    int i=0;\n"
"    while( ( PAGE_SIZE > i++ ) && cats.next() ) pageOfCats.add"
"( cats.get(1) );\n"
"\n"
"}\n"
"cats.close()"

#. Tag: para
#: session_api.xml:336
#, no-c-format
msgid ""
"Note that an open database connection and cursor is required for this "
"functionality. Use <literal>setMaxResult()/setFirstResult"
"()</literal> if you need offline pagination functionality."
msgstr ""
"この機能にはオープン状態のデータベースコネクションが必要であることに注意して"
"ください。もし、オフラインのページ分け機能が必要であれば、 "
"<literal>setMaxResult() / setFirstResult() を使"
"いましょう。"

#. Tag: title
#: session_api.xml:343
#, no-c-format
msgid "Externalizing named queries"
msgstr "名前付きクエリの外出し"

#. Tag: para
#: session_api.xml:345
#, no-c-format
msgid ""
"Queries can also be configured as so called named queries using annotations "
"or Hibernate mapping documents. <literal>@NamedQuery and "
"<literal>@NamedQueries can be defined at the class level as seen "
"in <xref linkend=\"example-named-query-annotation\"/> . However their "
"definitions are global to the session factory/entity manager factory scope. "
"A named query is defined by its name and the actual query string."
msgstr ""

#. Tag: title
#: session_api.xml:355
#, no-c-format
msgid "Defining a named query using <classname>@NamedQuery"
msgstr ""

#. Tag: programlisting
#: session_api.xml:358
#, no-c-format
msgid ""
"@Entity\n"
"@NamedQuery(name=\"night.moreRecentThan\", query=\"select n from Night n "
"where n.date >= :date\")\n"
"public class Night {\n"
"    ...\n"
"}\n"
"\n"
"public class MyDao {\n"
"    doStuff() {\n"
"        Query q = s.getNamedQuery(\"night.moreRecentThan\");\n"
"        q.setDate( \"date\", aMonthAgo );\n"
"        List results = q.list();\n"
"        ...\n"
"    }\n"
"    ...\n"
"}"
msgstr ""

#. Tag: para
#: session_api.xml:361
#, fuzzy, no-c-format
msgid ""
"Using a mapping document can be configured using the <literal><query>CDATA section if your "
"query contains characters that could be interpreted as markup."
msgstr ""
"マッピングドキュメントに名前付きのクエリを定義することができます。(マーク"
"アップと解釈される文字がクエリに含まれるなら、 <literal>CDATA セク"
"ションを使うことを忘れないようにしましょう。)"

#. Tag: title
#: session_api.xml:367
#, no-c-format
msgid "Defining a named query using <literal><query>"
msgstr ""

#. Tag: programlisting
#: session_api.xml:370
#, fuzzy, no-c-format
msgid ""
"<query name=\"ByNameAndMaximumWeight\"><![CDATA[\n"
"    from eg.DomesticCat as cat\n"
"        where cat.name = ?\n"
"        and cat.weight > ?\n"
"] ]></query>"
msgstr ""
"<query name=\"ByNameAndMaximumWeight\"><![CDATA[\n"
"    from eg.DomesticCat as cat\n"
"        where cat.name = ?\n"
"        and cat.weight > ?\n"
"] ]></query>"

#. Tag: para
#: session_api.xml:373
#, fuzzy, no-c-format
msgid ""
"Parameter binding and executing is done programatically as seen in <xref "
"linkend=\"example-parameter-binding-named-query\"/>."
msgstr ""
"パラメータのバインディングと実行は、以下のようなプログラムで行われます:"

#. Tag: title
#: session_api.xml:377
#, no-c-format
msgid "Parameter binding of a named query"
msgstr ""

#. Tag: programlisting
#: session_api.xml:379
#, fuzzy, no-c-format
msgid ""
"Query q = sess.getNamedQuery(\"ByNameAndMaximumWeight\");\n"
"q.setString(0, name);\n"
"q.setInt(1, minWeight);\n"
"List cats = q.list();"
msgstr ""
"Query q = sess.getNamedQuery(\"ByNameAndMaximumWeight\");\n"
"q.setString(0, name);\n"
"q.setInt(1, minWeight);\n"
"List cats = q.list();"

#. Tag: para
#: session_api.xml:382
#, no-c-format
msgid ""
"The actual program code is independent of the query language that is used. "
"You can also define native SQL queries in metadata, or migrate existing "
"queries to Hibernate by placing them in mapping files."
msgstr ""
"実際のプログラムコードは、使われるクエリ言語に依存していないことに注意しま"
"しょう。メタデータには、ネイティブ SQL クエリを定義することもできます。また、"
"既存のクエリをマッピングファイルに移すことで、 Hibernate に移行することもでき"
"ます。"

#. Tag: para
#: session_api.xml:387
#, no-c-format
msgid ""
"Also note that a query declaration inside a <literal><hibernate-"
"mapping></literal> element requires a global unique name for the query, "
"while a query declaration inside a <literal><class> element "
"is made unique automatically by prepending the fully qualified name of the "
"class. For example <literal>eg.Cat.ByNameAndMaximumWeight."
msgstr ""
"<literal><hibernate-mapping> 要素の中のクエリ定義は、クエリに"
"対するユニークな名前が必要なことにも注意してください。それに対して、 "
"<literal><class> 要素の中のクエリ定義は、クラスの完全限定名が"
"前に付けられるので、自動的にユニークな名前になります。例: <literal>eg.Cat."
"ByNameAndMaximumWeight</literal>"

#. Tag: title
#: session_api.xml:397
#, no-c-format
msgid "Filtering collections"
msgstr "フィルタリングコレクション"

#. Tag: para
#: session_api.xml:399
#, no-c-format
msgid ""
"A collection <emphasis>filter is a special type of query that can "
"be applied to a persistent collection or array. The query string can refer "
"to <literal>this, meaning the current collection element."
msgstr ""
"コレクション <emphasis>フィルタ は、永続化されているコレクションや"
"配列に適用される特殊なタイプのクエリです。そのクエリ文字列では、コレクション"
"のその時点での要素を意味する <literal>this を使います。"

#. Tag: programlisting
#: session_api.xml:404
#, fuzzy, no-c-format
msgid ""
"Collection blackKittens = session.createFilter(\n"
"    pk.getKittens(), \n"
"    \"where this.color = ?\")\n"
"    .setParameter( Color.BLACK, Hibernate.custom(ColorUserType.class) )\n"
"    .list()\n"
");"
msgstr ""
"Collection blackKittens = session.createFilter(\n"
"    pk.getKittens(), \n"
"    \"where this.color = ?\")\n"
"    .setParameter( Color.BLACK, Hibernate.custom(ColorUserType.class) )\n"
"    .list()\n"
");"

#. Tag: para
#: session_api.xml:406
#, no-c-format
msgid ""
"The returned collection is considered a bag that is a copy of the given "
"collection. The original collection is not modified. This is contrary to the "
"implication of the name \"filter\", but consistent with expected behavior."
msgstr ""
"返されるコレクションは Bag とみなされます。そして、それはもとのコレクションの"
"コピーになります。元のコレクションは修正されません(これは、 \"filter\" とい"
"う名前の意味とは異なりますが、期待される動き??は一致しています)。"

#. Tag: para
#: session_api.xml:411
#, no-c-format
msgid ""
"Observe that filters do not require a <literal>from clause, "
"although they can have one if required. Filters are not limited to returning "
"the collection elements themselves."
msgstr ""
"フィルタには <literal>from 節が不要であることに気づくでしょう(必要"
"なら、持つことも可能ですが)。フィルタは、コレクションの要素自体を返して構い"
"ません。"

#. Tag: programlisting
#: session_api.xml:415
#, fuzzy, no-c-format
msgid ""
"Collection blackKittenMates = session.createFilter(\n"
"    pk.getKittens(), \n"
"    \"select this.mate where this.color = eg.Color.BLACK.intValue\")\n"
"    .list();"
msgstr ""
"Collection blackKittenMates = session.createFilter(\n"
"    pk.getKittens(), \n"
"    \"select this.mate where this.color = eg.Color.BLACK.intValue\")\n"
"    .list();"

#. Tag: para
#: session_api.xml:417
#, no-c-format
msgid ""
"Even an empty filter query is useful, e.g. to load a subset of elements in a "
"large collection:"
msgstr ""
"クエリを含まないフィルタも役に立ちます。例えば、非常に大きなコレクションの部"
"分集合をロードするために使えます。"

#. Tag: programlisting
#: session_api.xml:420
#, fuzzy, no-c-format
msgid ""
"Collection tenKittens = session.createFilter(\n"
"    mother.getKittens(), \"\")\n"
"    .setFirstResult(0).setMaxResults(10)\n"
"    .list();"
msgstr ""
"Collection tenKittens = session.createFilter(\n"
"    mother.getKittens(), \"\")\n"
"    .setFirstResult(0).setMaxResults(10)\n"
"    .list();"

#. Tag: title
#: session_api.xml:424
#, no-c-format
msgid "Criteria queries"
msgstr "クライテリアのクエリ"

#. Tag: para
#: session_api.xml:426
#, no-c-format
msgid ""
"HQL is extremely powerful, but some developers prefer to build queries "
"dynamically using an object-oriented API, rather than building query "
"strings. Hibernate provides an intuitive <literal>Criteria query "
"API for these cases:"
msgstr ""
"HQL は非常に強力ですが、クエリ文字列を作るよりも、オブジェクト指向の API を"
"使って動的にクエリを作る方を好む開発者もいます。こういった場合のために、 "
"Hibernate は直感的な <literal>Criteria クエリ API を提供していま"
"す。"

#. Tag: programlisting
#: session_api.xml:431
#, fuzzy, no-c-format
msgid ""
"Criteria crit = session.createCriteria(Cat.class);\n"
"crit.add( Restrictions.eq( \"color\", eg.Color.BLACK ) );\n"
"crit.setMaxResults(10);\n"
"List cats = crit.list();"
msgstr ""
"Criteria crit = session.createCriteria(Cat.class);\n"
"crit.add( Expression.eq( \"color\", eg.Color.BLACK ) );\n"
"crit.setMaxResults(10);\n"
"List cats = crit.list();"

#. Tag: para
#: session_api.xml:433
#, fuzzy, no-c-format
msgid ""
"The <literal>Criteria and the associated ExampleExample API の詳細は、 "
"<xref linkend=\"querycriteria\"/> に述べられています。"

#. Tag: title
#: session_api.xml:439
#, no-c-format
msgid "Queries in native SQL"
msgstr "ネイティブ SQL のクエリ"

#. Tag: para
#: session_api.xml:441
#, no-c-format
msgid ""
"You can express a query in SQL, using <literal>createSQLQuery() "
"and let Hibernate manage the mapping from result sets to objects. You can at "
"any time call <literal>session.connection() and use the JDBC "
"<literal>Connection directly. If you choose to use the Hibernate "
"API, you must enclose SQL aliases in braces:"
msgstr ""
"<literal>createSQLQuery() を使って、 SQL でクエリを表現することもで"
"きます。そして、 Hibernate に、 ResultSet からオブジェクトへのマッピングをま"
"かせます。 <literal>session.connection() を呼べばどんなときでも、直"
"接、 JDBC <literal>Connection を使用できることを覚えておきましょ"
"う。もし、 Hibernate API を使うのであれば、下記のように SQL の別名を括弧でく"
"くらなければなりません。"

#. Tag: programlisting
#: session_api.xml:448
#, fuzzy, no-c-format
msgid ""
"List cats = session.createSQLQuery(\"SELECT {cat.*} FROM CAT {cat} WHERE "
"ROWNUM<10\")\n"
"    .addEntity(\"cat\", Cat.class)\n"
".list();"
msgstr ""
"List cats = session.createSQLQuery(\n"
"    \"SELECT {cat.*} FROM CAT {cat} WHERE ROWNUM<10\",\n"
"    \"cat\",\n"
"    Cat.class\n"
").list();"

#. Tag: programlisting
#: session_api.xml:450
#, fuzzy, no-c-format
msgid ""
"List cats = session.createSQLQuery(\n"
"    \"SELECT {cat}.ID AS {cat.id}, {cat}.SEX AS {cat.sex}, \" +\n"
"           \"{cat}.MATE AS {cat.mate}, {cat}.SUBCLASS AS {cat.class}, ... \" "
"+\n"
"    \"FROM CAT {cat} WHERE ROWNUM<10\")\n"
"    .addEntity(\"cat\", Cat.class)\n"
".list()"
msgstr ""
"List cats = session.createSQLQuery(\n"
"    \"SELECT {cat}.ID AS {cat.id}, {cat}.SEX AS {cat.sex}, \" +\n"
"           \"{cat}.MATE AS {cat.mate}, {cat}.SUBCLASS AS {cat.class}, ... \" "
"+\n"
"    \"FROM CAT {cat} WHERE ROWNUM<10\",\n"
"    \"cat\",\n"
"    Cat.class\n"
").list()"

#. Tag: para
#: session_api.xml:452
#, fuzzy, no-c-format
msgid ""
"SQL queries can contain named and positional parameters, just like Hibernate "
"queries. More information about native SQL queries in Hibernate can be found "
"in <xref linkend=\"querysql\"/>."
msgstr ""
"SQL クエリは、 Hibernate クエリと同じように、名前付きのパラメータと位置パラ"
"メータを持つことができます。 Hibernate におけるネイティブな SQL クエリの詳細"
"については、 <xref linkend=\"querysql\"/> を参照してください。"

#. Tag: title
#: session_api.xml:459
#, no-c-format
msgid "Modifying persistent objects"
msgstr "永続オブジェクトの修正"

#. Tag: para
#: session_api.xml:461
#, no-c-format
msgid ""
"<emphasis>Transactional persistent instances (i.e. objects "
"loaded, saved, created or queried by the <literal>Session) can be "
"manipulated by the application, and any changes to persistent state will be "
"persisted when the <literal>Session is flushed, which has a different "
"purpose) to make your modifications persistent. The most straightforward way "
"to update the state of an object is to <literal>load() it and then "
"manipulate it directly while the <literal>Session is open:"
msgstr ""
"<emphasis>処理中の永続インスタンス (例: Sessionフラッシュ されるときに、永続化されます(こ"
"れは、この章の後半で述べています)。変更を永続化するために、特殊なメソッド"
"( <literal>update() のようなもの。これは、別の目的で使用します)を"
"呼ぶ必要はありません。オブジェクトの状態を更新する一番簡単な方法は、オブジェ"
"クトを <literal>load() し、 Session をオープンに"
"している間に、直接操作することです。"

#. Tag: programlisting
#: session_api.xml:473
#, fuzzy, no-c-format
msgid ""
"DomesticCat cat = (DomesticCat) sess.load( Cat.class, new Long(69) );\n"
"cat.setName(\"PK\");\n"
"sess.flush();  // changes to cat are automatically detected and persisted"
msgstr ""
"DomesticCat cat = (DomesticCat) sess.load( Cat.class, new Long(69) );\n"
"cat.setName(\"PK\");\n"
"sess.flush();  // changes to cat are automatically detected and persisted"

#. Tag: para
#: session_api.xml:475
#, no-c-format
msgid ""
"Sometimes this programming model is inefficient, as it requires in the same "
"session both an SQL <literal>SELECT to load an object and an SQL "
"<literal>UPDATE to persist its updated state. Hibernate offers an "
"alternate approach by using detached instances."
msgstr ""
"(オブジェクトをロードするための) SQL の <literal>SELECT と(更新"
"された状態を永続化するための) SQL の <literal>UPDATE が同じセッ"
"ションで必要となるので、このプログラミングモデルは、効率が悪くなる場合があり"
"ます。そのため、 Hibernate は別の方法を用意しています。それは、 detached イン"
"スタンスを使用する方法です。"

#. Tag: title
#: session_api.xml:483
#, no-c-format
msgid "Modifying detached objects"
msgstr "detached オブジェクトの修正"

#. Tag: para
#: session_api.xml:485
#, no-c-format
msgid ""
"Many applications need to retrieve an object in one transaction, send it to "
"the UI layer for manipulation, then save the changes in a new transaction. "
"Applications that use this kind of approach in a high-concurrency "
"environment usually use versioned data to ensure isolation for the \"long\" "
"unit of work."
msgstr ""
"多くのアプリケーションでは次のことが必要になります。それは、あるトランザク"
"ションでオブジェクトを復元し、操作するためにそれを UI 層に送り、その後に、新"
"しいトランザクションで変更をセーブするといったことです。並行性の高い環境で、"
"このタイプのアプローチを使うアプリケーションでは、「期間の長い」作業単位の隔"
"離性を保証するために、バージョンデータが通常使われます。"

#. Tag: para
#: session_api.xml:491
#, no-c-format
msgid ""
"Hibernate supports this model by providing for reattachment of detached "
"instances using the <literal>Session.update() or Session."
"merge()</literal> methods:"
msgstr ""
"Hibernate は、 <literal>Session.update()Session.merge"
"()</literal> メソッドを使って、 detached インスタンスを再追加することで、この"
"モデルに対応します。"

#. Tag: programlisting
#: session_api.xml:495
#, fuzzy, no-c-format
msgid ""
"// in the first session\n"
"Cat cat = (Cat) firstSession.load(Cat.class, catId);\n"
"Cat potentialMate = new Cat();\n"
"firstSession.save(potentialMate);\n"
"\n"
"// in a higher layer of the application\n"
"cat.setMate(potentialMate);\n"
"\n"
"// later, in a new session\n"
"secondSession.update(cat);  // update cat\n"
"secondSession.update(mate); // update mate"
msgstr ""
"// in the first session\n"
"Cat cat = (Cat) firstSession.load(Cat.class, catId);\n"
"Cat potentialMate = new Cat();\n"
"firstSession.save(potentialMate);\n"
"\n"
"// in a higher layer of the application\n"
"cat.setMate(potentialMate);\n"
"\n"
"// later, in a new session\n"
"secondSession.update(cat);  // update cat\n"
"secondSession.update(mate); // update mate"

#. Tag: para
#: session_api.xml:497
#, no-c-format
msgid ""
"If the <literal>Cat with identifier catId had "
"already been loaded by <literal>secondSession when the application "
"tried to reattach it, an exception would have been thrown."
msgstr ""
"識別子 <literal>catId を持つ Cat が、既に "
"<literal>secondSession でロードされていた場合は、再追加しようとした"
"ときに、例外が投げられます。"

#. Tag: para
#: session_api.xml:502
#, no-c-format
msgid ""
"Use <literal>update() if you are certain that the session does not "
"contain an already persistent instance with the same identifier. Use "
"<literal>merge() if you want to merge your modifications at any "
"time without consideration of the state of the session. In other words, "
"<literal>update() is usually the first method you would call in a "
"fresh session, ensuring that the reattachment of your detached instances is "
"the first operation that is executed."
msgstr ""
"同じ識別子を持つ永続インスタンスをセッションが既に保持していないことを確信で"
"きるなら <literal>update() を使います。そして、セッションの状態を考"
"えずに、どんな場合でも変更をマージしたい場合は、 <literal>merge() "
"を使います。すなわち、 detached インスタンスの再追加操作が、最初に実行される"
"ことを確実にするために、通常は <literal>update() が新しいセッション"
"のなかで最初に呼ばれるメソッドになります。"

#. Tag: para
#: session_api.xml:510
#, fuzzy, no-c-format
msgid ""
"The application should individually <literal>update() detached "
"instances that are reachable from the given detached instance "
"<emphasis>only if it wants their state to be updated. This can be "
"automated using <emphasis>transitive persistence. See  すべきです。それは、その状態を更新したい"
"場合に <emphasis>限ります。  遷移的な永続化 "
"を使えば、もちろん自動化できます。<xref linkend=\"objectstate-transitive\"/> "
"を参照してください。"

#. Tag: para
#: session_api.xml:516
#, no-c-format
msgid ""
"The <literal>lock() method also allows an application to "
"reassociate an object with a new session. However, the detached instance has "
"to be unmodified."
msgstr ""
"<literal>lock() メソッドでもまた、新しいセッションにオブジェクトを"
"再関連付けできます。しかし、 detached インスタンスは無修正でなければなりませ"
"ん。"

#. Tag: programlisting
#: session_api.xml:520
#, fuzzy, no-c-format
msgid ""
"//just reassociate:\n"
"sess.lock(fritz, LockMode.NONE);\n"
"//do a version check, then reassociate:\n"
"sess.lock(izi, LockMode.READ);\n"
"//do a version check, using SELECT ... FOR UPDATE, then reassociate:\n"
"sess.lock(pk, LockMode.UPGRADE);"
msgstr ""
"//just reassociate:\n"
"sess.lock(fritz, LockMode.NONE);\n"
"//do a version check, then reassociate:\n"
"sess.lock(izi, LockMode.READ);\n"
"//do a version check, using SELECT ... FOR UPDATE, then reassociate:\n"
"sess.lock(pk, LockMode.UPGRADE);"

#. Tag: para
#: session_api.xml:522
#, no-c-format
msgid ""
"Note that <literal>lock() can be used with various "
"<literal>LockModes. See the API documentation and the chapter on "
"transaction handling for more information. Reattachment is not the only "
"usecase for <literal>lock()."
msgstr ""
"<literal>lock() は、さまざまな LockMode とともに"
"使うことができます。詳細は、 API ドキュメントとトランザクション処理の章を参照"
"してください。再追加のときにだけ、 <literal>lock() が使われるわけで"
"はありません。"

#. Tag: para
#: session_api.xml:527
#, fuzzy, no-c-format
msgid ""
"Other models for long units of work are discussed in <xref linkend="
"\"transactions-optimistic\"/>."
msgstr ""
"期間の長い作業単位の、その他のモデルは、 <xref linkend=\"transactions-"
"optimistic\"/> で述べています。"

#. Tag: title
#: session_api.xml:532
#, no-c-format
msgid "Automatic state detection"
msgstr "自動的な状態検出"

#. Tag: para
#: session_api.xml:534
#, no-c-format
msgid ""
"Hibernate users have requested a general purpose method that either saves a "
"transient instance by generating a new identifier or updates/reattaches the "
"detached instances associated with its current identifier. The "
"<literal>saveOrUpdate() method implements this functionality."
msgstr ""
"Hibernate のユーザーは次の2つのケースのどちらにも使える汎用的なメソッドを要求"
"していました。それは、新しい識別子を生成して transient インスタンスをセーブす"
"ることと、その時点の識別子と関連づいている detached インスタンスを更新/再追加"
"することのできるメソッドです。 <literal>saveOrUpdate() はこのような"
"機能を実現したメソッドです。"

#. Tag: programlisting
#: session_api.xml:540
#, fuzzy, no-c-format
msgid ""
"// in the first session\n"
"Cat cat = (Cat) firstSession.load(Cat.class, catID);\n"
"\n"
"// in a higher tier of the application\n"
"Cat mate = new Cat();\n"
"cat.setMate(mate);\n"
"\n"
"// later, in a new session\n"
"secondSession.saveOrUpdate(cat);   // update existing state (cat has a non-"
"null id)\n"
"secondSession.saveOrUpdate(mate);  // save the new instance (mate has a null "
"id)"
msgstr ""
"// in the first session\n"
"Cat cat = (Cat) firstSession.load(Cat.class, catID);\n"
"\n"
"// in a higher tier of the application\n"
"Cat mate = new Cat();\n"
"cat.setMate(mate);\n"
"\n"
"// later, in a new session\n"
"secondSession.saveOrUpdate(cat);   // update existing state (cat has a non-"
"null id)\n"
"secondSession.saveOrUpdate(mate);  // save the new instance (mate has a null "
"id)"

#. Tag: para
#: session_api.xml:542
#, no-c-format
msgid ""
"The usage and semantics of <literal>saveOrUpdate() seems to be "
"confusing for new users. Firstly, so long as you are not trying to use "
"instances from one session in another new session, you should not need to "
"use <literal>update(), saveOrUpdate(), or "
"<literal>merge(). Some whole applications will never use either of "
"these methods."
msgstr ""
"<literal>saveOrUpdate() の使用方法と意味は、新しいユーザーにとって"
"混乱を招くかもしれません。まず第一に、あるセッションで使用したインスタンスを"
"別の新しいセッションで使おうとしない限り、 <literal>update() や "
"<literal>saveOrUpdate() や merge() を使う必要は"
"ありません。アプリケーション全体を通じて、これらのメソッドを全く使わないこと"
"もあります。"

#. Tag: para
#: session_api.xml:549
#, no-c-format
msgid ""
"Usually <literal>update() or saveOrUpdate() are "
"used in the following scenario:"
msgstr ""
"通常、 <literal>update() や saveOrUpdate() は次"
"のシナリオで使われます:"

#. Tag: para
#: session_api.xml:555
#, no-c-format
msgid "the application loads an object in the first session"
msgstr "アプリケーションが最初のセッションでオブジェクトをロードします。"

#. Tag: para
#: session_api.xml:559
#, no-c-format
msgid "the object is passed up to the UI tier"
msgstr "オブジェクトが UI 層に送られます。"

#. Tag: para
#: session_api.xml:563
#, no-c-format
msgid "some modifications are made to the object"
msgstr "オブジェクトに対して変更が加えられます。"

#. Tag: para
#: session_api.xml:567
#, no-c-format
msgid "the object is passed back down to the business logic tier"
msgstr "オブジェクトがビジネスロジック層に送られます。"

#. Tag: para
#: session_api.xml:571
#, no-c-format
msgid ""
"the application persists these modifications by calling <literal>update() を呼ぶこ"
"とで、これらの変更を永続化します。"

#. Tag: para
#: session_api.xml:576
#, no-c-format
msgid "<literal>saveOrUpdate() does the following:"
msgstr "<literal>saveOrUpdate() は以下のことを行います:"

#. Tag: para
#: session_api.xml:580
#, no-c-format
msgid "if the object is already persistent in this session, do nothing"
msgstr ""
"オブジェクトがこのセッションで、すでに永続化されていれば、何もしません。"

#. Tag: para
#: session_api.xml:585
#, no-c-format
msgid ""
"if another object associated with the session has the same identifier, throw "
"an exception"
msgstr ""
"そのセッションに関連づいている別のオブジェクトが同じ識別子を持っているなら、"
"例外を投げます。"

#. Tag: para
#: session_api.xml:590
#, no-c-format
msgid "if the object has no identifier property, <literal>save() it"
msgstr ""
"オブジェクトの識別子が値を持たないならば、 <literal>save() します。"

#. Tag: para
#: session_api.xml:595
#, no-c-format
msgid ""
"if the object's identifier has the value assigned to a newly instantiated "
"object, <literal>save() it"
msgstr ""
"オブジェクトの識別子が値を持ち、その値が新たにインスタンス化されたオブジェク"
"トのための値である場合、そのオブジェクトを <literal>save() します。"

#. Tag: para
#: session_api.xml:600
#, no-c-format
msgid ""
"if the object is versioned by a <literal><version> or "
"<literal><timestamp>, and the version property value is the "
"same value assigned to a newly instantiated object, <literal>save()<"
"timestamp></literal> によって)バージョンづけされていて、バージョンのプロ"
"パティが値を持ち、その値が新しくインスタンス化されたオブジェクトのための値で"
"ある場合、そのオブジェクトを <literal>save() します。"

#. Tag: para
#: session_api.xml:608
#, no-c-format
msgid "otherwise <literal>update() the object"
msgstr ""
"そうでない場合は、そのオブジェクトを <literal>update() します。"

#. Tag: para
#: session_api.xml:612
#, no-c-format
msgid "and <literal>merge() is very different:"
msgstr "そして、 <literal>merge() は以下のように非常に異なります:"

#. Tag: para
#: session_api.xml:616
#, no-c-format
msgid ""
"if there is a persistent instance with the same identifier currently "
"associated with the session, copy the state of the given object onto the "
"persistent instance"
msgstr ""
"同じ識別子を持つ永続化インスタンスがその時点でセッションと関連付いているなら"
"ば、引数で受け取った??ブジェクトの状態を永続化インスタンスにコピーします。"

#. Tag: para
#: session_api.xml:622
#, no-c-format
msgid ""
"if there is no persistent instance currently associated with the session, "
"try to load it from the database, or create a new persistent instance"
msgstr ""
"永続化インスタンスがその時点でセッションに関連付いていないなら、データベース"
"からそれをロードするか、あるいは、新しい永続化インスタンスを作成します。"

#. Tag: para
#: session_api.xml:628
#, no-c-format
msgid "the persistent instance is returned"
msgstr "永続化インスタンスが返されます。"

#. Tag: para
#: session_api.xml:632
#, no-c-format
msgid ""
"the given instance does not become associated with the session, it remains "
"detached"
msgstr ""
"引数として与えたインスタンスはセッションと関連を持ちません。それは、分離状態"
"のままです。"

#. Tag: title
#: session_api.xml:639
#, no-c-format
msgid "Deleting persistent objects"
msgstr "永続オブジェクトの削除"

#. Tag: para
#: session_api.xml:641
#, no-c-format
msgid ""
"<literal>Session.delete() will remove an object's state from the "
"database. Your application, however, can still hold a reference to a deleted "
"object. It is best to think of <literal>delete() as making a "
"persistent instance, transient."
msgstr ""
"<literal>Session.delete() はオブジェクトの状態をデータベースから削"
"除します。もちろん、削除したオブジェクトをアプリケーションが保持したままでも"
"よいです。そのため、 <literal>delete() は永続インスタンスを "
"transient にするものと考えるのが一番です。"

#. Tag: programlisting
#: session_api.xml:646
#, fuzzy, no-c-format
msgid "sess.delete(cat);"
msgstr "sess.delete(cat);"

#. Tag: para
#: session_api.xml:648
#, no-c-format
msgid ""
"You can delete objects in any order, without risk of foreign key constraint "
"violations. It is still possible to violate a <literal>NOT NULL "
"constraint on a foreign key column by deleting objects in the wrong order, e."
"g. if you delete the parent, but forget to delete the children."
msgstr ""
"外部キー制約に違反するリスクもなく、好きな順番でオブジェクトを削除することが"
"できます。ただし、間違った順番でオブジェクトを削除すると、外部キーカラムの "
"<literal>NOT NULL 制約に違反する可能性があります。例えば、親オブ"
"ジェクトを削除したときに、子供オブジェクトを削除し忘れた場合です。"

#. Tag: title
#: session_api.xml:656
#, no-c-format
msgid "Replicating object between two different datastores"
msgstr "異なる二つのデータストア間でのオブジェクトのレプリケーション"

#. Tag: para
#: session_api.xml:658
#, no-c-format
msgid ""
"It is sometimes useful to be able to take a graph of persistent instances "
"and make them persistent in a different datastore, without regenerating "
"identifier values."
msgstr ""
"永続インスタンスのグラフを別のデータストアに永続化する場合に、識別子の値を再"
"生成せずにすむと便利な場合があります。"

#. Tag: programlisting
#: session_api.xml:662
#, fuzzy, no-c-format
msgid ""
"//retrieve a cat from one database\n"
"Session session1 = factory1.openSession();\n"
"Transaction tx1 = session1.beginTransaction();\n"
"Cat cat = session1.get(Cat.class, catId);\n"
"tx1.commit();\n"
"session1.close();\n"
"\n"
"//reconcile with a second database\n"
"Session session2 = factory2.openSession();\n"
"Transaction tx2 = session2.beginTransaction();\n"
"session2.replicate(cat, ReplicationMode.LATEST_VERSION);\n"
"tx2.commit();\n"
"session2.close();"
msgstr ""
"//retrieve a cat from one database\n"
"Session session1 = factory1.openSession();\n"
"Transaction tx1 = session1.beginTransaction();\n"
"Cat cat = session1.get(Cat.class, catId);\n"
"tx1.commit();\n"
"session1.close();\n"
"\n"
"//reconcile with a second database\n"
"Session session2 = factory2.openSession();\n"
"Transaction tx2 = session2.beginTransaction();\n"
"session2.replicate(cat, ReplicationMode.LATEST_VERSION);\n"
"tx2.commit();\n"
"session2.close();"

#. Tag: para
#: session_api.xml:664
#, no-c-format
msgid ""
"The <literal>ReplicationMode determines how replicate()ReplicationMode で指定"
"します。"

#. Tag: para
#: session_api.xml:670
#, no-c-format
msgid ""
"<literal>ReplicationMode.IGNORE: ignores the object when there is "
"an existing database row with the same identifier"
msgstr ""
"<literal>ReplicationMode.IGNORE - 同じ識別子を持つ行がデータベース"
"に存在するなら、そのオブジェクトを無視します。"

#. Tag: para
#: session_api.xml:675
#, no-c-format
msgid ""
"<literal>ReplicationMode.OVERWRITE: overwrites any existing "
"database row with the same identifier"
msgstr ""
"<literal>ReplicationMode.OVERWRITE - 同じ識別子を持つ既存の行をすべ"
"て上書きします。"

#. Tag: para
#: session_api.xml:680
#, no-c-format
msgid ""
"<literal>ReplicationMode.EXCEPTION: throws an exception if there "
"is an existing database row with the same identifier"
msgstr ""
"<literal>ReplicationMode.EXCEPTION - 同じ識別子を持つ行がデータベー"
"スに存在するなら、例外を投げます。"

#. Tag: para
#: session_api.xml:686
#, no-c-format
msgid ""
"<literal>ReplicationMode.LATEST_VERSION: overwrites the row if its "
"version number is earlier than the version number of the object, or ignore "
"the object otherwise"
msgstr ""
"<literal>ReplicationMode.LATEST_VERSION - 行に保存されているバー"
"ジョン番号が、引数のオブジェクトのバージョン番号より古いならば、その行を上書"
"きします。"

#. Tag: para
#: session_api.xml:692
#, no-c-format
msgid ""
"Usecases for this feature include reconciling data entered into different "
"database instances, upgrading system configuration information during "
"product upgrades, rolling back changes made during non-ACID transactions and "
"more."
msgstr ""
"次のようなケースで、この機能を使用します。異なるデータベースインスタンスに入"
"れられたデータの同期、製品更新時におけるシステム設定情報の更新、非 ACID トラ"
"ンザクションのなかで加えられた変更のロールバックなどです。"

#. Tag: title
#: session_api.xml:699
#, no-c-format
msgid "Flushing the Session"
msgstr "セッションのフラッシュ"

#. Tag: para
#: session_api.xml:701
#, no-c-format
msgid ""
"Sometimes the <literal>Session will execute the SQL statements "
"needed to synchronize the JDBC connection's state with the state of objects "
"held in memory. This process, called <emphasis>flush, occurs by "
"default at the following points:"
msgstr ""
"JDBC コネクションの状態とメモリ上のオブジェクトの状態を同期させるために必要"
"な SQL 文を <literal>Session が実行することがときどきあります。この"
"処理 <emphasis>flush は、デフォルトでは次のときに起こります。"

#. Tag: para
#: session_api.xml:709
#, no-c-format
msgid "before some query executions"
msgstr "クエリを実行する前"

#. Tag: para
#: session_api.xml:713
#, no-c-format
msgid "from <literal>org.hibernate.Transaction.commit()"
msgstr "<literal>org.hibernate.Transaction.commit() を実行したとき"

#. Tag: para
#: session_api.xml:718
#, no-c-format
msgid "from <literal>Session.flush()"
msgstr "<literal>Session.flush() を実行したとき"

#. Tag: para
#: session_api.xml:722
#, no-c-format
msgid "The SQL statements are issued in the following order:"
msgstr "SQL 文は以下の順番で発行されます。"

#. Tag: para
#: session_api.xml:726
#, no-c-format
msgid ""
"all entity insertions in the same order the corresponding objects were saved "
"using <literal>Session.save()"
msgstr ""
"すべてのエンティティの挿入。これは、 <literal>Session.save() を使っ"
"てセーブしたオブジェクトの順に実行していきます。"

#. Tag: para
#: session_api.xml:731
#, no-c-format
msgid "all entity updates"
msgstr "すべてのエンティティの更新"

#. Tag: para
#: session_api.xml:735
#, no-c-format
msgid "all collection deletions"
msgstr "すべてのコレクションの削除"

#. Tag: para
#: session_api.xml:739
#, no-c-format
msgid "all collection element deletions, updates and insertions"
msgstr "すべてのコレクションの要素に対する削除、更新、挿入"

#. Tag: para
#: session_api.xml:743
#, no-c-format
msgid "all collection insertions"
msgstr "すべてのコレクションの挿入"

#. Tag: para
#: session_api.xml:747
#, no-c-format
msgid ""
"all entity deletions in the same order the corresponding objects were "
"deleted using <literal>Session.delete()"
msgstr ""
"すべてのエンティティの削除。これは、 <literal>Session.delete() を"
"使って削除したオブジェクトの順に実行していきます。"

#. Tag: para
#: session_api.xml:752
#, no-c-format
msgid ""
"An exception is that objects using <literal>native ID generation "
"are inserted when they are saved."
msgstr ""
"(1つ例外があります。 <literal>native ID 生成を使ったオブジェクト"
"は、それらがセーブされたときに挿入されます。)"

#. Tag: para
#: session_api.xml:755
#, no-c-format
msgid ""
"Except when you explicitly <literal>flush(), there are absolutely "
"no guarantees about <emphasis>when the Session "
"executes the JDBC calls, only the <emphasis>order in which they "
"are executed. However, Hibernate does guarantee that the <literal>Query.list"
"(..)</literal> will never return stale or incorrect data."
msgstr ""
"明示的に <literal>flush() するときを除いて、 いつSession が JDBC をコールするのかについて絶対的な"
"保証はありません。ただし、それらが実行される <emphasis>順番 だけは"
"保証されます。また、 Hibernate は、 <literal>Query.list(..) が古い"
"データや間違ったデータ返さないことを保証しています。"

#. Tag: para
#: session_api.xml:762
#, fuzzy, no-c-format
msgid ""
"It is possible to change the default behavior so that flush occurs less "
"frequently. The <literal>FlushMode class defines three different "
"modes: only flush at commit time when the Hibernate <literal>Transaction is called explicitly. The last "
"mode is useful for long running units of work, where a <literal>Session クラスは3つの異なるモードを定義します。それ"
"は、コミット時にだけフラッシュするモード(Hibernate の <literal>Transaction が明示的に呼ばれない限りフ"
"ラッシュしないモードの3つです。最後のモードは、作業単位が長期間に及ぶ場合に"
"役に立ちます ( <xref linkend=\"transactions-optimistic-longsession\"/> を参照"
"してください)。"

#. Tag: programlisting
#: session_api.xml:772
#, fuzzy, no-c-format
msgid ""
"sess = sf.openSession();\n"
"Transaction tx = sess.beginTransaction();\n"
"sess.setFlushMode(FlushMode.COMMIT); // allow queries to return stale state\n"
"\n"
"Cat izi = (Cat) sess.load(Cat.class, id);\n"
"izi.setName(iznizi);\n"
"\n"
"// might return stale data\n"
"sess.find(\"from Cat as cat left outer join cat.kittens kitten\");\n"
"\n"
"// change to izi is not flushed!\n"
"...\n"
"tx.commit(); // flush occurs\n"
"sess.close();"
msgstr ""
"sess = sf.openSession();\n"
"Transaction tx = sess.beginTransaction();\n"
"sess.setFlushMode(FlushMode.COMMIT); // allow queries to return stale state\n"
"\n"
"Cat izi = (Cat) sess.load(Cat.class, id);\n"
"izi.setName(iznizi);\n"
"\n"
"// might return stale data\n"
"sess.find(\"from Cat as cat left outer join cat.kittens kitten\");\n"
"\n"
"// change to izi is not flushed!\n"
"...\n"
"tx.commit(); // flush occurs\n"
"sess.close();"

#. Tag: para
#: session_api.xml:774
#, fuzzy, no-c-format
msgid ""
"During flush, an exception might occur (e.g. if a DML operation violates a "
"constraint). Since handling exceptions involves some understanding of "
"Hibernate's transactional behavior, we discuss it in <xref linkend="
"\"transactions\"/>."
msgstr ""
"フラッシュのとき、例外が発生するかもしれません(例えば、 DML 操作が制約を違反"
"するような場合です)。例外処理を理解するためには、 Hibernate のトランザクショ"
"ンの振る舞いを理解する必要があるため、 <xref linkend=\"transactions\"/> で説"
"明します。"

#. Tag: title
#: session_api.xml:781
#, no-c-format
msgid "Transitive persistence"
msgstr "連鎖的な永続化"

#. Tag: para
#: session_api.xml:783
#, no-c-format
msgid ""
"It is quite cumbersome to save, delete, or reattach individual objects, "
"especially if you deal with a graph of associated objects. A common case is "
"a parent/child relationship. Consider the following example:"
msgstr ""
"個々のオブジェクトをセーブしたり、削除したり、再追加したりすることはかなり面"
"倒です。特に、関連するオブジェクトを扱うような場合には際立ちます。よくあるの"
"は、親子関係を扱うケースです。以下の例を考えてみましょう:"

#. Tag: para
#: session_api.xml:788
#, no-c-format
msgid ""
"If the children in a parent/child relationship would be value typed (e.g. a "
"collection of addresses or strings), their life cycle would depend on the "
"parent and no further action would be required for convenient \"cascading\" "
"of state changes. When the parent is saved, the value-typed child objects "
"are saved and when the parent is deleted, the children will be deleted, etc. "
"This works for operations such as the removal of a child from the "
"collection. Since value-typed objects cannot have shared references, "
"Hibernate will detect this and delete the child from the database."
msgstr ""
"もし、親子関係の子が値型なら(例えば、住所や文字列のコレクション)、それらの"
"ライフサイクルは親に依存しており、便利な状態変化の「カスケード」を使うため"
"に、追加の作業は必要はありません。親がセーブされたとき、値型の子オブジェクト"
"も同じようにセーブされますし、親が削除されたときは、子も削除されます。その他"
"の操作も同じです。コレクションから1つの子を削除するような操作でもうまくいきま"
"す。すなわち、 Hibernate はこの削除操作を検出すると、値型のオブジェクトは参照"
"を共有できないので、データベースからその子供を削除します。"

#. Tag: para
#: session_api.xml:798
#, no-c-format
msgid ""
"Now consider the same scenario with parent and child objects being entities, "
"not value-types (e.g. categories and items, or parent and child cats). "
"Entities have their own life cycle and support shared references. Removing "
"an entity from the collection does not mean it can be deleted), and there is "
"by default no cascading of state from one entity to any other associated "
"entities. Hibernate does not implement <emphasis>persistence by "
"reachability</emphasis> by default."
msgstr ""
"ここで、親と子が値型でなくエンティティであるとして同じシナリオを考えてみま"
"しょう。(例えば、カテゴリーと品目の関係や親と子の猫の関係です。)エンティ"
"ティは、それ自身がライフサイクルを持ち、参照の共有をサポートします。(そのた"
"め、コレクションからエンティティを削除することは、エンティティ自身の削除を意"
"味しません。)また、エンティティは、デフォルトでは、関連する他のエンティティ"
"へ状態をカスケードすることはありません。 Hibernate は <emphasis>到達可能性に"
"よる永続化</emphasis> をデフォルトでは実行しません。"

#. Tag: para
#: session_api.xml:806
#, no-c-format
msgid ""
"For each basic operation of the Hibernate session - including "
"<literal>persist(), merge(), saveOrUpdate(), delete(), lock(), refresh(), "
"evict(), replicate()</literal> - there is a corresponding cascade style. "
"Respectively, the cascade styles are named <literal>create, merge, save-"
"update, delete, lock, refresh, evict, replicate</literal>. If you want an "
"operation to be cascaded along an association, you must indicate that in the "
"mapping document. For example:"
msgstr ""
"Hibernate の Session の基本操作( <literal>persist(), merge(), saveOrUpdate"
"(), delete(), lock(), refresh(), evict(), replicate()</literal> が含まれま"
"す)に対して、それぞれに対応するカスケードスタイルがあります。それぞれのカス"
"ケードスタイルには、 <literal>create, merge, save-update, delete, lock, "
"refresh, evict, replicate</literal> という名前がついています。もし、関連に"
"沿ってカスケードさせたい操作があるなら、マッピングファイルにそう指定しなけれ"
"ばなりません。例えば、以下のようにします:"

#. Tag: programlisting
#: session_api.xml:814
#, fuzzy, no-c-format
msgid "<one-to-one name=\"person\" cascade=\"persist\"/>"
msgstr "<one-to-one name=\"person\" cascade=\"persist\"/>"

#. Tag: para
#: session_api.xml:816
#, no-c-format
msgid "Cascade styles my be combined:"
msgstr "カスケードスタイルは、組み合わせることができます:"

#. Tag: programlisting
#: session_api.xml:818
#, fuzzy, no-c-format
msgid "<one-to-one name=\"person\" cascade=\"persist,delete,lock\"/>"
msgstr "<one-to-one name=\"person\" cascade=\"persist,delete,lock\"/>"

#. Tag: para
#: session_api.xml:820
#, no-c-format
msgid ""
"You can even use <literal>cascade=\"all\" to specify that "
"<emphasis>all operations should be cascaded along the "
"association. The default <literal>cascade=\"none\" specifies that "
"no operations are to be cascaded."
msgstr ""
"<emphasis>すべての 操作を関連に沿ってカスケードするよう指定すると"
"きは、 <literal>cascade=\"all\" を使います。デフォルトの "
"<literal>cascade=\"none\" は、どの操作もカスケードしないことを意味"
"します。"

#. Tag: para
#: session_api.xml:825
#, no-c-format
msgid ""
"In case you are using annotatons you probably have noticed the "
"<literal>cascade attribute taking an array of "
"<classname>CascadeType as a value. The cascade concept in JPA is "
"very is similar to the transitive persistence and cascading of operations as "
"described above, but with slightly different semantics and cascading types:"
msgstr ""

#. Tag: para
#: session_api.xml:834
#, no-c-format
msgid ""
"<literal>CascadeType.PERSIST: cascades the persist (create) "
"operation to associated entities persist() is called or if the entity is "
"managed"
msgstr ""

#. Tag: para
#: session_api.xml:840
#, no-c-format
msgid ""
"<literal>CascadeType.MERGE: cascades the merge operation to "
"associated entities if merge() is called or if the entity is managed"
msgstr ""

#. Tag: para
#: session_api.xml:846
#, no-c-format
msgid ""
"<literal>CascadeType.REMOVE: cascades the remove operation to "
"associated entities if delete() is called"
msgstr ""

#. Tag: para
#: session_api.xml:851
#, no-c-format
msgid ""
"<literal>CascadeType.REFRESH: cascades the refresh operation to "
"associated entities if refresh() is called"
msgstr ""

#. Tag: para
#: session_api.xml:856
#, no-c-format
msgid ""
"<literal>CascadeType.DETACH: cascades the detach operation to "
"associated entities if detach() is called"
msgstr ""

#. Tag: para
#: session_api.xml:861
#, fuzzy, no-c-format
msgid "<literal>CascadeType.ALL: all of the above"
msgstr "<literal>saveOrUpdate() は以下のことを行います:"

#. Tag: para
#: session_api.xml:866
#, no-c-format
msgid ""
"CascadeType.ALL also covers Hibernate specific operations like save-update, "
"lock etc..."
msgstr ""

#. Tag: para
#: session_api.xml:870
#, no-c-format
msgid ""
"A special cascade style, <literal>delete-orphan, applies only to "
"one-to-many associations, and indicates that the <literal>delete() "
"operation should be applied to any child object that is removed from the "
"association. Using annotations there is no <literal>CascadeType.DELETE-"
"ORPHAN</literal> equivalent. Instead you can use the attribute "
"<literal>orphanRemoval as seen in  collection or an associated entity is "
"dereferenced from a <classname>@OneToOne association, this "
"associated entity can be marked for deletion if <literal>orphanRemoval with orphanRemoval"
msgstr ""

#. Tag: programlisting
#: session_api.xml:886
#, no-c-format
msgid ""
"@Entity \n"
"public class Customer {\n"
"   private Set<Order> orders;\n"
"\n"
"   @OneToMany(cascade=CascadeType.ALL, orphanRemoval=true) \n"
"   public Set<Order> getOrders() { return orders; }\n"
"\n"
"   public void setOrders(Set<Order> orders) { this.orders = orders; }\n"
"\n"
"   [...]\n"
"}\n"
"\n"
"@Entity \n"
"public class Order { ... }\n"
"\n"
"Customer customer = em.find(Customer.class, 1l);\n"
"Order order = em.find(Order.class, 1l);\n"
"customer.getOrders().remove(order); //order will be deleted by cascade"
msgstr ""

#. Tag: para
#: session_api.xml:889
#, no-c-format
msgid "Recommendations:"
msgstr "おすすめ:"

#. Tag: para
#: session_api.xml:893
#, fuzzy, no-c-format
msgid ""
"It does not usually make sense to enable cascade on a many-to-one or many-to-"
"many association. In fact the <literal>@ManyToOne and "
"<literal>@ManyToMany don't even offer a orphanRemoval<many-to-"
"many></literal> 関連に対しては、カスケードを設定する意味はありません。 "
"<literal><one-to-one><one-to-many> by specifying "
"<literal>cascade=\"all,delete-orphan\"(@OneToMany"
"(cascade=CascadeType.ALL, orphanRemoval=true)</literal>)."
msgstr ""
"子供オブジェクトの寿命が親オブジェクトの寿命に制限を受けるならば、 "
"<literal>cascade=\"all,delete-orphan\" を指定し、子供オブジェクト"
"を <emphasis>ライフサイクルオブジェクト にします。"

#. Tag: para
#: session_api.xml:909
#, no-c-format
msgid ""
"Otherwise, you might not need cascade at all. But if you think that you will "
"often be working with the parent and children together in the same "
"transaction, and you want to save yourself some typing, consider using "
"<literal>cascade=\"persist,merge,save-update\"."
msgstr ""
"それ以外の場合は、カスケードはほとんど必要ないでしょう。しかし、同じトランザ"
"クションのなかで親と子が一緒に動作することが多いと思い、いくらかのコードを書"
"く手間を省きたいのであれば、 <literal>cascade=\"persist,merge,save-update\" marks the association as a "
"<emphasis>parent/child style relationship where save/update/"
"delete of the parent results in save/update/delete of the child or children."
msgstr ""
"<literal>cascade=\"all\" でマッピングした関連(単値関連やコレクショ"
"ン)は、 <emphasis>親子 スタイルの関連とマークされます。それは、親"
"のセーブ/更新/削除が、子のセーブ/更新/削除を引き起こす関係のことです。"

#. Tag: para
#: session_api.xml:923
#, fuzzy, no-c-format
msgid ""
"Furthermore, a mere reference to a child from a persistent parent will "
"result in save/update of the child. This metaphor is incomplete, however. A "
"child which becomes unreferenced by its parent is <emphasis>not "
"automatically deleted, except in the case of a one-to-many association "
"mapped with <literal>cascade=\"delete-orphan\". The precise "
"semantics of cascading operations for a parent/child relationship are as "
"follows:"
msgstr ""
"さらに、永続化された親が子を単に参照しているだけで、子のセーブ/更新を引き起こ"
"します。しかし、このメタファーは不完全です。親から参照されなくなった子は、自"
"動的に削除 <emphasis>されません 。ただし、 cascade="
"\"delete-orphan\"</literal> でマッピングされた <one-to-many>, all children are "
"passed to <literal>persist()"
msgstr ""
"親が <literal>persist() に渡されたならば、すべての子は "
"<literal>persist() に渡されます。"

#. Tag: para
#: session_api.xml:939
#, no-c-format
msgid ""
"If a parent is passed to <literal>merge(), all children are passed "
"to <literal>merge()"
msgstr ""
"<literal>merge() に渡されたならば、すべての子は merge(), update()saveOrUpdate(), all children are passed to "
"<literal>saveOrUpdate()"
msgstr ""
"親が <literal>save() 、 update() 、 "
"<literal>saveOrUpdate() に渡されたならば、すべての子は "
"<literal>saveOrUpdate() に渡されます。"

#. Tag: para
#: session_api.xml:950
#, no-c-format
msgid ""
"If a transient or detached child becomes referenced by a persistent parent, "
"it is passed to <literal>saveOrUpdate()"
msgstr ""
"transient または detached の子が、永続化された親に参照されたならば、 "
"<literal>saveOrUpdate() に渡されます。"

#. Tag: para
#: session_api.xml:956
#, no-c-format
msgid ""
"If a parent is deleted, all children are passed to <literal>delete() に渡されま"
"す。"

#. Tag: para
#: session_api.xml:961
#, no-c-format
msgid ""
"If a child is dereferenced by a persistent parent, <emphasis>nothing special "
"happens</emphasis> - the application should explicitly delete the child if "
"necessary - unless <literal>cascade=\"delete-orphan\", in which "
"case the \"orphaned\" child is deleted."
msgstr ""
"子が永続化された親から参照されなくなったときは、 <emphasis>特に何も起こりませ"
"ん</emphasis> 。よって、アプリケーションが必要であれば、明示的に削除する必要"
"があります。ただし、 <literal>cascade=\"delete-orphan\" の場合を除"
"きます。この場合、「親のない」子は削除されます。"

#. Tag: para
#: session_api.xml:969
#, no-c-format
msgid ""
"Finally, note that cascading of operations can be applied to an object graph "
"at <emphasis>call time or at flush time. All "
"operations, if enabled, are cascaded to associated entities reachable when "
"the operation is executed. However, <literal>save-update and "
"<literal>delete-orphan are transitive for all associated entities "
"reachable during flush of the <literal>Session."
msgstr ""
"最後に、操作のカスケードがオブジェクトグラフに適用されるのは、 <emphasis>コー"
"ルした時</emphasis> あるいは、 flushした時 であることに"
"注意してください。すべての操作は、その操作が実行されたときに、到達可能な関連"
"するエンティティに対してカスケードが可能ならカスケードします。しかし、 "
"<literal>save-upate と delete-orphan は、 "
"<literal>Session が flush している間に、すべての到達可能な関連する"
"エンティティに伝播します。"

#. Tag: title
#: session_api.xml:979
#, no-c-format
msgid "Using metadata"
msgstr "メタデータの使用"

#. Tag: para
#: session_api.xml:981
#, no-c-format
msgid ""
"Hibernate requires a rich meta-level model of all entity and value types. "
"This model can be useful to the application itself. For example, the "
"application might use Hibernate's metadata to implement a \"smart\" deep-"
"copy algorithm that understands which objects should be copied (eg. mutable "
"value types) and which objects that should not (e.g. immutable value types "
"and, possibly, associated entities)."
msgstr ""
"Hibernate は、すべてのエンティティと値型の非常にリッチなメタレベルのモデルを"
"必要とします。ときどき、このモデルはアプリケーションにとってとても役に立ちま"
"す。例えば、アプリケーションは、 Hibernate のメタデータを使って、「賢い」"
"ディープコピーアルゴリズムを実装できるかもしません。そのアルゴリズムとは、ど"
"のオブジェクトがコピーされるべきか(例:可変の値型)やどのオブジェクトはコ"
"ピーされないべきか(例:不変な値型や可能なら関連するエンティティ)を判断でき"
"るものです。"

#. Tag: para
#: session_api.xml:988
#, no-c-format
msgid ""
"Hibernate exposes metadata via the <literal>ClassMetadata and "
"<literal>CollectionMetadata interfaces and the Type."
msgstr ""
"Hibernate は <literal>ClassMetadata と "
"<literal>CollectionMetadata インタフェースと Type から得られます。"

#. Tag: programlisting
#: session_api.xml:993
#, fuzzy, no-c-format
msgid ""
"Cat fritz = ......;\n"
"ClassMetadata catMeta = sessionfactory.getClassMetadata(Cat.class);\n"
"\n"
"Object[] propertyValues = catMeta.getPropertyValues(fritz);\n"
"String[] propertyNames = catMeta.getPropertyNames();\n"
"Type[] propertyTypes = catMeta.getPropertyTypes();\n"
"\n"
"// get a Map of all properties which are not collections or associations\n"
"Map namedValues = new HashMap();\n"
"for ( int i=0; i<propertyNames.length; i++ ) {\n"
"    if ( !propertyTypes[i].isEntityType() && !propertyTypes[i]."
"isCollectionType() ) {\n"
"        namedValues.put( propertyNames[i], propertyValues[i] );\n"
"    }\n"
"}"
msgstr ""
"Cat fritz = ......;\n"
"ClassMetadata catMeta = sessionfactory.getClassMetadata(Cat.class);\n"
"\n"
"Object[] propertyValues = catMeta.getPropertyValues(fritz);\n"
"String[] propertyNames = catMeta.getPropertyNames();\n"
"Type[] propertyTypes = catMeta.getPropertyTypes();\n"
"\n"
"// get a Map of all properties which are not collections or associations\n"
"Map namedValues = new HashMap();\n"
"for ( int i=0; i<propertyNames.length; i++ ) {\n"
"    if ( !propertyTypes[i].isEntityType() && !propertyTypes[i]."
"isCollectionType() ) {\n"
"        namedValues.put( propertyNames[i], propertyValues[i] );\n"
"    }\n"
"}"

#, fuzzy
#~ msgid ""
#~ "Hibernate does not offer its own API for direct execution of "
#~ "<literal>UPDATE or DELETE statements. "
#~ "Hibernate is a <emphasis>state management service, you do not "
#~ "have to think in <emphasis>statements to use it. JDBC is a "
#~ "perfect API for executing SQL statements, you can get a JDBC "
#~ "<literal>Connection at any time by calling session."
#~ "connection()</literal>. Furthermore, the notion of mass operations "
#~ "conflicts with object/relational mapping for online transaction "
#~ "processing-oriented applications. Future versions of Hibernate can, "
#~ "however, provide special mass operation functions. See <xref linkend="
#~ "\"batch\"/> for some possible batch operation tricks."
#~ msgstr ""
#~ "Hibernate は、 <literal>UPDATE 文や DELETE 文"
#~ "を直接実行する API を用意していません。 Hibernate は、 <emphasis>ステート"
#~ "マネージメント</emphasis> サービスであり、それを使うのに ステー"
#~ "トメント</emphasis> のことを開発者が考える必要はありません。 JDBC は SQL "
#~ "文を実行する完璧な API であり、 <literal>session.connection() を"
#~ "呼ぶことでいつでも、 JDBC <literal>Connection を開発者は取得でき"
#~ "ます。さらに、大量のデータ操作の考え方は、オンライントランザクション処理向"
#~ "きアプリケーションのオブジェクト/リレーショナルマッピングと衝突します。し"
#~ "かし、 Hibernate の今後のバージョンでは、大量データを処理する特別な機能を"
#~ "提供するかもしれません。バッチ操作に利用できるいくつかの工夫については、 "
#~ "<xref linkend=\"batch\"/> を参照してください。"

#~ msgid ""
#~ "A special cascade style, <literal>delete-orphan, applies only "
#~ "to one-to-many associations, and indicates that the <literal>delete() は、一対多関連に"
#~ "だけ適用できます。これは、関連から削除された子供のオブジェクトに対して、 "
#~ "<literal>delete() 操作が適用されることを意味します。"

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate session_api.po source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.