Mixing table for each subclass and for the hibernate hierarchy
There are two three tables in my database. The first, table ABSTRACT, contains three columns
id, type, someText
This table contains all the abstract information for an abstract abstract class. The two tables CONCRETEONE and CONCRETETWO now contain all the information for the specific classes specificOne and concreteTwo. Now I know I can use a table for each subclassing strategy from hibernate to create an inheritance mapping. But since I have a column denoting the type of a specific implementation, is it possible to create mixed behavior, such as a table for each subclass strategy with a discriminator?
a source to share
Hibernate inheritance mapping strategies should be chosen based on database design.
If you are unable to redesign your database, then stick to the best strategy for your current database design. those. a table for each subclass strategy.
If you can change the database design, forget about Hibernate first, focus on which database table design is best for your application. Some factors to consider a) How will the data be extracted / used? For example, if in most cases the logic is not related to the differentiation of CONCRETEONE and CONCRETETWO, then there is no point in looking for subelements. b) How many additional columns are required for CONCRETE and CONCRETE? If you have so many columns belonging to subcategories, then "Table in Hierarchy Class" is not a good idea. c) Columns related to auxiliary tables must not be "NOT-NULL".
Hope this helps.
a source to share