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.  [ 2 posts ] 
Author Message
 Post subject: Duplicate import, Abstract class and different packages
PostPosted: Thu Nov 26, 2009 11:52 am 
Newbie

Joined: Thu Nov 26, 2009 11:38 am
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: Duplicate import, Abstract class and different packages
PostPosted: Fri Dec 04, 2009 2:35 pm 
Newbie

Joined: Thu Nov 26, 2009 11:38 am
Posts: 2
like it's said, it was due to a duplicate import. I Forgot one test configuration file, which defined Personne Entity;
it's now working fine


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.