生成的 DAO
适用于 ✅ 开源版 ✅ 专业版 ✅ 企业版
数据库中的每个表和视图都将生成一个 org.jooq.DAO
实现,如下所示
public class BookDao extends DAOImpl<BookRecord, Book, Integer> { // Generated constructors public BookDao() { super(BOOK, Book.class); } public BookDao(Configuration configuration) { super(BOOK, Book.class, configuration); } // Every column generates at least one fetch method public List<Book> fetchById(Integer... values) { return fetch(BOOK.ID, values); } public Book fetchOneById(Integer value) { return fetchOne(BOOK.ID, value); } public List<Book> fetchByAuthorId(Integer... values) { return fetch(BOOK.AUTHOR_ID, values); } // [...] }
XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration> <generator> <generate> <!-- Generate the DAO classes --> <daos>true</daos> <!-- Annotate DAOs (and other types) with spring annotations, such as @Repository and @Autowired for auto-wiring the Configuration instance, e.g. from Spring Boot's jOOQ starter --> <springAnnotations>true</springAnnotations> <!-- Generate Spring-specific DAOs containing @Transactional annotations --> <springDao>true</springDao> <!-- Optionally, limit DAOs generation to only tables matching this regular expression. --> <pojosIncludes>.*</pojosIncludes> <!-- Optionally, limit DAOs generation to only tables not matching this regular expression. Excludes match before includes. --> <pojosExcludes>SYSTEM_TABLE_.*</pojosExcludes> </generate> </generator> </configuration>
有关更多详细信息,请参阅配置 XSD、独立代码生成和maven 代码生成。
new org.jooq.meta.jaxb.Configuration() .withGenerator( new Generate() // Generate the DAO classes .withDaos(true) // Annotate DAOs (and other types) with spring annotations, such as @Repository and @Autowired // for auto-wiring the Configuration instance, e.g. from Spring Boot's jOOQ starter .withSpringAnnotations(true) // Generate Spring-specific DAOs containing @Transactional annotations .withSpringDao(true) // Optionally, limit DAOs generation to only tables matching this regular expression. .withPojosIncludes(".*") // Optionally, limit DAOs generation to only tables not matching this regular expression. // Excludes match before includes. .withPojosExcludes("SYSTEM_TABLE_.*") )
import org.jooq.meta.jaxb.* configuration { generator { generate { // Generate the DAO classes isDaos = true // Annotate DAOs (and other types) with spring annotations, such as @Repository and @Autowired // for auto-wiring the Configuration instance, e.g. from Spring Boot's jOOQ starter isSpringAnnotations = true // Generate Spring-specific DAOs containing @Transactional annotations isSpringDao = true // Optionally, limit DAOs generation to only tables matching this regular expression. pojosIncludes = ".*" // Optionally, limit DAOs generation to only tables not matching this regular expression. // Excludes match before includes. pojosExcludes = "SYSTEM_TABLE_.*" } } }
有关更多详细信息,请参阅配置 XSD和gradle 代码生成。
configuration { generator { generate { // Generate the DAO classes daos = true // Annotate DAOs (and other types) with spring annotations, such as @Repository and @Autowired // for auto-wiring the Configuration instance, e.g. from Spring Boot's jOOQ starter springAnnotations = true // Generate Spring-specific DAOs containing @Transactional annotations springDao = true // Optionally, limit DAOs generation to only tables matching this regular expression. pojosIncludes = ".*" // Optionally, limit DAOs generation to only tables not matching this regular expression. // Excludes match before includes. pojosExcludes = "SYSTEM_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.
一如既往,当使用正则表达式时,它们是具有默认标志的正则表达式。
有关注释特定标志的更多信息,请参阅生成注释。
反馈
您对此页面有任何反馈吗? 我们很乐意听到!