我尝试使用 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/