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
On Oct 26, 2015 8:37 PM, "Lukas Eder" <[email protected]> wrote:

> I'm not sure how Guice works in detail, but could you, perhaps, inject the
> configuration via the constructor instead?
>
> Note that we've had a lot of feedback about "final" on methods in DAOImpl.
> It appears that our "best practice" of closing our implementation from the
> outside is mostly criticised in this context, where - apparently - we did
> something wrong in our design of this particular class. I suspect that for
> the time being, it may be useful for users to be able to override behaviour
> in their implementations, even if we prefer discussing things to come to a
> better API.
>
> Thus, I've created this feature request for jOOQ 3.8:
> https://github.com/jOOQ/jOOQ/issues/4696
>
> Best Regards,
> Lukas
>
> 2015-10-22 11:41 GMT+02:00 <[email protected]>:
>
>> I don't know if this helps or if it's a best practice, but I extended the
>> JavaGenerator to inject the Configuration. Sadly setConfiguration in
>> DaoImpl is final so I had to create a new method for all DAOs. Here is the
>> Generator-Class:
>>
>> 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");
>>         }
>>     }
>>
>> }
>>
>> Has anyone a better idea how to implement this properly?
>>
>> Am Mittwoch, 14. Oktober 2015 17:22:52 UTC+2 schrieb Lukas Eder:
>>>
>>> Hi Sachin,
>>>
>>> Well, yes you can do that. The generated DAO just links the generated
>>> Table to the generated POJO type, and adds some convenience methods for
>>> fetching.
>>>
>>> What is the concern you are having? I mean, why did you think there
>>> might be a risk in doing so?
>>>
>>> Cheers,
>>> Lukas
>>>
>>> 2015-10-12 18:26 GMT+02:00 <[email protected]>:
>>>
>>>> Hi Lukas,
>>>>
>>>> My query is, can I directly use the generated DAO in production
>>>> environment.
>>>>
>>>> Thanks,
>>>> Sachin
>>>>
>>>> --
>>>> 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 [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>> 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 [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to