Hello,

Your listener is correct and it works for me, but I just noticed that
perhaps you meant that the patched SQL doesn't appear in jOOQ's default log
output, which is logged by the LoggerListener. That's true, because the
LoggerListener is the first one that is applied, and I wonder if that is
the correct behaviour. Perhaps we should log stuff only after all the
custom ExecuteListeners have been invoked... I have registered an issue for
this:
https://github.com/jOOQ/jOOQ/issues/3905

You can work around this issue by manually adding
the org.jooq.tools.LoggerListener to your listeners.

Note that this:

    sql = sql.replace("`", "");


... is not necessary if you use the RenderNameStyle.AS_IS Setting:
-
http://www.jooq.org/javadoc/latest/org/jooq/conf/RenderNameStyle.html#AS_IS
-
http://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-settings/

Hope this helps,
Lukas

2015-01-07 13:27 GMT+01:00 Kristoffer Sjögren <[email protected]>:

> Sorry, I was a bit hasty on the send button I must admit :-)
>
> ... these are the insert statements ...
>
> DSL.using(getConf(con)).executeInsert(record);
>
> DSL.using(getConf(con))
>  .insertInto(TABLE)
>  .set(record)
> .execute();
>
> ... using the following configuration ...
>
> Configuration configuration = new
> DefaultConfiguration().set(con).set(SQLDialect.MYSQL);
> configuration.set(new DefaultExecuteListenerProvider(new
> PhoenixListener()));
>
> ... with the following listener ...
>
> public class PhoenixListener extends DefaultExecuteListener {
>
>   @Override
>   public void start(ExecuteContext ctx) {
>     String sql = ctx.sql();
>     System.out.println(sql);
>   }
>
>   @Override
>   public void renderEnd(ExecuteContext ctx) {
>     String sql = ctx.sql();
>     sql = sql.replace("insert", "UPSERT");
>     sql = sql.replace("`", "");
>     ctx.sql(sql);
>   }
>
>   @Override
>   public void prepareEnd(ExecuteContext ctx) {
>     ctx.query();
>     String sql = ctx.sql();
>     sql = sql.replace("insert", "UPSERT");
>     sql = sql.replace("`", "");
>     ctx.sql(sql);
>   }
>
>   @Override
>   public void bindEnd(ExecuteContext ctx) {
>     String sql = ctx.sql();
>     System.out.println(sql);
>   }
> }
>
>
>
>
>
>
>
> On Wed, Jan 7, 2015 at 1:20 PM, Lukas Eder <[email protected]> wrote:
>
>> Hi Kristoffer,
>>
>> We're more than happy to help, but it would be easier if you show us what
>> you've tried so far... :)
>>
>> Cheers
>> Lukas
>>
>> 2015-01-07 13:01 GMT+01:00 <[email protected]>:
>>
>>> Hi
>>>
>>> I'm trying to make a slight modification to the generated SQL from
>>> INSERT to UPSERT but can't make it happen with ExecutionListeners (which
>>> works fine for SELECT).
>>>
>>> The ExecutionListener is called but the changes does not affect the
>>> actual statement that later get executed.
>>>
>>> Cheers,
>>> -Kristoffer
>>>
>>>  --
>>> 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 a topic in the
>> Google Groups "jOOQ User Group" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/jooq-user/-gI2yrEuaik/unsubscribe.
>> To unsubscribe from this group and all its topics, 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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to