0

我试图在命名查询中调用一个函数,但我得到:

java.lang.IllegalStateException: No data type for node:     org.hibernate.hql.ast.tree.MethodNode 
 \-[METHOD_CALL] MethodNode: '('
    +-[METHOD_NAME] IdentNode: 'MYFUNCTION' {originalText=MYFUNCTION}
    \-[EXPR_LIST] SqlNode: 'exprList'
       \-[NUM_INT] LiteralNode: '1'

我的查询类似于

@NamedQuery(name = "myQuery",
            query = " select r, MYFUNCTION(r.id) from ResPO r "
                + " where  r.status like 'A'")

如果我简化查询,一切正常:

@NamedQuery(name = "myQuery",
        query = " select r from ResPO r "
            + " where  r.status like 'A'")

错误是什么?谢谢++

4

1 回答 1

1

您可以通过扩展您正在使用的方言并通过调用该registerFunction()方法来注册您的功能来做到这一点。

http://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/dialect/Dialect.html#registerFunction%28java.lang.String,%20org.hibernate.dialect.function.SQLFunction%29

于 2012-06-01T20:16:09.760 回答