Hi all,
I have a big class with multiple collections and other properties. Now I need to write a report query to efficiently return only the data I really need. Problem is that I haven't figured out any way how to return a collection from the report query.
For example I have class like this
Code:
class Test
Long id
String name
List list1
List list2
Set set1
and as a result of my report query I'd like to fill objects like this:
Code:
class TestInfo
Long id // Here would be the id of the Test
String name // Here would be the name of the Test
List list2 // Here would be the list2 of the Test
Now if I use a query like this
Code:
SELECT test.id, test.name, test.list2 FROM Test as test"
I get an error saying that elements() or indices() is expected.
When using elements() like this
Code:
SELECT test.id, test.name, elements(test.list2) FROM Test as test"
I don't get any errors and query is executed fine. Only problem is that I get multiple results for each Test instance I have in the DB because there is a new result for each item in list2. This means that I have to manually go though the results and create my TestInfo objects using hideous comparisons etc..
Is there any way I could write my query so that it would return me already initialized list and only as many results as I have Test instances in the DB?
Sincerely,
Jouni Hartikainen