From: Budhaditya (JIRA) <no...@at...> - 2006-05-16 14:45:19
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1?page=comments#action_23107 ] Budhaditya commented on HHH-1: ------------------------------ Hibernate Bulk Insert is not Working for me..... Hi, I am using hibernate version 3.1.2 spring version 2.0 In my test-beans.xml I have these following entries...... <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> ............ ............ <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> <prop key="hibernate.hbm2ddl.auto">create</prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.cache.use_second_level_cache">false</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.use_structured_entries">true</prop> <prop key="hibernate.generate_statistics">true</prop> <prop key="hibernate.jdbc.batch_size">35</prop> </props> </property> .................... </bean> Now two important things to note here is 1. hibernate.cache.use_second_level_cache set to false 2. hibernate.jdbc.batch_size set to 35 Now I believe this is all the setting needed. My model names are Components and Process. for Bulk insert I was trying this.... for (int i = 0; i < 1000; i++) { hibernateTemplate.save(components.get(i)); } for (int i = 0; i < 1000; i++) { hibernateTemplate.save(processes.get(i)); } Instead of Single insert like this..... for (int i = 0; i < 1000; i++) { hibernateTemplate.save(components.get(i)); hibernateTemplate.save(processes.get(i)); } My problem is that both way the time taken is the same........... I tried putting trace on SQL database and I dint see any difference in queries also....... Can u please help me and tell me how do I make this Hibernate Bulk Insert Work???? Thanks and waitng in anticipation.... > Optimize Hibernate for the bulk insertion of related entities > ------------------------------------------------------------- > > Key: HHH-1 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1 > Project: Hibernate3 > Type: New Feature > Components: core > Environment: Hibernate 1.2, MySql 3.1 > Reporter: Bradley Leupen > Priority: Minor > > > It is currently difficult to batch the creation of persistent entities that maintain associations with other entities. > Add necessary api to hibernate to support the save or update of a collection of entities. An optimization can be applied in this scenario to group inserts / updates by entity class, or table. This will enable the hibernate engine to utilize batching if available, drastically improving performance over a network. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |