Thread: Order of generated keys during inserts

Order of generated keys during inserts

From
Andrei Tsibets
Date:
Hello,

I’m doing multiple inserts into PostgreSQL using executeBatch, and then retrieving generated primary keys via getGeneratedKeys().
The question is: is it save to match inserts with retuned keys by order? Is it guaranteed that generated keys are ordered according
to the order in which commands were added to the batch?

PostgreSQL 11
JDBC driver 42.2.5

Thank you,
Andrei

Re: Order of generated keys during inserts

From
Dave Cramer
Date:


On Wed, 16 Oct 2019 at 20:26, Andrei Tsibets <andreit@geomotiv.com> wrote:
Hello,

I’m doing multiple inserts into PostgreSQL using executeBatch, and then retrieving generated primary keys via getGeneratedKeys().
The question is: is it save to match inserts with retuned keys by order? Is it guaranteed that generated keys are ordered according
to the order in which commands were added to the batch?

They should be but we make no such guarantee.