I have tree of classes:
classA {
classB b;
classC c;
.....
}
I have HQL query like this:
SELECT a.field1, b.field2, c.field3, c.field4
FROM a LEFT OUTER JOIN b ON a.id = b.fk
LEFT OUTER JOIN c ON b.id = c.fk
This query returns List<Object[]>.
Is it possible to cast the returned data to the following class:
classD {
Type1 fiedl1;
Type2 field2;
Type3 field3;
}
So can casting be made by Hibernate or I need manually do all casting?
There are different types of selects in JPA queries. You are currently using Array as a return type, what you need is Construct return type. Here is how to achieve this:
Basically there are two things:
Read more on selects in JPA2 queries.