alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  
\");\n" " out.println(\"<td>\" + dateFormatter.format(event.getDate()) " "+ \"</td>\");\n" " out.println(\"</tr>\");\n" " }\n" " out.println(\"</table>\");\n" " }\n" " }]]>" msgstr "" #. Tag: para #: tutorial.xml:1052 #, no-c-format msgid "" "Finally, the <literal>store action is dispatched to the " "<literal>createAndStoreEvent() method, which also uses the " "<literal>Session of the current thread:" msgstr "" "Enfin, l'action <literal>store renvoie à la méthode " "<literal>createAndStoreEvent(), qui utilise aussi la " "<literal>Session du thread courant:" #. Tag: programlisting #: tutorial.xml:1058 #, no-c-format msgid "" "<![CDATA[ protected void createAndStoreEvent(String title, Date theDate) " "{\n" " Event theEvent = new Event();\n" " theEvent.setTitle(title);\n" " theEvent.setDate(theDate);\n" "\n" " HibernateUtil.getSessionFactory()\n" " .getCurrentSession().save(theEvent);\n" " }]]>" msgstr "" #. Tag: para #: tutorial.xml:1060 #, no-c-format msgid "" "The servlet is now complete. A request to the servlet will be processed in a " "single <literal>Session and Transaction. As " "earlier in the standalone application, Hibernate can automatically bind " "these objects to the current thread of execution. This gives you the freedom " "to layer your code and access the <literal>SessionFactory in any " "way you like. Usually you would use a more sophisticated design and move the " "data access code into data access objects (the DAO pattern). See the " "Hibernate Wiki for more examples." msgstr "" "La servlet est complétée. Une requête à la servlet sera exécutée par une " "seule <literal>Session et Transaction. Comme " "dans l'application autonome vue auparavant, Hibernate peut automatiquement " "lier ces objets au thread courant d'exécution. Cela vous laisse la liberté " "de séparer votre code en couches et d'accéder à la <literal>SessionFactory" #. Tag: programlisting #: tutorial.xml:1082 #, no-c-format msgid "" "<![CDATA[\n" " <servlet-class>org.hibernate.tutorial.web.EventManagerServlet\n" " <url-pattern>/eventmanager\n" " </servlet-mapping>\n" "</web-app>]]>" msgstr "" #. Tag: para #: tutorial.xml:1084 #, no-c-format msgid "" "To build and deploy call <literal>mvn package in your project " "directory and copy the <filename>hibernate-tutorial.war file into " "your Tomcat <filename>webapps directory." msgstr "" "Pour construire et déployer, appelez <literal>ant war dans votre " "projet et copiez le fichier <literal>hibernate-tutorial.war dans " "le répertoire <literal>webapp de Tomcat. " #. Tag: para #: tutorial.xml:1091 #, fuzzy, no-c-format msgid "" "If you do not have Tomcat installed, download it from <ulink url=\"http://" "tomcat.apache.org/\"></ulink> and follow the installation instructions. Our " "application requires no changes to the standard Tomcat configuration." msgstr "" "Si vous n'avez pas installé Tomcat, téléchargez-le de <ulink url=\"http://" "tomcat.apache.org/\" /> et suivez la notice d'installation. Vous n'avez pas " "à modifier la configuration Tomcat pour déployer cette application." #. Tag: para #: tutorial.xml:1099 #, no-c-format msgid "" "Once deployed and Tomcat is running, access the application at " "<literal>http://localhost:8080/hibernate-tutorial/eventmanager. " "Make sure you watch the Tomcat log to see Hibernate initialize when the " "first request hits your servlet (the static initializer in " "<literal>HibernateUtil is called) and to get the detailed output " "if any exceptions occurs." msgstr "" "Une fois l'application déployée et Tomcat lancé, accédez à l'application via " "<literal>http://localhost:8080/hibernate-tutorial/eventmanager. " "Assurez vous de consulter les traces Tomcat pour observer l'initialisation " "d'Hibernate à la première requête touchant votre servlet (l'initialisation " "statique dans <literal>HibernateUtil est invoquée) et pour " "vérifier qu'aucune exception ne survienne." #. Tag: title #: tutorial.xml:1112 #, no-c-format msgid "Summary" msgstr "Résumé" #. Tag: para #: tutorial.xml:1114 #, no-c-format msgid "" "This tutorial covered the basics of writing a simple standalone Hibernate " "application and a small web application. More tutorials are available from " "the Hibernate <ulink url=\"http://hibernate.org\">website." msgstr "" "Ce didacticiel a couvert les bases de l'écriture d'une simple application " "Hibernate ainsi qu'une petite application web. Vous trouverez des tutoriels " "supplémentaires dans le site Hibernate <ulink url=\"http://hibernate.org" "\">website</ulink>."

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate tutorial.po source code file:

Hibernate example source code file (tutorial.po)

This example Hibernate source code file (tutorial.po) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Hibernate tags/keywords

cdata, cdata, hibernate, hibernate, java, maven, nous, sql, tag, tag, the, the, this, vous

The Hibernate tutorial.po source code

# translation of tutorial.po to French
# Myriam Malga <mmalga@redhat.com>, 2007.
# Xi HUANG <xhuang@redhat.com>, 2007.
# Corina Roe <croe@redhat.com>, 2009, 2010.
# translation of Collection_Mapping.po to
msgid ""
msgstr ""
"Project-Id-Version: tutorial\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-07-20 21:02+0000\n"
"PO-Revision-Date: 2010-01-05 10:08+1000\n"
"Last-Translator: Corina Roe <croe@redhat.com>\n"
"Language-Team: French <i18@redhat.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"

#. Tag: title
#: tutorial.xml:34
#, no-c-format
msgid "Tutorial"
msgstr "Tutoriel"

#. Tag: para
#: tutorial.xml:36
#, no-c-format
msgid ""
"Intended for new users, this chapter provides an step-by-step introduction "
"to Hibernate, starting with a simple application using an in-memory "
"database. The tutorial is based on an earlier tutorial developed by Michael "
"Gloegl. All code is contained in the <filename>tutorials/web "
"directory of the project source."
msgstr ""
"A l'intention des nouveaux utilisateurs, ce chapitre fournit une "
"introduction étape par étape à Hibernate, en commençant par une application "
"simple, avec une base de données en-mémoire. Le tutoriel est basé sur une "
"tutoriel antérieur qui avait été développé par Michael Gloegl. Tout le code "
"est contenu dans <filename>tutorials/web qui se trouve dans le "
"répertoire source du projet. "

#. Tag: para
#: tutorial.xml:45
#, no-c-format
msgid ""
"This tutorial expects the user have knowledge of both Java and SQL. If you "
"have a limited knowledge of JAVA or SQL, it is advised that you start with a "
"good introduction to that technology prior to attempting to learn Hibernate."
msgstr ""
"Ce tutoriel assume que l'utilisateur est déjà familier avec Java et SQL à la "
"fois. Si vous ne possédez qu'une connaissance de Java et d'SQL limitée, il "
"est conseillé de commencer par vous familiariser avec ces technologies avant "
"d'aborder Hibernate."

#. Tag: para
#: tutorial.xml:54
#, no-c-format
msgid ""
"The distribution contains another example application under the "
"<filename>tutorial/eg project source directory."
msgstr ""
"La distribution contient un autre exemple d'application qui se trouve dans "
"le répertoire source du projet <filename>tutorial/eg."

#. Tag: title
#: tutorial.xml:62
#, no-c-format
msgid "Part 1 - The first Hibernate Application"
msgstr "Section 1 - Première application Hibernate"

#. Tag: para
#: tutorial.xml:64
#, no-c-format
msgid ""
"For this example, we will set up a small database application that can store "
"events we want to attend and information about the host(s) of these events."
msgstr ""
"Supposons que nous ayons besoin d'une petite application de base de données "
"qui puisse stocker des événements que nous voulons suivre, et des "
"informations à propos des hôtes de ces événements."

#. Tag: para
#: tutorial.xml:70
#, no-c-format
msgid ""
"Although you can use whatever database you feel comfortable using, we will "
"use <ulink url=\"http://hsqldb.org/\">HSQLDB (an in-memory, Java "
"database) to avoid describing installation/setup of any particular database "
"servers."
msgstr ""
"Malgré que vous puissiez utiliser tout base de données qui vous convienne, "
"on choisira <ulink url=\"http://hsqldb.org/\">HSQLDB (une base de "
"données Java, en-mémoire) pour éviter de décrire l'installation et la "
"configuration de n'importe quel serveur de base de données particulière."

#. Tag: title
#: tutorial.xml:79
#, no-c-format
msgid "Setup"
msgstr "Configuration"

#. Tag: para
#: tutorial.xml:81
#, no-c-format
msgid ""
"The first thing we need to do is to set up the development environment. We "
"will be using the \"standard layout\" advocated by alot of build tools such "
"as <ulink url=\"http://maven.org\">Maven. Maven, in particular, has "
"a good resource describing this <ulink url=\"http://maven.apache.org/guides/"
"introduction/introduction-to-the-standard-directory-layout.html\">layout</"
"ulink>. As this tutorial is to be a web application, we will be creating and "
"making use of <filename>src/main/java, src/main/"
"resources</filename> and src/main/webapp directories."
msgstr ""
"La première chose que nous devons faire est de configurer l'environnement de "
"développement. Nous utiliserons la \"standard layout\" préconisée par de "
"nombreux outils de génération tels que <ulink url=\"http://maven.org"
"\">Maven</ulink>. Maven, en particulier, a une bonne ressource décrivant "
"cette <ulink url=\"http://maven.apache.org/guides/introduction/introduction-"
"to-the-standard-directory-layout.html\">layout</ulink>. Comme ce tutoriel va "
"devenir une application web, nous allons créer et utiliser les répertoires "
"<filename>src/main/java., src/main/ressourcessrc/main/webapp."

#. Tag: para
#: tutorial.xml:91
#, no-c-format
msgid ""
"We will be using Maven in this tutorial, taking advantage of its transitive "
"dependency management capabilities as well as the ability of many IDEs to "
"automatically set up a project for us based on the maven descriptor."
msgstr ""
"Nous utiliserons Maven dans ce tutoriel. Nous profiterons de ses capacités "
"de gestion de dépendances transitives, ainsi que de la capacité des nombreux "
"IDE à installer automatiquement un projet sur la base du descripteur Maven."

#. Tag: programlisting
#: tutorial.xml:97
#, no-c-format
msgid ""
"<![CDATA[\n"
"\n"
"    <groupId>org.hibernate.tutorials\n"
"    <artifactId>hibernate-tutorial\n"
"    <version>1.0.0-SNAPSHOT\n"
"    <name>First Hibernate Tutorial\n"
"\n"
"    <build>\n"
"         <!-- we dont want the version to be part of the generated war file "
"name -->\n"
"         <finalName>${artifactId}\n"
"    </build>\n"
"\n"
"    <dependencies>\n"
"        <dependency>\n"
"            <groupId>org.hibernate\n"
"            <artifactId>hibernate-core\n"
"        </dependency>\n"
"\n"
"        <!-- Because this is a web app, we also have a dependency on the "
"servlet api. -->\n"
"        <dependency>\n"
"            <groupId>javax.servlet\n"
"            <artifactId>servlet-api\n"
"        </dependency>\n"
"\n"
"        <!-- Hibernate uses slf4j for logging, for our purposes here use the "
"simple backend -->\n"
"        <dependency>\n"
"            <groupId>org.slf4j\n"
"            <artifactId>slf4j-simple\n"
"        </dependency>\n"
"\n"
"        <!-- Hibernate gives you a choice of bytecode providers between "
"cglib and javassist -->\n"
"        <dependency>\n"
"            <groupId>javassist\n"
"            <artifactId>javassist\n"
"        </dependency>\n"
"    </dependencies>\n"
"\n"
"</project>]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:100
#, fuzzy, no-c-format
msgid ""
"It is not a requirement to use Maven. If you wish to use something else to "
"build this tutorial (such as Ant), the layout will remain the same. The only "
"change is that you will need to manually account for all the needed "
"dependencies. If you use something like <ulink url=\"http://ant.apache.org/"
"ivy/\">Ivy</ulink> providing transitive dependency management you would "
"still use the dependencies mentioned below. Otherwise, you'd need to grab "
"<emphasis>all dependencies, both explicit and transitive, and add "
"them to the project's classpath. If working from the Hibernate distribution "
"bundle, this would mean <filename>hibernate3.jar, all artifacts "
"in the <filename>lib/required directory and all files from either "
"the <filename>lib/bytecode/cglib or lib/bytecode/"
"javassist</filename> directory; additionally you will need both the servlet-"
"api jar and one of the slf4j logging backends."
msgstr ""
"Vous n'êtes pas obligés d'utiliser Maven. Si vous souhaitez utiliser une "
"autre technologie pour créer ce tutoriel (comme Ant), la mise en page "
"restera le même. Le seul changement est que vous devrez manuellement tenir "
"compte de toutes les dépendances nécessaires. Si vous utilisez <ulink url="
"\"http://ant.apache.org/ivy/\">Ivy</ulink> pour assurer la gestion des "
"dépendances transitives, vous utiliserez toujours les dépendances "
"mentionnées ci-dessous. Dans le cas contraire, vous devrez trouver toutes "
"les dépendances, explicites et transitives, et les ajouter au chemin de "
"classe des projets. Si vous travaillez à partir de l'offre de distribution "
"Hibernate, il s'agit de <filename>hibernate3.jar, de tous les "
"artefacts du répertoire <filename>lib / requis et de tous les "
"fichiers des répertoires <filename>lib / pseudo-code binaire/cgliblib/pseudo-code binaire/javassist; en "
"outre, vous aurez besoin à la fois du bocal servlet-api et de l'un des "
"gestionnaires de journalisation slf4j."

#. Tag: para
#: tutorial.xml:117
#, no-c-format
msgid ""
"Save this file as <filename>pom.xml in the project root directory."
msgstr ""
"Sauvegardez ce fichier sous la forme <filename>pom.xml dans le "
"répertoire root du projet."

#. Tag: title
#: tutorial.xml:124
#, no-c-format
msgid "The first class"
msgstr "La première classe"

#. Tag: para
#: tutorial.xml:126
#, no-c-format
msgid ""
"Next, we create a class that represents the event we want to store in the "
"database; it is a simple JavaBean class with some properties:"
msgstr ""
"Ensuite, nous créons une classe qui représente l'évènement que nous voulons "
"stocker dans notre base de données. Il s'agit d'une simple classe JavaBean "
"avec quelques propriétés :"

#. Tag: programlisting
#: tutorial.xml:131
#, no-c-format
msgid ""
"<![CDATA[package org.hibernate.tutorial.domain;\n"
"\n"
"import java.util.Date;\n"
"\n"
"public class Event {\n"
"    private Long id;\n"
"\n"
"    private String title;\n"
"    private Date date;\n"
"\n"
"    public Event() {}\n"
"\n"
"    public Long getId() {\n"
"        return id;\n"
"    }\n"
"\n"
"    private void setId(Long id) {\n"
"        this.id = id;\n"
"    }\n"
"\n"
"    public Date getDate() {\n"
"        return date;\n"
"    }\n"
"\n"
"    public void setDate(Date date) {\n"
"        this.date = date;\n"
"    }\n"
"\n"
"    public String getTitle() {\n"
"        return title;\n"
"    }\n"
"\n"
"    public void setTitle(String title) {\n"
"        this.title = title;\n"
"    }\n"
"}]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:133
#, no-c-format
msgid ""
"This class uses standard JavaBean naming conventions for property getter and "
"setter methods, as well as private visibility for the fields. Although this "
"is the recommended design, it is not required. Hibernate can also access "
"fields directly, the benefit of accessor methods is robustness for "
"refactoring."
msgstr ""
"Vous constaterez que cette classe utilise les conventions de nommage "
"standard JavaBean pour les méthodes getter/setter des propriétés, ainsi "
"qu'une visibilité privée pour les champs. Ceci est la conception recommandée "
"- mais pas obligatoire. Hibernate peut aussi accéder aux champs directement, "
"le bénéfice des méthodes d'accès est la robustesse pour la refonte de code. "

#. Tag: para
#: tutorial.xml:141
#, no-c-format
msgid ""
"The <literal>id property holds a unique identifier value for a "
"particular event. All persistent entity classes (there are less important "
"dependent classes as well) will need such an identifier property if we want "
"to use the full feature set of Hibernate. In fact, most applications, "
"especially web applications, need to distinguish objects by identifier, so "
"you should consider this a feature rather than a limitation. However, we "
"usually do not manipulate the identity of an object, hence the setter method "
"should be private. Only Hibernate will assign identifiers when an object is "
"saved. Hibernate can access public, private, and protected accessor methods, "
"as well as public, private and protected fields directly. The choice is up "
"to you and you can match it to fit your application design."
msgstr ""
"La propriété <literal>id contient la valeur d'un identifiant "
"unique pour un événement particulier. Toutes les classes d'entités "
"persistantes (il y a également des classes dépendantes de moindre "
"importance) auront besoin d'une telle propriété identifiante si nous voulons "
"utiliser l'ensemble complet des fonctionnalités de Hibernate. En fait, la "
"plupart des applications (surtout les applications web) ont besoin de "
"distinguer des objets par des identifiants, par conséquent considérez cela "
"comme une fonctionnalité et non comme une limitation. Cependant, nous ne "
"manipulons généralement pas l'identité d'un objet, dorénavant la méthode "
"setter devrait être privée. Seul Hibernate assignera les identifiants "
"lorsqu'un objet est sauvegardé. Remarquez que Hibernate peut accéder aux "
"méthodes publiques, privées et protégées, ainsi qu'aux champs (publics, "
"privés, protégés) directement. À vous de choisir, et vous pouvez également "
"l'ajuster à la conception de votre application. "

#. Tag: para
#: tutorial.xml:156
#, no-c-format
msgid ""
"The no-argument constructor is a requirement for all persistent classes; "
"Hibernate has to create objects for you, using Java Reflection. The "
"constructor can be private, however package or public visibility is required "
"for runtime proxy generation and efficient data retrieval without bytecode "
"instrumentation."
msgstr ""
"Le constructeur sans argument est requis pour toutes les classes "
"persistantes; Hibernate doit créer des objets pour vous en utilisant la "
"réflexion Java. Le constructeur peut être privé, cependant, la visibilité du "
"paquet est requise pour la génération de proxies à l'exécution et une "
"récupération efficace des données sans instrumentation du bytecode. "

#. Tag: para
#: tutorial.xml:164
#, no-c-format
msgid ""
"Save this file to the <filename>src/main/java/org/hibernate/tutorial/domain"
msgstr ""

#. Tag: para
#: tutorial.xml:187
#, no-c-format
msgid ""
"Hibernate DTD is sophisticated. You can use it for auto-completion of XML "
"mapping elements and attributes in your editor or IDE. Opening up the DTD "
"file in your text editor is the easiest way to get an overview of all "
"elements and attributes, and to view the defaults, as well as some comments. "
"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 "
"<filename>hibernate-core.jar (it is also included in the "
"<filename>hibernate3.jar, if using the distribution bundle)."
msgstr ""
"Notez que la DTD Hibernate est très sophistiquée. Vous pouvez l'utiliser "
"pour l'auto-finalisation des éléments et des attributs de mappage XML dans "
"votre éditeur ou votre IDE. Ouvrez également 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 chemin de "
"classe de l'application. Le fichier DTD est inclus dans <filename>hibernate-"
"core.jar ainsi que </filename>dans le répertoire src de "
"la distribution Hibernate)."

#. Tag: para
#: tutorial.xml:200
#, no-c-format
msgid ""
"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. Évidemment il n'est pas optionnel. "

#. Tag: para
#: tutorial.xml:206
#, no-c-format
msgid ""
"Between the two <literal>hibernate-mapping tags, include a "
"<literal>class element. All persistent entity classes (again, "
"there might be dependent classes later on, which are not first-class "
"entities) need a mapping to a table in the SQL database:"
msgstr ""
"Entre les deux balises <literal>hibernate-mapping, incluez un "
"élément <literal>class. 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 mappage vers une table de la "
"base de données SQL :"

#. Tag: programlisting
#: tutorial.xml:213
#, no-c-format
msgid ""
"<![CDATA["
msgstr ""

#. Tag: para
#: tutorial.xml:215
#, no-c-format
msgid ""
"So far we have told Hibernate how to persist and load object of class "
"<literal>Event to the table EVENTS. Each "
"instance is now represented by a row in that table. Now we can continue by "
"mapping the unique identifier property to the tables primary key. As we do "
"not want to care about handling this identifier, we configure Hibernate's "
"identifier generation strategy for a surrogate primary key column:"
msgstr ""
"Plus loin, nous indiquons à Hibernate comment persister et charger un objet "
"de la classe <literal>Event dans la table EVENTS"
msgstr ""

#. Tag: para
#: tutorial.xml:227
#, no-c-format
msgid ""
"The <literal>id element is the declaration of the identifier "
"property. The <literal>name=\"id\" mapping attribute declares the "
"name of the JavaBean property and tells Hibernate to use the <literal>getId()"
"</literal> and setId() methods to access the property. "
"The column attribute tells Hibernate which column of the <literal>EVENTS est la déclaration de l'identifiant de "
"propriété. L'attribut de mappage <literal>name=\"id\" déclare le "
"nom de la propriété JavaBean et indique à Hibernate d'utiliser les méthodes "
"<literal>getId() et setId() pour accéder à la "
"propriété. L'attribut de colonne indique à Hibernate quelle colonne de la "
"table <literal>EVENTS contient la valeur de clé primaire."

#. Tag: para
#: tutorial.xml:237
#, no-c-format
msgid ""
"The nested <literal>generator element specifies the identifier "
"generation strategy (aka how are identifier values generated?). In this case "
"we choose <literal>native, which offers a level of portability "
"depending on the configured database dialect. Hibernate supports database "
"generated, globally unique, as well as application assigned, identifiers. "
"Identifier value generation is also one of Hibernate's many extension points "
"and you can plugin in your own strategy."
msgstr ""
"L'élément imbriqué <literal>Générateur spécifie la stratégie de "
"génération d'identifiant (c'est à dire comment les valeurs d'identifiant "
"sont-elles générées?). Dans ce cas nous avons choisi <literal>native is no longer consider the best strategy in terms "
"of portability. for further discussion, see"
msgstr ""
"<literal>native n'est plus considéré comme la meilleure stratégie "
"en terme de  portabilité. Pour obtenir davantage d'explications, voir <xref "
"linkend=\"portability-idgen\" />"

#. Tag: para
#: tutorial.xml:255
#, no-c-format
msgid ""
"Lastly, we need to tell Hibernate about the remaining entity class "
"properties. By default, no properties of the class are considered persistent:"
msgstr ""
"Enfin, nous incluons des déclarations pour les propriétés persistantes de la "
"classe dans le fichier de mappage. Par défaut, aucune propriété de la classe "
"n'est considérée comme persistante : "

#. Tag: programlisting
#: tutorial.xml:261
#, no-c-format
msgid ""
"<![CDATA[\n"
"<hibernate-mapping package=\"org.hibernate.tutorial.domain\">\n"
"\n"
"    <class name=\"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:263
#, no-c-format
msgid ""
"Similar to the <literal>id element, the name "
"attribute of the <literal>property element tells Hibernate which "
"getter and setter methods to use. In this case, Hibernate will search for "
"<literal>getDate(), setDate(), getTitle"
"()</literal> and setTitle() methods."
msgstr ""
"Comme avec l'élément <literal>id, l'attribut nameproperty indique à Hibernate "
"quelles méthodes getters/setters utiliser. Par conséquent dans ce cas, "
"Hibernate cherchera <literal>getDate()/setDate(), de même que "
"<literal>getTitle()/setTitle(). "

#. Tag: para
#: tutorial.xml:274
#, no-c-format
msgid ""
"Why does the <literal>date property mapping include the "
"<literal>column attribute, but the title does "
"not? Without the <literal>column attribute, Hibernate by default "
"uses the property name as the column name. This works for <literal>titledate is a reserved keyword in most "
"databases so you will need to map it to a different name."
msgstr ""
"Pourquoi le mappage de la propriété <literal>date inclut-il "
"l'attribut <literal>column, mais non le title ? "
"Sans l'attribut <literal>column, Hibernate utilise par défaut le "
"nom de la propriété comme nom de colonne. Cela fonctionne bien pour "
"<literal>title. Cependant, date est un mot clé "
"réservé dans la plupart des bases de données, donc nous utilisons un nom "
"différent pour le mappage. "

#. Tag: para
#: tutorial.xml:284
#, no-c-format
msgid ""
"The <literal>title mapping also lacks a type "
"attribute. The types declared and used in the mapping files are not Java "
"data types; they are not SQL database types either. These types are called "
"<emphasis>Hibernate mapping types, 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 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 property. Hibernate cannot know if the property, "
"which is of <literal>java.util.Date, should map to a SQL "
"<literal>date, timestamp, or time converter."
msgstr ""
"Il est intéressant de noter que le mappage de <literal>title "
"manque également d'un attribut <literal>type. Les types que nous "
"déclarons et utilisons dans les fichiers de mappage 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 "
"<emphasis>types de mappage Hibernate, 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 mappage "
"lui-même si l'attribut <literal>type n'est pas présent dans le "
"mappage. 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, timestamp ou "
"<literal>time. Nous déclarons que nous voulons conserver des "
"informations avec une date complète et l'heure en mappant la propriété avec "
"un convertisseur <literal>timestamp. "

#. Tag: para
#: tutorial.xml:300
#, no-c-format
msgid ""
"Hibernate makes this mapping type determination using reflection when the "
"mapping files are processed. This can take time and resources, so if startup "
"performance is important you should consider explicitly defining the type to "
"use."
msgstr ""
"Hibernate rend cette détermination de type de mappage en utilisant la "
"réflection au moment du traitement des fichiers de mappage. Cela prend du "
"temps et consomme des ressources, donc, si la performance de démarrage est "
"importante, vous devriez considérer définir explicitement quel type utiliser."

#. Tag: para
#: tutorial.xml:307
#, no-c-format
msgid ""
"Save this mapping file as <filename>src/main/resources/org/hibernate/"
"tutorial/domain/Event.hbm.xml</filename>."
msgstr ""
"Sauvegardez ce fichier de mappage ainsi <filename>src/main/resources/org/"
"hibernate/tutorial/domain/Event.hbm.xml</filename>."

#. Tag: title
#: tutorial.xml:315
#, no-c-format
msgid "Hibernate configuration"
msgstr "Configuration d'Hibernate"

#. Tag: para
#: tutorial.xml:317
#, no-c-format
msgid ""
"At this point, you should have the persistent class and its mapping file in "
"place. It is now time to configure Hibernate. First let's set up HSQLDB to "
"run in \"server mode\""
msgstr ""
"A ce niveau là, vous devriez avoir la classe persistante et son fichier de "
"mappage en place. Il est temps maintenant de configurer Hibernate. Tout "
"d'abord, il nous faut configurer HSQLDB pour qu'il puisse exécuter en "
"\"server mode\""

#. Tag: para
#: tutorial.xml:324
#, fuzzy, no-c-format
msgid "We do this do that the data remains between runs."
msgstr "xxx"

#. Tag: para
#: tutorial.xml:329
#, no-c-format
msgid ""
"We will utilize the Maven exec plugin to launch the HSQLDB server by "
"running: <command> mvn exec:java -Dexec.mainClass=\"org.hsqldb.Server\" -"
"Dexec.args=\"-database.0 file:target/data/tutorial\"</command> You will 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 HSQLDB, delete all files in the <filename>target/data et redémarrez HSQL DB."

#. Tag: para
#: tutorial.xml:340
#, no-c-format
msgid ""
"Hibernate will be connecting to the database on behalf of your application, "
"so it needs to know how to obtain connections. For this tutorial we will be "
"using a standalone connection pool (as opposed to a <interfacename>javax.sql."
"DataSource</interfacename>). Hibernate comes with support for two third-"
"party open source JDBC connection pools: <ulink url=\"https://sourceforge."
"net/projects/c3p0\">c3p0</ulink> and . However, we will be using the Hibernate built-in "
"connection pool for this tutorial."
msgstr ""
"Hibernate se connectera à la base de données pour le compte de votre "
"application, donc il devra savoir comment obtenir des connexions. Pour ce "
"tutoriel, nous devrons utliser un pool de connexions autonomes (et non pas "
"<interfacename>javax.sql.DataSource). Hibernate bénéficie du "
"support de deux pools de connexions JDBC open source de tierce partie : "
"<ulink url=\"https://sourceforge.net/projects/c3p0\">c3p0 and . Cependant, nous "
"utiliserons le pool de connexions intégré Hibernate pour ce tutoriel."

#. Tag: para
#: tutorial.xml:351
#, fuzzy, no-c-format
msgid ""
"The built-in Hibernate connection pool is in no way intended for production "
"use. It lacks several features found on any decent connection pool."
msgstr ""
"Le pool de connexions intégré Hibernate n'est pas conçu pour les "
"environnements de production."

#. Tag: para
#: tutorial.xml:357
#, no-c-format
msgid ""
"For Hibernate's configuration, we can use a simple <literal>hibernate."
"properties</literal> file, a more sophisticated hibernate.cfg.xml, un fichier 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:363
#, no-c-format
msgid ""
"<![CDATA[\n"
"        <property name=\"connection.password\">\n"
"\n"
"        <!-- JDBC connection pool (use the built-in) -->\n"
"        <property name=\"connection.pool_size\">1\n"
"\n"
"        <!-- SQL dialect -->\n"
"        <property name=\"dialect\">org.hibernate.dialect.HSQLDialect\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\n"
"\n"
"        <!-- Drop and re-create the database schema on startup -->\n"
"        <property name=\"hbm2ddl.auto\">update\n"
"\n"
"        <mapping resource=\"org/hibernate/tutorial/domain/Event.hbm.xml\"/>\n"
"\n"
"    </session-factory>\n"
"\n"
"</hibernate-configuration>]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:366
#, no-c-format
msgid "Notice that this configuration file specifies a different DTD"
msgstr ""
"Vous pourrez remarquer que cette configuration XML utilise une DTD "
"différente."

#. Tag: para
#: tutorial.xml:369
#, no-c-format
msgid ""
"You configure Hibernate's <literal>SessionFactory. SessionFactory "
"is a global factory responsible for a particular database. If you have "
"several databases, for easier startup you should use several <literal><"
"session-factory></literal> configurations in several configuration files."
msgstr ""
"Nous configurons une <literal>SessionFactory de 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><session-factory>, généralement dans des fichiers "
"de configuration différents (pour un démarrage plus facile)."

#. Tag: para
#: tutorial.xml:376
#, no-c-format
msgid ""
"The first four <literal>property elements contain the necessary "
"configuration for the JDBC connection. The dialect <literal>property contiennent la "
"configuration nécessaire pour la connexion JDBC. L'élément "
"<literal>property du dialecte spécifie quelle variante du SQL "
"Hibernate va générer. "

#. Tag: para
#: tutorial.xml:383
#, fuzzy, no-c-format
msgid ""
"In most cases, Hibernate is able to properly determine which dialect to use. "
"See <xref linkend=\"portability-dialectresolver\"/> for more information."
msgstr ""
"Hibernate est capable de déterminer correctement quel dialecte utiliser dans "
"la plupart des cas. Voir <xref linkend=\"portability-dialectresolver\" /> "
"pour obtenir davantage d'informations. "

#. Tag: para
#: tutorial.xml:389
#, no-c-format
msgid ""
"Hibernate's automatic session management for persistence contexts is "
"particularly useful in this context. The <literal>hbm2ddl.auto "
"option turns on automatic generation of database schemas directly into the "
"database. This can also be turned off by removing the configuration option, "
"or redirected to a file with the help of the <literal>SchemaExport "
"Ant task. Finally, add the mapping file(s) for persistent classes to the "
"configuration."
msgstr ""
"La gestion automatique des sessions d'Hibernate pour les contextes de "
"persistance est bien pratique, comme vous pourrez le constater. L'option "
"<literal>hbm2ddl.auto active la génération automatique des schémas "
"de base de données - directement dans la base de données. Cela peut "
"également être désactivé (en supprimant l'option de configuration) ou "
"redirigé vers un fichier avec l'aide de la tâche Ant <literal>SchemaExport into the "
"<filename>src/main/resources directory."
msgstr ""
"Sauvegarder ce fichier en tant que <filename>hibernate.cfg.xml "
"dans le répertoire <filename>src/main/resources."

#. Tag: title
#: tutorial.xml:406
#, no-c-format
msgid "Building with Maven"
msgstr "Construction avec Maven"

#. Tag: para
#: tutorial.xml:408
#, no-c-format
msgid ""
"We will now build the tutorial with Maven. You will need to have Maven "
"installed; it is available from the <ulink url=\"http://maven.apache.org/"
"download.html\">Maven download page</ulink>. Maven will read the /"
"pom.xml</filename> file we created earlier and know how to perform some "
"basic project tasks. First, lets run the <literal>compile goal to "
"make sure we can compile everything so far:"
msgstr ""
"Nous allons maintenant construire le tutoriel avec Maven. Vous aurez besoin "
"d'installer Maven pour cela. Il est disponible dans la page <ulink url="
"\"http://maven.apache.org/download.html\">Maven download page</ulink>. Maven "
"pourra lire le fichier <filename>/pom.xml que nous avons créé "
"plus tôt et saura comment effectuer quelques tâches du projet de base. Tout "
"d'abord, exécutons <literal>compile pour s'assurer que nous "
"pouvons tout compiler jusqu'à maintenant :"

#. Tag: programlisting
#: tutorial.xml:418
#, no-c-format
msgid ""
"<![CDATA[[hibernateTutorial]$ mvn compile\n"
"[INFO] Scanning for projects...\n"
"[INFO] "
"------------------------------------------------------------------------\n"
"[INFO] Building First Hibernate Tutorial\n"
"[INFO]    task-segment: [compile]\n"
"[INFO] "
"------------------------------------------------------------------------\n"
"[INFO] [resources:resources]\n"
"[INFO] Using default encoding to copy filtered resources.\n"
"[INFO] [compiler:compile]\n"
"[INFO] Compiling 1 source file to /home/steve/projects/sandbox/"
"hibernateTutorial/target/classes\n"
"[INFO] "
"------------------------------------------------------------------------\n"
"[INFO] BUILD SUCCESSFUL\n"
"[INFO] "
"------------------------------------------------------------------------\n"
"[INFO] Total time: 2 seconds\n"
"[INFO] Finished at: Tue Jun 09 12:25:25 CDT 2009\n"
"[INFO] Final Memory: 5M/547M\n"
"[INFO] "
"------------------------------------------------------------------------]]>"
msgstr ""

#. Tag: title
#: tutorial.xml:423
#, no-c-format
msgid "Startup and helpers"
msgstr "Démarrage et aides"

#. Tag: para
#: tutorial.xml:425
#, no-c-format
msgid ""
"It is time to load and store some <literal>Event objects, but "
"first you have to complete the setup with some infrastructure code. You have "
"to startup Hibernate by building a global <interfacename>org.hibernate."
"SessionFactory</interfacename> object and storing it somewhere for easy "
"access in application code. A <interfacename>org.hibernate.SessionFactoryorg.hibernate.Sessionorg.hibernate.Session is a thread-safe "
"global object that is instantiated once."
msgstr ""
"Il est temps de charger et de stocker quelques objets <literal>Event global et le "
"stocker dans un lieu facile d'accès dans le code de l'application. Une "
"<literal>SessionFactory peut ouvrir de nouvelles SessionSession représente une unité de travail "
"simplement \"threadée\". La <interfacename>org.hibernate.SessionFactory helper class that takes "
"care of startup and makes accessing the <interfacename>org.hibernate."
"SessionFactory</interfacename> more convenient."
msgstr ""
"Nous créerons une classe d'aide <literal>HibernateUtil qui "
"s'occupe du démarrage et rend la gestion des <interfacename>org.hibernate."
"SessionFactory</interfacename> plus facile. "

#. Tag: programlisting
#: tutorial.xml:445
#, no-c-format
msgid ""
"<![CDATA[package org.hibernate.tutorial.util;\n"
"\n"
"import org.hibernate.SessionFactory;\n"
"import org.hibernate.cfg.Configuration;\n"
"\n"
"public class HibernateUtil {\n"
"\n"
"    private static final SessionFactory sessionFactory = buildSessionFactory"
"();\n"
"\n"
"    private static SessionFactory buildSessionFactory() {\n"
"        try {\n"
"            // Create the SessionFactory from hibernate.cfg.xml\n"
"            return new Configuration().configure().buildSessionFactory();\n"
"        }\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:447
#, no-c-format
msgid ""
"Save this code as <filename>src/main/java/org/hibernate/tutorial/util/"
"HibernateUtil.java</filename>"
msgstr ""
"Sauvegardez ce code en tant que <filename>src/main/java/org/hibernate/"
"tutorial/util/HibernateUtil.java</filename>"

#. Tag: para
#: tutorial.xml:452
#, no-c-format
msgid ""
"This class not only produces the global <interfacename>org.hibernate."
"SessionFactory</interfacename> reference in its static initializer; it also "
"hides the fact that it uses a static singleton. We might just as well have "
"looked up the <interfacename>org.hibernate.SessionFactory "
"reference from JNDI in an application server or any other location for that "
"matter."
msgstr ""
"Cette classe ne produit pas seulement la <interfacename>org.hibernate."
"SessionFactory</interfacename> globale dans un initialiseur statique. Elle "
"masque le fait qu'elle exploite un singleton statique. Nous aurions pu aussi "
"bien vérouiller la référence <interfacename>org.hibernate.SessionFactory depuis JNDI dans un serveur d'applications."

#. Tag: para
#: tutorial.xml:461
#, no-c-format
msgid ""
"If you give the <interfacename>org.hibernate.SessionFactory "
"a name in your configuration, Hibernate will try to bind it to JNDI under "
"that name after it has been built. Another, better option is to use a JMX "
"deployment and let the JMX-capable container instantiate and bind a "
"<literal>HibernateService to JNDI. Such advanced options are "
"discussed later."
msgstr ""
"Si vous nommez <interfacename>org.hibernate.SessionFactory "
"dans votre fichier de configuration, Hibernate tentera la récupération "
"depuis JNDI. Pour éviter ce code, vous pouvez aussi utiliser un déploiement "
"JMX et laisser le conteneur (compatible JMX) instancier et lier un "
"<literal>HibernateService à JNDI. Ces options avancées sont "
"expliquées plus loin."

#. Tag: para
#: tutorial.xml:470
#, no-c-format
msgid ""
"You now need to configure a logging system. Hibernate uses commons logging "
"and provides two choices: Log4j and JDK 1.4 logging. Most developers prefer "
"Log4j: copy <literal>log4j.properties from the Hibernate "
"distribution in the <literal>etc/ directory to your srchibernate.cfg.xml. If you "
"prefer to have more verbose output than that provided in the example "
"configuration, you can change the settings. By default, only the Hibernate "
"startup message is shown on stdout."
msgstr ""
"Nous avons finalement besoin de configurer le système de journalisation - "
"Hibernate utilise commons-logging et vous laisse le choix entre log4j et le "
"système de logs du JDK 1.4. La plupart des développeurs préfèrent log4j : "
"copiez <literal>log4j.properties de la distribution de Hibernate "
"(il est dans le répertoire <literal>etc/) dans votre répertoire "
"<literal>src, puis faîtes de même avec hibernate.cfg.xml class with a main() avec une méthode "
"<literal>main() : "

#. Tag: programlisting
#: tutorial.xml:496
#, no-c-format
msgid ""
"<![CDATA[package org.hibernate.tutorial;\n"
"\n"
"import org.hibernate.Session;\n"
"\n"
"import java.util.*;\n"
"\n"
"import org.hibernate.tutorial.domain.Event;\n"
"import org.hibernate.tutorial.util.HibernateUtil;\n"
"\n"
"public class EventManager {\n"
"\n"
"    public static void main(String[] args) {\n"
"        EventManager mgr = new EventManager();\n"
"\n"
"        if (args[0].equals(\"store\")) {\n"
"            mgr.createAndStoreEvent(\"My Event\", new Date());\n"
"        }\n"
"\n"
"        HibernateUtil.getSessionFactory().close();\n"
"    }\n"
"\n"
"    private void createAndStoreEvent(String title, Date theDate) {\n"
"        Session session = HibernateUtil.getSessionFactory().getCurrentSession"
"();\n"
"        session.beginTransaction();\n"
"\n"
"        Event theEvent = new Event();\n"
"        theEvent.setTitle(title);\n"
"        theEvent.setDate(theDate);\n"
"        session.save(theEvent);\n"
"\n"
"        session.getTransaction().commit();\n"
"    }\n"
"\n"
"}]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:498
#, no-c-format
msgid ""
"In <literal>createAndStoreEvent() we created a new Event on the "
"database."
msgstr ""
"Nous créons un nouvel objet <literal>Event dans "
"<literal>createAndStoreEvent(), et nous le remettons à Hibernate, "
"qui s'occupe maintenant du SQL et exécute les <literal>INSERT s "
"dans la base de données."

#. Tag: para
#: tutorial.xml:505
#, fuzzy, no-c-format
msgid ""
"A <interface>org.hibernate.Session is designed to represent a "
"single unit of work (a single atomic piece of work to be performed). For now "
"we will keep things simple and assume a one-to-one granularity between a "
"Hibernate <interface>org.hibernate.Session and a database "
"transaction. To shield our code from the actual underlying transaction "
"system we use the Hibernate <interfacename>org.hibernate.Transaction est une unité de travail "
"unique (une unité atmoic simple). Pour le moment, nous allons faire les "
"choses simplement et présumer une granularité un-à-un entre une "
"<literal>Session Hibernate et une transaction de la base de "
"données. Pour isoler notre code du système de transaction sous-jacent, nous "
"utilisons l'API <interfacename>org.hibernate.Transaction "
"Hibernate. Dans notre cas, nous utilisons du pur JDBC, mais on aurait pu "
"utiliser JTA."

#. Tag: para
#: tutorial.xml:518
#, no-c-format
msgid ""
"What does <literal>sessionFactory.getCurrentSession() do? First, "
"you can call it as many times and anywhere you like once you get hold of "
"your <interfacename>org.hibernate.SessionFactory. The "
"<literal>getCurrentSession() method always returns the \"current\" "
"unit of work. Remember that we switched the configuration option for this "
"mechanism to \"thread\" in our <filename>src/main/resources/hibernate.cfg."
"xml</filename>? Due to that setting, the context of a current unit of work "
"is bound to the current Java thread that executes the application."
msgstr ""
"Quelle est la fonction de <literal>sessionFactory.getCurrentSession() (facile grâce à HibernateUtilgetCurrentSession() renvoie "
"toujours l'unité de travail courante. Souvenez vous que nous avons basculé "
"notre option de configuration au mécanisme basé sur le \"thread\" dans "
"<literal>hibernate.cfg.xml. Par conséquent, l'unité de travail "
"courante est liée au thread Java courant qui exécute notre application."

#. Tag: para
#: tutorial.xml:532
#, no-c-format
msgid ""
"Hibernate offers three methods of current session tracking. The \"thread\" "
"based method is not intended for production use; it is merely useful for "
"prototyping and tutorials such as this one. Current session tracking is "
"discussed in more detail later on."
msgstr ""
"Hibernate offre trois méthodes le suivi de session courant. La méthode basée "
"\"thread\" qui n'est pas conçue pour une utilisation de la production ; "
"seulement utile pour les prototypes et des tutoriels comme celui-ci. Le "
"suivi de session courant est abordé plus en détail par la suite."

#. Tag: para
#: tutorial.xml:541
#, no-c-format
msgid ""
"A <interface>org.hibernate.Session begins when the first call to "
"<literal>getCurrentSession() is made for the current thread. It is "
"then bound by Hibernate to the current thread. When the transaction ends, "
"either through commit or rollback, Hibernate automatically unbinds the "
"<interface>org.hibernate.Session from the thread and closes it "
"for you. If you call <literal>getCurrentSession() again, you get a "
"new <interface>org.hibernate.Session and can start a new unit of "
"work."
msgstr ""
"Une <interface>org.hibernate.Session commence lorsque le thread "
"courant commence à appeler <literal>getCurrentSession(). Ensuite, "
"elle est attachée par Hibernate au thread courant. Lorsque la transaction "
"s'achève, par commit ou par rollback, Hibernate détache automatiquement la "
"<literal>Session du thread et la ferme pour vous. Si vous invoquez "
"<literal>getCurrentSession() une nouvelle fois, vous obtenez une "
"nouvelle <literal>Session et pouvez entamer une nouvelle unité de "
"travail. "

#. Tag: para
#: tutorial.xml:554
#, no-c-format
msgid ""
"Related to the unit of work scope, should the Hibernate <interface>org."
"hibernate.Session</interface> be used to execute one or several database "
"operations? The above example uses one <interface>org.hibernate.Session is flexible but you "
"should never design your application to use a new Hibernate <interface>org."
"hibernate.Session</interface> for every database "
"operation. Even though it is used in the following examples, consider "
"<emphasis>session-per-operation an anti-pattern. A real web "
"application is shown later in the tutorial which will help illustrate this."
msgstr ""
"A propos de la portée de l'unité de travail, la session <interface>org."
"hibernate.Session</interface> Hibernate devrait-elle être utilisée pour "
"exécuter une ou plusieurs opérations en base de données ? L'exemple ci-"
"dessus utilise une <literal>Session pour une opération. C'est une "
"pure coïncidence, l'exemple n'est pas assez complexe pour montrer d'autres "
"approches. La portée d'une <literal>Session Hibernate est flexible "
"mais vous ne devriez jamais concevoir votre application de manière à "
"utiliser une nouvelle <literal>Session Hibernate pour "
"<emphasis>chaque opération en base de données. Donc même si vous "
"le voyez quelquefois dans les exemples suivants, considérez <emphasis>une "
"session par opération</emphasis> comme un anti-modèle. Une véritable "
"application (web) est affichée plus loin dans ce tutoriel. "

#. Tag: para
#: tutorial.xml:571
#, fuzzy, no-c-format
msgid ""
"See <xref linkend=\"transactions\"/> for more information about transaction "
"handling and demarcation. The previous example also skipped any error "
"handling and rollback."
msgstr ""
"Consultez <xref linkend=\"transactions\" /> pour plus d'informations sur la "
"gestion des transactions et leur démarcation. Nous n'avons pas géré les "
"erreurs et rollback dans l'exemple précédent."

#. Tag: para
#: tutorial.xml:577
#, no-c-format
msgid ""
"To run this, we will make use of the Maven exec plugin to call our class "
"with the necessary classpath setup: <command>mvn exec:java -Dexec.mainClass="
"\"org.hibernate.tutorial.EventManager\" -Dexec.args=\"store\"</command>"
msgstr ""
"Pour pouvoir exécuter ceci, nous utiliserons le plugin exec Maven pour "
"appeler notre classe avec la configuration de classpath qui convient : "
"<command>mvn exec:java -Dexec.mainClass=\"org.hibernate.tutorial.EventManager"
"\" -Dexec.args=\"store\"</command>"

#. Tag: para
#: tutorial.xml:584
#, no-c-format
msgid "You may need to perform <command>mvn compile first."
msgstr ""
"Vous aurez sans doute besoin d'effectuer <command>mvn compile pour "
"commencer."

#. Tag: para
#: tutorial.xml:589
#, no-c-format
msgid ""
"You should see Hibernate starting up and, depending on your configuration, "
"lots of log output. Towards the end, the following line will be displayed:"
msgstr ""
"Vous devriez constater qu'Hibernate démarre et selon votre configuration, "
"beaucoup de traces sur la sortie. À la fin, vous trouverez la ligne "
"suivante :"

#. Tag: programlisting
#: tutorial.xml:594
#, no-c-format
msgid ""
"<![CDATA[[java] Hibernate: insert into EVENTS (EVENT_DATE, title, EVENT_ID) "
"values (?, ?, ?)]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:596
#, no-c-format
msgid "This is the <literal>INSERT executed by Hibernate."
msgstr "C'est l' <literal>INSERT exécutée par Hibernate."

#. Tag: para
#: tutorial.xml:600
#, no-c-format
msgid "To list stored events an option is added to the main method:"
msgstr ""
"Maintenant nous aimerions aussi lister les événements stockés, donc nous "
"ajoutons une option à la méthode principale : "

#. Tag: programlisting
#: tutorial.xml:604
#, no-c-format
msgid ""
"<![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(\n"
"                        \"Event: \" + theEvent.getTitle() + \" Time: \" + "
"theEvent.getDate()\n"
"                );\n"
"            }\n"
"        }]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:606
#, no-c-format
msgid "A new <literal>listEvents() method is also added:"
msgstr ""
"Nous ajoutons aussi une nouvelle méthode <literal>listEvents() : "

#. Tag: programlisting
#: tutorial.xml:610
#, no-c-format
msgid ""
"<![CDATA[    private List listEvents() {\n"
"        Session session = HibernateUtil.getSessionFactory().getCurrentSession"
"();\n"
"        session.beginTransaction();\n"
"        List result = session.createQuery(\"from Event\").list();\n"
"        session.getTransaction().commit();\n"
"        return result;\n"
"    }]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:612
#, fuzzy, no-c-format
msgid ""
"Here, we are using a Hibernate Query Language (HQL) query to load all "
"existing <literal>Event objects from the database. Hibernate will "
"generate the appropriate SQL, send it to the database and populate "
"<literal>Event objects with the data. You can create more complex "
"queries with HQL. See <xref linkend=\"queryhql\"/> for more information."
msgstr ""
"Ici nous utilisons une requête HQL (Hibernate Query Language) pour charger "
"tous les objets <literal>Event existants de la base de données. "
"Hibernate générera le SQL approprié, l'enverra à la base de données et "
"peuplera des objets <literal>Event avec les données. Vous pouvez "
"évidemment créer des requêtes plus complexes avec HQL. Voir <xref linkend="
"\"queryhql\" /> pour obtenir davantage d'informations."

#. Tag: para
#: tutorial.xml:620
#, no-c-format
msgid ""
"Now we can call our new functionality, again using the Maven exec plugin: "
"<command>mvn exec:java -Dexec.mainClass=\"org.hibernate.tutorial.EventManager"
"\" -Dexec.args=\"list\"</command>"
msgstr ""
"Nous pouvons maintenant appeler notre nouvelle fonctionnalité, en utilisant "
"à nouveau le plugin exec Maven : <command>mvn exec:java -Dexec.mainClass="
"\"org.hibernate.tutorial.EventManager\" -Dexec.args=\"list\"</command>"

#. Tag: title
#: tutorial.xml:630
#, no-c-format
msgid "Part 2 - Mapping associations"
msgstr "Section 2 - Mapper des associations"

#. Tag: para
#: tutorial.xml:632
#, no-c-format
msgid ""
"So far we have mapped a single persistent entity class to a table in "
"isolation. Let's expand on that a bit and add some class associations. We "
"will add people to the application and store a list of events in which they "
"participate."
msgstr ""
"Pour l'instant, nous nous sommes contentés de mapper une classe d'une entité "
"persistante vers une table. Profitons-en pour ajouter quelques associations "
"de classe. D'abord nous ajouterons des gens à notre application, et "
"stockerons une liste d'événements auxquels ils participent."

#. Tag: title
#: tutorial.xml:640
#, no-c-format
msgid "Mapping the Person class"
msgstr "Mapper la classe Person"

#. Tag: para
#: tutorial.xml:642
#, no-c-format
msgid "The first cut of the <literal>Person class looks like this:"
msgstr ""
"La première version de la classe <literal>Person est simple : "

#. Tag: programlisting
#: tutorial.xml:646
#, no-c-format
msgid ""
"<![CDATA[package org.hibernate.tutorial.domain;\n"
"\n"
"public class Person {\n"
"\n"
"    private Long id;\n"
"    private int age;\n"
"    private String firstname;\n"
"    private String lastname;\n"
"\n"
"    public Person() {}\n"
"\n"
"    // Accessor methods for all properties, private setter for 'id'\n"
"\n"
"}]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:648
#, no-c-format
msgid ""
"Save this to a file named <filename>src/main/java/org/hibernate/tutorial/"
"domain/Person.java</filename>"
msgstr ""
"A sauvegarder dans le fichier nommé <filename>src/main/java/org/hibernate/"
"tutorial/domain/Person.java</filename>"

#. Tag: para
#: tutorial.xml:653
#, no-c-format
msgid ""
"Next, create the new mapping file as <filename>src/main/resources/org/"
"hibernate/tutorial/domain/Person.hbm.xml</filename>"
msgstr ""
"Puis, créez le nouveau fichier de mappage <filename>src/main/resources/org/"
"hibernate/tutorial/domain/Person.hbm.xml</filename>"

#. Tag: programlisting
#: tutorial.xml:658
#, no-c-format
msgid ""
"<![CDATA["
msgstr ""

#. Tag: para
#: tutorial.xml:660
#, no-c-format
msgid "Finally, add the new mapping to Hibernate's configuration:"
msgstr ""
"Finalement, ajoutez le nouveau mappage à la configuration d'Hibernate :"

#. Tag: programlisting
#: tutorial.xml:664
#, no-c-format
msgid ""
"<![CDATA["
msgstr ""

#. Tag: para
#: tutorial.xml:666
#, no-c-format
msgid ""
"Create an association between these two entities. Persons can participate in "
"events, and events have participants. The design questions you have to deal "
"with are: directionality, multiplicity, and collection behavior."
msgstr ""
"Nous allons maintenant créer une association entre ces deux entités. "
"Évidemment, des personnes peuvent participer aux événements, et des "
"événements ont des participants. Les questions de conception que nous devons "
"traiter sont : direction, cardinalité et comportement de la collection. "

#. Tag: title
#: tutorial.xml:676
#, no-c-format
msgid "A unidirectional Set-based association"
msgstr "Une association unidirectionnelle basée sur Set"

#. Tag: para
#: tutorial.xml:678
#, no-c-format
msgid ""
"By adding a collection of events to the <literal>Person class, you "
"can easily navigate to the events for a particular person, without executing "
"an explicit query - by calling <literal>Person#getEvents. Multi-"
"valued associations are represented in Hibernate by one of the Java "
"Collection Framework contracts; here we choose a <interfacename>java.util."
"Set</interfacename> because the collection will not contain duplicate "
"elements and the ordering is not relevant to our examples:"
msgstr ""
"Nous allons ajouter une collection d'événements à la classe <literal>Person. Nous utilisons une "
"collection Java, un <literal>Set, parce que la collection ne "
"contiendra pas d'éléments dupliqués et l'ordre ne nous importe pas pour ces "
"exemples :"

#. Tag: programlisting
#: tutorial.xml:689
#, no-c-format
msgid ""
"<![CDATA[public class Person {\n"
"\n"
"    private Set events = new HashSet();\n"
"\n"
"    public Set getEvents() {\n"
"        return events;\n"
"    }\n"
"\n"
"    public void setEvents(Set events) {\n"
"        this.events = events;\n"
"    }\n"
"}]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:691
#, no-c-format
msgid ""
"Before mapping this association, let's consider the other side. We could "
"just keep this unidirectional or create another collection on the "
"<literal>Event, if we wanted to be able to navigate it from both "
"directions. This is not necessary, from a functional perspective. You can "
"always execute an explicit query to retrieve the participants for a "
"particular event. This is a design choice left to you, but what is clear "
"from this discussion is the multiplicity of the association: \"many\" valued "
"on both sides is called a <emphasis>many-to-many association. "
"Hence, we use Hibernate's many-to-many mapping:"
msgstr ""
"D'abord nous mappons cette association, mais pensez à l'autre côté. "
"Clairement, nous pouvons la laisser unidirectionnelle. Ou bien, nous "
"pourrions créer une autre collection sur <literal>Event, si nous "
"voulons être capable de la parcourir de manière bidirectionnelle. Ce n'est "
"pas nécessaire d'un point de vue fonctionnel. Vous pourrez toujours exécuter "
"une requête explicite pour récupérer les participants d'un évènement "
"particulier. Vous êtes libre de choisir la conception, ce qui est certain, "
"c'est que la cardinalité de l'association : \"plusieurs\" valués des deux "
"côtés, est appelée <emphasis>plusieurs-à-plusieurs. Par "
"conséquent nous utilisons un mappage Hibernate plusieurs-à-plusieurs :"

#. Tag: programlisting
#: tutorial.xml:704
#, no-c-format
msgid ""
"<![CDATA["
msgstr ""

#. Tag: para
#: tutorial.xml:706
#, no-c-format
msgid ""
"Hibernate supports a broad range of collection mappings, a <literal>setn:"
"m</emphasis> entity relationship, an association table is required. Each row "
"in this table represents a link between a person and an event. The table "
"name is decalred using the <literal>table attribute of the "
"<literal>set element. The identifier column name in the "
"association, for the person side, is defined with the <literal>key "
"element, the column name for the event's side with the <literal>columnmany-to-many. You also have to "
"tell Hibernate the class of the objects in your collection (the class on the "
"other side of the collection of references)."
msgstr ""
"Hibernate supporte toutes sortes de mappage de collection, un <literal>set), une table d'association "
"est requise. Chaque ligne dans cette table représente un lien entre une "
"personne et un événement. Le nom de la table est configuré avec l'attribut "
"<literal>table de l'élément set. Le nom de la "
"colonne identifiant dans l'association, du côté de la personne, est défini "
"avec l'élément <literal>key, et le nom de la colonne pour "
"l'événement avec l'attribut <literal>column de many-to-"
"many</literal>. Vous devez aussi donner à Hibernate la classe des objets de "
"votre collection (c'est-à-dire : la classe de l'autre côté de la collection)."

#. Tag: para
#: tutorial.xml:722
#, no-c-format
msgid "The database schema for this mapping is therefore:"
msgstr "Le schéma de base de données pour ce mappage est donc :"

#. Tag: programlisting
#: tutorial.xml:726
#, no-c-format
msgid ""
"<![CDATA[\n"
"    _____________        __________________\n"
"   |             |      |                  |       _____________\n"
"   |   EVENTS    |      |   PERSON_EVENT   |      |             |\n"
"   |_____________|      |__________________|      |    PERSON   |\n"
"   |             |      |                  |      |_____________|\n"
"   | *EVENT_ID   | <--> | *EVENT_ID        |      |             |\n"
"   |  EVENT_DATE |      | *PERSON_ID       | <--> | *PERSON_ID  |\n"
"   |  TITLE      |      |__________________|      |  AGE        |\n"
"   |_____________|                                |  FIRSTNAME  |\n"
"                                                  |  LASTNAME   |\n"
"                                                  |_____________|\n"
" ]]>"
msgstr ""

#. Tag: title
#: tutorial.xml:731
#, no-c-format
msgid "Working the association"
msgstr "Travailler avec l'association"

#. Tag: para
#: tutorial.xml:733
#, no-c-format
msgid ""
"Now we will bring some people and events together in a new method in "
"<literal>EventManager:"
msgstr ""
"Réunissons quelques personnes et quelques événements dans une nouvelle "
"méthode dans <literal>EventManager : "

#. Tag: programlisting
#: tutorial.xml:737
#, no-c-format
msgid ""
"<![CDATA[    private void addPersonToEvent(Long personId, Long eventId) {\n"
"        Session session = HibernateUtil.getSessionFactory().getCurrentSession"
"();\n"
"        session.beginTransaction();\n"
"\n"
"        Person aPerson = (Person) session.load(Person.class, personId);\n"
"        Event anEvent = (Event) session.load(Event.class, eventId);\n"
"        aPerson.getEvents().add(anEvent);\n"
"\n"
"        session.getTransaction().commit();\n"
"    }]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:739
#, no-c-format
msgid ""
"After loading a <literal>Person and an Event, "
"simply modify the collection using the normal collection methods. There is "
"no explicit call to <literal>update() or save() state, that is, bound to a particular "
"Hibernate <interfacename>org.hibernate.Session, Hibernate "
"monitors any changes and executes SQL in a write-behind fashion. The process "
"of synchronizing the memory state with the database, usually only at the end "
"of a unit of work, is called <emphasis>flushing. In our code, the "
"unit of work ends with a commit, or rollback, of the database transaction."
msgstr ""
"Après le chargement d'une <literal>Person et d'un Event ou save(), "
"c'est-à-dire, liés à une <literal>Session Hibernate particulière "
"(c-à-d qu'ils ont juste été chargés ou sauvegardés dans une unité de "
"travail), Hibernate surveille les changements et exécute le SQL "
"correspondants. Le processus de synchronisation de l'état de la mémoire avec "
"la base de données, généralement seulement à la fin d'une unité de travail, "
"est appelé <emphasis>flushing. Dans notre code, l'unité de "
"travail s'achève par un commit (ou rollback) de la transaction avec la base "
"de données."

#. Tag: para
#: tutorial.xml:758
#, no-c-format
msgid ""
"You can load person and event in different units of work. Or you can modify "
"an object outside of a <interfacename>org.hibernate.Session, "
"when it is not in persistent state (if it was persistent before, this state "
"is called <emphasis>detached). You can even modify a collection "
"when it is detached:"
msgstr ""
"Vous pourriez bien sûr charger une personne et un événement dans différentes "
"unités de travail. Ou vous modifiez un objet à l'extérieur d'une "
"<literal>Session, s'il n'est pas dans un état persistant (s'il "
"était persistant avant, nous appelons cet état <emphasis>détaché makes a detached object persistent "
"again by binding it to a new unit of work, so any modifications you made to "
"it while detached can be saved to the database. This includes any "
"modifications (additions/deletions) you made to a collection of that entity "
"object."
msgstr ""
"L'appel à <literal>update rend un objet détaché à nouveau "
"persistant, vous pourriez dire qu'il le lie à une nouvelle unité de travail, "
"ainsi toutes les modifications que vous avez faites pendant qu'il était "
"détaché peuvent être sauvegardées dans la base de données, cela inclut toute "
"modification effectuées sur une collection de cet objet entité."

#. Tag: para
#: tutorial.xml:778
#, no-c-format
msgid ""
"This is not much use in our example, but it is an important concept you can "
"incorporate into your own application. Complete this exercise by adding a "
"new action to the main method of the <literal>EventManager and "
"call it from the command line. If you need the identifiers of a person and "
"an event - the <literal>save() method returns it (you might have "
"to modify some of the previous methods to return that identifier):"
msgstr ""
"Cela n'a pas grand intérêt dans notre situation, mais c'est un concept "
"important qu'il vous faut concevoir dans votre application. Pour le moment, "
"complétez cet exercice en ajoutant une nouvelle action à la méthode "
"principale de l'<literal>EventManager et invoquez-la depuis la "
"ligne de commande. Si vous avez besoin des identifiants d'un client et d'un "
"évènement - la méthode <literal>save() vous les retourne (vous "
"devrez peut-être modifier certaines méthodes précédentes pour retourner ces "
"identifiants) :"

#. Tag: programlisting
#: tutorial.xml:786
#, no-c-format
msgid ""
"<![CDATA[        else if (args[0].equals(\"addpersontoevent\")) {\n"
"            Long eventId = mgr.createAndStoreEvent(\"My Event\", new Date"
"());\n"
"            Long personId = mgr.createAndStorePerson(\"Foo\", \"Bar\");\n"
"            mgr.addPersonToEvent(personId, eventId);\n"
"            System.out.println(\"Added person \" + personId + \" to event \" "
"+ eventId);\n"
"        }]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:788
#, no-c-format
msgid ""
"This is an example of an association between two equally important classes : "
"two entities. As mentioned earlier, there are other classes and types in a "
"typical model, usually \"less important\". Some you have already seen, like "
"an <literal>int or a java.lang.String. We "
"call these classes <emphasis>value types, and their instances "
"<emphasis>depend on a particular entity. Instances of these types "
"do not have their own identity, nor are they shared between entities. Two "
"persons do not reference the same <literal>firstname object, even "
"if they have the same first name. Value types cannot only be found in the "
"JDK , but you can also write dependent classes yourself such as an "
"<literal>Address or MonetaryAmount class. In "
"fact, in a Hibernate application all JDK classes are considered value types."
msgstr ""
"C'était un exemple d'une association entre deux classes de même importance, "
"deux entités. Comme mentionné plus tôt, il y a d'autres classes et d'autres "
"types dans un modèle typique, généralement \"moins importants\". Vous en "
"avez déjà vu certains, comme un <literal>int ou une "
"<literal>String. Nous appelons ces classes des types de "
"valeur</emphasis>, et leurs instances dépendent d'une "
"entité particulière. Des instances de ces types n'ont pas leur propre "
"identité, elles ne sont pas non plus partagées entre des entités (deux "
"personnes ne référencent pas le même objet <literal>firstname, "
"même si elles ont le même prénom). Bien sûr, des types de valeur n'existent "
"pas seulement dans le JDK (en fait, dans une application Hibernate toutes "
"les classes du JDK sont considérées comme des types de valeur), vous pouvez "
"aussi écrire vous-même des classes dépendantes, <literal>Address "
"ou <literal>MonetaryAmount, par exemple. "

#. Tag: para
#: tutorial.xml:806
#, no-c-format
msgid ""
"You can also design a collection of value types. This is conceptually "
"different from a collection of references to other entities, but looks "
"almost the same in Java."
msgstr ""
"Vous pouvez aussi concevoir une collection de types de valeur. C'est "
"conceptuellement très différent d'une collection de références vers d'autres "
"entités, mais très ressemblant dans Java. "

#. Tag: title
#: tutorial.xml:815
#, no-c-format
msgid "Collection of values"
msgstr "Collection de valeurs"

#. Tag: para
#: tutorial.xml:817
#, no-c-format
msgid ""
"Let's add a collection of email addresses to the <literal>Person "
"entity. This will be represented as a <interfacename>java.util.Setjava.lang.String instances:"
msgstr ""
"Ajoutons un ensemble d'adresses email à l'entité <literal>Person "
"qui sera représenté en tant que <interfacename>java.util.Set "
"d'instance <classname>java.lang.String :"

#. Tag: programlisting
#: tutorial.xml:823
#, no-c-format
msgid ""
"<![CDATA[    private Set emailAddresses = new HashSet();\n"
"\n"
"    public Set getEmailAddresses() {\n"
"        return emailAddresses;\n"
"    }\n"
"\n"
"    public void setEmailAddresses(Set emailAddresses) {\n"
"        this.emailAddresses = emailAddresses;\n"
"    }]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:825
#, no-c-format
msgid "The mapping of this <literal>Set is as follows:"
msgstr "Le mappage de ce <literal>Set : "

#. Tag: programlisting
#: tutorial.xml:829
#, no-c-format
msgid ""
"<![CDATA[        "
msgstr ""

#. Tag: para
#: tutorial.xml:831
#, no-c-format
msgid ""
"The difference compared with the earlier mapping is the use of the "
"<literal>element part which tells Hibernate that the collection "
"does not contain references to another entity, but is rather a collection "
"whose elements are values types, here specifically of type <literal>string attribute of the set element defines the foreign-key column name in the "
"collection table. The <literal>column attribute in the "
"<literal>element element defines the column name where the email "
"address values will actually be stored."
msgstr ""
"La différence comparée au mappage vu plus tôt est la partie "
"<literal>element, qui indique à Hibernate que la collection ne "
"contient pas de référence vers une autre entité, mais une collection "
"d'éléments de type <literal>String (le nom en minuscule vous "
"indique que c'est un type/convertisseur du mappage Hibernate). Une fois "
"encore, l'attribut <literal>table de l'élément set définit le nom de la colonne de la clé étrangère dans "
"la table de la collection. L'attribut <literal>column dans "
"l'élément <literal>element définit le nom de la colonne où les "
"valeurs de <literal>String seront réellement stockées. "

#. Tag: para
#: tutorial.xml:847
#, no-c-format
msgid "Here is the updated schema:"
msgstr "Considérons le schéma mis à jour : "

#. Tag: programlisting
#: tutorial.xml:851
#, no-c-format
msgid ""
"<![CDATA[\n"
"  _____________        __________________\n"
" |             |      |                  |       _____________\n"
" |   EVENTS    |      |   PERSON_EVENT   |      |             |       "
"___________________\n"
" |_____________|      |__________________|      |    PERSON   |      "
"|                   |\n"
" |             |      |                  |      |_____________|      | "
"PERSON_EMAIL_ADDR |\n"
" | *EVENT_ID   | <--> | *EVENT_ID        |      |             |      |"
"___________________|\n"
" |  EVENT_DATE |      | *PERSON_ID       | <--> | *PERSON_ID  | <--> |  "
"*PERSON_ID       |\n"
" |  TITLE      |      |__________________|      |  AGE        |      |  "
"*EMAIL_ADDR      |\n"
" |_____________|                                |  FIRSTNAME  |      |"
"___________________|\n"
"                                                |  LASTNAME   |\n"
"                                                |_____________|\n"
" ]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:853
#, no-c-format
msgid ""
"You can see that the primary key of the collection table is in fact a "
"composite key that uses both columns. This also implies that there cannot be "
"duplicate email addresses per person, which is exactly the semantics we need "
"for a set in Java."
msgstr ""
"Vous pouvez voir que la clé primaire de la table de la collection est en "
"fait une clé composée, utilisant les deux colonnes. Ceci implique aussi "
"qu'il ne peut pas y avoir d'adresses email dupliquées par personne, ce qui "
"est exactement la sémantique dont nous avons besoin pour un ensemble dans "
"Java. "

#. Tag: para
#: tutorial.xml:859
#, no-c-format
msgid ""
"You can now try to add elements to this collection, just like we did before "
"by linking persons and events. It is the same code in Java:"
msgstr ""
"Vous pouvez maintenant tester et ajouter des éléments à cette collection, "
"juste comme nous l'avons fait auparavant en liant des personnes et des "
"événements. C'est le même code dans Java. "

#. Tag: programlisting
#: tutorial.xml:864
#, no-c-format
msgid ""
"<![CDATA[    private void addEmailToPerson(Long personId, String "
"emailAddress) {\n"
"        Session session = HibernateUtil.getSessionFactory().getCurrentSession"
"();\n"
"        session.beginTransaction();\n"
"\n"
"        Person aPerson = (Person) session.load(Person.class, personId);\n"
"        // adding to the emailAddress collection might trigger a lazy load "
"of the collection\n"
"        aPerson.getEmailAddresses().add(emailAddress);\n"
"\n"
"        session.getTransaction().commit();\n"
"    }]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:866
#, no-c-format
msgid ""
"This time we did not use a <emphasis>fetch query to initialize "
"the collection. Monitor the SQL log and try to optimize this with an eager "
"fetch."
msgstr ""
"Cette fois-ci, nous n'avons pas utilisé de requête de chargement "
"<emphasis>fetch pour initialiser la collection. Traquez les logs "
"SQL et tentez d'optimiser ce cas avec un chargement agressif."

#. Tag: title
#: tutorial.xml:875
#, no-c-format
msgid "Bi-directional associations"
msgstr "Associations bidirectionnelles"

#. Tag: para
#: tutorial.xml:877
#, no-c-format
msgid ""
"Next you will map a bi-directional association. You will make the "
"association between person and event work from both sides in Java. The "
"database schema does not change, so you will still have many-to-many "
"multiplicity."
msgstr ""
"Ensuite nous allons mapper une association bidirectionnelle - faire "
"fonctionner l'association entre une personne et un événement à partir des "
"deux côtés dans Java. Bien sûr, le schéma de la base de données ne change "
"pas, nous avons toujours une pluralité plusieurs-à-plusieurs. "

#. Tag: para
#: tutorial.xml:885
#, no-c-format
msgid ""
"A relational database is more flexible than a network programming language, "
"in that it does not need a navigation direction; data can be viewed and "
"retrieved in any possible way."
msgstr ""
"Une base de données relationnelle est plus flexible qu'un langage de "
"programmation réseau, donc elle n'a pas besoin de direction de navigation - "
"les données peuvent être vues et récupérées de toutes les manières possibles."

#. Tag: para
#: tutorial.xml:893
#, no-c-format
msgid ""
"First, add a collection of participants to the <literal>Event "
"class:"
msgstr ""
"D'abord, ajoutez une collection de participants à la classe <literal>Event."
msgstr ""
"Maintenant mappez ce côté de l'association aussi, dans <literal>Event.hbm."
"xml</literal>. "

#. Tag: programlisting
#: tutorial.xml:904
#, no-c-format
msgid ""
"<![CDATA[        "
msgstr ""

#. Tag: para
#: tutorial.xml:906
#, no-c-format
msgid ""
"These are normal <literal>set mappings in both mapping documents. "
"Notice that the column names in <literal>key and many-to-"
"many</literal> swap in both mapping documents. The most important addition "
"here is the <literal>inverse=\"true\" attribute in the "
"<literal>set element of the Event's collection "
"mapping."
msgstr ""
"Comme vous le voyez, ce sont des mappages de <literal>sets normaux "
"dans les deux documents de mappage. Notez que les noms de colonne dans "
"<literal>key et many-to-many sont inversés dans "
"les 2 documents de mappage. L'ajout le plus important ici est l'attribut "
"<literal>inverse=\"true\" dans l'élément set du "
"mappage de la collection des <literal>Events. "

#. Tag: para
#: tutorial.xml:914
#, no-c-format
msgid ""
"What this means is that Hibernate should take the other side, the "
"<literal>Person class, when it needs to find out information about "
"the link between the two. This will be a lot easier to understand once you "
"see how the bi-directional link between our two entities is created."
msgstr ""
"Cela signifie que Hibernate devrait prendre l'autre côté - la classe "
"<literal>Person - quand il a besoin de trouver des informations à "
"propos du lien entre les deux. Ce sera beaucoup plus facile à comprendre une "
"fois que vous verrez comment le lien bidirectionnel entre les deux entités "
"est créé. "

#. Tag: title
#: tutorial.xml:923
#, no-c-format
msgid "Working bi-directional links"
msgstr "Travailler avec des liens bidirectionnels"

#. Tag: para
#: tutorial.xml:925
#, no-c-format
msgid ""
"First, keep in mind that Hibernate does not affect normal Java semantics. "
"How did we create a link between a <literal>Person and an "
"<literal>Event in the unidirectional example? You add an instance "
"of <literal>Event to the collection of event references, of an "
"instance of <literal>Person. If you want to make this link bi-"
"directional, you have to do the same on the other side by adding a "
"<literal>Person reference to the collection in an EventEvent dans l'exemple unidirectionnel? Nous "
"avons ajouté une instance de <literal>Event à la collection des "
"références d'événement d'une instance de <literal>Person. Donc, "
"évidemment, si vous voulons rendre ce lien bidirectionnel, nous devons faire "
"la même chose de l'autre côté, en ajoutant une référence de <literal>PersonEvent. Cette "
"\"configuration du lien des deux côtés\" est absolument nécessaire et vous "
"ne devriez jamais oublier de le faire. "

#. Tag: para
#: tutorial.xml:935
#, no-c-format
msgid ""
"Many developers program defensively and create link management methods to "
"correctly set both sides (for example, in <literal>Person):"
msgstr ""
"Beaucoup de développeurs programment de manière défensive et créent des "
"méthodes de gestion de lien pour affecter correctement les deux côtés, par "
"exemple dans <literal>Person  :"

#. Tag: programlisting
#: tutorial.xml:940
#, no-c-format
msgid ""
"<![CDATA[    protected Set getEvents() {\n"
"        return events;\n"
"    }\n"
"\n"
"    protected void setEvents(Set events) {\n"
"        this.events = events;\n"
"    }\n"
"\n"
"    public void addToEvent(Event event) {\n"
"        this.getEvents().add(event);\n"
"        event.getParticipants().add(this);\n"
"    }\n"
"\n"
"    public void removeFromEvent(Event event) {\n"
"        this.getEvents().remove(event);\n"
"        event.getParticipants().remove(this);\n"
"    }]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:942
#, no-c-format
msgid ""
"The get and set methods for the collection are now protected. This allows "
"classes in the same package and subclasses to still access the methods, but "
"prevents everybody else from altering the collections directly. Repeat the "
"steps for the collection on the other side."
msgstr ""
"Notez que les méthodes get et set pour la collection sont maintenant "
"protégées - ceci permet aux classes et aux sous-classes du même paquetage "
"d'accéder aux méthodes, mais empêche quiconque de mettre le désordre "
"directement dans les collections (enfin, presque). Vous devriez probablement "
"faire de même avec la collection de l'autre côté. "

#. Tag: para
#: tutorial.xml:949
#, no-c-format
msgid ""
"What about the <literal>inverse mapping attribute? For you, and "
"for Java, a bi-directional link is simply a matter of setting the references "
"on both sides correctly. Hibernate, however, does not have enough "
"information to correctly arrange SQL <literal>INSERT and "
"<literal>UPDATE statements (to avoid constraint violations). "
"Making one side of the association <literal>inverse tells "
"Hibernate to consider it a <emphasis>mirror of the other side. "
"That is all that is necessary for Hibernate to resolve any issues that arise "
"when transforming a directional navigation model to a SQL database schema. "
"The rules are straightforward: all bi-directional associations need one side "
"as <literal>inverse. In a one-to-many association it has to be the "
"many-side, and in many-to-many association you can select either side."
msgstr ""
"Et à propos de l'attribut de mappage <literal>inverse ? Pour vous, "
"et pour Java, un lien bidirectionnel consiste simplement à configurer "
"correctement les références des deux côtés. Hibernate n'a cependant pas "
"assez d'informations pour ordonner correctement les expressions SQL "
"<literal>INSERT et UPDATE (pour éviter les "
"violations de contrainte), et a besoin d'aide pour gérer proprement les "
"associations bidirectionnelles. Rendre <literal>inverse un côté de "
"l'association, indique à Hibernate de l'ignorer, pour le considérer comme un "
"<emphasis>miroir de l'autre côté. Cela suffit à Hibernate pour "
"gérer tous les problèmes de transformation d'un modèle de navigation "
"directionnelle vers un schéma SQL de base de données. Les règles dont vous "
"devez vous souvenir sont : toutes les associations bidirectionnelles ont "
"besoin d'un côté marqué <literal>inverse. Dans une association un-"
"à-plusieurs ce doit être le côté plusieurs, dans une association plusieurs-à-"
"plusieurs, vous pouvez choisir n'importe quel côté, il n'y pas de différence."

#. Tag: title
#: tutorial.xml:965
#, no-c-format
msgid "Part 3 - The EventManager web application"
msgstr "Section 3 - L'application web EventManager"

#. Tag: para
#: tutorial.xml:967
#, no-c-format
msgid ""
"A Hibernate web application uses <literal>Session and "
"<literal>Transaction almost like a standalone application. "
"However, some common patterns are useful. You can now write an "
"<literal>EventManagerServlet. This servlet can list all events "
"stored in the database, and it provides an HTML form to enter new events."
msgstr ""
"Une application web Hibernate utilise la <literal>Session et "
"<literal>Transaction comme une application autonome. Cependant, "
"quelques modèles communs sont utiles. Nous allons coder une "
"<literal>EventManagerServlet. Ce servlet peut lister tous les "
"évènements stockés dans la base de données, et fournir une formulaire HTML "
"pour saisir de nouveaux évènements. "

#. Tag: title
#: tutorial.xml:975
#, no-c-format
msgid "Writing the basic servlet"
msgstr "Écrire la servlet de base"

#. Tag: para
#: tutorial.xml:977
#, no-c-format
msgid ""
"First we need create our basic processing servlet. Since our servlet only "
"handles HTTP <literal>GET requests, we will only implement the "
"<literal>doGet() method:"
msgstr ""
"Tout d'abord, nous devons créer notre servlet de base. La servlet n'accepte "
"que les requêtes HTTP <literal>GET, la méthode à implémenter est "
"donc <literal>doGet() :"

#. Tag: programlisting
#: tutorial.xml:983
#, no-c-format
msgid ""
"<![CDATA[package org.hibernate.tutorial.web;\n"
"\n"
"// Imports\n"
"\n"
"public class EventManagerServlet extends HttpServlet {\n"
"\n"
"    protected void doGet(\n"
"            HttpServletRequest request,\n"
"            HttpServletResponse response) throws ServletException, "
"IOException {\n"
"\n"
"        SimpleDateFormat dateFormatter = new SimpleDateFormat( \"dd.MM.yyyy"
"\" );\n"
"\n"
"        try {\n"
"            // Begin unit of work\n"
"            HibernateUtil.getSessionFactory().getCurrentSession()."
"beginTransaction();\n"
"\n"
"            // Process request and render page...\n"
"\n"
"            // End unit of work\n"
"            HibernateUtil.getSessionFactory().getCurrentSession()."
"getTransaction().commit();\n"
"        }\n"
"        catch (Exception ex) {\n"
"            HibernateUtil.getSessionFactory().getCurrentSession()."
"getTransaction().rollback();\n"
"            if ( ServletException.class.isInstance( ex ) ) {\n"
"                throw ( ServletException ) ex;\n"
"            }\n"
"            else {\n"
"                throw new ServletException( ex );\n"
"            }\n"
"        }\n"
"    }\n"
"\n"
"}]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:985
#, no-c-format
msgid ""
"Save this servlet as <filename>src/main/java/org/hibernate/tutorial/web/"
"EventManagerServlet.java</filename>"
msgstr ""
"Servir la servlet en tant que <filename>src/main/java/org/hibernate/tutorial/"
"web/EventManagerServlet.java</filename>"

#. Tag: para
#: tutorial.xml:990
#, no-c-format
msgid ""
"The pattern applied here is called <emphasis>session-per-request. "
"When a request hits the servlet, a new Hibernate <literal>Session "
"is opened through the first call to <literal>getCurrentSession() "
"on the <literal>SessionFactory. A database transaction is then "
"started. All data access occurs inside a transaction irrespective of whether "
"the data is read or written. Do not use the auto-commit mode in applications."
msgstr ""
"Le modèle appliqué ici est appelé <emphasis>session-per-request. "
"Lorsqu'une requête appelle la servlet, une nouvelle <literal>Session sur la SessionFactory use a new Hibernate Session "
"for every database operation. Use one Hibernate <literal>Session "
"that is scoped to the whole request. Use <literal>getCurrentSession() une nouvelle Session "
"Hibernate pour chaque opération en base de données. Utilisez une "
"<literal>Session Hibernate qui porte sur l'ensemble de la requête. "
"Utlisez <literal>getCurrentSession(), ainsi elle est "
"automatiquement attachée au thread Java courant."

#. Tag: para
#: tutorial.xml:1006
#, no-c-format
msgid ""
"Next, the possible actions of the request are processed and the response "
"HTML is rendered. We will get to that part soon."
msgstr ""
"Ensuite, les actions possibles de la requêtes sont exécutées et la réponse "
"HTML est rendue. Nous y reviendrons ultérieurement. "

#. Tag: para
#: tutorial.xml:1011
#, no-c-format
msgid ""
"Finally, the unit of work ends when processing and rendering are complete. "
"If any problems occurred during processing or rendering, an exception will "
"be thrown and the database transaction rolled back. This completes the "
"<literal>session-per-request pattern. Instead of the transaction "
"demarcation code in every servlet, you could also write a servlet filter. "
"See the Hibernate website and Wiki for more information about this pattern "
"called <emphasis>Open Session in View. You will need it as soon "
"as you consider rendering your view in JSP, not in a servlet."
msgstr ""
"Enfin, l'unité de travail s'achève lorsque l'exécution et le rendu sont "
"achevés. Si un problème survient lors de ces deux phases, une exception est "
"lancée et la transaction avec la base de données subit un rollback. Cela "
"complète le modèle <literal>session-per-request. Au lieu d'avoir "
"un code de délimitant les transactions au sein de chaque servlet, vous "
"pouvez écrire un filtre de servlet. Voir le site Hibernate et le Wiki pour "
"plus d'informations sur ce modèle, appelé <emphasis>Open Session in ViewEvent Manager"
"\");\n"
"\n"
"        // Handle actions\n"
"        if ( \"store\".equals(request.getParameter(\"action\")) ) {\n"
"\n"
"            String eventTitle = request.getParameter(\"eventTitle\");\n"
"            String eventDate = request.getParameter(\"eventDate\");\n"
"\n"
"            if ( \"\".equals(eventTitle) || \"\".equals(eventDate) ) {\n"
"                out.println(\"<b>Please enter event title and date.Added event.\");\n"
"            }\n"
"        }\n"
"\n"
"        // Print page\n"
"       printEventForm(out);\n"
"       listEvents(out, dateFormatter);\n"
"\n"
"       // Write HTML footer\n"
"       out.println(\"</body>\");\n"
"       out.flush();\n"
"       out.close();]]>"
msgstr ""

#. Tag: para
#: tutorial.xml:1033
#, no-c-format
msgid ""
"This coding style, with a mix of Java and HTML, would not scale in a more "
"complex application—keep in mind that we are only illustrating basic "
"Hibernate concepts in this tutorial. The code prints an HTML header and a "
"footer. Inside this page, an HTML form for event entry and a list of all "
"events in the database are printed. The first method is trivial and only "
"outputs HTML:"
msgstr ""
"Ce style de code avec une mixture de Java et d'HTML ne serait pas extensible "
"dans une application plus complexe - gardez à l'esprit que nous ne faisons "
"qu'illustrer les concepts basiques de Hibernate dans ce didacticiel. Ce code "
"affiche une entête et un pied de page HTML. Dans cette page, sont affichés "
"un formulaire pour la saisie d'évènements ainsi qu'une liste de tous les "
"évènements de la base de données. La première méthode est triviale et ne "
"fait que sortir de l'HTML :"

#. Tag: programlisting
#: tutorial.xml:1042
#, no-c-format
msgid ""
"<![CDATA[    private void printEventForm(PrintWriter out) {\n"
"        out.println(\"<h2>Add new event:\");\n"
"        out.println(\"<form>\");\n"
"        out.println(\"Title: <input name='eventTitle' length='50'/>
" "\");\n" " out.println(\"Date (e.g. 24.12.2009): <input name='eventDate' " "length='10'/><br/>\");\n" " out.println(\"<input type='submit' name='action' value='store'/>" "\");\n" " out.println(\"</form>\");\n" " }]]>" msgstr "" #. Tag: para #: tutorial.xml:1044 #, no-c-format msgid "" "The <literal>listEvents() method uses the Hibernate " "<literal>Session bound to the current thread to execute a query:" msgstr "" "La méthode <literal>listEvents() utilise la Session\");\n" " out.println(\"<table border='1'>\");\n" " out.println(\"<tr>\");\n" " out.println(\"<th>Event title\");\n" " out.println(\"<th>Event date\");\n" " out.println(\"</tr>\");\n" " Iterator it = result.iterator();\n" " while (it.hasNext()) {\n" " Event event = (Event) it.next();\n" " out.println(\"<tr>\");\n" " out.println(\"<td>\" + event.getTitle() + \"
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.