- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Postgresql 12.0
评估 jOOQ 3.11.12
。这是我的( super )简单数据库:
--
-- INITIAL DATABASE SETUP
--
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
--
-- CREATE STATEMENT(S)
--
CREATE TABLE departments
(
id UUID NOT NULL DEFAULT uuid_generate_v4(),
name VARCHAR(20) NOT NULL,
CONSTRAINT pk_department_id PRIMARY KEY (id)
);
CREATE TABLE employees
(
id UUID NOT NULL DEFAULT uuid_generate_v4(),
first_name VARCHAR(20) NOT NULL,
last_name VARCHAR(20) NOT NULL,
department_id UUID,
CONSTRAINT pk_employee_id PRIMARY KEY (id),
CONSTRAINT fk_employees_departments_id FOREIGN KEY (department_id) REFERENCES departments (id)
);
--
-- INSERT STATEMENT(S)
--
INSERT INTO departments(id, name)
VALUES ('945079360f314e93a749b1bd83e037bb', 'Clerical'), -- 94507936-0f31-4e93-a749-b1bd83e037bb
('b2759d843e8549c397d9b0ce265c3312', 'Engineering'), -- b2759d84-3e85-49c3-97d9-b0ce265c3312
('cdd1781eb948411ca15f2dfe462ce247', 'Sales'); -- cdd1781e-b948-411c-a15f-2dfe462ce247
INSERT INTO departments(name)
VALUES ('Marketing');
INSERT INTO employees(first_name, last_name, department_id)
VALUES ('Charles', 'Rafferty', '945079360f314e93a749b1bd83e037bb'),
('Joe', 'Armstrong', 'b2759d843e8549c397d9b0ce265c3312'),
('Robert', 'Virding', 'b2759d843e8549c397d9b0ce265c3312'),
('Mike', 'Williams', 'b2759d843e8549c397d9b0ce265c3312'),
('Elizabeth', 'Heisenberg', 'cdd1781eb948411ca15f2dfe462ce247'),
('x80486', 'Williams', NULL);
我有一个使用 Flyway 设置数据库的 Spring Boot 项目(暂时不要介意数据种子,例如:INSERT
语句),以及我正在使用的代码生成dev.bombinating.jooq-codegen
(Gradle) 插件版本 3.12.1
:
id("dev.bombinating.jooq-codegen").version("3.12.1")
...
configure<JooqExtension> {
val database = Database()
.withExcludes("flyway_schema_history.*|information_schema.*|pg_catalog.*")
.withIncludes(".*")
.withInputSchema("public")
val generate = Generate().withDeprecated(false)
.withFluentSetters(false)
.withImmutablePojos(false)
.withRecords(false)
val target = Target().withDirectory("${project.buildDir}/generated-sources/jooq/")
.withPackageName("${project.group}.codegen") // io.shido.codegen
val jooqVersion: String by project
edition = JooqEdition.OpenSource
generator = Generator().withDatabase(database)
.withGenerate(generate)
.withName("org.jooq.codegen.DefaultGenerator")
.withStrategy(Strategy().withName("org.jooq.codegen.DefaultGeneratorStrategy"))
.withTarget(target)
jdbc = Jdbc().withDriver("org.postgresql.Driver")
.withPassword("postgres")
.withUrl("jdbc:postgresql://localhost:5432/kotlin_spring_boot_jooq")
.withUser("postgres")
version = jooqVersion
}
sourceSets { // TODO: dev.bombinating.jooq-codegen should configure this automatically with sane defaults
main { java.srcDir("${buildDir.absolutePath}/generated-sources/jooq/") }
}
我可以“解析”(导入)并使用生成的类型:io.shido.codegen.tables.Departments.DEPARTMENTS
,但是一旦我尝试运行该应用程序,我就会得到一堆像这样的错误:
/home/x80486/Workshop/Development/kotlin-spring-boot-jooq/build/generated-sources/jooq/io/shido/codegen/tables/Departments.java:61: error: no suitable method found for createField(Name,DataType<UUID>,Departments,String)
public final TableField<Record, UUID> ID = createField(DSL.name("id"), org.jooq.impl.SQLDataType.UUID.nullable(false).defaultValue(org.jooq.impl.DSL.field("uuid_generate_v4()", org.jooq.impl.SQLDataType.UUID)), this, "");
...
/home/x80486/Workshop/Development/kotlin-spring-boot-jooq/build/generated-sources/jooq/io/shido/codegen/tables/Departments.java:66: error: no suitable method found for createField(Name,DataType<String>,Departments,String)
public final TableField<Record, String> NAME = createField(DSL.name("name"), org.jooq.impl.SQLDataType.VARCHAR(20).nullable(false), this, "");
NOTE: I get pretty much the same result(s) if I do
.withExcludes("")
also.
...还有一些其他错误,但这些可能与我设置插件设置的方式有关(我猜):
W o.j.m.AbstractDatabase - SQL exception : Exception while executing meta query: ERROR: column c.consrc does not exist
Hint: Perhaps you meant to reference the column "c.conkey" or the column "c.conbin".
Position: 127
有什么办法可以解决这个问题吗?我已经看到那里的大多数示例都将生成的代码放在 sourceSets["main"]
中,但我认为它的行为应该与我配置它的方式相同。
IMPORTANT: The
jOOQ
artifact is provided byorg.springframework.boot:spring-boot-starter-jooq
(inferred from the2.1.9.RELEASE
Spring BOM).
最佳答案
spring-boot-starter-jooq(spring boot release 2.1.9)中的jOOQ版本是3.11.12,而你根据id("dev.bombinating.jooq-codegen ").version("3.12.1")
。我们应该确保它们的版本完全相同。
您还可以使用 jOOQ version=3.12.1 附带的 spring boot release 2.2.0。
关于postgresql - 成功生成后jOOQ总是提示 "no suitable method found for createField",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58440663/
我已经从 MySQL 表生成了 java 模型文件。但是现在我们正在切换到 PostgreSQL,我需要一切才能在那里工作。所以我为 PostgreSQL 配置创建了一个新的 jooq.propert
在 mysql 数据库中,我有一个字段名称 date 类型 date 该字段的值如下2019-11-05 如何在jooq中查询上面提到的日期 我试着跟随 java.util.Date date = S
我正在调查一个问题,我们看到与 jooq 相关的奇怪异常试图填充生成的 Record 类,它在其中获取数据类型错误,因为它使用 java.sql.ResultSet::getXXX(int)(基于列索
我一直在寻找一种在 jOOQ 中实现以下查询的方法,但找不到任何东西。 SELECT * FROM tableName WHERE 'this is a string' LIKE CONCAT(
我一直在寻找一种在 jOOQ 中实现以下查询的方法,但找不到任何东西。 SELECT * FROM tableName WHERE 'this is a string' LIKE CONCAT(
我有一个使用gradle-jooq-plugin-3.0.1、jooq-3.11.2 和 Spring Boot 1 的项目。当我尝试生成 JOOQ 文件时我收到以下错误消息: > Task :gen
我刚刚尝试将我的项目升级到 Java 15,现在出现以下错误: both interface org.jooq.Record in org.jooq and class java.lang.Rec
我很好奇 jOOQ 是否可以与 Quarkus 一起工作,所以我创建了一个 Gradle 项目。我收到此构建错误: Caused by: io.quarkus.creator.AppCreatorEx
来自 fetchNext(int number) 的文档 -“在获取最后一条记录后,这将方便地关闭游标。” 假设number=100,一共有1000条记录。它会在获取第 100 条记录后关闭游标,还是
在我们的项目中,概念是在配置文件中定义的。举个例子: ... ... 虽然这与 SQL 没有太大关系,但这个配置文件恰好可以映射到 S
我在我的 java gradle 项目中找到一个有效的 JOOQ 插件或其配置为最新的 JOOQ 库时遇到问题。 我找到了以下插件: https://github.com/jOOQ/jOOQ/tree
我得到了一个使用 gradle (v2.1.0) 和 jooq (v3.8.1) 生成类文件的 Ratpack 应用程序。 这是我的 build.gradle 文件: buildscript {
我有一个界面 public interface HistoryDao, H extends UpdatableRecord> extends TableDao{ default void sa
我正在使用 jOOQ 生成针对 Athena(又名 PrestoDB/Trino)运行的查询 为此,我使用了 SQLDialects.DEFAULT,它之所以有效,是因为我使用了非常基本的查询功能。
如何在jooq的查询中绑定(bind)一个数组作为参数? 这是我添加名为“someIds”的命名参数的地方 Query query = selectJoinStep.where(field("
我有一个多模块 maven 项目,我正在实现一个 ant 任务以直接从 jpa 生成 jooq 类 实体。 这些是我引用的教程: Code generation with Ant Code gener
我想在 JOOQ 中实现一个基本的 time_bucket 语句。 如果我在控制台中运行此语句,它运行得非常好: SELECT time_bucket('5 minutes', time) as t,
我关于在 jooq dsl 中编写查询的问题。 我在 Oracle 数据库中存储了一些客户端属性列表。 表结构如下: CLIENT_ATTRIBUTE_DICT (ID、CODE、DEFAULT_VA
我很惊讶地发现 JOOQ(从 3.16 开始)将时间戳绑定(bind)到 LocalDateTime。在我看来,时间戳最自然地映射到一个 Instant,它是一个 Unix 纪元时间戳。 那么我们怎样
你好,我正在方法中执行此操作 public void update(Table table, String tableName){ ArrayList firstRowInDslFormat
我是一名优秀的程序员,十分优秀!