Home » Java » Java Database Entity Inheritance-Exceptionshub

Java Database Entity Inheritance-Exceptionshub

Posted by: admin February 23, 2020 Leave a comment

Questions:

In my database, I have 2 table is Categories and Products.
The Products table has a reference key references to CategoryId in the Categories table.
And in my Java Project, I have 2 entities: Category and Product.
So I wonder does the Product class have to extends Category class?

How to&Answers:

In your case you need to add Category like a attribut in your Product Class.
You can add a list of Product in your Category class for biderctionnal relation.