Hello,
I'm using Hibernate 3.1, and I've got a problem to map an inheritance relation.
I've got an abstract class Person extended by two class USer and Admin.
The problem is that Admin doesn't have aditionnal attirbute but it's the concrete class.
I try to map it using the one class per concrete class strategy.
There is my mapping file :
Code:
<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>
</union-subclass>
<union-subclass name="persistance.admin" table="admin">
</union-subclass>
</class>
</hibernate-mapping>
and the exception returned :
Code:
ava.lang.ExceptionInInitializerError
at persistance.HibernateUtil.<clinit>(HibernateUtil.java:17)
at persistance.HibernateManager.recupererUser(HibernateManager.java:123)
at metier.GestionUser.recupererUser(GestionUser.java:165)
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: entity class not found: persistance.admin
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:99)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:122)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.UnionSubclassEntityPersister.<init>(UnionSubclassEntityPersister.java:63)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:61)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at persistance.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 19 more
Caused by: java.lang.ClassNotFoundException: persistance.admin
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:96)
... 26 more
What's the problem ??