Say that I want to do a select from 2 databases. Database1 has fields A, B and C. Database2 has fields D, E and F. I have a POJO that consists of fields X, Y and Z. I want to write a CriteriaBuilder query to select all of the B, D and F fields in the result set and map them to the fields X, Y and Z in my POJO, returning a list of my POJO objects. Is this possible? I can do this with a native query, but I don’t want to use native queries.
Share
You can try using the below query to return a entity initialized by other entities :
Then you have to provide a constructor with similar signature as in query, where you can set the field values as required.