📄 tutorial.po
字号:
"<![CDATA[<?xml version=\"1.0\"?>\n""<!DOCTYPE hibernate-mapping PUBLIC\n"" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"" \"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd\">\n""\n""<hibernate-mapping>\n""[...]\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:181#, no-c-formatmsgid """Note that the Hibernate DTD is very sophisticated. You can use it for auto-""completion of XML mapping elements and attributes in your editor or IDE. You ""also should open up the DTD file in your text editor - it's the easiest way ""to get an overview of all elements and attributes and to see the defaults, ""as well as some comments. Note that Hibernate will not load the DTD file ""from the web, but first look it up from the classpath of the application. ""The DTD file is included in <literal>hibernate3.jar</literal> as well as in ""the <literal>src/</literal> directory of the Hibernate distribution."msgstr """Notez que la DTD Hibernate est très sophistiquée. Vous pouvez l'utiliser ""pour l'auto-complétement des éléments et des attributs de mapping XML dans ""votre éditeur ou votre IDE. Vous devriez aussi ouvrir le fichier DTD dans ""votre éditeur de texte - c'est le moyen le plus facile d'obtenir une vue ""d'ensemble de tous les éléments et attributs, et de voir les valeurs par ""défaut, ainsi que quelques commentaires. Notez qu'Hibernate ne chargera pas ""le fichier DTD à partir du web, mais regardera d'abord dans le classpath de ""l'application. Le fichier DTD est inclus dans <literal>hibernate3.jar</""literal> ainsi que dans le répertoire <literal>src</literal> de la ""distribution Hibernate."#. Tag: para#: tutorial.xml:192#, no-c-formatmsgid """We will omit the DTD declaration in future examples to shorten the code. It ""is of course not optional."msgstr """Nous omettrons la déclaration de la DTD dans les exemples futurs pour ""raccourcir le code. Bien sûr il n'est pas optionnel."#. Tag: para#: tutorial.xml:197#, no-c-formatmsgid """Between the two <literal>hibernate-mapping</literal> tags, include a ""<literal>class</literal> element. All persistent entity classes (again, ""there might be dependent classes later on, which are not first-class ""entities) need such a mapping, to a table in the SQL database:"msgstr """Entre les deux balises <literal>hibernate-mapping</literal>, incluez un ""élément <literal>class</literal>. Toutes les classes d'entités persistantes ""(encore une fois, il pourrait y avoir des classes dépendantes plus tard, qui ""ne sont pas des entités mère) ont besoin d'un mapping vers une table de la ""base de données SQL :"#. Tag: programlisting#: tutorial.xml:204#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"events.Event\" table=\"EVENTS\">\n""\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:206#, no-c-formatmsgid """So far we told Hibernate how to persist and load object of class ""<literal>Event</literal> to the table <literal>EVENTS</literal>, each ""instance represented by a row in that table. Now we continue with a mapping ""of the unique identifier property to the tables primary key. In addition, as ""we don't want to care about handling this identifier, we configure ""Hibernate's identifier generation strategy for a surrogate primary key ""column:"msgstr """Plus loin, nous disons à Hibernate comment persister et charger un objet de ""la classe <literal>Event</literal> dans la table <literal>EVENTS</literal>, ""chaque instance est représentée par une ligne dans cette table. Maintenant ""nous continuons avec le mapping de la propriété de l'identifiant unique vers ""la clef primaire de la table. De plus, comme nous ne voulons pas nous ""occuper de la gestion de cet identifiant, nous utilisons une stratégie de ""génération d'identifiant d'Hibernate pour la colonne de la clef primaire ""subrogée :"#. Tag: programlisting#: tutorial.xml:214#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"events.Event\" table=\"EVENTS\">\n"" <id name=\"id\" column=\"EVENT_ID\">\n"" <generator class=\"native\"/>\n"" </id>\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:216#, fuzzy, no-c-formatmsgid """The <literal>id</literal> element is the declaration of the identifier ""property, <literal>name=\"id\"</literal> declares the name of the Java ""property - Hibernate will use the getter and setter methods to access the ""property. The column attribute tells Hibernate which column of the ""<literal>EVENTS</literal> table we use for this primary key. The nested ""<literal>generator</literal> element specifies the identifier generation ""strategy, in this case we used <literal>native</literal>, which picks the ""best strategy depending on the configured database (dialect). Hibernate ""supports database generated, globally unique, as well as application ""assigned identifiers (or any strategy you have written an extension for)."msgstr """L'élément <literal>id</literal> est la déclaration de la propriété de ""l'identifiant, <literal>name=\"id\"</literal> déclare le nom de la propriété ""Java - Hibernate utilisera les méthodes getter et setter pour accéder à la ""propriété. L'attribut <literal>column</literal> indique à Hibernate quelle ""colonne de la table <literal>EVENTS</literal> nous utilisons pour cette clef ""primaire. L'élément <literal>generator</literal> imbriqué spécifie la ""stratégie de génération de l'identifiant, dans ce cas nous avons utilisé ""<literal>increment</literal>, laquelle est une méthode très simple utile ""surtout pour les tests (et didacticiels). Hibernate supporte aussi les ""identifiants générés par les bases de données, globalement uniques, ainsi ""que les identifiants assignés par l'application (ou n'importe quelle ""stratégie que vous avez écrit en extension)."#. Tag: para#: tutorial.xml:229#, no-c-formatmsgid """Finally we include declarations for the persistent properties of the class ""in the mapping file. By default, no properties of the class are considered ""persistent:"msgstr """Finalement nous incluons des déclarations pour les propriétés persistantes ""de la classe dans le fichier de mapping. Par défaut, aucune propriété de la ""classe n'est considérée comme persistante :"#. Tag: programlisting#: tutorial.xml:235#, no-c-formatmsgid """<![CDATA[\n""<hibernate-mapping>\n""\n"" <class name=\"events.Event\" table=\"EVENTS\">\n"" <id name=\"id\" column=\"EVENT_ID\">\n"" <generator class=\"native\"/>\n"" </id>\n"" <property name=\"date\" type=\"timestamp\" column=\"EVENT_DATE\"/>\n"" <property name=\"title\"/>\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:237#, no-c-formatmsgid """Just as with the <literal>id</literal> element, the <literal>name</literal> ""attribute of the <literal>property</literal> element tells Hibernate which ""getter and setter methods to use. So, in this case, Hibernate will look for ""<literal>getDate()/setDate()</literal>, as well as <literal>getTitle()/""setTitle()</literal>."msgstr """Comme avec l'élément <literal>id</literal>, l'attribut <literal>name</""literal> de l'élément <literal>property</literal> indique à Hibernate quels ""getters/setters utiliser."#. Tag: para#: tutorial.xml:244#, no-c-formatmsgid """Why does the <literal>date</literal> property mapping include the ""<literal>column</literal> attribute, but the <literal>title</literal> ""doesn't? Without the <literal>column</literal> attribute Hibernate by ""default uses the property name as the column name. This works fine for ""<literal>title</literal>. However, <literal>date</literal> is a reserved ""keyword in most database, so we better map it to a different name."msgstr """Pourquoi le mapping de la propriété <literal>date</literal> inclut ""l'attribut <literal>column</literal>, mais pas <literal>title</literal> ? ""Sans l'attribut <literal>column</literal> Hibernate utilise par défaut le ""nom de la propriété comme nom de colonne. Ca fonctionne bien pour ""<literal>title</literal>. Cependant, <literal>date</literal> est un mot clef ""réservé dans la plupart des bases de données, donc nous utilisons un nom ""différent pour le mapping."#. Tag: para#: tutorial.xml:253#, no-c-formatmsgid """The next interesting thing is that the <literal>title</literal> mapping also ""lacks a <literal>type</literal> attribute. The types we declare and use in ""the mapping files are not, as you might expect, Java data types. They are ""also not SQL database types. These types are so called <emphasis>Hibernate ""mapping types</emphasis>, converters which can translate from Java to SQL ""data types and vice versa. Again, Hibernate will try to determine the ""correct conversion and mapping type itself if the <literal>type</literal> ""attribute is not present in the mapping. In some cases this automatic ""detection (using Reflection on the Java class) might not have the default ""you expect or need. This is the case with the <literal>date</literal> ""property. Hibernate can't know if the property (which is of <literal>java.""util.Date</literal>) should map to a SQL <literal>date</literal>, ""<literal>timestamp</literal>, or <literal>time</literal> column. We preserve ""full date and time information by mapping the property with a ""<literal>timestamp</literal> converter."msgstr """La prochaine chose intéressante est que le mapping de <literal>title</""literal> manque aussi d'un attribut <literal>type</literal>. Les types que ""nous déclarons et utilisons dans les fichiers de mapping ne sont pas, comme ""vous pourriez vous y attendre, des types de données Java. Ce ne sont pas, ""non plus, des types de base de données SQL. Ces types sont donc appelés des ""<emphasis>types de mapping Hibernate</emphasis>, des convertisseurs qui ""peuvent traduire des types Java en types SQL et vice versa. De plus, ""Hibernate tentera de déterminer la bonne conversion et le type de mapping ""lui-même si l'attribut <literal>type</literal> n'est pas présent dans le ""mapping. Dans certains cas, cette détection automatique (utilisant la ""réflexion sur la classe Java) pourrait ne pas donner la valeur attendue ou ""dont vous avez besoin. C'est le cas avec la propriété <literal>date</""literal>. Hibernate ne peut pas savoir si la propriété \"mappera\" une ""colonne SQL de type <literal>date</literal>, <literal>timestamp</literal> ou ""<literal>time</literal>. Nous déclarons que nous voulons conserver des ""informations avec une date complète et l'heure en mappant la propriété avec ""un <literal>timestamp</literal>."#. Tag: para#: tutorial.xml:269#, no-c-formatmsgid """This mapping file should be saved as <literal>Event.hbm.xml</literal>, right ""in the directory next to the <literal>Event</literal> Java class source ""file. The naming of mapping files can be arbitrary, however the <literal>hbm.""xml</literal> suffix is a convention in the Hibernate developer community. ""The directory structure should now look like this:"msgstr """Ce fichier de mapping devrait être sauvegardé en tant que <literal>Event.hbm.""xml</literal>, juste dans le répertoire à côté du fichier source de la ""classe Java <literal>Event</literal>. Le nommage des fichiers de mapping ""peut être arbitraire, cependant le suffixe <literal>hbm.xml</literal> est ""devenu une convention dans la communauté des développeurs Hibernate. La ""structure du répertoire devrait ressembler à ça :"#. Tag: programlisting#: tutorial.xml:277#, no-c-formatmsgid """<![CDATA[.\n""+lib\n"" <Hibernate and third-party libraries>\n""+src\n"" +events\n"" Event.java\n"" Event.hbm.xml]]>"msgstr ""#. Tag: para#: tutorial.xml:279#, no-c-formatmsgid "We continue with the main configuration of Hibernate."msgstr "Nous poursuivons avec la configuration principale d'Hibernate."#. Tag: title#: tutorial.xml:286#, no-c-formatmsgid "Hibernate configuration"msgstr "Configuration d'Hibernate"#. Tag: para#: tutorial.xml:288#, 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 """Nous avons maintenant une classe persistante et son fichier de mapping. Il ""est temps de configurer Hibernate. Avant ça, nous avons besoin d'une base de ""données. HSQL DB, un SGBD SQL basé sur Java et travaillant en mémoire, peut ""être téléchargé à partir du site web de HSQL. En fait, vous avez seulement ""besoin de <literal>hsqldb.jar</literal>. Placez ce fichier dans le ""répertoire <literal>lib/</literal> du dossier de développement."#. Tag: para#: tutorial.xml:296#, 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 """Créez un répertoire appelé <literal>data</literal> à la racine du répertoire ""de développement - c'est là que HSQL DB stockera ses fichiers de données. ""Démarrez maintenant votre base de données en exécutant <literal>java -""classpath lib/hsqldb.jar org.hsqldb.Server</literal> dans votre répertoire ""de travail. Vous observez qu'elle démarre et ouvre une socket TCP/IP, c'est ""là que notre application se connectera plus tard. Si vous souhaitez démarrez ""à partir d'une nouvelle base de données pour ce tutoriel (faites ""<literal>CTRL + C</literal> dans la fenêtre the window), effacez le ""répertoire <literal>data/</literal> et redémarrez HSQL DB à nouveau."#. Tag: para#: tutorial.xml:306#, 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 "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -