I have a date object in the bean class called "dateTime" which contains both date and time. When I list the records of that bean class I am saying
criteria.addOrder(Order.desc("dateTime"));
This will sort based on date as well as the time. But I want the sorting only based on date not by time. Is there a way to do this in hibernate?
I am using PostgreSQL as well as SqlServer database. In postgreSQL,
criteria.addOrder(Order.desc("dateTime")); is equivalent to the SQL query "... ORDER BY dateTime desc;"
if I change my SQL query to "... ORDER BY to_char(dateTime, 'MM-DD-YYYY') desc;" I am getting the expected result. Is there an equivalent of this query in hibernate which I can use instead?
|