I have implemented along the lines of what is outlined at 
http://www.jooq.org/doc/3.2/manual/getting-started/tutorials/jooq-with-spring/

I now have transactions working for methods marked as @Transactional. But 
to get the DSLContext, I have only been able to do this thus far:

@Autowired private TransactionAwareDataSourceProxy _dataSource;
@Transactional
public void doMyTransactionalWork() {
    DSLContext dslContext = 
DSL.using(org.springframework.jdbc.datasource.DataSourceUtils.getConnection(_dataSource));
    .....
}

I would really like to be able to make my bean a prototype and then add the 
line:

@Autowired private DSLContext _dslContext;

If I wire the DSLContext as described at that same link (and snipped 
below), it's a different connection than is used by the transaction scope 
which obviously does not work.
...snip....

    <bean id="dsl" class="org.jooq.impl.DefaultDSLContext">
        <constructor-arg ref="config" />
    </bean>

    <!-- Invoking an internal, package-private constructor for the example
         Implement your own Configuration for more reliable behaviour -->
    <bean class="org.jooq.impl.DefaultConfiguration" name="config">
        <constructor-arg index="0" ref="connectionProvider" />
        <constructor-arg index="1"><null /></constructor-arg>
        <constructor-arg index="2"><value 
type="org.jooq.SQLDialect">H2</value></constructor-arg>
        <constructor-arg index="3"><null /></constructor-arg>
        <constructor-arg index="4"><null /></constructor-arg>
    </bean>

...snip....

How do I go about injecting my DSLContext? Would I need to extend or wrap 
DefaultDSLContext 
and return my own prototype instance that does an init() to load the DSLContext 
using DataSourceUtils? Surely someone has done this already.

-- 
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/groups/opt_out.

Reply via email to