• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPQL: SELECT queries and field aliases.

 
Avor Nadal
Ranch Hand
Posts: 151
Java Netbeans IDE Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!:

I've a very simple question. I've been re-reading "The Java EE 6 Tutorial", specifically the section about the Java Persistence Query Language (JPQL). I've got surprised to see no mention about the use of aliases for entity fields on SELECT queries. It only mentions aliases for entity names.

Although I know that field aliases are perfectly valid on several JPQL implementations (indeed I'm using them on JBoss AS 5/6), Aren't they supported by the official JPQL specification? Or is it only that the tutorial forgot to comment about them? If it's the former, I can't understand the reason for this decision, because many complex queries which make use of the ORDER BY clause need alias references.

Thanks a lot for your help.
 
James Sutherland
Ranch Hand
Posts: 553
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was added in JPA 2.0 using the AS keyword,



See,
http://en.wikibooks.org/wiki/Java_Persistence/JPQL_BNF#New_in_JPA_2.0
 
Avor Nadal
Ranch Hand
Posts: 151
Java Netbeans IDE Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James Sutherland: Very interesting. Thank you a lot. I have been looking for a list of the new features of JPA 2.0 for a long time .

PS: Oracle should update the tutorial.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic