File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Allowed ORDER BY fields question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Allowed ORDER BY fields question" Watch "Allowed ORDER BY fields question" New topic
Author

Allowed ORDER BY fields question

Tomaszz Lewandowski
Ranch Hand

Joined: Sep 07, 2007
Posts: 30
Hello,

In paragraph 4.9 of persistence spec. it is said that:

When the ORDER BY clause is used in a query, each element of the SELECT clause of the query must be one of the following:
1. an identification variable x, optionally denoted as OBJECT(x)
2. a single_valued_association_path_expression
3. a state_field_path_expression
In the first two cases, each orderby_item must be an orderable state-field of the entity abstract schema type value returned by the SELECT clause. In the third case,the orderby_item must evaluate to the same state-field of the same entity abstract schema type as the state_field_path_expression in the SELECT clause.


In "Pro EJB 3 Java Persistence API" (chapter 7) there is an example of, in my opinion, incorrect query:

SELECT e
FROM Employee e JOIN e.department d
ORDER BY d.name, e.name DESC

because, d.name isn't listed in select clause.

But this query works perfect on Toplink Essentials. Am I misunderstanding the spec or is it a bug/feature of Toplink Essentials?


Regards<br />Tomasz Lewandowski<br />SCJP5 (97%) | SCWCD5 (98%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Allowed ORDER BY fields question