Hi i am trying to run a hibernate query <query name="com.qwest.rx.entity.OutageT.all.active.current.bsi.version"> select outage from OutageT as outage left join fetch outage.tickets left join fetch outage.affectedTns left join fetch outage.products where outage.isCurrent = true and outage.isActive = true and outage.status != 'New' and outage.outageType = 'BSI' </query> which fetches around 15000 records. the sql generated from this query runs fine..within few seconds. All these records will be stored in a collection as a arraylist. But the problem is, hibernate is taking lot of time to load the collection of objects. It takes around 8 minutes. basically resultset to Object mapping is taking time. Below is the code snippet to fetch the result. I dont know if there is any configuration changes. I tried with the lazy loading as well.
public static Collection executeQuery(String queryName) {
Transaction tx = null;
Session session = null;
Collection results = null;
try {
_sessions = SessionFactoryUtil.getSessionFactory();
session = _sessions.openSession();
Query query = session.getNamedQuery(queryName);
//query.setCacheable(true);
tx = session.beginTransaction();
results = query.list();
System.out.println(results.size());
tx.commit();
} catch (MappingException e) {
log.error("EXCEPTION : 7105 - Exception while DB call...", e);
} catch (HibernateException e) {
log.error("EXCEPTION : 7106 - Exception while DB call...", e);
if (tx != null)
try {
tx.rollback();
} catch (HibernateException e1) {
log.error("EXCEPTION : 7107 - Exception while DB call...", e1);
}
} finally {
try {
if(session != null)session.close();
} catch (HibernateException e1) {
log.error("EXCEPTION : 7109 - Exception while DB call...", e1);
}
}
return results;
}
|