As shown in the picture, I need the last value of bookingID
column using hibernate in MySQL.
@SuppressWarnings("unchecked")
@Override
public Booking listBookingsID() {
Session session = this.sessionFactory.getCurrentSession();
Booking bookList = (Booking) session.createQuery("from Booking ORDER BY bookid DESC")
.setMaxResults(1).uniqueResult();
return bookList;
}
I tried that code which is found in this link, but it always shows as "9". If the last value is "1" then it should show as 1, but it's 9.
So my question is: "Are there any queries to get the last value of a column in hibernate?"