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

2020-12-06 Thread electrotype
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 sam

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

2020-12-09 Thread electrotype
I can't see how they could possibly be out of order. Thanks, that what I think too. But, to be honest, I'd really like to see this written in some documentation! In some cases, this small detail can be quite important.

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

2020-12-09 Thread electrotype
So I'm curious. Why does order matter ? Dave Cramer www.postgres.rocks When you have to save multiple new entities with subentities. You first save all the parent entities in a single SQL batch insert, you get the generated ids, then insert all the subentities in another single SQL batch ins

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

2020-12-09 Thread electrotype
Agreed. However, this isn't really the purview of JDBC - I'm doubting it does anything that would cause the order to be different than what is received, and the batch items are sent and results processed sequentially. The main question is whether any batch items are inserting multiple record

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

2020-12-11 Thread electrotype
My take is that there is presently no guarantee, and that with current efforts to add parallelism it is quite probable that observation of such non-orderedness is simply a matter of time. With batching it seems best to combine its use with single inserts in order to avoid this problem. David J.