📄 tutorial.po
字号:
#. Tag: para#: tutorial.xml:478#, no-c-formatmsgid """This is the <literal>INSERT</literal> executed by Hibernate, the question ""marks represent JDBC bind parameters. To see the values bound as arguments, ""or to reduce the verbosity of the log, check your <literal>log4j.properties</""literal>."msgstr """C'est l'<literal>INSERT</literal> exécuté par Hibernate, les points ""d'interrogation représentent les paramètres JDBC liés. Pour voir les valeurs ""liées aux arguments, ou pour réduire la verbosité des traces, vérifier votre ""<literal>log4j.properties</literal>."#. Tag: para#: tutorial.xml:484#, no-c-formatmsgid """Now we'd like to list stored events as well, so we add an option to the main ""method:"msgstr """Maintenant nous aimerions aussi lister les événements stockés, donc nous ""ajoutons une option à la méthode principale :"#. Tag: programlisting#: tutorial.xml:488#, no-c-formatmsgid """<![CDATA[if (args[0].equals(\"store\")) {\n"" mgr.createAndStoreEvent(\"My Event\", new Date());\n""}\n""else if (args[0].equals(\"list\")) {\n"" List events = mgr.listEvents();\n"" for (int i = 0; i < events.size(); i++) {\n"" Event theEvent = (Event) events.get(i);\n"" System.out.println(\"Event: \" + theEvent.getTitle() +\n"" \" Time: \" + theEvent.getDate());\n"" }\n""}]]>"msgstr ""#. Tag: para#: tutorial.xml:490#, no-c-formatmsgid "We also add a new <literal>listEvents() method</literal>:"msgstr """Nous ajoutons aussi une nouvelle méthode <literal>listEvents()</literal> :"#. Tag: programlisting#: tutorial.xml:494#, no-c-formatmsgid """<![CDATA[private List listEvents() {\n""\n"" Session session = HibernateUtil.getSessionFactory().getCurrentSession""();\n""\n"" session.beginTransaction();\n""\n"" List result = session.createQuery(\"from Event\").list();\n""\n"" session.getTransaction().commit();\n""\n"" return result;\n""}]]>"msgstr ""#. Tag: para#: tutorial.xml:496#, no-c-formatmsgid """What we do here is use an HQL (Hibernate Query Language) query to load all ""existing <literal>Event</literal> objects from the database. Hibernate will ""generate the appropriate SQL, send it to the database and populate ""<literal>Event</literal> objects with the data. You can create more complex ""queries with HQL, of course."msgstr """Ce que nous faisons ici c'est utiliser une requête HQL (Hibernate Query ""Language) pour charger tous les objets <literal>Event</literal> 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</literal> avec les données. ""Vous pouvez créer des requêtes plus complexes avec HQL, bien sûr."#. Tag: para#: tutorial.xml:503#, no-c-formatmsgid "Now, to execute and test all of this, follow these steps:"msgstr "Maintenant, pour exécuter et tester tout ça, suivez ces étapes :"#. Tag: para#: tutorial.xml:509#, no-c-formatmsgid """Run <literal>ant run -Daction=store</literal> to store something into the ""database and, of course, to generate the database schema before through ""hbm2ddl."msgstr """Exécutez <literal>ant run -Daction=store</literal> pour stocker quelque ""chose dans la base de données et, bien sûr, pour générer, avant, le schéma ""de la base de données grâce à hbm2ddl."#. Tag: para#: tutorial.xml:515#, no-c-formatmsgid """Now disable hbm2ddl by commenting out the property in your ""<literal>hibernate.cfg.xml</literal> file. Usually you only leave it turned ""on in continous unit testing, but another run of hbm2ddl would ""<emphasis>drop</emphasis> everything you have stored - the <literal>create</""literal> configuration setting actually translates into \"drop all tables ""from the schema, then re-create all tables, when the SessionFactory is build""\"."msgstr """Maintenant désactivez hbm2ddl en commentant la propriété dans votre fichier ""<literal>hibernate.cfg.xml</literal>. Généralement vous la laissez seulement ""activée dans des tests unitaires en continu, mais une autre exécution de ""hbm2ddl <emphasis>effacerait</emphasis> tout ce que vous avez stocké - le ""paramètre de configuration <literal>create</literal> se traduit en fait par ""\"supprimer toutes les tables du schéma, puis re-créer toutes les tables, ""lorsque la SessionFactory est construite\"."#. Tag: para#: tutorial.xml:525#, no-c-formatmsgid """If you now call Ant with <literal>-Daction=list</literal>, you should see ""the events you have stored so far. You can of course also call the ""<literal>store</literal> action a few times more."msgstr """Si maintenant vous appelez Ant avec <literal>-Daction=list</literal>, vous ""devriez voir les événements que vous avez stockés jusque là. Vous pouvez ""bien sûr aussi appeler l'action <literal>store</literal> plusieurs fois."#. Tag: para#: tutorial.xml:531#, no-c-formatmsgid """Note: Most new Hibernate users fail at this point and we see questions about ""<emphasis>Table not found</emphasis> error messages regularly. However, if ""you follow the steps outlined above you will not have this problem, as ""hbm2ddl creates the database schema on the first run, and subsequent ""application restarts will use this schema. If you change the mapping and/or ""database schema, you have to re-enable hbm2ddl once again."msgstr """UNTRANSLATED! Note: Most new Hibernate users fail at this point and we see ""questions about <emphasis>Table not found</emphasis> error messages ""regularly. However, if you follow the steps outlined above you will not have ""this problem, as hbm2ddl creates the database schema on the first run, and ""subsequent application restarts will use this schema. If you change the ""mapping and/or database schema, you have to re-enable hbm2ddl once again."#. Tag: title#: tutorial.xml:544#, no-c-formatmsgid "Part 2 - Mapping associations"msgstr "Partie 2 - Mapper des associations"#. Tag: para#: tutorial.xml:546#, no-c-formatmsgid """We mapped a persistent entity class to a table. Let's build on this and add ""some class associations. First we'll add people to our application, and ""store a list of events they participate in."msgstr """Nous avons mappé une classe d'une entité persistante vers une table. Partons ""de là et ajoutons 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:552#, no-c-formatmsgid "Mapping the Person class"msgstr "Mapper la classe Person"#. Tag: para#: tutorial.xml:554#, no-c-formatmsgid "The first cut of the <literal>Person</literal> class is simple:"msgstr """La première version de la classe <literal>Person</literal> est simple :"#. Tag: programlisting#: tutorial.xml:558#, no-c-formatmsgid """<![CDATA[package events;\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:560#, no-c-formatmsgid """Create a new mapping file called <literal>Person.hbm.xml</literal> (don't ""forget the DTD reference at the top):"msgstr """Créez un nouveau fichier de mapping appelé <literal>Person.hbm.xml</literal> ""(n'oubliez pas la référence à la DTD)"#. Tag: programlisting#: tutorial.xml:565#, no-c-formatmsgid """<![CDATA[<hibernate-mapping>\n""\n"" <class name=\"events.Person\" table=\"PERSON\">\n"" <id name=\"id\" column=\"PERSON_ID\">\n"" <generator class=\"native\"/>\n"" </id>\n"" <property name=\"age\"/>\n"" <property name=\"firstname\"/>\n"" <property name=\"lastname\"/>\n"" </class>\n""\n""</hibernate-mapping>]]>"msgstr ""#. Tag: para#: tutorial.xml:567#, no-c-formatmsgid "Finally, add the new mapping to Hibernate's configuration:"msgstr """Finalement, ajoutez la nouveau mapping à la configuration d'Hibernate :"#. Tag: programlisting#: tutorial.xml:571#, no-c-formatmsgid """<![CDATA[<mapping resource=\"events/Event.hbm.xml\"/>\n""<mapping resource=\"events/Person.hbm.xml\"/>]]>"msgstr ""#. Tag: para#: tutorial.xml:573#, no-c-formatmsgid """We'll now create an association between these two entities. Obviously, ""persons can participate in events, and events have participants. The design ""questions we 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:583#, no-c-formatmsgid "A unidirectional Set-based association"msgstr "Une association unidirectionnelle basée sur Set"#. Tag: para#: tutorial.xml:585#, no-c-formatmsgid """We'll add a collection of events to the <literal>Person</literal> class. ""That way we can easily navigate to the events for a particular person, ""without executing an explicit query - by calling <literal>aPerson.getEvents()""</literal>. We use a Java collection, a <literal>Set</literal>, because the ""collection will not contain duplicate elements and the ordering is not ""relevant for us."msgstr """Nous allons ajouter une collection d'événements à la classe <literal>Person</""literal>. De cette manière nous pouvons facilement naviguer dans les ""événements d'une personne particulière, sans exécuter une requête explicite ""- en appelant <literal>aPerson.getEvents()</literal>. Nous utilisons une ""collection Java, un <literal>Set</literal>, parce que la collection ne ""contiendra pas d'éléments dupliqués et l'ordre ne nous importe pas."#. Tag: para#: tutorial.xml:592#, no-c-formatmsgid """We need a unidirectional, many-valued associations, implemented with a ""<literal>Set</literal>. Let's write the code for this in the Java classes ""and then map it:"msgstr """Nous avons besoin d'une association unidirectionnelle, pluri-valuée, ""implémentée avec un <literal>Set</literal>. Écrivons le code pour ça dans ""les classes Java et mappons les :"#. Tag: programlisting#: tutorial.xml:597#, no-c-formatmsgid """<![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:599#, no-c-formatmsgid """Before we map this association, think about the other side. Clearly, we ""could just keep this unidirectional. Or, we could create another collection ""on the <literal>Event</literal>, if we want to be able to navigate it bi-""directional, i.e. <literal>anEvent.getParticipants()</literal>. This is not ""necessary, from a functional perspective. You could always execute an ""explicit query to retrieve the participants for a particular event. This is ""a design choi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -