Great. I found an easy way to inject jOOQ's DSLContext to controllers (and 
so services).
You just have to define DefaultDSLContext as a bean (since we are talking 
about Grails 3.x, it goes into grails-app/conf/spring/resources.groovy) 
like this:

beans = {
    jooqContext(DefaultDSLContext, ref("dataSource"), SQLDialect.whatever)
}


I have the dataSource defined in application.yml configuration. The only 
thing you need to do is then write

class MyService {
    def jooqContext
}


and then you can just use it like if you defined it through DSL.using()

Thank you for your participation. I like jOOQ and believe you can push it 
as far as me and most other people could use it instead of Hibernate sh*t 
in big enterprise projects.

Best regards
Tomáš

Dne pondělí 4. ledna 2016 9:34:21 UTC+1 Tomáš Cigler napsal(a):
>
> 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.

Reply via email to