• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JPQL

 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. Select o
2. From Order o
3. Where o.qty>50
4. ORDER BY o.item

I thought removing removing line 4. would make it valid query, my logic is o.item is not part of select statement (first line).

Is it correct?


Thanks.
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the query expression is valid as it is ('select o' contains each state field and single value assocation field since it is resolved by the persistence provider like 'select o.name, o.item, o.price, ... from order o ...').
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To use GROUP BY we need to mention field name in Select clause,
don't we need to follow same rule for ORDER BY.

Am I correct?

Thanks.
 
Ralph Jaus
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From JPA spec 4.9 (order by):

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
2. a single_valued_path_expression
3. a state_field_path_expression


So you can use identifaction variables without causing problems (see also the ORDER BY examples in the quoted JPA reference).
reply
    Bookmark Topic Watch Topic
  • New Topic