Hi,
I'm using hibernate-2.1
and my relational DB is Microsoft SQL Server 2000 - 8.00.760.
When i used sql server specific functions like datepart and cast in the select clause of my hql, hibernate was throwing undefined alias error. To solve that, i extended the sqlserverdialect class and registered these functions as StandardSQLFunction.
Now these functions are working fine in my hql. But if i nest my functions, hibernate is not able to recognize it. Given below is the hql that i tried from console.
Hql is
select tbl0.pbxId, cast(datepart(mm,tbl0.callEndTs) as varchar) from com.sti.billing.CallDetail tbl0 where tbl0.callDetailRowId = 3953
and the error i'm getting is
1 errors occurred while listing (and calling getPathNames). net.sf.hibernate.exception.SQLGrammarException: Could not execute query java.sql.SQLException: Line 1: Incorrect syntax near 'asvarchar'.
Even though there is a space between 'as' and 'varchar' in my hql, when it is translated to sql, the space is getting removed.
I'm not facing this problem if i don't nest these functions. Also if i have these nested functions in my where clause, it is not creating any problem.
The problem occurs only in the select clause.
I have to get this working urgently.
Any help on this would be really appreciated.
Regards,
Kartikeya
|