-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: spring hibernate batch insert
PostPosted: Wed Jan 02, 2013 5:44 am 
Newbie

Joined: Fri Oct 12, 2012 1:22 am
Posts: 3
applicationContext

<context:component-scan base-package="com.abc" />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
</bean>

in java code:
List<Contact> contacts = entityService.findByNamedQuery(qury1);

i have all the records here,now i have to insert contacts in batch of 100 , in hibernate older version i can use
getHibernateTemplate().saveorupdateall() but in hibernate 4 i have no idea for batch insert

thanks in adv


Top
 Profile  
 
 Post subject: Re: spring hibernate batch insert
PostPosted: Thu Jan 03, 2013 8:35 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Hello,
Code:
<property name="hibernate.jdbc.batch_size" value="100"/>
    <property name="hibernate.order_inserts" value="true"/>
    <property name="hibernate.order_updates" value="true"/>


with these properties, hibernate should batch the inserts even if you use the common api to persist new objects.


Top
 Profile  
 
 Post subject: Re: spring hibernate batch insert
PostPosted: Fri Jan 04, 2013 12:49 am 
Newbie

Joined: Fri Oct 12, 2012 1:22 am
Posts: 3
hi pb00067 thanks for reply,
i have to insert only one entity using batch insert ur suggestion is wonderful but i have to process batch insert only for contact not other entities, so i am confuse abt it.
thanks once again


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.