1

I am using hibernate(3.3 vesion) with sql server 2005. I have to insert 100 thousands records in to database. Since I am using IDENTITY for primary generation strategy, I am not able do bulk insert in hibernate. I tried StatelessSession and couldn't gain any performance.

Could anyone please suggest a way to improve performance?

Please help.

2 Answers 2

1

Use HibernateTemplate.saveOrUpdateAll(Collection entities) will give better performance.

Sign up to request clarification or add additional context in comments.

Comments

0

Your main issue here is to prevent Hibernate from caching in memory all the records you are going to insert. If you only bulk insert records in your transaction, you can use StatelessSession. If you do other operations, for example record some statistics about the bulk load, you should call session.flush(), session.clear() after certain number of records, for example, every 10K records.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.