I want to collect data from two tables (one-to-many relationship). In most cases for one record in first table there are two records in second.
In my case I want to filter records from second table.
Native SQL would look like this.
SELECT *
FROM X
JOIN Y ON X.id= Y.id
WHERE Y.specificField = 'value';
And the question is – what should I use – best practice in this case – native sql or rather use pure JPA with entity with added field (relation one to many).
Looks like in case jpa mapping all filtering will be done in my app not db – are there any tricks to do filtering when gathering data from two tables with entity usage ?