• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA inheritance and entity classes

 
Vinay Taneja
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am new to JPA and trying to do some testing and practice. I have a very specific scenario, I have two entities as below
Person:
Mapped to person class as single table

Customer:
extends Person and fields specific to customer are stored in customer table however person related fields are stored in person class/table itself.

Now what I want is I don't want to describe a descriptor in person table as a person record in this table is complete itself to define a person however when i ask for a customer JPA should map person record in person table and fetch them in customer instance. As customer class extends person class it has all the fields.

What actually I want is a customer is anyway a person so by inheritance it gets all the fields of person. but because person is mapped to person table and it has all its persisting fields mapped to person table. When I try to load or save person object it tries to fetch dtype column (descriptor) but in actual when I try to fetch person i just need a person definition not its customer fields and a person can also be inherited by employee class or a normal person itself (no need to be customer or no need to be an employee).

Please help!
Regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic