Re: INSERT ... RETURNING when doing CRUD with Record objects

Sun, 31 Mar 2019 06:36:25 -0700

Hi  Marshall  ,

Maybe this helps:
https://www.jooq.org/doc/latest/manual/sql-building/dsl-context/custom-settings/settings-return-all-on-store

The default value for the returnAllOnUpdatableRecord is false, as this is
usually not needed, and it causes an extra query on some RDBMS that do not
support the functionality natively (i.e. an implicit refresh() call)

Thanks,
Lukas

On Sat, Mar 30, 2019 at 4:45 AM Marshall Pierce <[email protected]>
wrote:

> I might be missing something obvious in the UpdatableRecord API, but I
> didn't find a way to emulate INSERT ... RETURNING. Is there a way to do
> that?
>
> As an example, I'd like to mimic this behavior (inserting into a simple
> table that only needs `name` specified):
>
> txnContext.insertInto(WIDGETS, WIDGETS.NAME)
>      .values(name)
>      .returning()
>      .fetchOne()
>
> with this:
>
> txnContext.newRecord(WIDGETS).apply {
>      this.name = name
>      store() // INSERT
>      refresh() // SELECT -- ideally not needed
> }
>
> Without that `refresh()`, the new `WidgetsRecord` doesn't have, for
> instance, its db-populated `createdAt`.
>
> Thanks,
> Marshall
>
> --
> 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