aspose file tools*
The moose likes Object Relational Mapping and the fly likes Finding the Max of Select Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Finding the Max of Select Query" Watch "Finding the Max of Select Query" New topic
Author

Finding the Max of Select Query

Skanda Siva
Greenhorn

Joined: Jul 29, 2013
Posts: 5
I am new developer for JPA and have a assignment to write the retrieve records from database using JPQL. Below is my Query. Basically I am trying to find the max of field1 from table Z



While Executing this query I am getting the error as below



Please Advise. When I am running the query using normal sql, its working fine.

When I tried removing the SELECT Query from the MAX and do something like MAX(somefield), it is working fine. Do you think if there are issues with the Syntax? Please let me know

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30548
    
152

That query is complicated enough that it is hard to tell what is wrong. Can you try a simpler one and build up to where the error shows up?

For example, getting this working shows you know how to use an aggregate query/group by.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Skanda Siva
Greenhorn

Joined: Jul 29, 2013
Posts: 5
As I mentioned in my post, when I try query with Max(some field), its working fine. Error seems to be only when there is select statement in Max query. I tried NVL also to return ZERO in case if there are No records, but the error seems to still exist.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30548
    
152

Sorry, I missed that. This post says that it might not be supported by your JPA provider.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Finding the Max of Select Query