I succeded, one way or another :-P, to have it work and with good performance.
Please check hibernate docs chapter 13 for more accurate infos.
I added the following to the main configuration file
Code:
<property name="hibernate.jdbc.batch_size">20</property>
<property name="hibernate.cache.use_second_level_cache">false</property>
This improved a lot the speed while bulk inserting thousands of records into one of the two opened connections. I flush and clear the session that takes care of writing into the target db every 100 records.
I am using saveOrUpdate to insert newly created objects instances owning sets of children objects.
About the "bulk reading" I eliminated all the iterators and used arrays instead and created a home made caching system in which I load all the IDs I need, then loading blocks of 100 records and then writing them into the target DB.
I hope this can be helpful.