-->
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.  [ 2 posts ] 
Author Message
 Post subject: getHibernateTemplate() is taking very Long
PostPosted: Fri Feb 26, 2010 4:18 am 
Newbie

Joined: Fri Dec 04, 2009 5:10 am
Posts: 14
Hello All,
I am using a spring hibernate application. But when I call getHibernateTemplate(), it goes to some kind of sleep state after 5 to 6 calls to this class. I have changed the way, the spring beans are taken from application context in order to save some development time. Here is what I do:

public class SurveySupportDAO extends HibernateDaoSupport{
private static final Log log = LogFactory.getLog(SurveySupportDAO.class);
static ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {"applicationContext.xml"});
static SessionFactory bean = (SessionFactory) ctx.getBean("sessionFactory");
public SurveySupportDAO(){
super.setSessionFactory(bean);
}


//rest of the functions

}

I just take the sessionFactory bean from applicationContext and in SurveySupportDAO constructor I set it to the parent class's attribute instead of injecting sessionFactory to SurveySupportDAO.

I get the sessionFactory Bean, and I can also call the different functions of getHibernate, But it goes to sleep state after some time. Can anyone suggest me how should I go for this solution?


Top
 Profile  
 
 Post subject: Re: getHibernateTemplate() is taking very Long
PostPosted: Fri Feb 26, 2010 5:03 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Generally if a java application becomes slow I suggest following:
1. Check the through-put of the garbage-collector.
If your JVM risks to go in OUT-OF-MEM, then the garbage-collector will run very often trying to release some memory.
This can reduce the performance of your application in remarkable way.
2. Produce some stacktraces of your slow java application with jstack
Check where the code is stucking.
Looking a the stacktraces usually helps very fast to locate eventual bottlenecks in java code.
Usual scenarios for slow applications are:
- thread waiting for accessing a synchronized block which actually is executed by another thread
- almost-endless-loops: uneffective alghorhythms with large iterations over the same code-lines again and again.
- waiting on response of an external source (socketRead) for example waiting for a result set from the database


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.