I asked a similar question to this, but I didn't provide good details, so I am re-asking the question with better details.
I have 2 tables that look like this:
Table1
A
B
C
PK
Table2
D
E
F
PK
These 2 tables have JPA entities associated with them as follows (I'm leaving out the annotations for brevity):
Entity1
{
String a;
String b;
String c;
int PK;
}
Entity2
{
String d;
String e;
String f;
int PK;
}
I also have a simple POJO that I am using (not mapped to any table) as follows:
MyPOJO
{
String x;
String y;
String z;
}
I currently am using JPA's native SQL functionality to return a result set of type List and the query looks something like this:
SELECT A as x, D as y, F as z from Table1, Table2 WHERE Table1.PK = Table2.PK
My question is, can I do this using CriteriaBuilder? If so, how? I am trying to stay away from native queries. I am using OpenJPA, if that makes any difference.