-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate error mapping
PostPosted: Sun Apr 10, 2011 4:44 am 
Newbie

Joined: Fri Apr 08, 2011 2:06 pm
Posts: 3
Hello,
Please help me to find this error mapping


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;

Thanks.


Top
 Profile  
 
 Post subject: Re: Hibernate error mapping
PostPosted: Mon Apr 11, 2011 2:37 am 
Newbie

Joined: Thu Mar 31, 2011 4:37 am
Posts: 11
Show us your "Player" bean...
... I guess you didn't define any "ID" field in this class..


Top
 Profile  
 
 Post subject: Re: Hibernate error mapping
PostPosted: Mon Apr 11, 2011 5:42 am 
Newbie

Joined: Fri Apr 08, 2011 2:06 pm
Posts: 3
libuma wrote:
Show us your "Player" bean...
... I guess you didn't define any "ID" field in this class..


Thanks, you find it ...


Top
 Profile  
 
 Post subject: Re: Hibernate error mapping
PostPosted: Tue Apr 12, 2011 5:09 am 
Newbie

Joined: Thu Mar 31, 2011 4:37 am
Posts: 11
Cheers :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.