2015-12-02 18:59 GMT+01:00 Max Kremer <[email protected]>:
> Ok Lukas I think I've figured it out - can you advise if I'm on the write
> track:
>
> First think I did was create an *ExecuteListener* by extending
> *DefaultExecuteListener*
>
Hmm, I suspect you might have side effects this way as the executeStart()
event is triggered after the prepareXXX() events. I don't know if there are
any side effects here as jOOQ will prepare the real statement already
before you call "SET enable_sort TO TRUE"
Also, do make sure that you don't run into any resource leaks. You should
close your statement eagerly:
try (Statement s = ctx.connection().createStatement()) {
s.execute("...");
}
>
> Then wherever I need to employ this execute listener I do:
>
>
> dslContext.configuration().set(new DefaultExecuteListenerProvider(new
> ParamsListener()));
>
> So here are a couple things I'm not sure of:
> - Whats the lifecycle of DSLContext ? I'm assuming it gets reused
>
You define that. If it gets reused, then this approach will be wrong and
not thread safe. A better solution would be:
DSL.using(dslContext.configuration().derive(new
DefaultExecuteListenerProvider(new ParamsListener())));
- How do I set the DSLcontext configuration back to default?
>
I would just create two different Configurations / DSLContexts in your
application for those purposes.
Hope this helps,
Lukas
--
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.