From e4aa7c1eedaaf90e028abba2938534073e1e3db5 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 20 Nov 2020 15:43:45 +0100 Subject: [PATCH] [jOOQ/jOOQ#10801] Add JavaGenerator.printDaoConstructorAnnotations() to allow for custom annotations in generated DAO constructors --- .../main/java/org/jooq/codegen/JavaGenerator.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java b/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java index 4d8fa37113..a0a269cde3 100644 --- a/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java +++ b/jOOQ-codegen/src/main/java/org/jooq/codegen/JavaGenerator.java @@ -4077,9 +4077,7 @@ public class JavaGenerator extends AbstractGenerator { if (!scala && !kotlin) { out.javadoc("Create a new %s with an attached configuration", className); - if (generateSpringAnnotations()) - out.println("@%s", out.ref("org.springframework.beans.factory.annotation.Autowired")); - + printDaoConstructorAnnotations(table, out); out.println("%s%s(%s configuration) {", visibility(), className, Configuration.class); out.println("super(%s, %s.class, configuration);", tableIdentifier, pType); out.println("}"); @@ -4216,6 +4214,15 @@ public class JavaGenerator extends AbstractGenerator { out.println("}"); } + /** + * Subclasses may override this method to provide alternative DAO + * constructor annotations, such as DI annotations. [#10801] + */ + protected void printDaoConstructorAnnotations(TableDefinition table, JavaWriter out) { + if (generateSpringAnnotations()) + out.println("@%s", out.ref("org.springframework.beans.factory.annotation.Autowired")); + } + /** * Subclasses may override this method to provide dao class footer code. */