合成只读列
适用于 ❌ 开源版 ✅ Express 版 ✅ 专业版 ✅ 企业版
jOOQ 的代码生成器如果配置正确,可以识别只读列。有些数据库不支持“真正的”只读列,但允许通过模拟来实现,例如通过触发器。如果一个列是已知的“只读列”,但形式上不是,用户可以指定正则表达式来匹配所有表和列,这些表和列将被视为正式的只读列。例如
XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration>
<generator>
<database>
<syntheticObjects>
<readonlyColumns>
<readonlyColumn>
<!-- Optional regular expression matching all tables that have this identity. -->
<tables>SCHEMA\.TABLE</tables>
<!-- List all columns that are readonly -->
<fields>ID</fields>
</readonlyColumn>
</readonlyColumns>
</syntheticObjects>
</database>
</generator>
</configuration>
有关更多详细信息,请参阅配置 XSD、独立代码生成和maven 代码生成。
new org.jooq.meta.jaxb.Configuration()
.withGenerator(new Generator()
.withDatabase(new Database()
.withSyntheticObjects(new SyntheticObjectsType()
.withReadonlyColumns(
new SyntheticReadonlyColumnType()
// Optional regular expression matching all tables that have this identity.
.withTables("SCHEMA\\.TABLE")
// List all columns that are readonly
.withFields("ID")
)
)
)
)
import org.jooq.meta.jaxb.*
configuration {
generator {
database {
syntheticObjects {
readonlyColumns {
readonlyColumn {
// Optional regular expression matching all tables that have this identity.
tables = "SCHEMA\\.TABLE"
// List all columns that are readonly
fields = "ID"
}
}
}
}
}
}
有关更多详细信息,请参阅配置 XSD和gradle 代码生成。
configuration {
generator {
database {
syntheticObjects {
readonlyColumns {
readonlyColumn {
// Optional regular expression matching all tables that have this identity.
tables = "SCHEMA\\.TABLE"
// List all columns that are readonly
fields = "ID"
}
}
}
}
}
}
有关更多详细信息,请参阅配置 XSD和gradle 代码生成。
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19. // Please use the official plugin instead of the third party plugin that was recommended before.
一如既往,当使用正则表达式时,它们是具有默认标志的正则表达式。
反馈
您对此页面有任何反馈吗? 我们很乐意听取您的意见!