Your search for the parent table will automatically bring up the child tables regardless of your query.
For what reason? The framework (let's say Hibernate) does not know if you, after picking up the parent entity, will want to (or try) a cast for some of the child entities, so he's already wary of this.
If you ask to display the SQL of this query, you will see that the child tables will also be in the query by a LEFT JOIN
. Something like that, if you are using the JOIN table strategy 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 are using the SINGLE table strategy, all information is in the same table, so you will see in SQL only one table:
SELECT ocr.* FROM OCR ocr