合成只读 ROWID
适用于 ❌ 开源版 ✅ Express 版 ✅ 专业版 ✅ 企业版
一些数据库产品支持 ROWID
类型,它模拟了行在磁盘上的物理位置。ROWID
可以用作主键,例如在没有正式主键的情况下,尽管它是一个物理地址,而不是逻辑地址,但通常不能保证 ROWID
永远不变。对于短期记录访问,这可能无关紧要(例如,在单个查询中,用于更快的自连接)。
jOOQ 的代码生成器允许指定一个合成 ROWID 配置,该配置会在所有匹配的表上生成此类 ROWID
列。将此与 合成主键功能 相结合,您可以替换所有与行的交互中可能存在的现有主键,包括例如 可更新记录的 CRUD 操作(可能存在某些特定于供应商的限制)。
XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration> <generator> <database> <syntheticObjects> <readonlyRowids> <readonlyRowid> <!-- Optional name of the column in generated code. --> <name>ROWID</name> <!-- Regular expression matching all tables that have this synthetic ROWID. --> <tables>SCHEMA\.TABLE</tables> </readonlyRowid> </readonlyRowids> </syntheticObjects> </database> </generator> </configuration>
有关更多详细信息,请参阅 配置 XSD、独立代码生成 和 Maven 代码生成。
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withDatabase(new Database() .withSyntheticObjects(new SyntheticObjectsType() .withReadonlyRowids( new SyntheticReadonlyRowidType() // Optional name of the column in generated code. .withName("ROWID") // Regular expression matching all tables that have this synthetic ROWID. .withTables("SCHEMA\\.TABLE") ) ) ) )
import org.jooq.meta.jaxb.* configuration { generator { database { syntheticObjects { readonlyRowids { readonlyRowid { // Optional name of the column in generated code. name = "ROWID" // Regular expression matching all tables that have this synthetic ROWID. tables = "SCHEMA\\.TABLE" } } } } } }
有关更多详细信息,请参阅 配置 XSD 和 Gradle 代码生成。
configuration { generator { database { syntheticObjects { readonlyRowids { readonlyRowid { // Optional name of the column in generated code. name = "ROWID" // Regular expression matching all tables that have this synthetic ROWID. tables = "SCHEMA\\.TABLE" } } } } } }
有关更多详细信息,请参阅 配置 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.
一如既往,当使用正则表达式时,它们是具有默认标志的正则表达式。
反馈
您对此页面有任何反馈吗?我们很乐意听取您的意见!