tags:

views:

364

answers:

1

I am importing raw data in groovy, hundreds of thousands of entries. I use the table fields as the keys of a hash map and then use the add(hash) method on a groove sql Dataset. The Dataset goes to a postgres table and the ID field is autogenerated from a sequence. I need to get the ID of each record as it is inserted.

In java + hibernate the ID gets inserted automatically inside the corresponding field of the object being persisted. In this case the add() method does not return anything nor does it add an id field to the hash table. I am trying to avoid using hibernate/gorm here for efficiency reason.

Thanks for any pointers or for a better approach.

+1  A: 

groovy.sql.SQL has an executeInsert() query which returns a list of the auto-generated column values for each inserted row.

Sean A.O. Harney
I need to rewrite the code to generate my insert sql statement but that's easy to do from the hash table that holds the record.
Marius Seritan