Great, thanks for the additional feedback.
2013/10/23 <[email protected]> > So it appears that > https://groups.google.com/forum/?fromgroups#!topic/jooq-user/XTDG9VVP-3I is > what I want. I need a Spring DSLContext configured against a > DataSourceConnectionProvider that uses a TransactionAwareDataSourceProxy. > > <bean id="transactionManager" > class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> > <property name="dataSource" ref="dataSource" /> > </bean> > > <bean id="transactionAwareDataSource" > class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"> > <constructor-arg ref="dataSource"/> > </bean> > <bean id="jooqContext" class="org.jooq.impl.DefaultDSLContext"> > <constructor-arg index="0" ref="config"/> > </bean> > > <bean class="org.jooq.impl.DataSourceConnectionProvider" > name="connectionProvider"> > <constructor-arg ref="transactionAwareDataSource"/> > </bean> > <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"><null /></constructor-arg> > <constructor-arg index="3"><value > type="org.jooq.SQLDialect">MYSQL</value></constructor-arg> > <constructor-arg index="4"><null /></constructor-arg> > <constructor-arg index="5"><null /></constructor-arg> > </bean> > > Then I could do > > @Autowired *private *DSLContext context; > > Craig > > On Wednesday, October 23, 2013 11:15:42 AM UTC-4, Lukas Eder wrote: > >> Hello Craig, >> >> (I should fix the manual's markup / CSS, such that copy pasting code >> works better...) >> >> The manual's current spring example is indeed a bit minimalistic and has >> been challenged before, e.g. by Ben Manes. A good starting point is this >> issue here: >> https://github.com/jOOQ/jOOQ/**issues/1836<https://github.com/jOOQ/jOOQ/issues/1836> >> >> I'm open to suggestions how to improve the manual to show examples using >> @Autowired (It's been a while since I've been doing spring...) >> >> Cheers >> Lukas >> >> 2013/10/22 <[email protected]> >> >>> 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/<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 TransactionAwareDataSourceProx**y _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 jooq-user+...@**googlegroups.com. >>> >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >> >> -- > 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. > -- 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.
