How to access the object created in a select clause with constructor in an order by? [message #520639] |
Sat, 13 March 2010 16:10 |
Daniel Le Berre Messages: 82 Registered: July 2009 |
Member |
|
|
I have the following JPQL query that works fine:
"SELECT interest, COUNT(contact) AS nbContacts " +
"FROM SocialEntity soc, IN(soc.contacts) contact, " +
"IN(contact.interests) interest " +
"WHERE soc = :socialEntity AND interest NOT MEMBER OF soc.interests " +
"GROUP BY interest ORDER BY nbContacts DESC")
The problem is that the result of my query is a list of array of objects.
I would like to create new objects MyResult to have a list of MyResult using a TypedQuery:
"SELECT new path.to.MyResult(interest, COUNT(contact)) AS result " +
"FROM SocialEntity soc, IN(soc.contacts) contact, " +
"IN(contact.interests) interest " +
"WHERE soc = :socialEntity AND interest NOT MEMBER OF soc.interests " +
"GROUP BY interest ORDER BY result.count DESC",MyResult.class)
Unfortunately, it looks like it is not possible to access result in the ORDER BY:
invalid navigation expression [result.count], cannot navigate expression [result] of type [null] inside a query.
I cannot find in JPA 2.0 spec how to access the objects created in the SELECT clause.
Does anyone know how to do this?
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03519 seconds