hi all,
I'm trying to retrieve of some hotels from the database with max(id). say the table is as follows:
Id Hotel Year Month values 1 3 2010 5 8 2 2 2010 6 10 3 4 2011 8 20 4 3 2011 3 16 5 1 2011 4 15 6 4 2011 8 23 7 3 2011 3 31
So lets say i want to get details of the hotels 3 and 4 where year = 2011 and month = 3 and 4 respectively. for queries, hotel no. is given.
so the result set would be: ID hotel year month values for hotel 3, out of 2 records : 7 3 2011 3 31 hotel 4, out of 2 records : 6 4 2011 8 23
following is the code i used:
Criteria criteria = session.createCriteria(cls); criteria.setProjection( Projections.max("decisionID") ) .add( Restrictions.like("year", year)) .add(Restrictions.like("month", month));
hotelList = criteria.list(); but this returns an empty list. note that ID is not given.
could anyone please explain what is wrong in this code.
thanks in advance.
|