I have a full-text search query that I'm writing for SQL Server 2000. Since I need to use the CONTAINS operator, I decided to write a native SQL query. At the same time, I want to page through the results, so I am using the setMaxResults method of the Query object. My code looks like this -
Code:
Query query = sess.getNamedQuery(queryStr);
query.setMaxResults(pgSize);
What happens though, is the SQL Query created fails - the error message is -
Code:
18:06:42,953 ERROR [JDBCExceptionReporter] Incorrect syntax near the keyword 'top'.
And the statement generated by the log looks something like this -
Code:
top 26
SELECT
<some vars>
FROM <some tables>
WHERE <some condition>
The way SQL Server expects top to be used is something like
Code:
SELECT top (some stuff)
So I'm assuming Hibernate (version 2.x) is generating the wrong Statement. Am I stuck here? Or is there some workaround tht I haven't thought of?[/code]