Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Query won't give me the Integer value

 
Dave Elwood
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a JavaEE6 app using NetBeans and persisting the entities on Glassfish
I've got a table of rooms with the Entity Room class to access the data.
The primary key is room_id and I need to find the last value used in order to bump up
the value and then insert a new room record.

So...in order to find the last value used I have a named query which calls the aggregate function MAX

In the session bean I fetch the value this way

Is there a member function of the Query object which returns the value MAX(r.roomId) ??
Something like :

this is what the whole Entity class looks like
 
Jayesh A Lalwani
Rancher
Pie
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say, "doesn't work", what error do you get? Is it a compilation error? Is it a runtime error?
 
Dave Elwood
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It compiles and runs, but there are three records, and the last record has room_id = 3 but this returns a value of 0
when I use

then I get a value of 2147483647

How do I get it to show me the value of 3??
 
Sameer Mali
Greenhorn
Posts: 2
Java Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try using
 
Dave Elwood
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Sameer, now it works like a charm.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic