I am trying to use batch insert using hibernate. I am using Oracle .
Have set up in hibernate.cfg.xml
hibernate.jdbc.batch_size=20
hibernate.jdbc.fetch_size=20
I am using oracle sequence for insert and so have the sequence
also set in file hbm.xml
<param name="sequence">XYZ_ID_SEQ</param>
However , it seems like although say 20 inserts it does in one batch with one round trip to the database. But to get the oracle generated sequence value it has to do 20 roundtrips to the database for each insert.
So actually it takes 21 round trips to insert 20 rows in the database.
Is there a solution to reduce it to only 2 or 3 round trips.
Thanks,
vikas
|