Hi Marcus,

Thanks for your message.

Not excluding any bugs in the below, this additional select statement is
run only on those databases that are not able to fetch non-identity columns
through JDBC's getGeneratedKeys() method, and only if such non-identity
columns are needed. This is the case, e.g.

- When Settings.returnAllOnUpdatableRecord flag is set to true
- When the primary key is composite, or does not coincide 100% with the
identity column

Can you confirm any of the above?

Thanks,
Lukas


On Thu, Aug 30, 2018 at 11:56 AM Marcus Gattinger <[email protected]> wrote:

> Hi Lukas,
>
> I currently compare jOOQ and Hibernate in terms of rendered and executed
> statements. For my tests I use MySQL and for the low level profiling I use
> the tool "Neor Profile SQL".
>
> Inserting new rows to a table with a primary key declared as
> AUTO_INCREMENT shows me that jOOQ renders and executes an explicit
>
> SELECT [pk column] FROM [table] WHERE [pk column] = [value]
>
> after each INSERT statement.
>
> However Hibernate does not execute such an additional SELECT statement.
>
> From the documentation of the JDBC driver for MySQL Connector/J I see that
> it supports the method getGeneratedKeys() to retrieve the assigned value.
> So an additionall SELECT statement is not necessary, isn't it?
>
> I debugged jOOQ's code execution and come across code lines 234ff. in
> class TableRecordImpl:
>
> // [#1859] In some databases, not all fields can be fetched via 
> getGeneratedKeys()
> if (REFRESH_GENERATED_KEYS.contains(configuration().family()) && this 
> instanceof UpdatableRecord)
>     ((UpdatableRecord<?>) this).refresh(key.toArray(EMPTY_FIELD));
>
> And to me here is the problem, because the enumeration
> REFREH_GENERATED_KEYS contains the MySQL dialect, which seems to be wrong.
> Can you confirm this?
>
> If the behaviour is correct, are there any other possibilty the prevent
> executing the extra SELECT statement after each INSERT statement.
>
> Kind regards,
> Marcus
>
> --
> 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