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

📄 tutorial.po

📁 hibernate 开源框架的代码 jar包希望大家能喜欢
💻 PO
📖 第 1 页 / 共 5 页
字号:
#. 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 est la couche de votre application qui se connecte à cette base de ""données, donc il a besoin des informations de connexion. Les connexions sont ""établies à travers un pool de connexions JDBC, que nous devons aussi ""configurer. La distribution Hibernate contient différents outils de gestion ""de pools de connexions JDBC open source, mais pour ce didacticiel nous ""utiliserons le pool de connexions intégré à Hibernate. Notez que vous devez ""copier les bibliothèques requises dans votre classpath et utiliser une ""configuration de pool de connexions différente si vous voulez utiliser un ""logiciel de gestion de pools JDBC tiers avec une qualité de production."#. 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 """Pour la configuration d'Hibernate, nous pouvons utiliser un simple fichier ""<literal>hibernate.properties</literal>, un fichier <literal>hibernate.cfg.""xml</literal> légèrement plus sophistiqué, ou même une configuration ""complète par programmation. La plupart des utilisateurs préfèrent le fichier ""de configuration 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 """Notez que cette configuration XML utilise une DTD différente. Nous ""configurons une <literal>SessionFactory</literal> d'Hibernate - une fabrique ""globale responsable d'une base de données particulière. Si vous avez ""plusieurs base de données, utilisez plusieurs configurations <literal>&lt;""session-factory&gt;</literal>, généralement dans des fichiers de ""configuration différents (pour un démarrage plus facile)."#. 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 """Les quatre premiers éléments <literal>property</literal> contiennent la ""configuration nécessaire pour la connexion JDBC. L'élément ""<literal>property</literal> du dialecte spécifie quelle variante du SQL ""Hibernate va générer. La gestion automatique des sessions d'Hibernate pour ""les contextes de persistance sera détaillée très vite. L'option ""<literal>hbm2ddl.auto</literal> active la génération automatique des schémas ""de base de données - directement dans la base de données. Cela peut bien sûr ""aussi être désactivé (en supprimant l'option de configuration) ou redirigé ""vers un fichier avec l'aide de la tâche Ant <literal>SchemaExport</literal>. ""Finalement, nous ajoutons le(s) fichier(s) de mapping pour les classes ""persistantes."#. 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 """Copiez ce fichier dans le répertoire source, il terminera dans la racine du ""classpath. Hibernate cherchera automatiquement, au démarrage, un fichier ""appelé <literal>hibernate.cfg.xml</literal> dans la racine du classpath."#. Tag: title#: tutorial.xml:305#, no-c-formatmsgid "Building with Ant"msgstr "Construction avec 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 """Nous allons maintenant construire le didacticiel avec Ant. Vous aurez besoin ""d'avoir Ant d'installé - récupérez-le à partir de <ulink url=\"http://ant.""apache.org/bindownload.cgi\"> la page de téléchargement de Ant</ulink>. ""Comment installer Ant ne sera pas couvert ici. Référez-vous au <ulink url=""\"http://ant.apache.org/manual/index.html\">manuel d'Ant</ulink>. Après que ""vous aurez installé Ant, nous pourrons commencer à créer le fichier de ""construction. Il s'appellera <literal>build.xml</literal> et sera placé ""directement dans le répertoire de développement."#. Tag: para#: tutorial.xml:316#, no-c-formatmsgid "A basic build file looks like this:"msgstr "Un fichier de construction basique ressemble à ça :"#. 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 """Cela dira à Ant d'ajouter tous les fichiers du répertoire lib finissant par ""<literal>.jar</literal> dans le classpath utilisé pour la compilation. Cela ""copiera aussi tous les fichiers source non Java dans le répertoire cible, ""par exemple les fichiers de configuration et de mapping d'Hibernate. Si vous ""lancez Ant maintenant, vous devriez obtenir cette sortie :"#. 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""Total time: 1 second ]]>"msgstr ""#. Tag: title#: tutorial.xml:334#, no-c-formatmsgid "Startup and helpers"msgstr "Démarrage et aides"#. Tag: para#: tutorial.xml:336#, no-c-formatmsgid """It's time to load and store some <literal>Event</literal> objects, but first ""we have to complete the setup with some infrastructure code. We have to ""startup Hibernate. This startup includes building a global ""<literal>SessionFactory</literal> object and to store it somewhere for easy ""access in application code. A <literal>SessionFactory</literal> can open up ""new <literal>Session</literal>'s. A <literal>Session</literal> represents a ""single-threaded unit of work, the <literal>SessionFactory</literal> is a ""thread-safe global object, instantiated once."msgstr """Il est temps de charger et de stocker quelques objets <literal>Event</""literal>, mais d'abord nous devons compléter la configuration avec du code ""d'infrastructure. Nous devons démarrer Hibernate. Ce démarrage inclut la ""construction d'un objet <literal>SessionFactory</literal> global et le ""stocker quelque part facile d'accès dans le code de l'application. Une ""<literal>SessionFactory</literal> peut ouvrir des nouvelles ""<literal>Session</literal>s. Une <literal>Session</literal> représente une ""unité de travail simplement \"threadée\", la <literal>SessionFactory</""literal> est un objet global \"thread-safe\", instancié une seule fois."#. Tag: para#: tutorial.xml:346#, no-c-formatmsgid """We'll create a <literal>HibernateUtil</literal> helper class which takes ""care of startup and makes accessing a <literal>SessionFactory</literal> ""convenient. Let's have a look at the implementation:"msgstr """Nous créerons une classe d'aide <literal>HibernateUtil</literal> qui ""s'occupe du démarrage et rend la gestion des <literal>Session</literal>s ""plus facile. Regardons l'implémentation :"#. Tag: programlisting#: tutorial.xml:352#, no-c-formatmsgid """<![CDATA[package util;\n""\n""import org.hibernate.*;\n""import org.hibernate.cfg.*;\n""\n""public class HibernateUtil {\n""\n""    private static final SessionFactory sessionFactory;\n""\n""    static {\n""        try {\n""            // Create the SessionFactory from hibernate.cfg.xml\n""            sessionFactory = new Configuration().configure().""buildSessionFactory();\n""        } catch (Throwable ex) {\n""            // Make sure you log the exception, as it might be swallowed\n""            System.err.println(\"Initial SessionFactory creation failed.\" + ""ex);\n""            throw new ExceptionInInitializerError(ex);\n""        }\n""    }\n""\n""    public static SessionFactory getSessionFactory() {\n""        return sessionFactory;\n""    }\n""\n""}]]>"msgstr ""#. Tag: para#: tutorial.xml:354#, no-c-formatmsgid """This class does not only produce the global <literal>SessionFactory</""literal> in its static initializer (called once by the JVM when the class is ""loaded), but also hides the fact that it uses a static singleton. It might ""as well lookup the <literal>SessionFactory</literal> from JNDI in an ""application server."

⌨️ 快捷键说明

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