-->
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: héritage toujours
PostPosted: Thu Jun 09, 2005 9:18 am 
Regular
Regular

Joined: Mon Apr 25, 2005 5:36 am
Posts: 103
Dans ma classe

<class>

<id name="Id" type="java.lang.Integer">
<column name="ID" not-null="true" unique="true" sql-type="NUMBER(6)" />
<generator class="assigned" />
</id>
....
<joined-subclass name="Externe" table="EXTERNE" >
<key column="Id"/>
<property name="MontantFacturation" column="MONTANTFACTURATION"/>
</joined-subclass>

<joined-subclass name="Interne" table="INTERNE" >
<key column="Id"/>
<property name="SalaireMensuel" column="SALAIREMENSUEL"/>
</joined-subclass>

</class>



Dasn mes sous classes

<class name="fr.icdc.dei.fwk.sample.dto.Interne" table="INTERNE" schema="HIBERNATE">
<id name="Id" type="java.lang.Integer">
<column name="ID" not-null="true" unique="true" sql-type="NUMBER(6)" />
<generator class="assigned" />
</id>
<property name="SalaireMensuel" type="java.math.BigDecimal">
<column name="SALAIREMENSUEL" not-null="false" sql-type="NUMBER(8,2)" />
</property>
</class>
</hibernate-mapping>


AND



<class name="fr.icdc.dei.fwk.sample.dto.Externe" table="EXTERNE" schema="HIBERNATE">
<id name="Id" type="java.lang.Integer">
<column name="ID" scale="6" precision="0" not-null="true" unique="true" sql-type="NUMBER" />
<generator class="assigned" />
</id>
<property name="MontantFacturation" type="java.math.BigDecimal">
<column name="MONTANTFACTURATION" not-null="true" sql-type="NUMBER(8,2)" />
</property>
</class>
</hibernate-mapping>



J'ai le message d'erreur suivant
Initial SessionFactory creation failed
java.lang.ExceptionInInitializerError
at fr.icdc.dei.fwk.test.HibernateUtil.<clinit>(HibernateUtil.java:22)
at fr.icdc.dei.fwk.test.Test.main(Test.java:15)
Caused by: org.hibernate.MappingException: Error reading resource: fr/icdc/dei/fwk/sample/dto/Ressource.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:447)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1392)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1364)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1346)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1313)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1241)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1227)
at fr.icdc.dei.fwk.test.HibernateUtil.<clinit>(HibernateUtil.java:16)
... 1 more
Caused by: org.hibernate.MappingException: duplicate import: Externe
at org.hibernate.cfg.Mappings.addImport(Mappings.java:101)
at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:540)
at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:487)
at org.hibernate.cfg.HbmBinder.bindJoinedSubclass(HbmBinder.java:758)
at org.hibernate.cfg.HbmBinder.handleJoinedSubclass(HbmBinder.java:1791)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1732)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:317)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:235)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:151)
at org.hibernate.cfg.Configuration.add(Configuration.java:358)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:395)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:444)
... 8 more
Exception in thread "main"




Qu'est-ce qui va pas dasn mon mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 09, 2005 11:04 am 
Regular
Regular

Joined: Tue May 03, 2005 8:19 am
Posts: 53
Location: Paris
Tu déclares 2 fois les mêmes objets!
pourquoi ne pas faire un one-to-one plutôt que le joined-subclass?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 09, 2005 1:33 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
si tu déclares ton arbre d'héritage dans un seul fichier (ton premier fichier de mapping) tu n'as pas à écrire ceux des sous classes puisqu'ils n'apportent pas d'autres infos.

Si un interne ne peux pas devenir externe, tu as raison d'utiliser l'héritage.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.