postgresql - Jooq 无法从数据库找到我的公共(public)模式

标签 postgresql jooq

我尝试使用 jooq 3.12.3 和以下代码以编程方式生成代码,但程序运行成功并且没有生成代码。

  Configuration configuration =
      new Configuration()
          .withJdbc(
              new Jdbc()
                  .withDriver("org.postgresql.Driver")
                  .withUrl("jdbc:postgresql://127.0.0.1:6666/postgres")
                  .withUser("<username>")
                  .withPassword("<correct password>"))
          .withGenerator(
              new Generator()
                  .withDatabase(
                      new Database()
                          .withName("org.jooq.meta.postgres.PostgresDatabase")
                          .withIncludes(".*")
                          .withExcludes("")
                          .withInputSchema("public"))

                  .withGenerate(
                      new Generate()
                          .withDaos(true)
                          .withDeprecated(false)
                          .withImmutablePojos(false)
                          .withPojosEqualsAndHashCode(true)
                          .withValidationAnnotations(true)
                          .withVarargSetters(false))
                  .withTarget(
                      new Target()
                          .withPackageName("com.package.data.jooq")
                          .withDirectory("src/main/java")));
  GenerationTool.generate(configuration);

一些调试信息

\dt
               List of relations
 Schema |       Name        | Type  |  Owner
--------+-------------------+-------+----------
 public | django_migrations | table | postgres
 public | table1            | table | postgres
 public | table2            | table | postgres

\l
                                                List of databases
     Name      |       Owner       | Encoding |  Collate   |   Ctype    |            Access privileges
---------------+-------------------+----------+------------+------------+-----------------------------------------
 cloudsqladmin | cloudsqladmin     | UTF8     | en_US.UTF8 | en_US.UTF8 |
 postgres      | cloudsqlsuperuser | UTF8     | en_US.UTF8 | en_US.UTF8 |

SELECT table_catalog, table_schema, table_name
FROM information_schema.tables;

在 table_schema 下不公开显示 可能是什么问题?

最佳答案

问题出在权限上..

GRANT SELECT ON TABLE public.table1 TO user;
GRANT SELECT ON TABLE public.table2 TO user;

解决了问题。此后,表格开始出现在

SELECT table_catalog, table_schema, table_name
FROM information_schema.tables;

关于postgresql - Jooq 无法从数据库找到我的公共(public)模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59555738/

相关文章:

mysql - 如何使用索引在两列之间进行查询过滤

postgresql - 连接到 Postgres 中的位置参数

mysql - 搜索逻辑分片

java - JOOQ嵌套条件

java - 如何使用 jOOQ gradle 插件将 bigint[] 字段从 postgres 转换为类字段

postgresql - JOOQ 和字段值 : BigDecimal to Int

postgresql - ST_Distance返回值的单位

postgresql - 记录 PostgreSQL 交互式查询

java - 如何在 jOOQ 中为 VisitListener 中的每一行正确地将值添加到 StoreQuery 中?

spring - jooq @NotNull 自动增量验证