⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tutorial.po

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 PO
📖 第 1 页 / 共 5 页
字号:
#. Tag: para#: tutorial.xml:230#, no-c-formatmsgid "We continue with the main configuration of Hibernate."msgstr "Hibernateの主要な設定を続けます。"#. Tag: title#: tutorial.xml:237#, no-c-formatmsgid "Hibernate configuration"msgstr "Hibernateの設定"#. Tag: para#: tutorial.xml:239#, no-c-formatmsgid """We now have a persistent class and its mapping file in place. It is time to ""configure Hibernate. Before we do this, we will need a database. HSQL DB, a ""java-based SQL DBMS, can be downloaded from the HSQL DB website(http://""hsqldb.org/). Actually, you only need the <literal>hsqldb.jar</literal> from ""this download. Place this file in the <literal>lib/</literal> directory of ""the development folder."msgstr """ここまでで永続クラスとマッピングファイルが揃いました。これからHibernateの設定""を行いますが、 その前にデータベースが必要です。 HSQL DBはJavaベースのインメモ""リSQL DBMSであり、HSQL DBウェブサイトからダウンロードできます。 実際にはダウ""ンロードした中の <literal>hsqldb.jar</literal> だけが必要です。 このファイル""を開発フォルダの <literal>lib/</literal> ディレクトリに配置してください。"#. Tag: para#: tutorial.xml:247#, no-c-formatmsgid """Create a directory called <literal>data</literal> in the root of the ""development directory - this is where HSQL DB will store its data files. Now ""start the database by running <literal>java -classpath ../lib/hsqldb.jar org.""hsqldb.Server</literal> in this data directory. You can see it start up and ""bind to a TCP/IP socket, this is where our application will connect later. ""If you want to start with a fresh database during this tutorial, shutdown ""HSQL DB (press <literal>CTRL + C</literal> in the window), delete all files ""in the <literal>data/</literal> directory, and start HSQL DB again."msgstr """<literal>data</literal> というディレクトリを開発ディレクトリのルートに作成し""てください。 HSQL DBはここにデータファイルを格納します。 このデータディレクト""リにおいて <literal>java -classpath lib/hsqldb.jar org.hsqldb.Server</""literal> を実行し、 データベースを起動させてください。 動作の開始と、TCP/IPソ""ケットのバインドが確認できます。 後ほど作成するアプリケーションはここに接続し""ます。 もしこのチュートリアル中にデータベースを初期化したければ、 HSQL DBを""シャットダウンして(作業ウィンドウで <literal>CTRL + C</literal> を押しま""す) <literal>data/</literal> ディレクトリ内のファイルを全て消去した後、 ""HSQL DBを再起動します。"#. Tag: para#: tutorial.xml:257#, no-c-formatmsgid """Hibernate is the layer in your application which connects to this database, ""so it needs connection information. The connections are made through a JDBC ""connection pool, which we also have to configure. The Hibernate distribution ""contains several open source JDBC connection pooling tools, but will use the ""Hibernate built-in connection pool for this tutorial. Note that you have to ""copy the required library into your classpath and use different connection ""pooling settings if you want to use a production-quality third party JDBC ""pooling software."msgstr """Hibernateはアプリケーションのデータベースに接続する層なので、 コネクションの""情報が必要になります。 コネクションはJDBCコネクションプールを通じて行われます""が、これも設定する必要があります。 Hibernateディストリビューションにはいくつ""かのオープンソースのJDBCコネクションプールツールが含まれていますが、 この""チュートリアルではHibernateに組み込まれたコネクションプールを使います。 もし""製品レベルの品質のサードパーティJDBCコネクションプールソフトウェアを使いたけ""れば、 クラスパスに必要なライブラリをコピーして、異なるコネクションプールを設""定しなければ ならないことに注意してください。"#. Tag: para#: tutorial.xml:267#, no-c-formatmsgid """For Hibernate's configuration, we can use a simple <literal>hibernate.""properties</literal> file, a slightly more sophisticated <literal>hibernate.""cfg.xml</literal> file, or even complete programmatic setup. Most users ""prefer the XML configuration file:"msgstr """Hibernateの設定では、単純な <literal>hibernate.properties</literal> ファイ""ル、 それより少し洗練されている <literal>hibernate.cfg.xml</literal> ファイ""ル、 または完全にプログラム上でセットアップする方法が利用できます。 ほとんど""のユーザが好むのはXML設定ファイルです:"#. Tag: programlisting#: tutorial.xml:273#, no-c-formatmsgid """<![CDATA[<?xml version='1.0' encoding='utf-8'?>\n""<!DOCTYPE hibernate-configuration PUBLIC\n""        \"-//Hibernate/Hibernate Configuration DTD 3.0//EN\"\n""        \"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd""\">\n""\n""<hibernate-configuration>\n""\n""    <session-factory>\n""\n""        <!-- Database connection settings -->\n""        <property name=\"connection.driver_class\">org.hsqldb.jdbcDriver</""property>\n""        <property name=\"connection.url\">jdbc:hsqldb:hsql://localhost</""property>\n""        <property name=\"connection.username\">sa</property>\n""        <property name=\"connection.password\"></property>\n""\n""        <!-- JDBC connection pool (use the built-in) -->\n""        <property name=\"connection.pool_size\">1</property>\n""\n""        <!-- SQL dialect -->\n""        <property name=\"dialect\">org.hibernate.dialect.HSQLDialect</""property>\n""\n""        <!-- Enable Hibernate's automatic session context management -->\n""        <property name=\"current_session_context_class\">thread</property>\n""\n""        <!-- Disable the second-level cache  -->\n""        <property name=\"cache.provider_class\">org.hibernate.cache.""NoCacheProvider</property>\n""\n""        <!-- Echo all executed SQL to stdout -->\n""        <property name=\"show_sql\">true</property>\n""\n""        <!-- Drop and re-create the database schema on startup -->\n""        <property name=\"hbm2ddl.auto\">create</property>\n""\n""        <mapping resource=\"events/Event.hbm.xml\"/>\n""\n""    </session-factory>\n""\n""</hibernate-configuration>]]>"msgstr ""#. Tag: para#: tutorial.xml:275#, no-c-formatmsgid """Note that this XML configuration uses a different DTD. We configure ""Hibernate's <literal>SessionFactory</literal> - a global factory responsible ""for a particular database. If you have several databases, use several ""<literal>&lt;session-factory&gt;</literal> configurations, usually in ""several configuration files (for easier startup)."msgstr """このXMLの設定が異なるDTDを使うことに注意してください。 特定のデータベースを受""け持つグローバルファクトリであるHibernateの <literal>SessionFactory</""literal> を設定します。 もし複数のデータベースがある場合には、 (スタートアッ""プを簡単にするため)通常いくつかの設定ファイル内で、 いくつかの <literal>&lt;""session-factory&gt;</literal> を使う設定にしてください。"#. Tag: para#: tutorial.xml:283#, no-c-formatmsgid """The first four <literal>property</literal> elements contain the necessary ""configuration for the JDBC connection. The dialect <literal>property</""literal> element specifies the particular SQL variant Hibernate generates. ""Hibernate's automatic session management for persistence contexts will come ""in handy as you will soon see. The <literal>hbm2ddl.auto</literal> option ""turns on automatic generation of database schemas - directly into the ""database. This can of course also be turned off (by removing the config ""option) or redirected to a file with the help of the <literal>SchemaExport</""literal> Ant task. Finally, we add the mapping file(s) for persistent ""classes to the configuration."msgstr """最初の4つの <literal>property</literal> 要素はJDBCコネクションに必要な設定を""含んでいます。 dialectという名前の <literal>property</literal> 要素は、""Hibernateが生成する特定のSQL方言を指定します。 永続的なコンテキストに対する""Hibernateのセッションの自動管理は、後の例ですぐにわかるように、役に立つことで""しょう。 <literal>hbm2ddl.auto</literal> オプションはデータベーススキーマの自""動生成をonにします。 これは直接データベースに対して生成されます。 当然""(configオプションを削除して)offにしたり、 <literal>SchemaExport</literal> ""というAntタスクの助けを借りてファイルにリダイレクトしたりできます。 最後に永""続クラスのためのマッピングファイルを設定に追加します。"#. Tag: para#: tutorial.xml:296#, no-c-formatmsgid """Copy this file into the source directory, so it will end up in the root of ""the classpath. Hibernate automatically looks for a file called ""<literal>hibernate.cfg.xml</literal> in the root of the classpath, on ""startup."msgstr """このファイルをソースディレクトリにコピーしてください。 するとこれはクラスパス""のルートにあることになります。 Hibernateは、スタートアップ時にクラスパスの""ルートで <literal>hibernate.cfg.xml</literal> というファイルを自動的に探しま""す。"#. Tag: title#: tutorial.xml:305#, no-c-formatmsgid "Building with Ant"msgstr "Antによるビルド"#. Tag: para#: tutorial.xml:307#, no-c-formatmsgid """We'll now build the tutorial with Ant. You will need to have Ant installed - ""get it from the <ulink url=\"http://ant.apache.org/bindownload.cgi\">Ant ""download page</ulink>. How to install Ant will not be covered here. Please ""refer to the <ulink url=\"http://ant.apache.org/manual/index.html\">Ant ""manual</ulink>. After you have installed Ant, we can start to create the ""buildfile. It will be called <literal>build.xml</literal> and placed ""directly in the development directory."msgstr """それではAntを使ってチュートリアルをビルドしましょう。 それにはAntがインストー""ルされていなければなりません。 <ulink url=\"http://ant.apache.org/""bindownload.cgi\">Antダウンロードページ</ulink> からダウンロードしてくださ""い。 Antのインストール方法はここでは説明しませんので、 <ulink url=\"http://""ant.apache.org/manual/index.html\">Antマニュアル</ulink> を参照してくださ""い。 Antをインストールすれば、ビルドファイルの作成を開始できます。 このファイ""ルは <literal>build.xml</literal> と呼ばれ、開発ディレクトリに直接配置しま""す。"#. Tag: para#: tutorial.xml:316#, no-c-formatmsgid "A basic build file looks like this:"msgstr "基本的なビルドファイルはこのようになります:"#. Tag: programlisting#: tutorial.xml:320#, no-c-formatmsgid """<![CDATA[<project name=\"hibernate-tutorial\" default=\"compile\">\n""\n""    <property name=\"sourcedir\" value=\"${basedir}/src\"/>\n""    <property name=\"targetdir\" value=\"${basedir}/bin\"/>\n""    <property name=\"librarydir\" value=\"${basedir}/lib\"/>\n""\n""    <path id=\"libraries\">\n""        <fileset dir=\"${librarydir}\">\n""            <include name=\"*.jar\"/>\n""        </fileset>\n""    </path>\n""\n""    <target name=\"clean\">\n""        <delete dir=\"${targetdir}\"/>\n""        <mkdir dir=\"${targetdir}\"/>\n""    </target>\n""\n""    <target name=\"compile\" depends=\"clean, copy-resources\">\n""      <javac srcdir=\"${sourcedir}\"\n""             destdir=\"${targetdir}\"\n""             classpathref=\"libraries\"/>\n""    </target>\n""\n""    <target name=\"copy-resources\">\n""        <copy todir=\"${targetdir}\">\n""            <fileset dir=\"${sourcedir}\">\n""                <exclude name=\"**/*.java\"/>\n""            </fileset>\n""        </copy>\n""    </target>\n""\n""</project>]]>"msgstr ""#. Tag: para#: tutorial.xml:322#, no-c-formatmsgid """This will tell Ant to add all files in the lib directory ending with ""<literal>.jar</literal> to the classpath used for compilation. It will also ""copy all non-Java source files to the target directory, e.g. configuration ""and Hibernate mapping files. If you now run Ant, you should get this output:"msgstr """これは <literal>.jar</literal> で終わるlibディレクトリのすべてのファイルを、 ""コンパイルに使用するクラスパスに追加することをAntに教えます。 また、Javaソー""スファイルでないすべてのファイルをターゲットディレクトリにコピーするというこ""とでもあります。 例えば設定ファイルやHibernateマッピングファイルなどです。 今""Antを実行すると、このような出力があるはずです:"#. Tag: programlisting#: tutorial.xml:329#, no-c-formatmsgid """<![CDATA[C:\\hibernateTutorial\\>ant\n""Buildfile: build.xml\n""\n""copy-resources:\n""     [copy] Copying 2 files to C:\\hibernateTutorial\\bin\n""\n""compile:\n""    [javac] Compiling 1 source file to C:\\hibernateTutorial\\bin\n""\n""BUILD SUCCESSFUL\n"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -