0

In my application I am using Spring 4.0 declarative transaction management and hibernate in dao layer...I use hibernate template for insert and updates. ..since I have to insert a large number of records I do call flush and clear methods on hibernate template..after every 50 records..But what I have observe is it locks that particular table while processing. ..only after all records are inserted in db I can fire a query on db... Is this behavior correct ??? Does it have any proper solution

2
  • Did you change the default flush mode? Try like this : Session session = sessionFactory.openSession(); session.setFlushMode(FlushMode.AUTO); Nov 27, 2015 at 2:09
  • I did not change default values and secondly I do not use session factory ..I use hibernate template directly and call flush and clear on that Nov 27, 2015 at 2:48

1 Answer 1

0

Try adding following data source properties to your datasource configuration.

<property name="maxActive" value="100"></property> 
<property name="maxIdle" value="30"></property> 
<property name="maxWait" value="10000"></property> 

Check this also. Hope this helps.

4
  • I use hibernate 4.. i dont think above properties will help..My question here is ..Is this hibernate feature to take the lock on database in above situation Nov 27, 2015 at 5:02
  • Did you try adding that or just assuming? Here is one more reference, how you can add these properties. forum.spring.io/forum/spring-projects/data/… Nov 27, 2015 at 5:11
  • I use websphere as application server and configure datasource at server level where connections are well managed. Do you want me to changes ds configurations at server level? Nov 27, 2015 at 5:33
  • I think it's worth trying. I don't know about websphere but in tomcat, we could add these properties in server.xml. Nov 27, 2015 at 5:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.