-->
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.  [ 6 posts ] 
Author Message
 Post subject: Duplicate class mapping
PostPosted: Mon Nov 07, 2005 9:03 am 
Newbie

Joined: Mon Nov 07, 2005 8:51 am
Posts: 4
Hi,

I'm a newbie what concerns Hibernate and i'm experiencing some problems with inheritance and annotations...

I've read in the docs that the easiest way was the TABLE_PER_CLASS strategy, and that is what i would like to start with..

I have following Superclass:

Code:
@Entity
public class happening{...}


I have following SubClasses:

Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Activity extends happening{...}


Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class ActivityWithCard extends happening{...}


Code:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Exam extends Activity{...}


I read in the docs that you have to declare '@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)' on every leaf, so in this case Activity, ActivityWithCard and Exam. Though i always get a mappingexception: "Duplicate class mapping: duplicate found for class "Happening".

I've probably made some stupid mistake, I would be very gratefull if someone could help me out...

Much Thanks in Advance

El_Homer

_________________
I think i just pulled a Homer !


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 3:29 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
My first guess would be that something (likely in the annotations part) is expecting your happening class to follow standard Java naming conventions - all classes start with a capital letter.

Try renaming your base class to Happening (capital H) and see if the problem goes away...

_________________
nathan


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 07, 2005 3:43 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
Make sure Happening is not mapped more than once in hibernate.cfg.xml, make sure hibernate.cfg.xml is not being loaded more than once.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 08, 2005 3:55 am 
Newbie

Joined: Mon Nov 07, 2005 8:51 am
Posts: 4
nathanmoon wrote:
Try renaming your base class to Happening (capital H) and see if the problem goes away...


I've renamed the class with a capital, but still i get the error...

My hibernate.cfg.xml his mapping classes are:

Code:
<mapping class="com.hodori.model.Happening"/>
<mapping class="com.hodori.model.Activity"/>
<mapping class="com.hodori.model.ActivityWithCard"/>
<mapping class="com.hodori.model.Exam"/>


Could this been seen as duplicates ? How can you check the time of loading hibernate.cfg.xml ? In my Junit TestCase i only make one configuration (= annotationconfiguration) and one sessionfactory (configuration.configure.buildSessionFactory).

Many thanks allready

El_Homer

_________________
I think i just pulled a Homer !


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 7:13 am 
Newbie

Joined: Mon Nov 07, 2005 8:51 am
Posts: 4
Is it needed/mandatory to repeat the classes that extend of the superclass ? Or can you leave the superclass behind in the hibernate.cfg.xml ?

_________________
I think i just pulled a Homer !


Top
 Profile  
 
 Post subject: Fixed
PostPosted: Wed Nov 09, 2005 2:01 pm 
Newbie

Joined: Mon Nov 07, 2005 8:51 am
Posts: 4
Hey everybody,

I've been able to fix my problem with the JOINED method.

Tnx anyway for your reply's.

Greetzzz,

El_Homer

_________________
I think i just pulled a Homer !


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