【问题标题】:Not able to call pg_advisory_lock function in Postgres using jooq无法使用 jooq 在 Postgres 中调用 pg_advisory_lock 函数
【发布时间】:2017-01-08 14:44:09
【问题描述】:

我正在尝试使用 JOOQ 调用管理功能 pg_catalog.pg_advisory_unlock。我可以通过在我的 gradle 构建文件中生成该函数的模型:

schemata {
    schema {
        inputSchema = "public"
    }
    schema {
        inputSchema = "pg_catalog"
    }
    includes = "public.*|pg_catalog.pg_advisory_lock"
}

文件pg_catalog>Routines.java 有一个方法 public static void pgAdvisoryLock1(Configuration configuration, Long __1) 我这样称呼它:

Connection connection = DatabaseService.getInstance().getConnection("sampleUser");
    Settings settings = new Settings()
        .withRenderMapping(new RenderMapping()
            .withSchemata(
                new MappedSchema().withInput("shard_0")
                    .withOutput("shard_1")));
    DSLContext create = DSL.using(connection, settings);

    Long param = 1l;
    pgAdvisoryLock1(create.configuration(), param);

我得到错误:

Exception in thread "main" org.jooq.exception.DataAccessException: SQL [select * from "pg_catalog"."pg_advisory_lock"("_1" := ?)]; ERROR: function pg_catalog.pg_advisory_lock(_1 => bigint) does not exist
  Hint: No function matches the given name and argument types. You might need to add explicit type casts.

不胜感激。谢谢!

编辑:再想一想,我想我记得在某处读到 JOOQ 在 postgres 函数中存在非命名参数的问题。想知道这是否与此有关。由于它是一个管理内置函数,我无法将非命名参数更改为命名参数。我正在使用 3.6.2 版的 JOOQ(主要是因为我正在使用这个 gradle 插件(https://github.com/etiennestuder/gradle-jooq-plugin),我认为它正在使用该版本的 JOOQ。不确定新版本的 JOOQ 是否已修复。

【问题讨论】:

    标签: java jooq


    【解决方案1】:

    确实,此问题已在此期间修复。

    此插件中对特定 jOOQ 版本的硬连线依赖是一个已知问题 (https://github.com/etiennestuder/gradle-jooq-plugin/pull/14),我希望很快能解决这个问题。

    【讨论】:

    • 谢谢 Lukas,非常感谢!
    猜你喜欢
    • 2017-01-24
    • 2017-09-02
    • 2021-08-28
    • 2017-02-08
    • 2018-06-29
    • 1970-01-01
    • 2021-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多