Hibernate HQL - casting NTEXT to NVARCHAR for a GROUP BY

784 Views Asked by At

I'm having some problems running a group by on a SQL Server query using Hibernate HQL. The table in question has NTEXT columns. Note the two CONVERT fields...

However, Hibernate chokes on this. Any suggestions on how best to pass this through to the Hibernate layer?

SELECT     CONVERT(NVARCHAR(4000), A.DESCRIPTION),
           CONVERT(NVARCHAR(4000), A.NEWS),
           ....
FROM       ACCOUNT A
           INNER JOIN A
           ...
GROUP BY   CONVERT(NVARCHAR(4000), A.DESCRIPTION ),
           CONVERT(NVARCHAR(4000), A.NEWS) 

Error message:

[16:45:12.067] uncaught ERROR: No data type for node: org.hibernate.hql.ast.tree.MethodNode 
 +-[METHOD_CALL] MethodNode: '('
 |  +-[METHOD_NAME] IdentNode: 'convert' {originalText=convert}
 |  \-[EXPR_LIST] SqlNode: 'exprList'
 |     +-[METHOD_CALL] MethodNode: '('
 |     |  +-[METHOD_NAME] IdentNode: 'nvarchar' {originalText=nvarchar}
 |     |  \-[EXPR_LIST] SqlNode: 'exprList'
 |     |     \-[NUM_INT] LiteralNode: '4000'
 |     \-[DOT] DotNode: 'account0_.Description' {propertyName=description,dereferenceType=ALL,propertyPath=description,path=a.description,tableAlias=account0_,className=classAlias=a}
 |        +-[ALIAS_REF] IdentNode: 'account0_.AccountID' {alias=a, className=com.recruitni.model.Account, tableAlias=account0_}
 |        \-[IDENT] IdentNode: 'description' {originalText=description}
0

There are 0 best solutions below