Inheriting sleep mode with existing tables

I have two existing tables in my database. Name them Table and Chair . Both of these tables display as objects in Hibernate.

Both of these tables have already existed in my database for some time, and they have their own, automatically generated identifier as primary keys.

Now, however, I want to group these objects under the very logical interface Furniture in my Java code so that I have a list in the House class .

I studied the inheritance of Hibernate, but did not seem to understand this. How can I let House class get a list of all the Furniture he owns? And which inheritance mapping strategy should be used?

Thanks Bart

+3
source share
1 answer

You are on the right track. If you are creating a Furniture interface or a base class, as well as a Table and Chair, implementing / expanding this type, you should be good to go. Then you can have

List<Furniture> 

for your home.

, , - , .

  • / ( ). . , . "", .

  • , / /, . . ( )

  • .

1 hibernate docs, .

- / - , .

JUnit .

+1

Source: https://habr.com/ru/post/1758203/


All Articles