• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

inheritance mapping

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a inheritance hierarchy like this

Employee
|
|__Assessee
|
|__Appraiser
|
|__Reviewer

and there is one table Employee representing all the information.
when i am trying to map Employee.hbm its saying that no discriminator
found for Assessee (single table per class). I am not sure whether to put a dcriminator column(Employee_Type) in database because the type might change at runtime. Is there a other way to do it without discriminator.

Thanks
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tell me if I have this correct.

In the database you have only one table to store all the employee data of all three types.

So in that table, if I look at a row, how do I know which type of employee that row is? That is what hibernate needs to know in order to accurately create instance of the three subtypes. If it isn't there and you are using that inheritence strategy then there is going to be a problem.

You also mention something about runtime changing of types. So youa re saying that if you create an Appraiser object, later in runtime that object type will change to be a Reviewer object?

Mark
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic