--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks,
Sachin
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
public class InjectConfigurationGenerator extends JavaGenerator {
@Override protected void generateDaoClassFooter(TableDefinition table, JavaWriter out) { super.generateDaoClassFooter(table, out); out.tab(1).println("@com.google.inject.Inject"); out.tab(1).println("public void injectConfiguration(Configuration configuration) {"); out.tab(2).println("super.setConfiguration(configuration);"); out.tab(1).println("}"); }
@Override protected void printClassAnnotations(JavaWriter out, SchemaDefinition schema) { super.printClassAnnotations(out, schema); if(out.file().getName().contains("Dao")){ out.println("@%s", "com.google.inject.Singleton"); } }
}I have done the same Lukas. After the DAO is generated, I just annotate the constructor with parameterized configuration as @Inject. Also, I have defined a provider to use a Singleton Configuration. It is working for me. I can post the code if you want but the code is very basic.
Thanks,
Sachin
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/-4FMMKajTv0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
- DefaultGeneratorStrategy.getJavaClassExtends(Definition, Mode) (org.jooq.util)
if (generateSpringAnnotations()) out.println("@%s", out.ref("org.springframework.stereotype.Repository"));So my first attempt was to create my own GeneratorStrategy and overwrite
- DefaultGeneratorStrategy.getJavaClassExtends(Definition, Mode) (org.jooq.util)
but for some reason this does not get called for DAOs.
Even if this would have been possible, because setConfiguration is final, I wouldn't be able to overwrite and annotate the method. I agree it would have been the best to annotate the constructor, but there is no method in the JavaGenerator that I can overwrite. I've foundif (generateSpringAnnotations())out.println("@%s", out.ref("org.springframework.stereotype.Repository"));
which adds an annotation to the constructor. Maybe this can be rewritten and extracted into a protected method writeConstructorAnnotations or something? I could then overwrite that method and add my annotations to inject the configuration via constructor so there is no need to remove the final keyword from setConfiguration.
Great (frame) work btw!