• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inheritance mapping

 
nelson christos
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic