-->
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.  [ 4 posts ] 
Author Message
 Post subject: mapping subclasses of an abstract class using joined-subclas
PostPosted: Wed Jan 14, 2004 11:28 pm 
Newbie

Joined: Wed Jan 14, 2004 4:44 pm
Posts: 13
Location: Wellington, New Zealand
Hi

I have an abstract super class that does not have a table, and two subclasses that do have tables. Is it possible to map this, or do I *have* to have a table for the abstract class (and use the same table for the subclasses)?

Is there any way to map without a table for the abstract class, and two tables for the subclasses?

Let me know if I need to explain more.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 7:35 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You can do that, this is the table-per-concrete-class strategy.

Just map the subclass as classical classes.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 3:24 pm 
Newbie

Joined: Wed Jan 14, 2004 4:44 pm
Posts: 13
Location: Wellington, New Zealand
But I get this exception:

Exception building SessionFactory: Association references unmapped class: nz.govt.msd.inet.HR.HRExit.InterviewQuestion

because the class I am currently persisting has a member variable which is a Set whose contents are the type of the abstract base class.

eg:

Classes:

public abstract class InterviewQuestions { ... }

public class ReasonIntQues extends InterviewQuestions { ... }

public class GenericIntQues extends InterviewQuestions { ... }

public class ExitInterview {
private Set interviewQuestions;
...
}

mapping:

<class name="ExitInterview" table="Exit_Interviews">
...
<set name="interviewQuestions" lazy="true">
<key column="ID"/>
<one-to-many class="InterviewQuestion"/>
</set>
</class>

I have mappings for ReasonIntQues and GenericIntQues, because I have tables for them, but I have no mapping for InterviewQuestions, because the mapping seems to require a table (or default to one)

What am I doing wrong? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 15, 2004 3:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You need to use many-to-any and any mappings if you have a reference to the unmapped abstract class. See http://www.hibernate.org/hib_docs/reference/html/inheritance.html


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