Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPA and aggregate functions. How do I retrieve the query result?

822327May 26 2011 — edited Jun 30 2011
I read the documentation, there's JPQL Constructor Expressions:

for example:

SELECT new com.yourproject.ResultHolder(insp, COUNT(test.testId))
FROM Inspection insp LEFT JOIN insp.testList AS test GROUP BY insp.inspId

OR:

SELECT new list(insp, COUNT(test.testId))
FROM Inspection insp LEFT JOIN insp.testList AS test GROUP BY insp.inspId

Now how do we process the query result from here? (I couldn't find anywhere in the documentation)

Is it like the following (the select statement above, is it supposed to be lowercase "list" as a variable or uppercase "List" as the type)?

List list = (List)selectQuery.getSingleResult();
Inspection insp = (Inspection)list.get(0);
int count = list.get(1);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 28 2011
Added on May 26 2011
13 comments
2,306 views