Hibernate HQL - 将NTEXT转换为NVARCHAR以获取GROUP BY

时间:2012-01-18 17:03:10

标签: sql-server hibernate hql nvarchar ntext

我在使用Hibernate HQL的SQL Server查询上运行组时遇到一些问题。相关表格包含NTEXT列。请注意两个CONVERT字段...

然而,Hibernate对此嗤之以鼻。关于如何最好地将其传递给Hibernate层的任何建议?

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) 

错误讯息:

[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 个答案:

没有答案