jooq 从 Postgres 程序生成未编译的代码

jooq generates not compiled code from Postgres procedures

现在我正在尝试在同时与 2 个数据库通信的新版本程序中使用 JOOQ。但是问题来自 Postgres 程序,我无法停用 Routine generation cannot be deactivated 的原因,即使我的程序中不需要它们。

问题 1

Jooq 了解一些表格之类的程序。我不是 SQL 的专家,所以我不知道为什么会这样,也许是程序 return 类型的原因?用于生成具有此 "bug":

的过程之一的代码
CREATE OR REPLACE FUNCTION dblink_get_notify(IN conname text, OUT notify_name text, OUT be_pid integer, OUT extra text)
  RETURNS SETOF record AS
'$libdir/dblink', 'dblink_get_notify'
  LANGUAGE c VOLATILE STRICT
  COST 1
  ROWS 1000;
ALTER FUNCTION dblink_get_notify(text)
  OWNER TO postgres;

可能问题的原因是存在另一个具有相同名称但没有 IN 参数的过程:

    CREATE OR REPLACE FUNCTION dblink_get_notify(OUT notify_name text, OUT be_pid integer, OUT extra text)
  RETURNS SETOF record AS
'$libdir/dblink', 'dblink_get_notify'
  LANGUAGE c VOLATILE STRICT
  COST 1
  ROWS 1000;
ALTER FUNCTION dblink_get_notify()
  OWNER TO postgres;

问题2

一些从过程中生成的 classes 有编译错误(上面的过程也有这个错误

我再举个例子:

    CREATE OR REPLACE FUNCTION bt_page_stats(IN relname text, IN blkno integer, OUT blkno integer, OUT type "char", OUT live_items integer,
OUT dead_items integer, OUT avg_item_size integer, OUT page_size integer, OUT free_size integer, OUT btpo_prev integer,
OUT btpo_next integer, OUT btpo integer, OUT btpo_flags integer)
  RETURNS record AS '$libdir/pageinspect', 'bt_page_stats'
  LANGUAGE c VOLATILE STRICT
  COST 1;
ALTER FUNCTION bt_page_stats(text, integer)
  OWNER TO postgres;

JOOQ 将此过程理解为例行程序。但是生成的代码有两次相同的 Parameter<Integer> BLKNO 字段。我发现 strange 是 class:

的构造函数
/**
 * Create a new routine call instance
 */
public BtPageStats() {
    super("bt_page_stats", Public.PUBLIC);

    addInParameter(RELNAME);
    addInOutParameter(BLKNO);
    addInOutParameter(BLKNO);
    addOutParameter(TYPE);
    addOutParameter(LIVE_ITEMS);
    addOutParameter(DEAD_ITEMS);
    addOutParameter(AVG_ITEM_SIZE);
    addOutParameter(PAGE_SIZE);
    addOutParameter(FREE_SIZE);
    addOutParameter(BTPO_PREV);
    addOutParameter(BTPO_NEXT);
    addOutParameter(BTPO);
    addOutParameter(BTPO_FLAGS);
}

看double addOutParameter(BLKNO)!

哇哦,就这些吧。希望你能帮我解决这些问题:)

您 运行 遇到了错误 #4055。从 jOOQ 3.6 开始,重载的 table 值函数生成无法编译的代码。

But problem is coming from Postgres procedures which I cant deactivate cause of Routine generation cannot be deactivated, even if I don't need them in my program.

的确如此,但您可以通过名称明确地将它们从代码生成器中排除,例如通过指定:

<excludes>dblink_get_notify|bt_page_stats</excludes>

More info about the code generator configuration can be found here