可用版本: Dev (3.21) | 最新 (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14

合成标识

适用于 ✅ 开源版   ✅ 专业版   ✅ 企业版

如果数据库报告 jOOQ 的代码生成器将识别标识列。某些数据库不支持“真实的”标识列,但允许模拟它们,例如,通过触发器和序列(例如 12c 之前的 Oracle)。如果某个列是已知的“标识”,但不是正式标识,则用户可以指定正则表达式来匹配所有表和列,这些表和列将被视为正式标识。例如

XML(独立和 Maven)
编程方式
Gradle(Kotlin)
Gradle(Groovy)
Gradle(第三方)
<configuration>
  <generator>
    <database>
      <syntheticObjects>
        <identities>
          <identity>

            <!-- Optional regular expression matching all tables that have this identity. -->
            <tables>SCHEMA\.TABLE</tables>

            <!-- List all columns that are identities -->
            <fields>ID</fields>
          </identity>
        </identities>
      </syntheticObjects>
    </database>
  </generator>
</configuration>

有关更多详细信息,请参阅配置 XSD独立代码生成maven 代码生成

new org.jooq.meta.jaxb.Configuration()
  .withGenerator(new Generator()
    .withDatabase(new Database()
      .withSyntheticObjects(new SyntheticObjectsType()
        .withIdentities(
          new SyntheticIdentityType()

            // Optional regular expression matching all tables that have this identity.
            .withTables("SCHEMA\\.TABLE")

            // List all columns that are identities
            .withFields("ID")
        )
      )
    )
  )

有关更多详细信息,请参阅配置 XSD程序化代码生成

import org.jooq.meta.jaxb.*


configuration {
  generator {
    database {
      syntheticObjects {
        identities {
          identity {

            // Optional regular expression matching all tables that have this identity.
            tables = "SCHEMA\\.TABLE"

            // List all columns that are identities
            fields = "ID"
          }
        }
      }
    }
  }
}

有关更多详细信息,请参阅配置 XSDgradle 代码生成

configuration {
  generator {
    database {
      syntheticObjects {
        identities {
          identity {

            // Optional regular expression matching all tables that have this identity.
            tables = "SCHEMA\\.TABLE"

            // List all columns that are identities
            fields = "ID"
          }
        }
      }
    }
  }
}

有关更多详细信息,请参阅配置 XSDgradle 代码生成

// 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.

一如既往,当使用正则表达式时,它们是具有默认标志的正则表达式

引用此页

反馈

您对此页面有任何反馈吗? 我们很乐意听到!

The jOOQ Logo