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

From: electrotype <electrotype(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?
Date: 2020-12-06 20:51:51
Message-ID: 36689061-0844-2dfd-a4ee-8006d8a15ca9@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

Thanks in advance!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Godfrin, Philippe E 2020-12-06 23:27:57 Partitioning with FDW and table size limits
Previous Message Alexander Farber 2020-12-06 19:30:08 Re: SELECT but only if not present in another table