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

Hibernate example source code file (persistent_classes.po)

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

cat, hibernate, hibernate, if, les, pojo, pojo, string, string, tag, tag, the, vous, you

The Hibernate persistent_classes.po source code

# translation of persistent_classes.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: persistent_classes\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 09:39+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
#: persistent_classes.xml:32
#, no-c-format
msgid "Persistent Classes"
msgstr "Classes persistantes"

#. Tag: para
#: persistent_classes.xml:34
#, fuzzy, no-c-format
msgid ""
"Persistent classes are classes in an application that implement the entities "
"of the business problem (e.g. Customer and Order in an E-commerce "
"application). The term \"persistent\" here means that the classes are able "
"to be persisted, not that they are in the persistent state (see <xref "
"linkend=\"objectstate-overview\"/> for discussion)."
msgstr ""
"Les classes persistantes sont les classes d'une application qui implémentent "
"les entités d'un problème métier (par ex. Client et Commande dans une "
"application de commerce électronique). Toutes les instances d'une classe "
"persistante ne sont pas forcément dans l'état persistant - en revanche, une "
"instance peut être éphémère (transient) ou détachée."

#. Tag: para
#: persistent_classes.xml:41
#, fuzzy, no-c-format
msgid ""
"Hibernate works best if these classes follow some simple rules, also known "
"as the Plain Old Java Object (POJO) programming model. However, none of "
"these rules are hard requirements. Indeed, Hibernate assumes very little "
"about the nature of your persistent objects. You can express a domain model "
"in other ways (using trees of <interfacename>java.util.Map "
"instances, for example)."
msgstr ""
"Hibernate fonctionne de manière optimale lorsque ces classes suivent "
"quelques règles simples, aussi connues comme le modèle de programmation "
"Plain Old Java Object (POJO). Cependant, aucune de ces règles ne sont des "
"besoins absolus. En effet, Hibernate3 présuppose très peu de choses à propos "
"de la nature de vos objets persistants. Vous pouvez exprimer un modèle de "
"domaine par d'autres moyens : utiliser des arbres d'instances de "
"<literal>Map, par exemple."

#. Tag: title
#: persistent_classes.xml:49
#, no-c-format
msgid "A simple POJO example"
msgstr "Un exemple simple de POJO"

#. Tag: title
#: persistent_classes.xml:52
#, no-c-format
msgid "Simple POJO representing a cat"
msgstr ""

#. Tag: programlisting
#: persistent_classes.xml:53
#, no-c-format
msgid ""
"package eg;\n"
"import java.util.Set;\n"
"import java.util.Date;\n"
"\n"
"public class Cat {\n"
"private Long id; // identifier\n"
"\n"
"private Date birthdate;\n"
"private Color color;\n"
"private char sex;\n"
"private float weight;\n"
"    private int litterId;\n"
"\n"
"    private Cat mother;\n"
"    private Set kittens = new HashSet();\n"
"\n"
"    private void setId(Long id) {\n"
"        this.id=id;\n"
"    }\n"
"    public Long getId() {\n"
"        return id;\n"
"    }\n"
"\n"
"    void setBirthdate(Date date) {\n"
"        birthdate = date;\n"
"    }\n"
"    public Date getBirthdate() {\n"
"        return birthdate;\n"
"    }\n"
"\n"
"    void setWeight(float weight) {\n"
"        this.weight = weight;\n"
"    }\n"
"    public float getWeight() {\n"
"        return weight;\n"
"    }\n"
"\n"
"    public Color getColor() {\n"
"        return color;\n"
"    }\n"
"    void setColor(Color color) {\n"
"        this.color = color;\n"
"    }\n"
"\n"
"    void setSex(char sex) {\n"
"        this.sex=sex;\n"
"    }\n"
"    public char getSex() {\n"
"        return sex;\n"
"    }\n"
"\n"
"    void setLitterId(int id) {\n"
"        this.litterId = id;\n"
"    }\n"
"    public int getLitterId() {\n"
"        return litterId;\n"
"    }\n"
"\n"
"    void setMother(Cat mother) {\n"
"        this.mother = mother;\n"
"    }\n"
"    public Cat getMother() {\n"
"        return mother;\n"
"    }\n"
"    void setKittens(Set kittens) {\n"
"        this.kittens = kittens;\n"
"    }\n"
"    public Set getKittens() {\n"
"        return kittens;\n"
"    }\n"
"\n"
"    // addKitten not needed by Hibernate\n"
"    public void addKitten(Cat kitten) {\n"
"        kitten.setMother(this);\n"
"    kitten.setLitterId( kittens.size() );\n"
"        kittens.add(kitten);\n"
"    }\n"
"}"
msgstr ""

#. Tag: para
#: persistent_classes.xml:57
#, no-c-format
msgid ""
"The four main rules of persistent classes are explored in more detail in the "
"following sections."
msgstr ""
"On explore quatre règles principales de classes persistantes en détail dans "
"les sections qui suivent :"

#. Tag: title
#: persistent_classes.xml:62
#, no-c-format
msgid "Implement a no-argument constructor"
msgstr "Implémenter un constructeur sans argument"

#. Tag: para
#: persistent_classes.xml:64
#, fuzzy, no-c-format
msgid ""
"<classname>Cat has a no-argument constructor. All persistent "
"classes must have a default constructor (which can be non-public) so that "
"Hibernate can instantiate them using <literal>java.lang.reflect."
"Constructor</classname>.newInstance(). It is recommended that this "
"constructor be defined with at least <emphasis>package visibility "
"in order for runtime proxy generation to work properly."
msgstr ""
"<literal>Cat a un constructeur sans argument. Toutes les classes "
"persistantes doivent avoir un constructeur par défaut (lequel peut ne pas "
"être public) pour que Hibernate puisse les instancier en utilisant "
"<literal>Constructor.newInstance(). Nous recommandons fortement "
"d'avoir un constructeur par défaut avec au moins une visibilité "
"<emphasis>paquetage pour la génération du proxy à l'exécution "
"dans Hibernate. "

#. Tag: title
#: persistent_classes.xml:74
#, fuzzy, no-c-format
msgid "Provide an identifier property"
msgstr "Fournir une propriété d'identifiant (optionnel)"

#. Tag: para
#: persistent_classes.xml:77
#, no-c-format
msgid ""
"Historically this was considered option. While still not (yet) enforced, "
"this should be considered a deprecated feature as it will be completely "
"required to provide a identifier property in an upcoming release."
msgstr ""

#. Tag: para
#: persistent_classes.xml:84
#, no-c-format
msgid ""
"<classname>Cat has a property named id. This "
"property maps to the primary key column(s) of the underlying database table. "
"The type of the identifier property can be any \"basic\" type (see <xref "
"linkend=\"types.value.basic\"/>). See <xref linkend=\"components-compositeid"
"\"/> for information on mapping composite (multi-column) identifiers."
msgstr ""

#. Tag: para
#: persistent_classes.xml:92
#, no-c-format
msgid ""
"Identifiers do not necessarily need to identify column(s) in the database "
"physically defined as a primary key. They should just identify columns that "
"can be used to uniquely identify rows in the underlying table."
msgstr ""

#. Tag: para
#: persistent_classes.xml:99
#, no-c-format
msgid ""
"We recommend that you declare consistently-named identifier properties on "
"persistent classes and that you use a nullable (i.e., non-primitive) type."
msgstr ""
"Nous recommandons que vous déclariez les propriétés d'identifiant de manière "
"uniforme. Nous recommandons également que vous utilisiez un type nullable "
"(c'est-à-dire non primitif). "

#. Tag: title
#: persistent_classes.xml:107
#, fuzzy, no-c-format
msgid "Prefer non-final classes (semi-optional)"
msgstr "Favoriser les classes non finales (optionnel)"

#. Tag: para
#: persistent_classes.xml:109
#, no-c-format
msgid ""
"A central feature of Hibernate, <emphasis>proxies (lazy loading), "
"depends upon the persistent class being either non-final, or the "
"implementation of an interface that declares all public methods. You can "
"persist <literal>final classes that do not implement an interface "
"with Hibernate; you will not, however, be able to use proxies for lazy "
"association fetching which will ultimately limit your options for "
"performance tuning. To persist a <literal>final class which does "
"not implement a \"full\" interface you must disable proxy generation. See "
"<xref linkend=\"persistent-classes-pojo-final-example-disable-proxies-xml\"/"
"> and <xref linkend=\"persistent-classes-pojo-final-example-disable-proxies-"
"ann\"/>."
msgstr ""

#. Tag: title
#: persistent_classes.xml:121
#, no-c-format
msgid "Disabling proxies in <literal>hbm.xml"
msgstr ""

#. Tag: programlisting
#: persistent_classes.xml:122
#, no-c-format
msgid "<![CDATA[]]>"
msgstr ""

#. Tag: title
#: persistent_classes.xml:126
#, no-c-format
msgid "Disabling proxies in annotations"
msgstr ""

#. Tag: programlisting
#: persistent_classes.xml:127
#, no-c-format
msgid "<![CDATA[@Entity @Proxy(lazy=false) public class Cat { ... }]]>"
msgstr ""

#. Tag: para
#: persistent_classes.xml:130
#, no-c-format
msgid ""
"If the <literal>final class does implement a proper interface, you "
"could alternatively tell Hibernate to use the interface instead when "
"generating the proxies. See <xref linkend=\"persistent-classes-pojo-final-"
"example-proxy-interface-xml\"/> and <xref linkend=\"persistent-classes-pojo-"
"final-example-proxy-interface-ann\"/>."
msgstr ""

#. Tag: title
#: persistent_classes.xml:139
#, no-c-format
msgid "Proxying an interface in <literal>hbm.xml"
msgstr ""

#. Tag: programlisting
#: persistent_classes.xml:140
#, no-c-format
msgid "<![CDATA[]]>"
msgstr ""

#. Tag: title
#: persistent_classes.xml:144
#, no-c-format
msgid "Proxying an interface in annotations"
msgstr ""

#. Tag: programlisting
#: persistent_classes.xml:145
#, no-c-format
msgid ""
"<![CDATA[@Entity @Proxy(proxyClass=ICat.class) public class Cat implements "
"ICat { ... }]]>"
msgstr ""

#. Tag: para
#: persistent_classes.xml:148
#, fuzzy, no-c-format
msgid ""
"You should also avoid declaring <literal>public final methods as "
"this will again limit the ability to generate <emphasis>proxies "
"from this class. If you want to use a class with <literal>public final, vous devez explicitement "
"désactiver les proxies en paramétrant <literal>lazy=\"false\". "

#. Tag: title
#: persistent_classes.xml:158
#, no-c-format
msgid "Declare accessors and mutators for persistent fields (optional)"
msgstr ""
"Déclarer les accesseurs et mutateurs des attributs persistants (optionnel)"

#. Tag: para
#: persistent_classes.xml:160
#, fuzzy, no-c-format
msgid ""
"<classname>Cat declares accessor methods for all its persistent "
"fields. Many other ORM tools directly persist instance variables. It is "
"better to provide an indirection between the relational schema and internal "
"data structures of the class. By default, Hibernate persists JavaBeans style "
"properties and recognizes method names of the form <literal>getFooisFoo and setFoo. If "
"required, you can switch to direct field access for particular properties."
msgstr ""
"<literal>Cat déclare des mutateurs pour tous ses champs "
"persistants. Beaucoup d'autres solutions de mappage Objet/relationnel "
"persistent directement les variables d'instance. Nous pensons qu'il est "
"préférable de fournir une indirection entre le schéma relationnel et les "
"structures de données internes de la classe. Par défaut, Hibernate persiste "
"les propriétés suivant le style JavaBean, et reconnaît les noms de méthodes "
"de la forme <literal> getFoo, isFoo et "
"<literal>setFoo. Vous pouvez changer pour un accès direct aux "
"champs pour des propriétés particulières, si besoin est. "

#. Tag: para
#: persistent_classes.xml:169
#, fuzzy, no-c-format
msgid ""
"Properties need <emphasis>not be declared public. Hibernate can "
"persist a property declared with <literal>package, "
"<literal>protected or private visibility as "
"well."
msgstr ""
"Les propriétés <emphasis>n'ont pas à être déclarées publiques - "
"Hibernate peut persister une propriété avec une paire de getter/setter par "
"défault, <literal>protected ou  private. "

#. Tag: title
#: persistent_classes.xml:178
#, no-c-format
msgid "Implementing inheritance"
msgstr "Implémenter l'héritage"

#. Tag: para
#: persistent_classes.xml:180
#, no-c-format
msgid ""
"A subclass must also observe the first and second rules. It inherits its "
"identifier property from the superclass, <literal>Cat. For example:"
msgstr ""
"Une sous-classe doit également suivre la première et la seconde règle. Elle "
"hérite sa propriété d'identifiant de la classe mère <literal>Cat. "
"Par exemple :"

#. Tag: programlisting
#: persistent_classes.xml:184
#, no-c-format
msgid ""
"package eg;\n"
"\n"
"public class DomesticCat extends Cat {\n"
"        private String name;\n"
"\n"
"        public String getName() {\n"
"                return name;\n"
"        }\n"
"        protected void setName(String name) {\n"
"                this.name=name;\n"
"        }\n"
"}"
msgstr ""

#. Tag: title
#: persistent_classes.xml:188
#, no-c-format
msgid ""
"Implementing <literal>equals() and hashCode()"
msgstr ""
"Implémenter <literal>equals() et hashCode() "

#. Tag: para
#: persistent_classes.xml:191
#, no-c-format
msgid ""
"You have to override the <literal>equals() and hashCode()"
"</literal> methods if you:"
msgstr ""
"Vous devez surcharger les méthodes <literal>equals() et "
"<literal>hashCode() si vous :"

#. Tag: para
#: persistent_classes.xml:196
#, no-c-format
msgid ""
"intend to put instances of persistent classes in a <literal>Set "
"(the recommended way to represent many-valued associations); <emphasis>and (la manière recommandée pour représenter des "
"associations pluri-valuées); <emphasis>et"

#. Tag: para
#: persistent_classes.xml:202
#, no-c-format
msgid "intend to use reattachment of detached instances"
msgstr "avez l'intention d'utiliser le rattachement d'instances détachées"

#. Tag: para
#: persistent_classes.xml:206
#, no-c-format
msgid ""
"Hibernate guarantees equivalence of persistent identity (database row) and "
"Java identity only inside a particular session scope. When you mix instances "
"retrieved in different sessions, you must implement <literal>equals()hashCode() if you wish to have meaningful "
"semantics for <literal>Sets."
msgstr ""
"Hibernate garantit l'équivalence de l'identité persistante (ligne de base de "
"données) et l'identité Java seulement à l'intérieur de la portée d'une "
"session particulière. Donc dès que nous mélangeons des instances venant de "
"différentes sessions, nous devons implémenter <literal>equals() et "
"<literal>hashCode() si nous souhaitons avoir une sémantique "
"correcte pour les <literal>Set s. "

#. Tag: para
#: persistent_classes.xml:212
#, no-c-format
msgid ""
"The most obvious way is to implement <literal>equals()/"
"<literal>hashCode() by comparing the identifier value of both "
"objects. If the value is the same, both must be the same database row, "
"because they are equal. If both are added to a <literal>Set, you "
"will only have one element in the <literal>Set). Unfortunately, "
"you cannot use that approach with generated identifiers. Hibernate will only "
"assign identifier values to objects that are persistent; a newly created "
"instance will not have any identifier value. Furthermore, if an instance is "
"unsaved and currently in a <literal>Set, saving it will assign an "
"identifier value to the object. If <literal>equals() and "
"<literal>hashCode() are based on the identifier value, the hash "
"code would change, breaking the contract of the <literal>Set. See "
"the Hibernate website for a full discussion of this problem. This is not a "
"Hibernate issue, but normal Java semantics of object identity and equality."
msgstr ""
"La manière la plus évidente est d'implémenter <literal>equals()/"
"<literal>hashCode() en comparant la valeur de l'identifiant des "
"deux objets. Si cette valeur est identique, les deux doivent représenter la "
"même ligne de base de données, ils sont donc égaux (si les deux sont ajoutés "
"à un <literal>Set, nous n'aurons qu'un seul élément dans le "
"<literal>Set). Malheureusement, nous ne pouvons pas utiliser cette "
"approche avec des identifiants générés ! Hibernate n'assignera de valeur "
"d'identifiant qu'aux objets qui sont persistants, une instance nouvellement "
"créée n'aura donc pas de valeur d'identifiant ! De plus, si une instance est "
"non sauvegardée et actuellement dans un <literal>Set, le "
"sauvegarder assignera une valeur d'identifiant à l'objet. Si <literal>equals"
"()</literal> et hashCode() sont basées sur la valeur de "
"l'identifiant, le code de hachage devrait changer, rompant le contrat du "
"<literal>Set. Consultez le site web de Hibernate pour des "
"informations plus approfondies. Notez que ceci n'est pas un problème "
"Hibernate, mais concerne la sémantique normale de Java pour l'identité et "
"l'égalité d'un objet. "

#. Tag: para
#: persistent_classes.xml:228
#, no-c-format
msgid ""
"It is recommended that you implement <literal>equals() and "
"<literal>hashCode() using Business key equalityequals() "
"method compares only the properties that form the business key. It is a key "
"that would identify our instance in the real world (a <emphasis>natural et "
"<literal>hashCode() en utilisant  l'égalité par clé "
"métier</emphasis>. L'égalité par clé métier signifie que la méthode "
"<literal>equals() compare uniquement les propriétés qui forment "
"une clé métier, une clé qui identifierait notre instance dans le monde réel "
"(une clé candidate <emphasis>naturelle) : "

#. Tag: programlisting
#: persistent_classes.xml:235
#, no-c-format
msgid ""
"public class Cat {\n"
"\n"
"    ...\n"
"    public boolean equals(Object other) {\n"
"        if (this == other) return true;\n"
"        if ( !(other instanceof Cat) ) return false;\n"
"\n"
"        final Cat cat = (Cat) other;\n"
"\n"
"        if ( !cat.getLitterId().equals( getLitterId() ) ) return false;\n"
"        if ( !cat.getMother().equals( getMother() ) ) return false;\n"
"\n"
"        return true;\n"
"    }\n"
"\n"
"    public int hashCode() {\n"
"        int result;\n"
"        result = getMother().hashCode();\n"
"        result = 29 * result + getLitterId();\n"
"        return result;\n"
"    }\n"
"\n"
"}"
msgstr ""

#. Tag: para
#: persistent_classes.xml:237
#, fuzzy, no-c-format
msgid ""
"A business key does not have to be as solid as a database primary key "
"candidate (see <xref linkend=\"transactions-basics-identity\"/>). Immutable "
"or unique properties are usually good candidates for a business key."
msgstr ""
"Notez qu'une clé métier ne doit pas être solide comme une clé primaire de "
"base de données (voir <xref linkend=\"transactions-basics-identity\" />). "
"Les propriétés immuables ou uniques sont généralement de bonnes candidates "
"pour une clé métier. "

#. Tag: title
#: persistent_classes.xml:244
#, no-c-format
msgid "Dynamic models"
msgstr "Modèles dynamiques"

#. Tag: title
#: persistent_classes.xml:247
#, no-c-format
msgid "Note"
msgstr "Remarque"

#. Tag: emphasis
#: persistent_classes.xml:249
#, fuzzy, no-c-format
msgid ""
"The following features are currently considered experimental and may change "
"in the near future."
msgstr ""
"<emphasis>Notez que les fonctionnalités suivantes sont actuellement "
"considérées comme expérimentales et pourront changer dans un futur proche.</"
"emphasis>"

#. Tag: para
#: persistent_classes.xml:253
#, no-c-format
msgid ""
"Persistent entities do not necessarily have to be represented as POJO "
"classes or as JavaBean objects at runtime. Hibernate also supports dynamic "
"models (using <literal>Maps of Maps at runtime) "
"and the representation of entities as DOM4J trees. With this approach, you "
"do not write persistent classes, only mapping files."
msgstr ""
"Les entités persistantes ne doivent pas nécessairement être représentées "
"comme des classes POJO ou des objets JavaBean à l'exécution. Hibernate "
"supporte aussi les modèles dynamiques (en utilisant des <literal>MapMap s à l'exécution) et la représentation "
"des entités comme des arbres DOM4J. Avec cette approche, vous n'écrivez pas "
"de classes persistantes, seulement des fichiers de mappage. "

#. Tag: para
#: persistent_classes.xml:259
#, fuzzy, no-c-format
msgid ""
"By default, Hibernate works in normal POJO mode. You can set a default "
"entity representation mode for a particular <literal>SessionFactorydefault_entity_mode configuration "
"option (see <xref linkend=\"configuration-optional-properties\"/>)."
msgstr ""
"Par défaut, Hibernate fonctionne en mode POJO normal. Vous pouvez paramétrer "
"un mode de représentation d'entité par défaut pour une "
"<literal>SessionFactory particulière en utilisant l'option de "
"configuration <literal>default_entity_mode (voir entity-name has "
"to be declared instead of, or in addition to, a class name:"
msgstr ""
"Les exemples suivants démontrent la représentation utilisant des "
"<literal>Map s. D'abord, dans le fichier de mappage, un "
"<literal>entity-name doit être déclaré au lieu (ou en plus) d'un "
"nom de classe :"

#. Tag: programlisting
#: persistent_classes.xml:270
#, no-c-format
msgid ""
"<hibernate-mapping>\n"
"\n"
"    <class entity-name=\"Customer\">\n"
"\n"
"        <id name=\"id\"\n"
"            type=\"long\"\n"
"            column=\"ID\">\n"
"            <generator class=\"sequence\"/>\n"
"        </id>\n"
"\n"
"        <property name=\"name\"\n"
"            column=\"NAME\"\n"
"            type=\"string\"/>\n"
"\n"
"        <property name=\"address\"\n"
"            column=\"ADDRESS\"\n"
"            type=\"string\"/>\n"
"\n"
"        <many-to-one name=\"organization\"\n"
"            column=\"ORGANIZATION_ID\"\n"
"            class=\"Organization\"/>\n"
"\n"
"        <bag name=\"orders\"\n"
"            inverse=\"true\"\n"
"            lazy=\"false\"\n"
"            cascade=\"all\">\n"
"            <key column=\"CUSTOMER_ID\"/>\n"
"            <one-to-many class=\"Order\"/>\n"
"        </bag>\n"
"\n"
"    </class>\n"
"    \n"
"</hibernate-mapping>"
msgstr ""

#. Tag: para
#: persistent_classes.xml:272
#, no-c-format
msgid ""
"Even though associations are declared using target class names, the target "
"type of associations can also be a dynamic entity instead of a POJO."
msgstr ""
"Notez que même si des associations sont déclarées en utilisant des noms de "
"classe cible, le type de cible d'une association peut aussi être une entité "
"dynamique au lieu d'un POJO. "

#. Tag: para
#: persistent_classes.xml:276
#, no-c-format
msgid ""
"After setting the default entity mode to <literal>dynamic-map for "
"the <literal>SessionFactory, you can, at runtime, work with "
"<literal>Maps of Maps:"
msgstr ""
"Après avoir configuré le mode d'entité par défaut à <literal>dynamic-mapSessionFactory, nous pouvons lors de "
"l'exécution fonctionner avec des <literal>Map s de Map :"

#. Tag: programlisting
#: persistent_classes.xml:293
#, no-c-format
msgid ""
"Session dynamicSession = pojoSession.getSession(EntityMode.MAP);\n"
"\n"
"// Create a customer\n"
"Map david = new HashMap();\n"
"david.put(\"name\", \"David\");\n"
"dynamicSession.save(\"Customer\", david);\n"
"...\n"
"dynamicSession.flush();\n"
"dynamicSession.close()\n"
"...\n"
"// Continue on pojoSession"
msgstr ""

#. Tag: para
#: persistent_classes.xml:295
#, no-c-format
msgid ""
"Please note that the call to <literal>getSession() using an "
"<literal>EntityMode is on the Session API, not "
"the <literal>SessionFactory. That way, the new Sessionclose() on the secondary Session en utilisant un "
"<literal>EntityMode se fait sur l'API Session, "
"et non sur <literal>SessionFactory. De cette manière, la nouvelle "
"<literal>Session partage les connexions JDBC, transactions et "
"autres informations de contexte sous-jacentes. Cela signifie que vous n'avez "
"pas à appeler <literal>flush() et close() sur "
"la <literal>Session secondaire, et laissez aussi la gestion de la "
"transaction et de la connexion à l'unité de travail primaire. "

#. Tag: para
#: persistent_classes.xml:304
#, fuzzy, no-c-format
msgid ""
"More information about the XML representation capabilities can be found in "
"<xref linkend=\"xml\"/>."
msgstr ""
"Pour plus d'informations à propos de la représentation XML, veuillez "
"consulter <xref linkend=\"xml\" />."

#. Tag: title
#: persistent_classes.xml:310
#, no-c-format
msgid "Tuplizers"
msgstr "Tuplizers"

#. Tag: para
#: persistent_classes.xml:312
#, fuzzy, no-c-format
msgid ""
"<interfacename>org.hibernate.tuple.Tuplizer and its sub-"
"interfaces are responsible for managing a particular representation of a "
"piece of data given that representation's <classname>org.hibernate."
"EntityMode</classname>. If a given piece of data is thought of as a data "
"structure, then a tuplizer is the thing that knows how to create such a data "
"structure, how to extract values from such a data structure and how to "
"inject values into such a data structure. For example, for the POJO entity "
"mode, the corresponding tuplizer knows how create the POJO through its "
"constructor. It also knows how to access the POJO properties using the "
"defined property accessors."
msgstr ""
"<literal>org.hibernate.tuple.Tuplizer, et ses sous-interfaces, "
"sont responsables de la gestion d'une représentation particulière d'un "
"fragment de données, en fonction du <literal>org.hibernate.EntityMode "
"which is responsible for managing the above mentioned contracts in regards "
"to entities"
msgstr ""

#. Tag: para
#: persistent_classes.xml:332
#, no-c-format
msgid ""
"<interfacename>org.hibernate.tuple.component.ComponentTuplizer implementation other than "
"<classname>java.util.HashMap be used while in the dynamic-map "
"entity-mode. Or perhaps you need to define a different proxy generation "
"strategy than the one used by default. Both would be achieved by defining a "
"custom tuplizer implementation. Tuplizer definitions are attached to the "
"entity or component mapping they are meant to manage. Going back to the "
"example of our <classname>Customer entity,  "
"using annotations while <xref linkend=\"example-specify-custom-tuplizer-xml"
"\"/> shows how to do the same in <literal>hbm.xml"
msgstr ""
"Les utilisateurs peuvent aussi brancher leurs propres tuplizers. Il vous "
"faudra peut-être utiliser une implémentation de <literal>java.util.Mapjava.util.HashMap dans le mode "
"d'entité dynamic-map ; ou peut-être aurez vous besoin de définir une "
"stratégie de génération de proxy différente de celle utilisée par défaut. "
"Les deux devraient être effectuées en définissant une implémentation de "
"tuplizer utilisateur. Les définitions de tuplizers sont attachées au mappage "
"de l'entité ou du composant qu'ils devraient gérer. Revenons à l'exemple de "
"notre entité utilisateur : "

#. Tag: title
#: persistent_classes.xml:353
#, no-c-format
msgid "Specify custom tuplizers in annotations"
msgstr ""

#. Tag: programlisting
#: persistent_classes.xml:354
#, no-c-format
msgid ""
"@Entity\n"
"@Tuplizer(impl = DynamicEntityTuplizer.class)\n"
"public interface Cuisine {\n"
"    @Id\n"
"    @GeneratedValue\n"
"    public Long getId();\n"
"    public void setId(Long id);\n"
"\n"
"    public String getName();\n"
"    public void setName(String name);\n"
"\n"
"    @Tuplizer(impl = DynamicComponentTuplizer.class)\n"
"    public Country getCountry();\n"
"    public void setCountry(Country country);\n"
"}"
msgstr ""

#. Tag: title
#: persistent_classes.xml:357
#, no-c-format
msgid "Specify custom tuplizers in <literal>hbm.xml"
msgstr ""

#. Tag: programlisting
#: persistent_classes.xml:358
#, no-c-format
msgid ""
"<hibernate-mapping>\n"
"    <class entity-name=\"Customer\">\n"
"        <!--\n"
"            Override the dynamic-map entity-mode\n"
"            tuplizer for the customer entity\n"
"        -->\n"
"        <tuplizer entity-mode=\"dynamic-map\"\n"
"                class=\"CustomMapTuplizerImpl\"/>\n"
"\n"
"        <id name=\"id\" type=\"long\" column=\"ID\">\n"
"            <generator class=\"sequence\"/>\n"
"        </id>\n"
"\n"
"        <!-- other properties -->\n"
"        ...\n"
"    </class>\n"
"</hibernate-mapping>"
msgstr ""

#. Tag: title
#: persistent_classes.xml:363
#, no-c-format
msgid "EntityNameResolvers"
msgstr "EntityNameResolvers"

#. Tag: para
#: persistent_classes.xml:365
#, fuzzy, no-c-format
msgid ""
"<interfacename>org.hibernate.EntityNameResolver is a "
"contract for resolving the entity name of a given entity instance. The "
"interface defines a single method <methodname>resolveEntityName "
"which is passed the entity instance and is expected to return the "
"appropriate entity name (null is allowed and would indicate that the "
"resolver does not know how to resolve the entity name of the given entity "
"instance). Generally speaking, an <interfacename>org.hibernate."
"EntityNameResolver</interfacename> is going to be most useful in the case of "
"dynamic models. One example might be using proxied interfaces as your domain "
"model. The hibernate test suite has an example of this exact style of usage "
"under the <package>org.hibernate.test.dynamicentity.tuplizer2. "
"Here is some of the code from that package for illustration."
msgstr ""
"L'interface <interfacename>org.hibernate.EntityNameResolver "
"représente un contrat pour résoudre le nom de l'entité d'une instance "
"d'entité donnée. L'interface définit une méthode simple "
"<methodname>resolveEntityName, à qui l'on passe l'instance "
"d'entité et qui doit retourner le nom d'entité qui convient (null est "
"accepté et indiquerait que le resolver ne sait pas comment résoudre le nom "
"de l'entité de l'instance d'entité donnée). Normalement, un "
"<interfacename>org.hibernate.EntityNameResolver est surtout "
"utile pour les modèles dynamiques. Vous pourriez, par exemple, utiliser des "
"interfaces proxy comme modèle de domaine. La suite de test Hibernate "
"comprend un exemple de ce style précis d'utilisation dans <package>org."
"hibernate.test.dynamicentity.tuplizer2</package>. Vous trouverez ci dessous "
"une illustration du code de ce package."

#. Tag: programlisting
#: persistent_classes.xml:377
#, no-c-format
msgid ""
"/**\n"
" * A very trivial JDK Proxy InvocationHandler implementation where we proxy "
"an\n"
" * interface as the domain model and simply store persistent state in an "
"internal\n"
" * Map.  This is an extremely trivial example meant only for illustration.\n"
" */\n"
"public final class DataProxyHandler implements InvocationHandler {\n"
"        private String entityName;\n"
"        private HashMap data = new HashMap();\n"
"\n"
"        public DataProxyHandler(String entityName, Serializable id) {\n"
"                this.entityName = entityName;\n"
"                data.put( \"Id\", id );\n"
"        }\n"
"\n"
"        public Object invoke(Object proxy, Method method, Object[] args) "
"throws Throwable {\n"
"                String methodName = method.getName();\n"
"                if ( methodName.startsWith( \"set\" ) ) {\n"
"                        String propertyName = methodName.substring( 3 );\n"
"                        data.put( propertyName, args[0] );\n"
"                }\n"
"                else if ( methodName.startsWith( \"get\" ) ) {\n"
"                        String propertyName = methodName.substring( 3 );\n"
"                        return data.get( propertyName );\n"
"                }\n"
"                else if ( \"toString\".equals( methodName ) ) {\n"
"                        return entityName + \"#\" + data.get( \"Id\" );\n"
"                }\n"
"                else if ( \"hashCode\".equals( methodName ) ) {\n"
"                        return new Integer( this.hashCode() );\n"
"                }\n"
"                return null;\n"
"        }\n"
"\n"
"        public String getEntityName() {\n"
"                return entityName;\n"
"        }\n"
"\n"
"        public HashMap getData() {\n"
"                return data;\n"
"        }\n"
"}\n"
"\n"
"public class ProxyHelper {\n"
"    public static String extractEntityName(Object object) {\n"
"        // Our custom java.lang.reflect.Proxy instances actually bundle\n"
"        // their appropriate entity name, so we simply extract it from "
"there\n"
"        // if this represents one of our proxies; otherwise, we return null\n"
"        if ( Proxy.isProxyClass( object.getClass() ) ) {\n"
"            InvocationHandler handler = Proxy.getInvocationHandler"
"( object );\n"
"            if ( DataProxyHandler.class.isAssignableFrom( handler.getClass"
"() ) ) {\n"
"                DataProxyHandler myHandler = ( DataProxyHandler ) handler;\n"
"                return myHandler.getEntityName();\n"
"            }\n"
"        }\n"
"        return null;\n"
"    }\n"
"\n"
"    // various other utility methods ....\n"
"\n"
"}\n"
"\n"
"/**\n"
" * The EntityNameResolver implementation.\n"
" *\n"
" * IMPL NOTE : An EntityNameResolver really defines a strategy for how "
"entity names\n"
" * should be resolved.  Since this particular impl can handle resolution for "
"all of our\n"
" * entities we want to take advantage of the fact that SessionFactoryImpl "
"keeps these\n"
" * in a Set so that we only ever have one instance registered.  Why?  Well, "
"when it\n"
" * comes time to resolve an entity name, Hibernate must iterate over all the "
"registered\n"
" * resolvers.  So keeping that number down helps that process be as speedy "
"as possible.\n"
" * Hence the equals and hashCode implementations as is\n"
" */\n"
"public class MyEntityNameResolver implements EntityNameResolver {\n"
"    public static final MyEntityNameResolver INSTANCE = new "
"MyEntityNameResolver();\n"
"\n"
"    public String resolveEntityName(Object entity) {\n"
"        return ProxyHelper.extractEntityName( entity );\n"
"    }\n"
"\n"
"    public boolean equals(Object obj) {\n"
"        return getClass().equals( obj.getClass() );\n"
"    }\n"
"\n"
"    public int hashCode() {\n"
"        return getClass().hashCode();\n"
"    }\n"
"}\n"
"\n"
"public class MyEntityTuplizer extends PojoEntityTuplizer {\n"
"        public MyEntityTuplizer(EntityMetamodel entityMetamodel, "
"PersistentClass mappedEntity) {\n"
"                super( entityMetamodel, mappedEntity );\n"
"        }\n"
"\n"
"        public EntityNameResolver[] getEntityNameResolvers() {\n"
"                return new EntityNameResolver[] { MyEntityNameResolver."
"INSTANCE };\n"
"        }\n"
"\n"
"    public String determineConcreteSubclassEntityName(Object entityInstance, "
"SessionFactoryImplementor factory) {\n"
"        String entityName = ProxyHelper.extractEntityName"
"( entityInstance );\n"
"        if ( entityName == null ) {\n"
"            entityName = super.determineConcreteSubclassEntityName"
"( entityInstance, factory );\n"
"        }\n"
"        return entityName;\n"
"    }\n"
"\n"
"    ..."
msgstr ""

#. Tag: para
#: persistent_classes.xml:379
#, no-c-format
msgid ""
"In order to register an <interfacename>org.hibernate.EntityNameResolvergetEntityNameResolvers "
"method"
msgstr ""
"Implémenter un <xref linkend=\"persistent-classes-tuplizers\" /> "
"personnalisé, en implémentant la méthode <methodname>getEntityNameResolversorg."
"hibernate.SessionFactory</interfacename>) using the "
"<methodname>registerEntityNameResolver method."
msgstr ""
"L'enregistrer dans <classname>org.hibernate.impl.SessionFactoryImplorg."
"hibernate.SessionFactory</interfacename>) à l'aide de la méthode "
"<methodname>registerEntityNameResolver."

#~ msgid ""
#~ "Most Java applications require a persistent class representing felines. "
#~ "For example:"
#~ msgstr ""
#~ "Toute bonne application Java nécessite une classe persistante "
#~ "représentant les félins. Par exemple :"

#~ msgid ""
#~ "<literal>Cat has a property called id. This "
#~ "property maps to the primary key column of a database table. The property "
#~ "might have been called anything, and its type might have been any "
#~ "primitive type, any primitive \"wrapper\" type, <literal>java.lang."
#~ "String</literal> or java.util.Date. If your legacy "
#~ "database table has composite keys, you can use a user-defined class with "
#~ "properties of these types (see the section on composite identifiers later "
#~ "in the chapter.)"
#~ msgstr ""
#~ "<literal>Cat possède une propriété appelée idjava.util.Date. (Si votre base de "
#~ "données héritée possède des clés composites, elles peuvent être mappées "
#~ "en utilisant une classe définie par l'utilisateur et possédant les "
#~ "propriétés associées aux types de la clé composite - voir la section "
#~ "concernant les identifiants composites ultérieurement). "

#~ msgid ""
#~ "The identifier property is strictly optional. You can leave them off and "
#~ "let Hibernate keep track of object identifiers internally. We do not "
#~ "recommend this, however."
#~ msgstr ""
#~ "La propriété d'identifiant est strictement optionnelle. Vous pouvez "
#~ "l'oublier et laisser Hibernate s'occuper des identifiants de l'objet en "
#~ "interne. Toutefois, ce n'est pas recommandé. "

#~ msgid ""
#~ "In fact, some functionality is available only to classes that declare an "
#~ "identifier property:"
#~ msgstr ""
#~ "En fait, quelques fonctionnalités ne sont disponibles que pour les "
#~ "classes déclarant un identifiant de propriété : "

#, fuzzy
#~ msgid ""
#~ "Transitive reattachment for detached objects (cascade update or cascade "
#~ "merge) - see <xref linkend=\"objectstate-transitive\" />"
#~ msgstr ""
#~ "Pour les rattachements transitifs pour les objets détachés (mise à jour "
#~ "en cascade ou fusion en cascade) - consultez <xref linkend=\"objectstate-"
#~ "transitive\" />"

#, fuzzy
#~ msgid "<literal>Session.saveOrUpdate()"
#~ msgstr "<literal>Session.saveOrUpdate()"

#, fuzzy
#~ msgid "<literal>Session.merge()"
#~ msgstr "<literal>Session.merge()"

#~ msgid ""
#~ "A central feature of Hibernate, <emphasis>proxies, depends "
#~ "upon the persistent class being either non-final, or the implementation "
#~ "of an interface that declares all public methods."
#~ msgstr ""
#~ "Une fonctionnalité clé de Hibernate, les <emphasis>proxies, "
#~ "nécessitent que la classe persistante soit non finale ou qu'elle soit "
#~ "l'implémentation d'une interface qui déclare toutes les méthodes "
#~ "publiques."

#~ msgid ""
#~ "You can persist <literal>final classes that do not implement an "
#~ "interface with Hibernate. You will not, however, be able to use proxies "
#~ "for lazy association fetching which will ultimately limit your options "
#~ "for performance tuning."
#~ msgstr ""
#~ "Vous pouvez persister, grâce à Hibernate, les classes <literal>final and "
#~ "<literal>org.hibernate.tuple.component.ComponentTuplizer "
#~ "interfaces. <literal>EntityTuplizers are responsible for "
#~ "managing the above mentioned contracts in regards to entities, while "
#~ "<literal>ComponentTuplizers do the same for components."
#~ msgstr ""
#~ "Il y a deux types de Tuplizers de haut niveau, représentés par les "
#~ "interfaces <literal>org.hibernate.tuple.EntityTuplizer et "
#~ "<literal>org.hibernate.tuple.ComponentTuplizer. Les "
#~ "<literal>EntityTuplizer s sont responsables de la gestion des "
#~ "contrats mentionnés ci-dessus pour les entités, alors que les "
#~ "<literal>ComponentTuplizer s s'occupent des composants."

Other Hibernate examples (source code examples)

Here is a short list of links related to this Hibernate persistent_classes.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.