IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Hibernate Java Discussion :

problème de maping


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de anayathefirst
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    326
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Décembre 2006
    Messages : 326
    Par défaut problème de maping
    Salut,
    je commence dans l'utilisation de Hibernate et je doit mapper des classes pour la gestion de listes de cadeaux de mariages (site de e-commerce en gros).
    J'ai créé ma base de donnée et mes classes, et maintenant, je tente d'éditer des fichier xml pour le mapping objet/relationnel (le principe d'Hibernate d'apprès ce que j'ai compris ).
    j'ai lu la doc de hibernate.org, et j'ai réussi à mapper des classes simples .
    mais quand je tente de faire un mapping de toute mes classes, j'ai une erreur que je ne comprend pas .
    en fait, j'ai l'impression qu'il essaye de faire le mapping d'une classes deux fois (la classes Listes dans mon exemple) :
    voici le contenu du fichier de log (avec l'erreur) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
     
    INFO  Environment                     - Hibernate 3.2.1
    INFO  Environment                     - hibernate.properties not found
    INFO  Environment                     - Bytecode provider name : cglib
    INFO  Environment                     - using JDK 1.4 java.sql.Timestamp handling
    INFO  Configuration                   - configuring from resource: /hibernate.cfg.xml
    INFO  Configuration                   - Configuration resource: /hibernate.cfg.xml
    INFO  Configuration                   - Reading mappings from resource : Adresse.hbm.xml
    INFO  HbmBinder                       - Mapping class: beans.Adresse -> ADFRESSE
    INFO  Configuration                   - Reading mappings from resource : Article.hbm.xml
    INFO  HbmBinder                       - Mapping class: beans.Article -> ARTICLE
    INFO  Configuration                   - Reading mappings from resource : Couple.hbm.xml
    INFO  HbmBinder                       - Mapping class: beans.Liste -> LISTE
    INFO  Configuration                   - Reading mappings from resource : Evenement.hbm.xml
    INFO  HbmBinder                       - Mapping class: beans.Evenement -> EVENEMENT
    INFO  Configuration                   - Reading mappings from resource : FamilleArticles.hbm.xml
    INFO  HbmBinder                       - Mapping class: beans.FamilleArticles -> FAMILLE
    INFO  Configuration                   - Reading mappings from resource : Langue.hbm.xml
    INFO  HbmBinder                       - Mapping class: beans.Langue -> LANGUE
    INFO  Configuration                   - Reading mappings from resource : Liste.hbm.xml
    INFO  Mappings                        - duplicate import: beans.Liste->beans.Liste
    INFO  Mappings                        - duplicate import: beans.Liste->Liste
    INFO  HbmBinder                       - Mapping class: beans.Liste -> LISTE
    ERROR HibernateUtil                   - Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource Liste.hbm.xml
    Stack is : org.hibernate.InvalidMappingException: Could not parse mapping document from resource Liste.hbm.xml
    	at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
    	at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1584)
    	at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1552)
    	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1531)
    	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1505)
    	at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
    	at org.hibernate.cfg.Configuration.configure(Configuration.java:1411)
    	at util.HibernateUtil.<clinit>(HibernateUtil.java:35)
    	at tests.HibernateTest.processRequest(HibernateTest.java:48)
    	at tests.HibernateTest.doGet(HibernateTest.java:97)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:833)
    	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
    	at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1285)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping beans.Liste
    	at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
    	at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
    	at org.hibernate.cfg.Configuration.add(Configuration.java:669)
    	at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:504)
    	at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
    	... 23 more
     
    ERROR [HibernateTest]                 - "Servlet.service()" pour la servlet HibernateTest a généré une exception
    java.lang.ExceptionInInitializerError
    	at util.HibernateUtil.<clinit>(HibernateUtil.java:43)
    	at tests.HibernateTest.processRequest(HibernateTest.java:48)
    	at tests.HibernateTest.doGet(HibernateTest.java:97)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    	at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:833)
    	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
    	at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1285)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource Liste.hbm.xml
    	at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
    	at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1584)
    	at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1552)
    	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1531)
    	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1505)
    	at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
    	at org.hibernate.cfg.Configuration.configure(Configuration.java:1411)
    	at util.HibernateUtil.<clinit>(HibernateUtil.java:35)
    	... 16 more
    Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping beans.Liste
    	at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
    	at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
    	at org.hibernate.cfg.Configuration.add(Configuration.java:669)
    	at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:504)
    	at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
    	... 23 more
    si ça peut aider voici mon fichier Liste.hbm.xml :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
        <class name="beans.Liste" table="LISTE">
            <id name="databaseId" type="int" column="ID_LISTE" unsaved-value="0">
                <generator class="identity"/>
            </id>
     
            <many-to-one name="evenement" class="beans.Evenement" column="ID_EVENEMENT" not-null="true"/>
     
            <many-to-one name="couple" class="beans.Couple" column="ID_COUPLE" not-null="true"/>
     
            <property name="dateDeLEvenement" column="DATE_EVENEMENT" />
            <property name="montantRecu" column="LIQUIDE" />
            <property name="Commentaire" column="COMMENTAIRE" />
        </class>
    </hibernate-mapping>
    et voici le code de ma classe Liste :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
     
    /*
     * Liste.java
     *
     * Created on 14 décembre 2006, 15:38
     *
     * To change this template, choose Tools | Template Manager
     * and open the template in the editor.
     */
     
    package beans;
     
    import java.sql.Date;
     
    /**
     * 
     * @author Amine
     */
    public class Liste {
     
    	/**
             * Creates a new instance of Liste
             */
    	public Liste() {
    	}
     
    	public final String PROP_DATABASE_ID = "databaseId";
     
    	public final String PROP_DATE_EVENEMENT = "dateDeLEvenement";
     
    	public final String PROP_DATE_COMMENTAIRE = "Commentaire";
     
    	public final String PROP_MONTANT_RECU = "montantRecu";
     
    	public final String PROP_EVENEMENT = "evenement";
     
    	public final String PROP_COUPLE = "couple";
     
    	private int databaseId;
     
    	private Date dateDeLEvenement;
     
    	private double montantRecu;
     
    	private String Commentaire;
     
    	private Evenement evenement;
     
    	private Couple couple;
     
    	/**
             * @return the commentaire
             */
    	public String getCommentaire() {
    		return Commentaire;
    	}
     
    	/**
             * @return the couple
             */
    	public Couple getCouple() {
    		return couple;
    	}
     
    	/**
             * @return the databaseId
             */
    	public int getDatabaseId() {
    		return databaseId;
    	}
     
    	/**
             * @return the dateDeLEvenement
             */
    	public Date getDateDeLEvenement() {
    		return dateDeLEvenement;
    	}
     
    	/**
             * @return the evenement
             */
    	public Evenement getEvenement() {
    		return evenement;
    	}
     
    	/**
             * @return the montantRecu
             */
    	public double getMontantRecu() {
    		return montantRecu;
    	}
     
    	/**
             * @param commentaire
             *            the commentaire to set
             */
    	public void setCommentaire(String commentaire) {
    		Commentaire = commentaire;
    	}
     
    	/**
             * @param couple
             *            the couple to set
             */
    	public void setCouple(Couple couple) {
    		this.couple = couple;
    	}
     
    	/**
             * @param databaseId
             *            the databaseId to set
             */
    	public void setDatabaseId(int databaseId) {
    		this.databaseId = databaseId;
    	}
     
    	/**
             * @param dateDeLEvenement
             *            the dateDeLEvenement to set
             */
    	public void setDateDeLEvenement(Date dateDeLEvenement) {
    		this.dateDeLEvenement = dateDeLEvenement;
    	}
     
    	/**
             * @param evenement
             *            the evenement to set
             */
    	public void setEvenement(Evenement evenement) {
    		this.evenement = evenement;
    	}
     
    	/**
             * @param montantRecu
             *            the montantRecu to set
             */
    	public void setMontantRecu(double montantRecu) {
    		this.montantRecu = montantRecu;
    	}
     
    }
    et le scripte de génération de la table LISTE
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    CREATE TABLE IF NOT EXISTS LISTE
     (
       ID_LISTE INTEGER NOT NULL AUTO_INCREMENT ,
       ID_EVENEMENT BIGINT NOT NULL  ,
       DATE_EVENEMENT DATE NULL  ,
       LIQUIDE BIGINT NULL  ,
       COMMENTAIRE TEXT NULL  
       , PRIMARY KEY (ID_LISTE) 
     )
    si quelqu'un a une idée de l'erreur que j'aurais commise, je lui serais reconnaissant de m'en expliquait la correction.

    Merci d'avance.

    PS : désolé pour ceux qui trouvent que ce poste est excessivement Verbeux :p.

  2. #2
    Rédacteur
    Avatar de pseudocode
    Homme Profil pro
    Architecte système
    Inscrit en
    Décembre 2006
    Messages
    10 062
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Architecte système
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2006
    Messages : 10 062
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    INFO  Configuration  - Reading mappings from resource : Couple.hbm.xml
    INFO  HbmBinder      - Mapping class: beans.Liste -> LISTE
    (...)
    INFO  Configuration  - Reading mappings from resource : Liste.hbm.xml
    INFO  Mappings       - duplicate import: beans.Liste->beans.Liste
    INFO  Mappings       - duplicate import: beans.Liste->Liste
    A priori, il y a deja un mapping de beans.Liste dans le fichier Couple.hbm.xml
    ALGORITHME (n.m.): Méthode complexe de résolution d'un problème simple.

  3. #3
    Membre éclairé Avatar de anayathefirst
    Profil pro
    Inscrit en
    Décembre 2006
    Messages
    326
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations forums :
    Inscription : Décembre 2006
    Messages : 326
    Par défaut
    rappellez moi de vérifier les erreurs de copier coller avant de proposer une nouvelle discussion ...
    désolé les gas

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème d'installation oracle 8.1.7 sous NT
    Par Anonymous dans le forum Installation
    Réponses: 7
    Dernier message: 02/08/2002, 14h18
  2. Problème d'impression
    Par IngBen dans le forum C++Builder
    Réponses: 7
    Dernier message: 22/05/2002, 11h37
  3. Problème avec la mémoire virtuelle
    Par Anonymous dans le forum CORBA
    Réponses: 13
    Dernier message: 16/04/2002, 16h10
  4. Réponses: 6
    Dernier message: 25/03/2002, 21h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo