0

环境 - JavaSE 6、Oracle 11、WebSphere 7、eclipseLink 2.5.2

用例 我们想使用

@NamedPLSQLStoredFunctionQuery

像这样:

@NamedPLSQLStoredFunctionQuery
   (name = "convertToString",
    functionName = "my_schema.my_package.convert_to_string",
    parameters =
      { @PLSQLParameter(name = "p_boolean", databaseType = "BOOLEAN") },
        returnParameter = @PLSQLParameter(name = "RESULT", databaseType = "VARCHAR_TYPE"))

然后我们执行如下函数:

Query query = em.createNamedQuery("convertToString");
        query.setParameter("p_boolean", true);
        Object result = query.getSingleResult();
        System.out.println("result=" + result);

和/或

Query query = em.createNamedQuery("convertToInteger");
        query.setParameter("p_boolean", true);
        Object result = query.getSingleResult();
        System.out.println("result=" + result);

我们的Oracle函数实现如下:

CREATE OR REPLACE package body my_schema.my_package
as
    /**
    * Converts the given boolean into an integer (true: 1, false: 0).
    * @param p_boolean boolean value to convert to an integer
    */
    function convert_to_integer
    (
        p_boolean   in boolean
    )
        return integer
    is
    begin
        if (p_boolean = true) then
            return isac_api.api_boolean_constants_pg.integer_true;
        end if;

        return isac_api.api_boolean_constants_pg.integer_false;
    end;

    /**
    * Converts the given boolean into a string (true: 'true', false: 'false').
    * @param p_boolean boolean value to convert
    */
    function convert_to_string
    (
        p_boolean   in boolean
    )
        return varchar2
    is
    begin
        if (p_boolean = true) then
            return isac_api.api_boolean_constants_pg.string_true;
        end if;

        return isac_api.api_boolean_constants_pg.string_false;
    end;
end;

它真的不起作用。

问题

  • 问题是什么?
  • 如果不允许我们在数据库上安装“SYS.SQLJUTL”但 eclipseLink 似乎使用它进行转换,我们该怎么办?

问候简

4

0 回答 0