1 pièce(s) jointe(s)
[Hibernate]Problème pour mapping d' un héritage
J'ai un petit spucis sur le mapping d'un héritage avec stratégie une table par classe fille.
Voici un petit schema (mal fait) de l'héritage que je souhaite implémenter
Personne est une classe abstraite.
http://www.developpez.net/forums/att...1&d=1151401153
J'ai réalisé le mapping suivant :
Code:
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
<hibernate-mapping >
<class name="persistance.Personne" abstract="true">
<id name="id" type="integer">
<column name="id"/>
<generator class="assigned" />
</id>
<property name="nom" type="string"> </property>
<property name="prenom" type="string"> </property>
<many-to-one name="authentification"
column="auth_id"
class="persistance.Authentification"
unique="true"
not-null="true"
fetch="join" />
<union-subclass name="persistance.User" table="utilisateurs">
<property name="nom" type="string"> </property>
<property name="prenom" type="string"> </property>
<property name="societe" type="string"> </property>
<property name="quotaAut" column="quota_aut" />
<property name="quotaCour" column="quota_cour"/>
<property name="tel" type="string" />
<property name="adresse" type="string" />
<property name="cp" type="int" />
<property name="ville" type="string" />
<property name="mailPerso" type="string" />
<set name="fichiers" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="util_id"></key>
<one-to-many class="persistance.Fichier"></one-to-many>
</set>
<set name="mails" inverse="true" lazy="true" cascade="all-delete-orphan">
<key column="util_id"></key>
<one-to-many class="persistance.Mail"></one-to-many>
</set>
<many-to-one name="authentification"
column="auth_id"
class="persistance.Authentification"
unique="true"
not-null="true"
fetch="join" />
</union-subclass>
<union-subclass name="persistance.admin" table="admin">
<property name="nom" type="string" />
<property name="prenom" type="string" />
<many-to-one name="authentification"
column="auth_id"
class="persistance.Authentification"
unique="true"
not-null="true"
fetch="join" />
</union-subclass>
</class>
</hibernate-mapping> |
et j'ai l'erreur suivante en retour :
Code:
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
|
java.lang.ExceptionInInitializerError
at persistance.HibernateUtil.<clinit>(HibernateUtil.java:17)
at persistance.HibernateManager.recupererUser(HibernateManager.java:123)
at metier.GestionUser.recupererUser(GestionUser.java:163)
at controleur.ServletFichier.doPost(ServletFichier.java:190)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: persistance.admin column: nom (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:575)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:597)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:615)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:405)
at org.hibernate.mapping.UnionSubclass.validate(UnionSubclass.java:40)
at org.hibernate.cfg.Configuration.validate(Configuration.java:984)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1169)
at persistance.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 19 more |
Je ne comprend pas pourquoi il rale car c'est pourtant bien explicité dans le manuel :
Citation:
Chaque table définit des colonnes pour toutes les propriétés de la classe, incluant les propriétés héritéés.
cf : Manuel Hibernate