-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Probleme de mapping Hibernate
PostPosted: Fri Apr 08, 2011 2:09 pm 
Newbie

Joined: Fri Apr 08, 2011 2:06 pm
Posts: 3
Bonjour,
Pourriez m'aidez avec cette erreur


Echec création SessionFactoryorg.hibernate.InvalidMappingException: Could not parse mapping document from resource com/eyrolles/sportTracker/model/Player.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.eyrolles.sportTracker.util.HibernateUtil.<clinit>(HibernateUtil.java:17)
at com.eyrolles.sportTracker.test.Testplayer.chargementAvecGet(Testplayer.java:20)
at com.eyrolles.sportTracker.test.Testplayer.main(Testplayer.java:42)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/eyrolles/sportTracker/model/Player.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:616)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1635)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1476)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at com.eyrolles.sportTracker.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more
Caused by: org.hibernate.PropertyNotFoundException: field [id] not found on com.eyrolles.sportTracker.model.Player
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:145)
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:137)
at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:160)
at org.hibernate.util.ReflectHelper.getter(ReflectHelper.java:241)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:229)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:302)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:423)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:356)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
at org.hibernate.cfg.Configuration.add(Configuration.java:716)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:551)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
... 9 more




<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.eyrolles.sportTracker.model">
<class name="Team" table="TEAM" lazy="true">
<id name="id" column="TEAM_ID">
<generator class="native"/>
</id>
<property name="name" column="TEAM_NAME"/>
<property name="nbWon" column="NB_WON"/>
<property name="nbLost" column="NB_LOST"/>
<property name="nbPlayed" column="NB_PLAYED"/>
<many-to-one name="coach" class="Coach" column="COACH_ID" unique="true"/>
<set name="players" cascade="save-update" inverse="true">
<key column="TEAM_ID" />
<one-to-many class="Player" />
</set>
<map name="homeGames" cascade="save-update" inverse="true" lazy="true">
<key column="HOME_TEAM_ID" />
<index column="GAME_DATE" type="date" />
<one-to-many class="Game" />
</map>
<map name="awayGames" cascade="save-update" inverse="true" lazy="true">
<key column="AWAY_TEAM_ID" />
<index column="GAME_DATE" type="date" />
<one-to-many class="Game" />
</map>
</class>
</hibernate-mapping>



<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.eyrolles.sportTracker.model">
<class name="Player" table="PLAYER" >
<id name="id" column="PLAYER_ID">
<generator class="native"/>
</id>
<property name="name" column="PLAYER_NAME"/>
<property name="number" column="PLAYER_NUMBER"/>
<property name="birthday" column="BIRTHDAY"/>
<property name="height" column="HEIGHT"/>
<property name="weight" column="WEIGHT"/>
<many-to-one column="TEAM_ID" name="team" class="Team" />
</class>
</hibernate-mapping>






public class Team implements Serializable{
private Long id;
private String name;
private int nbWon;
private int nbLost;
private int nbPlayed;
private Coach coach;
private Set players = new HashSet();
// nous verrons plus tard comment choisir la collection
// private List players = new ArrayList
private Map homeGames = new HashMap();
private Map awayGames = new HashMap();
private transient int nbNull;
private transient Map games = new HashMap();
private transient Set wonGames = new HashSet();
private transient Set lostGames = new HashSet();



private String name;
private String number;
private Date birthday;
private double height;
private double weight;
private Team team;


Merci.


Top
 Profile  
 
 Post subject: Re: Probleme de mapping Hibernate
PostPosted: Fri Apr 15, 2011 8:53 am 
Newbie

Joined: Fri Apr 15, 2011 8:49 am
Posts: 2
Bonjour

L'erreur vient d'une erreur de parsing par Hibernate de votre fichier de configuration.

Je vous propose de vous référer au tutoriel suivant pour vous aider à reprendre votre fichier de Mapping : http://www.mistra.fr/tutoriel-hibernate ... o-one.html

L'équipe Mistra
www.mistra.fr


Top
 Profile  
 
 Post subject: Re: Probleme de mapping Hibernate
PostPosted: Fri Apr 15, 2011 9:03 am 
Regular
Regular

Joined: Fri Jan 28, 2011 11:44 am
Posts: 117
Ce problème a déjà été résolu dans la partie anglaise et n'a rien à voir avec le fichier de configuration ...
Il manque simplement la propriété id dans la classe Player.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.