In my current project I need to perform a few native queries which pick some fields from tables joined in the query e.g.:
SELECT t1.col1, t2.col5
FROM t1
JOIN t2 ON t2.id = t1.t2_id
I tried to store them in a class like
class Result {
String t1_col1;
String t2_col5;
}
using
Query q = entityManager.createNativeQuery( "THE SQL SELECT" , Result.class );
JPA now complains ("uknown entity: result") that the class 'result' isn't an entity which is probably required to map the columns into the object.
I also tried to repeat the @Column
declarations in the result class.
My question is how can I declare this without having to create the entites represented as tables in my DB?