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 :

erreur: Could not parse mapping document from resource


Sujet :

Hibernate Java

  1. #1
    Membre du Club Avatar de ferrero
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    75
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Octobre 2003
    Messages : 75
    Points : 56
    Points
    56
    Par défaut erreur: Could not parse mapping document from resource
    Bonjour,

    je veux persister un document XML en utlisatant hibernate, alors j'ai créé le fichier de configuration hibernate et le fichier de mapping, et une classe qui manipule les données XML mais quand j'execute cette classe j'obtient ça :
    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
    - Hibernate 3.2.0
    - hibernate.properties not found
    - Bytecode provider name : cglib
    - using JDK 1.4 java.sql.Timestamp handling
    - configuring from resource: /hibernate.cfg.xml
    - Configuration resource: /hibernate.cfg.xml
    - Reading mappings from resource: model/person.hbm.xml
    - Mapping class: model.Person -> person
    Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource model/person.hbm.xml
    	at org.hibernate.cfg.Configuration.addResource(Configuration.java:523)
    	at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1511)
    	at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1479)
    	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1458)
    	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1432)
    	at org.hibernate.cfg.Configuration.configure(Configuration.java:1352)
    	at org.hibernate.cfg.Configuration.configure(Configuration.java:1338)
    	at model.Mapping.<init>(Mapping.java:35)
    	at model.Mapping.main(Mapping.java:79)
    Caused by: org.hibernate.PropertyNotFoundException: field [id] not found on model.Person
    	at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:112)
    	at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:104)
    	at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:127)
    	at org.hibernate.util.ReflectHelper.getter(ReflectHelper.java:83)
    	at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:71)
    	at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276)
    	at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:401)
    	at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:334)
    	at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
    	at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
    	at org.hibernate.cfg.Configuration.add(Configuration.java:424)
    	at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:465)
    	at org.hibernate.cfg.Configuration.addResource(Configuration.java:520)
    	... 8 more
    le fichier de mapping hibernate :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
             "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping package="model">
      <class name="Person" table="person" node="person">
      <id name="id">
        	<generator class="increment"/>
      </id>
        <property name="person_nom"  not-null="true" node="nom"/>
        <property name="person_prenom" node="prenom"/>
      </class>
    </hibernate-mapping>
    le fichier de configuration :
    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
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
            "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
            "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
     
    <hibernate-configuration>
     
        <session-factory>
     
            <!-- Database connection settings -->
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="connection.url">jdbc:mysql://localhost/hibernate</property>
            <property name="connection.username">root</property>
            <property name="connection.password"></property>
     
            <!-- JDBC connection pool (use the built-in) -->
            <property name="connection.pool_size">10</property>
     
            <!-- SQL dialect -->
            <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
     
            <!-- Echo all executed SQL to stdout -->
            <property name="show_sql">true</property>
     
           <!-- <mapping resource="model/account.hbm.xml"/>-->
            <mapping resource="model/person.hbm.xml"/>
     
        </session-factory>
     
    </hibernate-configuration>


    quelqu'un peut m'aider?

    merci d'avance

  2. #2
    Membre du Club Avatar de ferrero
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    75
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Octobre 2003
    Messages : 75
    Points : 56
    Points
    56
    Par défaut
    enfin j'ai trouvé la solution

    il fallait ajouter l'attribut dans la balise ainsi que dans

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

Discussions similaires

  1. Réponses: 2
    Dernier message: 25/07/2012, 16h38
  2. Erreur : Could not parse application stylesheet
    Par axel584 dans le forum Débuter
    Réponses: 2
    Dernier message: 21/12/2010, 16h57
  3. [Erreur]Could not parse mapping document from resource
    Par Le Pharaon dans le forum Hibernate
    Réponses: 5
    Dernier message: 17/06/2009, 10h53
  4. Réponses: 0
    Dernier message: 15/05/2009, 12h13
  5. Réponses: 1
    Dernier message: 14/02/2009, 09h12

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