Flush synchronizes the hibernate session cache, sending any changes made down to the database. It doesn't affect any transactions, so the changes are applied (by the DBMS) only inside the current transaction.
You can turn on autocommit mode like this:
Code:
session.connection().setAutoCommit(true);
But don't, it's not a good thing to do. You should use batching: something to the effect of flushing after every 20 saves and committing at the end. Optionally, you can commit after (e.g.) every 200 saves, but then you risk ending up with a partially-updates DB. That probably isn't too bad in this case, as your code is obviously handles importing the same file more than once, so you can simply re-import it.
One thing that will probably improve performance is to run this as a two-step process. First, outside of a transaction (or in a read-only transaction), get all your existing (in DB) models, and use them to whittle down the list of models to be imported, so that you end up with only the 0 to 20 new models to write. You can even use a StatelessSession to speed this up a little bit. Then save the (relatively) tiny list of new models.