• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing Inheritance with Hibernate...

 
Joshua White
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
[ August 31, 2004: Message edited by: Joshua White ]
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I get it from the official ref there is no need to have a such a field in the AbstractCat (the value of this field will be the one declared for each subclass in discriminator-value attribute).
 
Gavin King
author
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The discriminator value can be determined by the class, so no, there is no need for a discriminator property.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<subclass> tag

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic