Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How to access the object created in a select clause with constructor in an order by? (JPQL)
How to access the object created in a select clause with constructor in an order by? [message #520639] Sat, 13 March 2010 11:10 Go to previous message
Daniel Le Berre is currently offline 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?
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:ValueHolder eats memory
Next Topic:How to handle Oracle Store Procedure call with Oracle Types as input or output using EclipseLink
Goto Forum:
  


Current Time: Wed May 22 18:20:43 EDT 2013

Powered by FUDForum. Page generated in 0.01630 seconds