alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Hibernate example source code file (example_parentchild.po)

This example Hibernate source code file (example_parentchild.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

hibernate, hibernate, in, le, le, nous, null, tag, tag, the, the, this, we, you

The Hibernate example_parentchild.po source code

# translation of example_parentchild.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: example_parentchild\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-02-10T07:25:35\n"
"PO-Revision-Date: 2010-01-05 09:05+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
#, no-c-format
msgid "Example: Parent/Child"
msgstr "Exemple : père/fils"

#. Tag: para
#, no-c-format
msgid ""
"One of the first things that new users want to do with Hibernate is to model "
"a parent/child type relationship. There are two different approaches to "
"this. The most convenient approach, especially for new users, is to model "
"both <literal>Parent and Child as entity "
"classes with a <literal><one-to-many> association from "
"<literal>Parent to Child. The alternative "
"approach is to declare the <literal>Child as a <"
"composite-element></literal>. The default semantics of a one-to-many "
"association in Hibernate are much less close to the usual semantics of a "
"parent/child relationship than those of a composite element mapping. We will "
"explain how to use a <emphasis>bidirectional one-to-many association with "
"cascades</emphasis> to model a parent/child relationship efficiently and "
"elegantly."
msgstr ""
"L'une des premières choses que les nouveaux utilisateurs essaient de faire "
"avec Hibernate est de modéliser une relation père/fils. Il y a deux "
"approches différentes pour cela. Pour un certain nombre de raisons, la "
"méthode la plus courante, en particulier pour les nouveaux utilisateurs, est "
"de modéliser les deux relations <literal>Père et Fils<"
"one-to-many></literal> du Père vers le FilsFils comme "
"un <literal><composite-element>). On constate que la "
"sémantique par défaut de l'association un-à-plusieurs (dans Hibernate) est "
"bien moins proche du sens habituel d'une relation père/fils que celle d'un "
"mappage d'élément composite. Nous allons vous expliquer comment utiliser une "
"association <emphasis>un-à-plusieurs bidirectionnelle avec cascade "
"association from <literal>Parent to Child."
msgstr ""
"Supposons que nous ayons une simple association <literal><one-to-many>"
"</literal> de Parent à Child."

#. Tag: para
#, no-c-format
msgid "If we were to execute the following code:"
msgstr "Si nous exécutions le code suivant :"

#. Tag: para
#, no-c-format
msgid "Hibernate would issue two SQL statements:"
msgstr "Hibernate exécuterait deux ordres SQL :"

#. Tag: para
#, no-c-format
msgid ""
"an <literal>INSERT to create the record for c"
msgstr ""
"un <literal>INSERT pour créer l'enregistrement pour c to create the link from p to "
"<literal>c"
msgstr ""
"un <literal>UPDATE pour créer le lien de p vers "
"<literal>c"

#. Tag: para
#, no-c-format
msgid ""
"This is not only inefficient, but also violates any <literal>NOT NULLparent_id column. You can fix "
"the nullability constraint violation by specifying <literal>not-null=\"true"
"\"</literal> in the collection mapping:"
msgstr ""
"Ceci est non seulement inefficace, mais viole aussi toute contrainte "
"<literal>NOT NULL sur la colonne parent_id. "
"Nous pouvons réparer la contrainte de nullité en spécifiant <literal>not-"
"null=\"true\"</literal> dans le mappage de la collection : "

#. Tag: para
#, no-c-format
msgid "However, this is not the recommended solution."
msgstr "Cependant ce n'est pas la solution recommandée."

#. Tag: para
#, no-c-format
msgid ""
"The underlying cause of this behavior is that the link (the foreign key "
"<literal>parent_id) from p to cChild "
"object and is therefore not created in the <literal>INSERT. The "
"solution is to make the link part of the <literal>Child mapping."
msgstr ""
"La cause sous jacente à ce comportement est que le lien (la clé étrangère "
"<literal>parent_id) de p vers c et n'est donc pas créé par l'INSERT. "

#. Tag: para
#, no-c-format
msgid ""
"You also need to add the <literal>parent property to the "
"<literal>Child class."
msgstr ""
"Nous avons aussi besoin d'ajouter la propriété <literal>parent "
"dans la classe <literal>Child."

#. Tag: para
#, no-c-format
msgid ""
"Now that the <literal>Child entity is managing the state of the "
"link, we tell the collection not to update the link. We use the "
"<literal>inverse attribute to do this:"
msgstr ""
"Maintenant que l'état du lien est géré par l'entité <literal>Child pour faire cela :"

#. Tag: para
#, no-c-format
msgid "The following code would be used to add a new <literal>Child:"
msgstr ""
"Le code suivant serait utilisé pour ajouter un nouveau <literal>Child would now be issued."
msgstr "Maintenant, seul un SQL <literal>INSERT est nécessaire."

#. Tag: para
#, no-c-format
msgid ""
"You could also create an <literal>addChild() method of "
"<literal>Parent."
msgstr ""
"Pour alléger encore un peu les choses, nous créerons une méthode "
"<literal>addChild() de Parent. "

#. Tag: para
#, no-c-format
msgid "The code to add a <literal>Child looks like this:"
msgstr "Le code d'ajout d'un <literal>Child serait alors :"

#. Tag: title
#, no-c-format
msgid "Cascading life cycle"
msgstr "Cycle de vie en cascade "

#. Tag: para
#, no-c-format
msgid ""
"You can address the frustrations of the explicit call to <literal>save() est un peu fastidieux. Nous "
"pouvons simplifier cela en utilisant les cascades. "

#. Tag: para
#, no-c-format
msgid "This simplifies the code above to:"
msgstr "Cela simplifie le code précédent en :"

#. Tag: para
#, no-c-format
msgid ""
"Similarly, we do not need to iterate over the children when saving or "
"deleting a <literal>Parent. The following removes p. Le code suivant efface "
"<literal>p et tous ses fils de la base de données. "

#. Tag: para
#, no-c-format
msgid "However, the following code:"
msgstr "Par contre, ce code :"

#. Tag: para
#, no-c-format
msgid ""
"will not remove <literal>c from the database. In this case, it "
"will only remove the link to <literal>p and cause a NOT "
"NULL</literal> constraint violation. You need to explicitly delete()"
"</literal> the Child."
msgstr ""
"n'effacera pas <literal>c de la base de données, il enlèvera "
"seulement le lien vers <literal>p (et causera une violation de "
"contrainte <literal>NOT NULL, dans ce cas). Vous devez "
"explicitement utiliser <literal>delete() sur Child cannot exist without its parent. So "
"if we remove a <literal>Child from the collection, we do want it "
"to be deleted. To do this, we must use <literal>cascade=\"all-delete-orphan"
"\"</literal>."
msgstr ""
"Dans notre cas, un <literal>Child ne peut pas vraiment exister "
"sans son père. Si nous effaçons un <literal>Child de la "
"collection, nous voulons vraiment qu'il soit effacé. Pour cela, nous devons "
"utiliser <literal>cascade=\"all-delete-orphan\". "

#. Tag: para
#, no-c-format
msgid ""
"Even though the collection mapping specifies <literal>inverse=\"true\""
msgstr ""
"Cascades et <literal>unsaved-value (valeurs non sauvegardées)"

#. Tag: para
#, fuzzy, no-c-format
msgid ""
"Suppose we loaded up a <literal>Parent in one Session. The "
"<literal>Parent will contain a collection of children and, since "
"the cascading update is enabled, Hibernate needs to know which children are "
"newly instantiated and which represent existing rows in the database. We "
"will also assume that both <literal>Parent and ChildLongIn Hibernate3, it is no longer "
"necessary to specify an <literal>unsaved-value explicitly. dans une "
"<literal>Session, que nous l'ayons ensuite modifié et que voulions "
"persister ces modifications dans une nouvelle session en appelant "
"<literal>update(). Le Parent contiendra une "
"collection de fils et, puisque la cascade est activée, Hibernate a besoin de "
"savoir quels fils viennent d'être instanciés et quels fils représentent des "
"lignes existantes dans la base de données. Supposons aussi que "
"<literal>Parent et Child ont tous deux des "
"identifiants du type <literal>Long. Hibernate utilisera la "
"propriété de l'identifiant et la propriété de la version/horodatage pour "
"déterminer quels fils sont nouveaux (vous pouvez aussi utiliser la propriété "
"version ou timestamp, consultez <xref linkend=\"objectstate-saveorupdate\" /"
">.) <emphasis>Dans Hibernate3, il n'est plus nécessaire de spécifier une "
"<literal>unsaved-value explicitement. "

#. Tag: para
#, no-c-format
msgid ""
"The following code will update <literal>parent and childnewChild:"
msgstr ""
"Le code suivant mettra à jour <literal>parent et childnewChild. "

#. Tag: para
#, no-c-format
msgid ""
"This may be suitable for the case of a generated identifier, but what about "
"assigned identifiers and composite identifiers? This is more difficult, "
"since Hibernate cannot use the identifier property to distinguish between a "
"newly instantiated object, with an identifier assigned by the user, and an "
"object loaded in a previous session. In this case, Hibernate will either use "
"the timestamp or version property, or will actually query the second-level "
"cache or, worst case, the database, to see if the row exists."
msgstr ""
"Ceci est très bien pour des identifiants générés, mais qu'en est-il des "
"identifiants assignés et des identifiants composés ? C'est plus difficile, "
"puisque Hibernate ne peut pas utiliser la propriété de l'identifiant pour "
"distinguer entre un objet nouvellement instancié (avec un identifiant "
"assigné par l'utilisateur) et un objet chargé dans une session précédente. "
"Dans ce cas, Hibernate utilisera soit la propriété de version ou "
"d'horodatage, soit effectuera vraiment une requête au cache de second "
"niveau, soit, dans le pire des cas, à la base de données, pour voir si la "
"ligne existe. "

#. Tag: title
#, no-c-format
msgid "Conclusion"
msgstr "Conclusion"

#. Tag: para
#, no-c-format
msgid ""
"The sections we have just covered can be a bit confusing. However, in "
"practice, it all works out nicely. Most Hibernate applications use the "
"parent/child pattern in many places."
msgstr ""
"Il y a quelques principes à maîtriser dans ce chapitre et tout cela peut "
"paraître déroutant la première fois. Cependant, dans la pratique, tout "
"fonctionne parfaitement. La plupart des applications Hibernate utilisent le "
"modèle père / fils. "

#. Tag: para
#, no-c-format
msgid ""
"We mentioned an alternative in the first paragraph. None of the above issues "
"exist in the case of <literal><composite-element> mappings, "
"which have exactly the semantics of a parent/child relationship. "
"Unfortunately, there are two big limitations with composite element classes: "
"composite elements cannot own collections and they should not be the child "
"of any entity other than the unique parent."
msgstr ""
"Nous avons évoqué une alternative dans le premier paragraphe. Aucun des "
"points traités précédemment n'existe dans le cas de mappings <literal><"
"composite-element></literal> qui possède exactement la sémantique d'une "
"relation père / fils. Malheureusement, il y a deux grandes limitations pour "
"les classes d'éléments composites : les éléments composites ne peuvent "
"contenir de collections, et ils ne peuvent être les fils d'entités autres "
"que l'unique parent. "

Other Hibernate examples (source code examples)

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

... 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.