Hi,
Quote:
Will there be 1000 individual insert statements or will it make batch up the inserts into 1 call?
That depends....
If you are using a databas-located identifier-generator (like identity) there would be no way for hibernate to do batch-inserts, so there will be 1000 single inserts. If your identity-generation happens without use of the database and batch-inserting is supported hibernate will do batch-inserts according to the value of hibernate.jdbc.batch_size. E.g. batch_size=200 means 5 inserts with 200 customers each.
Quote:
How are session.flush() and session.clear() suppose to give me a performance boost? Does the session.flush() do the inserts as 1 statement or does it do all 20 inserts as 1 call to the database?
As for the batch-inserts: it's just the same as without the flush()/clear().
Flushing/clearing does not necessarily improve performance - espacially not when batch-inserting is used. What it does is that it keeps the size of the hibernate-session within reasonable bounds. If you do save 100000 Customer-instances without flushing you're sure to experience a dramatic slowdown because of increasing garbage-collection-activity in the JVM before your application dies with an OutOfMemoryError: Without the clear() the saved instances can't be garbage-collected because the hibernate persistency-context is still holding on to them.
To find the best interval-size in which to do the flush/clear-thing does heavily depend on your application, so the only way to find out the best values is to try.
Regards
piet