Hi,
I am using Hibernate 3 with SQL Server 2000.
On one of the screens in my application, the User can sort by clicking on any of the column headers on the displayed table. One of the columns is of the type "ntext" in the database. I am appending and forming the HQL on runtime based on the User input to sort the result set
String getCompleteList = "from Ktp ktp left join ktp.ktpContact contact ORDER BY ";
StringBuffer queryString = new StringBuffer(getCompleteList);
//When the User clicks on the column in question, cast it to varchar
if("ktp.column2".equalsIgnoreCase(sortColumn))
{
sortColumn = "cast(ktp.column2 as varchar(8000))";
}
queryString.append(sortColumn);
queryString.append(" ");
queryString.append(" DESC ");
query = session.createQuery(queryString.toString());
result = query.list();
tx.commit();
However, I get the following error when I execute the above code. Any help is greatly appreciated.
SystemOut O QUERY IS from Ktp ktp left join ktp.ktpContact contact ORDER BY cast(ktp.column2 as varchar(8000)) DESC
00000044 PARSER E org.hibernate.hql.ast.ErrorCounter reportError line 1:178: expecting CLOSE, found '('
00000044 HqlParser W org.hibernate.hql.ast.HqlParser processEqualityExpression processEqualityExpression() : No expression to process!
|