Wouldn't it be better to create a query like

SELECT nextval(seq_table_id)

and execute it before you insert and use that as the ID... The "last_value" may be executed AFTER another item has been added to the table... so the Sequence number might not be the most current even though you are encapsulated in a transaction... Unless when you start the transaction, the Database automagically reserves a block of sequence numbers for that transaction...

I've been frustrated because the "getGeneratedKey()" method IS available in MySQL, but not in Postgresql, so I've been having to use the above method to capture unique keys associated with an Insert...