-->
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 + eclipse] probleme de compilation et de mapping
PostPosted: Wed Nov 23, 2005 10:33 am 
Newbie

Joined: Wed Nov 23, 2005 9:53 am
Posts: 9
Hibernate version: hibernate2

Bonjour,
j'ai un soucis lors de la compilation d'un projet avec hibernate
voila les erreurs console que me renvoie eclipse

22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Environment <clinit>
INFO: Hibernate 2.1.6
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: hibernate/mapping/Chanson.hbm
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: traitement.Chanson -> chanson
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: hibernate/mapping/Distributeur.hbm
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: traitement.Distributeur -> distributeur
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: hibernate/mapping/Genre.hbm
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: traitement.Genre -> genre
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Binder bindCollection
INFO: Mapping collection: traitement.Genre.oeuvre -> typer
22 nov. 2005 16:04:03 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: hibernate/mapping/Langue.hbm
22 nov. 2005 16:04:04 net.sf.hibernate.cfg.Binder bindRootClass
INFO: Mapping class: traitement.Langue -> langue
22 nov. 2005 16:04:04 net.sf.hibernate.cfg.Binder bindCollection
INFO: Mapping collection: traitement.Langue.film -> version
22 nov. 2005 16:04:04 net.sf.hibernate.cfg.Configuration addResource
INFO: Mapping resource: hibernate/mapping/Oeuvre.hbm
22 nov. 2005 16:04:04 net.sf.hibernate.util.XMLHelper$ErrorLogger error
GRAVE: Error parsing XML: XML InputStream(3 Lattribut "{0}" nest pas déclaré pour lélément "{1}".
22 nov. 2005 16:04:04 net.sf.hibernate.util.XMLHelper$ErrorLogger error
GRAVE: Error parsing XML: XML InputStream(53) Lélément "{0}" naccepte pas "one-to-one" ici.
22 nov. 2005 16:04:04 net.sf.hibernate.util.XMLHelper$ErrorLogger error
GRAVE: Error parsing XML: XML InputStream(53) La valeur dattribut pour "{0}" est #REQUIRED.
22 nov. 2005 16:04:04 net.sf.hibernate.util.XMLHelper$ErrorLogger error
GRAVE: Error parsing XML: XML InputStream(54) Lélément "{0}" nécessite des éléments additionnels.
java.lang.ExceptionInInitializerError
at ihm.Start.main(Start.java:46)
Caused by: java.lang.RuntimeException: Problème de configuration : Error reading resource: hibernate/mapping/Oeuvre.hbm
at traitement.HibernateUtil.<clinit>(HibernateUtil.java:16)
... 1 more
Caused by: net.sf.hibernate.MappingException: Error reading resource: hibernate/mapping/Oeuvre.hbm
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1013)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:969)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:897)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:883)
at traitement.HibernateUtil.<clinit>(HibernateUtil.java:14)
... 1 more
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
... 6 more
Caused by: org.xml.sax.SAXParseException: Lattribut "{0}" nest pas déclaré pour lélément "{1}".
at org.apache.crimson.parser.Parser2.error(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.content(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.content(Unknown Source)
at org.apache.crimson.parser.Parser2.maybeElement(Unknown Source)
at org.apache.crimson.parser.Parser2.parseInternal(Unknown Source)
at org.apache.crimson.parser.Parser2.parse(Unknown Source)
at org.apache.crimson.parser.XMLReaderImpl.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:286)
... 7 more
Exception in thread "main"


je vous donne aussi le mapping de ma classe oeuvre

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="traitement">
<class name="Oeuvre" table="oeuvre">
<id
column="idoeu"
name="idOeu"
type="java.lang.Short"
>
<generator class="vm" />
</id>
<property
column="annee"
length="10"
name="annoeu"
not-null="false"
type="date"
/>
<property
column="titreoeu"
length="60"
name="titreOeu"
not-null="false"
type="string"
/>
<property
column="imaoeu"
length="30"
name="imaOeu"
not-null="false"
type="string"
/>
<one-to-one
class="traitement.Distributeur"
name="distributeur"
column="iddist"/>
<set name="genre" table="typer">
<key column="typoeu" />
<many-to-many class="traitement.Genre"/>
</set>
<set name="nationnalite" table="nationnalite">
<key column="natoeu" />
<many-to-many class="traitement.Pays"/>
</set>
<set name="support" table="stocker">
<key column="stockoeu" />
<many-to-many class="traitement.Support"/>
</set>
<set name="emprunteur" table="emprunt">
<key column="empoeu" />
<one-to-one class="traitement.User"/>
</set>

<!-- MAPPING CLASSE FILLE -->
<!-- mapping classe Film -->
<subclass name="Film" >
<property name="idFilm" column="idfilm" type="java.lang.Short"/>
<property column="resfilm" name="resumeFilm" not-null="false"
type="string" />
<set name="acteur" table="jouer">
<key column="jouefilm" />
<many-to-many class="traitement.Personne"/>
</set>
<set name="realisateur" table="realiser">
<key column="reafilm" />
<many-to-many class="traitement.Personne"/>
</set>
<set name="langue" table="version">
<key column="versfilm" />
<many-to-many class="traitement.Langue"/>
</set>
<set name="st" table="soustitre">
<key column="stfilm" />
<many-to-many class="traitement.Langue"/>
</set>
</subclass>

<!-- mapping classe Music -->
<subclass name="Music" >
<property name="idMusic" column="idmusic" type="java.lang.Short"/>
<property column="nbmusic" length="3" name="nbChans"
not-null="false"
type="java.lang.Byte" />
<set name="chanson" cascade="all-delete-orphan">
<key column="idchans"/>
<one-to-many class="traitement.Chanson" />
</set>
<set name="interprete" table="interpreter">
<key column="intermusic" />
<many-to-many class="traitement.Personne"/>
</set>
<set name="compositeur" table="composer">
<key column="compmusic" />
<many-to-many class="traitement.Personne"/>
</set>
</subclass>

<!-- mapping classe Livre -->
<subclass name="Livre" >
<property name="idLivre" column="idlivre" type="java.lang.Short"/>
<property column="reslivre" name="resumeLivre" not-null="false"
type="string" />
<set name="ecrivain" table="ecrire">
<key column="ecrilivre" />
<many-to-many class="traitement.Personne"/>
</set>
<many-to-one
class="traitement.Langue"
name="langue"
column="codlang"/>
</subclass>

</class>
</hibernate-mapping>[/color]


je pense que cela vient du mapping par classe fille (partie en bleu), j'intègre lorsque je déclare les sub-class des relations (many-to-many, many-to-one, ...) vers d'autres classes qui ne sont pas en corélation directe avec la classe Oeuvre.

voila, merci pour vos réponses


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 4:17 am 
Newbie

Joined: Wed Nov 23, 2005 9:53 am
Posts: 9
quelqu'un peut il au moins me dire si je peux faire la partie bleu du code xml pour le mapping des sous-classes de la classe mere Oeuvre.
Je fais un sub-class et aprés je déclare les sous-classes avec des relations many-to-many vers d'autres classes
Voila, si quelqu'un pouvait m'aider.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 5:43 am 
Newbie

Joined: Wed Nov 23, 2005 9:53 am
Posts: 9
en fait, mon probleme vient du fait que je voudrais mapper une relation entre une classe Film (héritant de la classe Oeuvre) avec une classe Acteur. Dans ma BDD (mySQL), le MCD :

Oeuvre (0,1)--------------(1,1) Film
(1,n)
|
|
|
|
(0,n)
Acteur

Donc d'aprés Merise, la relation entre les tables Film et Personne deviennent une table que j'ai nommé Jouer (la clé primaire est la concaténation des 2 clés primaires des tables liées par la relation Film et Acteur, et 2 clés etrangères liées aux clés primaires des tables Film et Acteur) lors du MLD :

Oeuvre--------------Film
|
|
|
Jouer
|
|
|
Acteur

Comment je dois faire pour pouvoir mapper ces tables ? Je voudrais pouvoir utiliser les classes Film et Acteur, faire des update, des saves et que hibernate s'occupe de mettre à jour la table-relation Jouer.
Voilà, alors si quelqu'un peut m'aider ca serait cool, je galère depuis 3 jours. Yen a marre :snif:

ps : j'ai la meme relation entre 2 autres tables, mais elle est porteuse d'1 donnée. Voilà si vous pouvez me dire aussi comment faire ca serait sympa.

Merci


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 5:46 am 
Newbie

Joined: Wed Nov 23, 2005 9:53 am
Posts: 9
en fait, mon probleme vient du fait que je voudrais mapper une relation entre une classe Film (héritant de la classe Oeuvre) avec une classe Acteur. Dans ma BDD (mySQL), le MCD :

Film (1,1) -------------- (0,1)Oeuvre
(1,n)
|
|
|
|
(0,n)
Acteur

Donc d'aprés Merise, la relation entre les tables Film et Personne deviennent une table que j'ai nommé Jouer (la clé primaire est la concaténation des 2 clés primaires des tables liées par la relation Film et Acteur, et 2 clés etrangères liées aux clés primaires des tables Film et Acteur) lors du MLD :

Film--------------Oeuvre
|
|
|
Jouer
|
|
|
Acteur

Comment je dois faire pour pouvoir mapper ces tables ? Je voudrais pouvoir utiliser les classes Film et Acteur, faire des update, des saves et que hibernate s'occupe de mettre à jour la table-relation Jouer.
Voilà, alors si quelqu'un peut m'aider ca serait cool, je galère depuis 3 jours. Yen a marre :snif:

ps : j'ai la meme relation entre 2 autres tables, mais elle est porteuse d'1 donnée. Voilà si vous pouvez me dire aussi comment faire ca serait sympa.

Merci

désolé voila le bon schéma Merise (la misen page du forum avait tout décalé


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.