Your search for the parent table will automatically bring the daughter tables regardless of your query.
Why? The framework (say Hibernate) does not know if you, after taking the parent entity, will want to do (or try) a cast for some of the daughter entities, so he already cautions of this situation.
If you ask to display the SQL of this query, you will see that the child tables will also be in the query through a LEFT JOIN
. Something like that, if you’re using JOIN table for inheritance:
SELECT ocr.*, ocra.*,ocrb.* FROM OCR ocr
LEFT JOIN OCR_A ocra ON ocra.id = ocr.id
LEFT JOIN OCR_B ocrb ON ocrb.id = ocr.id
If you’re using strategy SINGLE table, all information is in the same table, then you will see in SQL only one table:
SELECT ocr.* FROM OCR ocr