📄 tutorial.po
字号:
"call to <literal>getCurrentSession()</literal> is made. It is then bound by ""Hibernate to the current thread. When the transaction ends, either through ""commit or rollback, Hibernate automatically unbinds the <literal>Session</""literal> from the thread and closes it for you. If you call ""<literal>getCurrentSession()</literal> again, you get a new ""<literal>Session</literal> and can start a new unit of work. This ""<emphasis>thread-bound</emphasis> programming model is the most popular way ""of using Hibernate, as it allows flexible layering of your code (transaction ""demarcation code can be separated from data access code, we'll do this later ""in this tutorial)."msgstr """<literal>Session</literal> は最初に必要となったとき、つまり最初に ""<literal>getCurrentSession()</literal> が 呼ばれたときに開始します。 そのとき""Hibernateにより現在のスレッドに結び付けられます。 トランザクションが終了(コ""ミットもしくはロールバック)したとき、 Hibernateもスレッドから ""<literal>Session</literal> を切り離し、クローズします。 再び ""<literal>getCurrentSession()</literal> を呼ぶと、 新しい <literal>Session</""literal> を取得して新しい作業単位をスタートできます。 この <emphasis>thread-""bound</emphasis> プログラミング・モデルはHibernateを利用する上で最も人気があ""ります。"#. Tag: para#: tutorial.xml:441#, no-c-formatmsgid """Related to the unit of work scope, should the Hibernate <literal>Session</""literal> be used to execute one or several database operations? The above ""example uses one <literal>Session</literal> for one operation. This is pure ""coincidence, the example is just not complex enough to show any other ""approach. The scope of a Hibernate <literal>Session</literal> is flexible ""but you should never design your application to use a new Hibernate ""<literal>Session</literal> for <emphasis>every</emphasis> database ""operation. So even if you see it a few more times in the following (very ""trivial) examples, consider <emphasis>session-per-operation</emphasis> an ""anti-pattern. A real (web) application is shown later in this tutorial."msgstr """Related to the unit of work scope, should the Hibernate <literal>Session</""literal> be used to execute one or several database operations? The above ""example uses one <literal>Session</literal> for one operation. This is pure ""coincidence, the example is just not complex enough to show any other ""approach. The scope of a Hibernate <literal>Session</literal> is flexible ""but you should never design your application to use a new Hibernate ""<literal>Session</literal> for <emphasis>every</emphasis> database ""operation. So even if you see it a few more times in the following (very ""trivial) examples, consider <emphasis>session-per-operation</emphasis> an ""anti-pattern. A real (web) application is shown later in this tutorial."#. Tag: para#: tutorial.xml:452#, no-c-formatmsgid """Have a look at <xref linkend=\"transactions\"/> for more information about ""transaction handling and demarcation. We also skipped any error handling and ""rollback in the previous example."msgstr """トランザクションの扱いと境界の詳しい情報については、 <xref linkend=""\"transactions\"/> を見てください。 この例ではエラー処理やロールバックも割愛""します。"#. Tag: para#: tutorial.xml:458#, no-c-formatmsgid """To run this first routine we have to add a callable target to the Ant build ""file:"msgstr """この最初のルーチンを実行するには、Antのビルドファイルに呼び出し可能なターゲッ""トを 追加しなければなりません:"#. Tag: programlisting#: tutorial.xml:462#, no-c-formatmsgid """<![CDATA[<target name=\"run\" depends=\"compile\">\n"" <java fork=\"true\" classname=\"events.EventManager\" classpathref=""\"libraries\">\n"" <classpath path=\"${targetdir}\"/>\n"" <arg value=\"${action}\"/>\n"" </java>\n""</target>]]>"msgstr ""#. Tag: para#: tutorial.xml:464#, no-c-formatmsgid """The value of the <literal>action</literal> argument is set on the command ""line when calling the target:"msgstr """<literal>action</literal> 引数の値は、ターゲットを呼ぶときにコマンドラインで""設定します:"#. Tag: programlisting#: tutorial.xml:469#, no-c-formatmsgid "<![CDATA[C:\\hibernateTutorial\\>ant run -Daction=store]]>"msgstr ""#. Tag: para#: tutorial.xml:471#, no-c-formatmsgid """You should see, after compilation, Hibernate starting up and, depending on ""your configuration, lots of log output. At the end you will find the ""following line:"msgstr """コンパイルすると、Hibernateがスタートし、あなたの設定によりますが、 多くのロ""グ出力があるはずです。 その最後には以下の行があるでしょう:"#. Tag: programlisting#: tutorial.xml:476#, no-c-formatmsgid """<![CDATA[[java] Hibernate: insert into EVENTS (EVENT_DATE, title, EVENT_ID) ""values (?, ?, ?)]]>"msgstr ""#. Tag: para#: tutorial.xml:478#, no-c-formatmsgid """This is the <literal>INSERT</literal> executed by Hibernate, the question ""marks represent JDBC bind parameters. To see the values bound as arguments, ""or to reduce the verbosity of the log, check your <literal>log4j.properties</""literal>."msgstr """これはHibernateが実行する <literal>INSERT</literal> で、 クエスチョンマークは""JDBCバインドパラメータを表しています。 引数としてバインドされる値を見るため、""あるいはログの冗長性を減らすためには、 <literal>log4j.properties</literal> を""チェックしてください。"#. Tag: para#: tutorial.xml:484#, no-c-formatmsgid """Now we'd like to list stored events as well, so we add an option to the main ""method:"msgstr """それでは同じように格納されたイベントの一覧を見ようと思います。 そのためメイン""メソッドにオプションを追加します:"#. Tag: programlisting#: tutorial.xml:488#, no-c-formatmsgid """<![CDATA[if (args[0].equals(\"store\")) {\n"" mgr.createAndStoreEvent(\"My Event\", new Date());\n""}\n""else if (args[0].equals(\"list\")) {\n"" List events = mgr.listEvents();\n"" for (int i = 0; i < events.size(); i++) {\n"" Event theEvent = (Event) events.get(i);\n"" System.out.println(\"Event: \" + theEvent.getTitle() +\n"" \" Time: \" + theEvent.getDate());\n"" }\n""}]]>"msgstr ""#. Tag: para#: tutorial.xml:490#, no-c-formatmsgid "We also add a new <literal>listEvents() method</literal>:"msgstr "新しい <literal>listEvents()メソッド</literal> も追加します。"#. Tag: programlisting#: tutorial.xml:494#, no-c-formatmsgid """<![CDATA[private List listEvents() {\n""\n"" Session session = HibernateUtil.getSessionFactory().getCurrentSession""();\n""\n"" session.beginTransaction();\n""\n"" List result = session.createQuery(\"from Event\").list();\n""\n"" session.getTransaction().commit();\n""\n"" return result;\n""}]]>"msgstr ""#. Tag: para#: tutorial.xml:496#, no-c-formatmsgid """What we do here is use an HQL (Hibernate Query Language) query to load all ""existing <literal>Event</literal> objects from the database. Hibernate will ""generate the appropriate SQL, send it to the database and populate ""<literal>Event</literal> objects with the data. You can create more complex ""queries with HQL, of course."msgstr """ここですることは、データベースから存在するすべての <literal>Event</literal> ""オブジェクトをロードするHQL (Hibernate Query Language) クエリを使うことで""す。 Hibernateは適切なSQLを生成し、それをデータベースに送り、 そのデータを""使って <literal>Event</literal> オブジェクトを生成します。 当然HQLでさらに複""雑なクエリを作成できます。"#. Tag: para#: tutorial.xml:503#, no-c-formatmsgid "Now, to execute and test all of this, follow these steps:"msgstr "以下のステップで、すべての実行とテストを行います。"#. Tag: para#: tutorial.xml:509#, no-c-formatmsgid """Run <literal>ant run -Daction=store</literal> to store something into the ""database and, of course, to generate the database schema before through ""hbm2ddl."msgstr """hbm2ddlを通す前にデータベースのデータを作成し、データベーススキーマを生成する""ために、 <literal>ant run -Daction=store</literal> を実行してください。"#. Tag: para#: tutorial.xml:515#, no-c-formatmsgid """Now disable hbm2ddl by commenting out the property in your ""<literal>hibernate.cfg.xml</literal> file. Usually you only leave it turned ""on in continous unit testing, but another run of hbm2ddl would ""<emphasis>drop</emphasis> everything you have stored - the <literal>create</""literal> configuration setting actually translates into \"drop all tables ""from the schema, then re-create all tables, when the SessionFactory is build""\"."msgstr """今は <literal>hibernate.cfg.xml</literal> ファイルのプロパティをコメントアウ""トしてhbm2ddlを無効にしてください。 通常は継続的に単体テストをしている間は""hbm2ddlを有効にしておくのですが、 それ以外の場合にhbm2ddlを起動すると格納して""おいた全てのデータを <emphasis>ドロップ</emphasis> するでしょう。 設定を ""<literal>create</literal> にすると、結果として 「SessionFactory生成の際、ス""キーマから全てのテーブルをドロップして再作成する」という設定になります。"#. Tag: para#: tutorial.xml:525#, no-c-formatmsgid """If you now call Ant with <literal>-Daction=list</literal>, you should see ""the events you have stored so far. You can of course also call the ""<literal>store</literal> action a few times more."msgstr """今 <literal>-Daction=list</literal> と指定してAntを呼ぶと、 これまで格納した""イベントが見えるはずです。 <literal>store</literal> アクションを数回以上呼ぶ""ことも可能です。"#. Tag: para#: tutorial.xml:531#, no-c-formatmsgid """Note: Most new Hibernate users fail at this point and we see questions about ""<emphasis>Table not found</emphasis> error messages regularly. However, if ""you follow the steps outlined above you will not have this problem, as ""hbm2ddl creates the database schema on the first run, and subsequent ""application restarts will use this schema. If you change the mapping and/or ""database schema, you have to re-enable hbm2ddl once again."msgstr """注意:初めてHibernateに触れる人々の多くがここで失敗するため、<emphasis>Table ""not found</emphasis> エラーメッセージに 関する質問を定期的に見かけます。 しか""し上記のステップに従えば、hbm2ddlが最初に実行されたときにデータベーススキーマ""を作成し、 その後の実行においてもこのスキーマを使用するので、問題は起こらない""でしょう。 マッピングやデータベーススキーマを変更したときは、もう一度hbm2ddl""を有効にしてください。"#. Tag: title#: tutorial.xml:544#, no-c-formatmsgid "Part 2 - Mapping associations"msgstr "パート2 - 関連のマッピング"#. Tag: para#: tutorial.xml:546#, no-c-formatmsgid """We mapped a persistent entity class to a table. Let's build on this and add ""some class associations. First we'll add people to our application, and ""store a list of events they participate in."msgstr """永続エンティティクラスをテーブルにマッピングしました。 さらにこの上にいくつか""のクラスの関連を追加しましょう。 まず初めにアプリケーションに人々を追加し、彼""らが参加するイベントのリストを格納します。"#. Tag: title#: tutorial.xml:552#, no-c-formatmsgid "Mapping the Person class"msgstr "Personクラスのマッピング"#. Tag: para#: tutorial.xml:554#, no-c-form
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -