Good day. enter image description here

There is such a set of tables. By default, using SQL, you can select all "services" with all their specific attributes using select union, (simplified)

SELECT common_attr1 as AA, common_attr2 as BB, specific_attr2 CC FROM Service INNER JOIN Specific_service1 ON id_Service WHERE ID_ = ... UNION SELECT common_attr1 as AA, specific_attr4 as BB, specific_attr5 CC FROM Service INNER JOIN Specific_service2 ON id_Service WHERE ID_ = ... UNION SELECT ... 

How to add / modify data using native SQL is clear.

But the project actively uses Hibernate. There is no directly Union in Hibernate.

Accordingly, the question is: How can I use an Hibernate to create an Entity capable of implementing such samples? What options are there? Maybe pre-do View in the database? Maybe there are useful links with a description of solving such problems? He himself has not yet found the information.

  • one
    To be honest, in such situations, I walked along a simple path and created a view. After that I simply created 'Entity' for it as for a table. - Riĥard Brugekĥaim

0