📄 transactions.po
字号:
msgid """However, it is often desirable to keep your persistence layer portable ""between non-managed resource-local environments, and systems that can rely ""on JTA but use BMT instead of CMT. In both cases you'd use programmatic ""transaction demaracation. Hibernate offers a wrapper API called ""<literal>Transaction</literal> that translates into the native transaction ""system of your deployment environment. This API is actually optional, but we ""strongly encourage its use unless you are in a CMT session bean."msgstr """しかしながら、管理されていないリソース・ローカルな環境と JTAに依存したシステ""ム(CMTではなくBMT)の両方に、 永続化層をポータブルに保つのは、しばしば望まし""いことです。 デプロイ環境のネイティブのトランザクションシステムを呼び出す ""<literal>Transaction</literal> というラッパーAPIをHibernateが提供します。 こ""のAPIを使うかは任意ですが、CMTのセッションBeanを使わないのであれば、使うこと""を強く推奨します。"#. Tag: para#: transactions.xml:379#, no-c-formatmsgid """Usually, ending a <literal>Session</literal> involves four distinct phases:"msgstr """通常、<literal>Session</literal> 終了は、4つの異なるフェーズを含みます。"#. Tag: para#: transactions.xml:385#, no-c-formatmsgid "flush the session"msgstr "セッションのフラッシュ"#. Tag: para#: transactions.xml:390#, no-c-formatmsgid "commit the transaction"msgstr "トランザクションのコミット"#. Tag: para#: transactions.xml:395#, no-c-formatmsgid "close the session"msgstr "セッションのクローズ"#. Tag: para#: transactions.xml:400#, no-c-formatmsgid "handle exceptions"msgstr "例外のハンドリング"#. Tag: para#: transactions.xml:406#, no-c-formatmsgid """Flushing the session has been discussed earlier, we'll now have a closer ""look at transaction demarcation and exception handling in both managed- and ""non-managed environments."msgstr """セッションのフラッシュについては、前のほうですでに議論しました。 管理された環""境と管理されていない環境の両方について、 トランザクション境界と例外ハンドリン""グをもっと詳しく見ていきましょう。"#. Tag: title#: transactions.xml:413#, no-c-formatmsgid "Non-managed environment"msgstr "管理されていない環境"#. Tag: para#: transactions.xml:415#, no-c-formatmsgid """If a Hibernate persistence layer runs in a non-managed environment, database ""connections are usually handled by simple (i.e. non-DataSource) connection ""pools from which Hibernate obtains connections as needed. The session/""transaction handling idiom looks like this:"msgstr """Hibernate永続化層を管理されていない環境で実装する場合は、 通常単純なコネク""ションプール(すなわちDataSourceではない)によって、 データベースコネクション""を制御します。 Hibernateはそのコネクションプールから必要なコネクションを取得""します。 セッション/トランザクション制御のイディオムは次のようになります。"#. Tag: programlisting#: transactions.xml:422#, no-c-formatmsgid """<![CDATA[// Non-managed environment idiom\n""Session sess = factory.openSession();\n""Transaction tx = null;\n""try {\n"" tx = sess.beginTransaction();\n""\n"" // do some work\n"" ...\n""\n"" tx.commit();\n""}\n""catch (RuntimeException e) {\n"" if (tx != null) tx.rollback();\n"" throw e; // or display error message\n""}\n""finally {\n"" sess.close();\n""}]]>"msgstr ""#. Tag: para#: transactions.xml:424#, no-c-formatmsgid """You don't have to <literal>flush()</literal> the <literal>Session</literal> ""explicitly - the call to <literal>commit()</literal> automatically triggers ""the synchronization (depending upon the <link linkend=\"objectstate-flushing""\">FlushMode</link> for the session. A call to <literal>close()</literal> ""marks the end of a session. The main implication of <literal>close()</""literal> is that the JDBC connection will be relinquished by the session. ""This Java code is portable and runs in both non-managed and JTA environments."msgstr """明示的に <literal>Session</literal> の <literal>flush()</literal> を呼び出す""べきではなく、 <literal>commit()</literal> を呼び出すことにより、自動的に同期""化処理が実行されます (セッションの <xref linkend=\"objectstate-flushing""\">FlushMode</xref> に依存している)。 <literal>close()</literal> を呼び出す""ことにより、セッションの終わりを明確にします。 <literal>close()</literal> が""暗黙的に行う主なことは、 セッションがJDBCコネクションを開放することです。 上""記のJavaコードはポータブルであり、管理されていない環境とJTA環境の両方で実行で""きます。"#. Tag: para#: transactions.xml:433#, no-c-formatmsgid """A much more flexible solution is Hibernate's built-in \"current session\" ""context management, as described earlier:"msgstr """より適応性のある解決策は、Hibernateに予め組み込まれている 「current session」""コンテキスト管理です。 言葉で説明するより下記を見たほうが速いでしょう。"#. Tag: programlisting#: transactions.xml:438#, no-c-formatmsgid """<![CDATA[// Non-managed environment idiom with getCurrentSession()\n""try {\n"" factory.getCurrentSession().beginTransaction();\n""\n"" // do some work\n"" ...\n""\n"" factory.getCurrentSession().getTransaction().commit();\n""}\n""catch (RuntimeException e) {\n"" factory.getCurrentSession().getTransaction().rollback();\n"" throw e; // or display error message\n""}]]>"msgstr ""#. Tag: para#: transactions.xml:440#, no-c-formatmsgid """You will very likely never see these code snippets in a regular application; ""fatal (system) exceptions should always be caught at the \"top\". In other ""words, the code that executes Hibernate calls (in the persistence layer) and ""the code that handles <literal>RuntimeException</literal> (and usually can ""only clean up and exit) are in different layers. The current context ""management by Hibernate can significantly simplify this design, as all you ""need is access to a <literal>SessionFactory</literal>. Exception handling is ""discussed later in this chapter."msgstr """正規のアプリケーションの中では、このようなコードの切れ端を決して見ないでしょ""う。 致命的な(システム)例外は、常に「最上位」でキャッチすべきです。 言い換""えれば、(永続化層で)Hibernate呼び出しを実行するコードと、 ""<literal>RuntimeException</literal> を制御する (通常はクリーンアップと終了の""み行うことができる)コードは、別々の層の中にあります。 Hibernateによるカレン""トコンテキスト管理は、この設計をかなり単純にします。 必要なのは、""<literal>SessionFactory</literal> にアクセスすることだけです。 例外処理は、こ""の章の後のほうで議論します。"#. Tag: para#: transactions.xml:450#, no-c-formatmsgid """Note that you should select <literal>org.hibernate.transaction.""JDBCTransactionFactory</literal> (which is the default), and for the second ""example <literal>\"thread\"</literal> as your <literal>hibernate.""current_session_context_class</literal>."msgstr """注意:(デフォルトですが) <literal>org.hibernate.transaction.""JDBCTransactionFactory</literal> を選択するべきです。 第2の用例としては、 ""<literal>hibernate.current_session_context_class</literal> を <literal>""\"thread\"</literal> とするとよいでしょう。"#. Tag: title#: transactions.xml:459#, no-c-formatmsgid "Using JTA"msgstr "JTAを使用する"#. Tag: para#: transactions.xml:461#, no-c-formatmsgid """If your persistence layer runs in an application server (e.g. behind EJB ""session beans), every datasource connection obtained by Hibernate will ""automatically be part of the global JTA transaction. You can also install a ""standalone JTA implementation and use it without EJB. Hibernate offers two ""strategies for JTA integration."msgstr """永続化層をアプリケーションサーバー(例えば、EJBセッションBeanの背後)で実行す""る場合、 Hibernateから取得するすべてのデータソースコネクションは、 自動的にグ""ローバルJTAトランザクションの一部になります。 EJBを使わずに、スタンドアロンの""JTA実装を導入することもできます。 JTA統合のために、Hibernateは2つの戦略を提""供します。"#. Tag: para#: transactions.xml:468#, no-c-formatmsgid """If you use bean-managed transactions (BMT) Hibernate will tell the ""application server to start and end a BMT transaction if you use the ""<literal>Transaction</literal> API. So, the transaction management code is ""identical to the non-managed environment."msgstr """Bean管理トランザクション(BMT)を使い、<literal>Transaction</literal> APIを使""う場合、 HibernateはアプリケーションサーバーにBMTトランザクションの開始と終わ""りを告げます。 すなわち、トランザクション管理のコードは、管理されない環境と同""じになります。"#. Tag: programlisting#: transactions.xml:474#, no-c-formatmsgid """<![CDATA[// BMT idiom\n""Session sess = factory.openSession();\n""Transaction tx = null;\n""try {\n"" tx = sess.beginTransaction();\n""\n"" // do some work\n"" ...\n""\n"" tx.commit();\n""}\n""catch (RuntimeException e) {\n"" if (tx != null) tx.rollback();\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -