Total Pageviews

Tuesday 20 March 2012

How to get max value for identity column in EJB-QL

For example,
I have a table Bookorder  with an Identity column Id.

I can execute the following:
Query query1 = em.createQuery("SELECT MAX(b.id) FROM Bookorder b");       
int bo_max=(Integer)query1.getSingleResult();

Please notice that it's Integer and not int when casting the result of query.

No comments:

Post a Comment