Hi All,
Im using Hibernate 3 and MS SQL 2005.
here is a code :
Criteria criteria = session.createCriteria(ZipdataEntity.class)
.setProjection(Projections.distinct(Projections.projectionList()
.add(Projections.property("city"), "city")
.add(Projections.property("state"), "state")
.add(Projections.property("zipcode"), "zipcode")))
.addOrder(Order.desc("city"))
.setFirstResult(1)
.setMaxResults(10);
Here i want only top 10 results.
The query generated by hibernate is :
Hibernate: select distinct this_.CITY as y0_, this_.STATE as y1_, this_.ZIPCODE as y2_ from zipdata this_ order by y0_ desc limit ?, ?
and im getting an exception as :
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: Incorrect syntax near 'limit'.
please let me know is there a different way when we tackle with MS SQL Server 2005 and criteria.setMaxResults()
Note: im using JDBC driver for SQL Server 2005 only.
Thanks in advance.
--Sidh
|