• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Implementing Inheritance with Hibernate...

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
author
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The discriminator value can be determined by the class, so no, there is no need for a discriminator property.
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<subclass> tag

 
reply
    Bookmark Topic Watch Topic
  • New Topic