Help coderanch get a
new server
by contributing to the fundraiser
  • 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

inheritance mapping

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic