Reputation: 57
I have a JPA wrapper like this:
public Wrapper(Object object, List<Bla> bla) {...
And i want to do a select to fill that wrapper.
SELECT new Wrapper(object, bla) FROM Object object...
But 'bla' is a list returned by a select like this:
SELECT bla FROM Bla bla WHERE bla.object = object
How can i fill the wrapper?
Thanks.
Upvotes: 2
Views: 2023
Reputation: 19002
You cannot do that, as the constructor is expected to have only simple types (no collections). The solution is to make two queries and construct the entities manually.
According to the JPA specification the elements in the constructor (called constructor_item) may be:
constructor_item ::=
single_valued_path_expression |
scalar_expression |
aggregate_expression |
identification_variable
Upvotes: 2