Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?

From: Dave Cramer <davecramer(at)postgres(dot)rocks>
To: electrotype <electrotype(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?
Date: 2020-12-08 23:23:44
Message-ID: CADK3HHL68fd+D_e-jGdx9J--hrwEx26-5a-V6fFf=OOLUTgApw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 6 Dec 2020 at 15:52, electrotype <electrotype(at)gmail(dot)com> wrote:

> Hi,
>
> Using JDBC, I batch insert multiple rows (*"executeBatch()*"). I then use
> *'**getGeneratedKeys("id")*' to get the generated ids ("id" is a "*SERIAL
> PRIMARY KEY*" column).
>
> My question: does the PostgreSQL JDBC driver *guarantees *that the order
> of the returned generated ids will be the same as the rows to insert have
> been specified, using "*addBatch()*"?
>
>
> The best "answer" to that question I have found is
> https://stackoverflow.com/a/16119489/843699 , but it is not 100% clear.
>
> Would it be possible to have an official answer on this?
>

I can't see how they could possibly be out of order.

Dave Cramer
www.postgres.rocks

>
> Thanks in advance!
>
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message electrotype 2020-12-09 01:23:47 Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?
Previous Message Huan Ruan 2020-12-08 23:07:21 Re: Potential BRIN Index Corruption