My Query in java:
QUERY_STRING = "select a.seqNum,a.eventId,a.srcAddress,a.srcUser,REPLACE(a.message,',',' ') as message,a.createdTime,a.type,a.networkGroupName from Fraud a";
获取异常如下:
04:38:55,193 ERROR AppEntityManager:90 - java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.MethodNode
+-[METHOD_CALL] MethodNode: '('
| +-[METHOD_NAME] IdentNode: 'REPLACE' {originalText=REPLACE}
| -[EXPR_LIST] SqlNode: 'exprList'
| +-[DOT] DotNode: 'fraud0_.MESSAGE' {propertyName=message,dereferenceType=4,propertyPath=message,path=a.message,tableAlias=fraud0_,className=com.redshift.mgmt.entity.Fraud,classAlias=a}
| | +-[ALIAS_REF] IdentNode: 'fraud0_.ALERT_ID' {alias=a, className=com.redshift.mgmt.entity.Fraud, tableAlias=fraud0_}
| | -[IDENT] IdentNode: 'message' {originalText=message}
| +-[QUOTED_STRING] LiteralNode: '',''
| -[QUOTED_STRING] LiteralNode: '' ''
Hibernate不知道replace函数,因此它也不知道用于从JDBC检索结果的结果类型。要么用你的方言注册函数,要么在:CAST(REPLACE(a.message,',',' ') as java.lang.String)