Hello,
i try to mapp my classes with Hibernate.
i have one parent abstract class (package1.Personne), and two extended concret classes (package2.Stagiaire) (package3.Intervenant).
I tried first with three files hbm.xml like this:
Personne.hbm.xml
with this code:
Code:
<hibernate-mapping package = "package1" auto-import="false">
<class name="package1.Personne" abstract="true">
<id name = "idPersonne" column = "ID_PERSONNE" type="long">
<generator class = "sequence" /> </id>
...
</class>
</hibernate-mapping>
Stagiaire.hbm.xml
Code:
<hibernate-mapping package = "package2" >
<union-subclass name="package2.Stagiaire" entity-name="Stagiaire" table="STAGIAIRE">
<property name = "typeCERFAStagiaire" column="TYPE_CERFA_STAGIAIRE" />
...
</union-subclass>
</hibernate-mapping>
and Intervenant.hbm.xml
Code:
<hibernate-mapping package = "package3" >
<union-subclass name="package3.Intervenant" entity-name="Intervenant" table="INTERVENANT">
<property name = "statutCERFAInvervenant" column="STATUT_CERFA_INTERVENANT" />
</union-subclass>
</hibernate-mapping>
And i tried to do it in one file:
Personne.hbm.xml
Code:
<hibernate-mapping package = "package1" auto-import="false">
<class name="package1.Personne" entity-name="Personne" abstract="true">
<id name = "idPersonne" column = "ID_PERSONNE" type="long">
<generator class = "sequence" /> </id>
<union-subclass name="package2.Stagiaire" entity-name="Stagiaire" table="STAGIAIRE">
<property name = "typeCERFAStagiaire" column="TYPE_CERFA_STAGIAIRE" />
...
</union-subclass>
<union-subclass name="package3.Intervenant" entity-name="Intervenant" table="INTERVENANT">
<property name = "statutCERFAInvervenant" column="STATUT_CERFA_INTERVENANT" />
...
</union-subclass>
</class>
</hibernate-mapping>
I indicated three files hbm.xml or one file: Personne.hbm.xml. in sessionFactory declaration in formco-data.xml
With every solutions, i obtained this error:
Code:
16:33:45,385 ERROR ContextLoader:215 - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/formco-data.xml]: Invocation of init method failed; nested exception is org.hibernate.DuplicateMappingException: duplicate import: Personne refers to both package2.Personne and Personne (try using auto-import="false")
.
If anybody could tell me where i could find the answer, it would be great!
thank you
JBA