Yes, it helped. Not so clean but for my purpose it's currently more than OK.

Good job, thank you

T

Dne pátek 8. ledna 2016 17:08:49 UTC+1 Lukas Eder napsal(a):
>
> Hi Tomáš,
>
> DAOs and dependency injection is a hot topic that was discussed a couple 
> of times, recently. We got 1-2 things "wrong" (depending on the use-case) 
> in our current implementation - specifically the fact that DAOImpl contains 
> final methods.
>
> You can, however, initialise a generated DAO with your own configuration. 
> Note that Configuration and DSLContext are more or less the same thing. The 
> Configuration is the essential item in jOOQ that contains references to all 
> SPIs, settings, and your DataSource. DSLContext just wraps Configuration 
> with DSL API. You can get access to your dependency-injected Configuration 
> via: DSLContext.configuration().
>
> Alternatively, you dependency-inject the Configuration directly, and build 
> DSLContext afresh from it.
>
> Let me know if this helps,
> Lukas
>
> 2016-01-08 14:37 GMT+01:00 Tomáš Cigler <[email protected] <javascript:>>:
>
>> As I mentioned in previous post about injecting DSLContext - I have on my 
>> mind how should I use it in generated DAOs? I looked into implementation 
>> and the context is created from some configuration, but I need to use that 
>> injected one. Is it planned as a feature to be able to put own DSLContext 
>> into DAO or is there some different way?
>>
>> BR
>> Tomáš
>>
>> Dne pondělí 4. ledna 2016 17:17:51 UTC+1 Lukas Eder napsal(a):
>>>
>>> Hi Tomáš,
>>>
>>> Thanks for the additional feedback. Indeed, you're using programmatic 
>>> configuration, then, so you can inject a Configuration to the 
>>> GenerationTool like this (my Groovy is not so fluent, so sorry if there are 
>>> syntax errors):
>>>
>>> GenerationTool tool = new GenerationTool()
>>> tool.setConnection(connection)
>>> tool.run(...)
>>>
>>>
>>> Issue https://github.com/jOOQ/jOOQ/issues/4891 will then also add 
>>> support for DataSources. Right now, you'll have to extract the Connection 
>>> from the DataSource manually.
>>>
>>> As far as DSLContext injection is concerned, yes, you can do this using 
>>> your favourite DI framework. People do this all the time with Spring or 
>>> CDI. I'm not sure what the best way in Grails / Gradle is, I'm afraid. If 
>>> you find out, it would be great if you could post an example here.
>>>
>>> Some additional info can be found, perhaps, on this third party blog 
>>> post that we've recently had on the jOOQ blog (it contains many additional 
>>> links):
>>>
>>> http://blog.jooq.org/2015/03/10/integrating-jooq-with-grails-featuring-the-uws-jooq-plugin
>>>
>>> I'm sure the authors from UWS can help out, too.
>>>
>>> Best Regards,
>>> Lukas
>>>
>>> 2016-01-04 15:08 GMT+01:00 Tomáš Cigler <[email protected]>:
>>>
>>>> Thank you for a super quick response, I didn't expect it :)
>>>> The way I'm using generator is exactly this one (I'm using it as a 
>>>> task):
>>>> http://www.jooq.org/doc/3.7/manual/code-generation/codegen-gradle/
>>>> To share database properties I'll use different environment settings 
>>>> only as strings for now. 
>>>>
>>>> But about this:
>>>> DSLContext create = DSL.using(dataSource, SQLDialect.MYSQL);
>>>>
>>>> I'm currently beginner in Grails and Gradle, it's pretty different than 
>>>> JavaEE, so I'm getting into it. So maybe this would be a silly question, 
>>>> but I suppose that if I need to use *DSLContext* in some service 
>>>> class, I need to create it like the way you suggested. But if I know that 
>>>> it will always use the same datasource and dialect would be MySQL, could I 
>>>> somehow configure it on the lower level level of abstraction and just have 
>>>> DSLContext injected into service? Should I create some kind of filter 
>>>> for it or is there any plugin that provides it?
>>>>
>>>> Thanks again
>>>>
>>>> Tomáš
>>>>
>>>> Dne pondělí 4. ledna 2016 9:50:48 UTC+1 Lukas Eder napsal(a):
>>>>>
>>>>> Hi Tomáš,
>>>>>
>>>>> Thank you for your enquiry. The jOOQ runtime library allows for using 
>>>>> standard javax.sql.DataSource instead of Connection. Just pass it to the 
>>>>> using method:
>>>>>
>>>>> DSLContext create = DSL.using(dataSource, SQLDialect.MYSQL);
>>>>>
>>>>>
>>>>> Surprisingly, this isn't possible right now using the jOOQ 
>>>>> GenerationTool API. I have created a feature request to implement this 
>>>>> for 
>>>>> jOOQ 3.8:
>>>>> https://github.com/jOOQ/jOOQ/issues/4891
>>>>>
>>>>> Just to be sure to get this right, how are you currently configuring 
>>>>> the code generator with Grails? Are you using the GenerationTool class 
>>>>> for 
>>>>> programmatic configuration?
>>>>>
>>>>> Cheers,
>>>>> Lukas
>>>>>
>>>>> 2016-01-04 9:34 GMT+01:00 Tomáš Cigler <[email protected]>:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have defined datasources in differerent build environments in 
>>>>>> Grails configuration. Now I can use injected datasource in service 
>>>>>> for gathering connection and then instantiate 
>>>>>> DSLContext create = DSL.using(connection, SQLDialect.MYSQL)
>>>>>>
>>>>>> Is there a way that I can defaultly assign the datasource (maybe by 
>>>>>> some existing plugin or configuration) to DSL, from which it would take 
>>>>>> the 
>>>>>> connections itself and tell it that I want to always use MySQL dialect, 
>>>>>> so 
>>>>>> I can then omit 
>>>>>> using(connection, SQLDialect.MYSQL)
>>>>>>
>>>>>> Can I somehow use this datasource even for generator plugin, which 
>>>>>> generates POJOs, DAOs etc.?
>>>>>>
>>>>>> Thanks
>>>>>> Tomáš
>>>>>>
>>>>>> -- 
>>>>>> 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 the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> 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