-->
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.  [ 5 posts ] 
Author Message
 Post subject: Implementing Inheritance
PostPosted: Tue Aug 31, 2004 12:03 pm 
Beginner
Beginner

Joined: Wed May 12, 2004 2:52 pm
Posts: 36
I have read through the Hibernate documentation regarding Inheritance. It is unclear however if the column name that is used as the discriminator also needs to be a member of the class. Because the class type can be determined by this discriminator and vice versa, I am not sure it should be needed. Could someone please clarify this for me?

For example, if I have the following tables:

CAT
--------------------
cat_id
cat_type_id
cat_name

CAT_TYPE
--------------------
cat_type_id
cat_type_name ex. Bengal, Persian, Siamese etc


If I created an abstract class "Cat", would I need to have "cat_type_id" as a member variable (so that it would be inherited by the different types)?

Regards,

Joshua


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 31, 2004 4:49 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
The descriminator field must be defined in your base class (afaik).

Look at http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-discriminator

and

http://www.hibernate.org/hib_docs/reference/en/html/example-mappings.html#example-mappings-authorwork


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 31, 2004 5:43 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
the discriminator is a column which determines the type of the class, it doesn't have to be mapped to a class property

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 31, 2004 5:53 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
anthony wrote:
the discriminator is a column which determines the type of the class, it doesn't have to be mapped to a class property


True.. I should have written the discriminator should be defined in the mapping of your base class...


Top
 Profile  
 
 Post subject: Thanks!
PostPosted: Tue Aug 31, 2004 8:22 pm 
Beginner
Beginner

Joined: Wed May 12, 2004 2:52 pm
Posts: 36
Thanks for your help.

Joshua


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