-->
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.  [ 1 post ] 
Author Message
 Post subject: Out of memory error
PostPosted: Sat Jul 31, 2010 6:05 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2010 3:35 pm
Posts: 37
Hi All,
I have a DAO method written to fetch a list of records based on certain search criteria's. The table mapped to the entity has lot of records and also keeps growing at a faster rate. I use the below method to get all the records satisfying some basic search criterias and show their property values in a 'pdf' or 'excel' . The method is,

@SuppressWarnings("unchecked")
public List<EntityAuditRecord> fetchEntityAuditRecords(Map<String, Object> searchCriteria) {

Criteria criteria = getSession().createCriteria(EntityAuditRecord.class);
Boolean flag = Boolean.FALSE;

if ((searchCriteria != null) && !(searchCriteria.isEmpty())) {

if (searchCriteria.containsKey("userId")) {
criteria = criteria.add(Restrictions.eq("userId", searchCriteria.get("userId")));
flag = Boolean.TRUE;
}

if (searchCriteria.containsKey("eventTypeCode")) {
criteria = criteria.add(Restrictions.eq("eventTypeCode", searchCriteria.get("eventTypeCode")));
flag = Boolean.TRUE;
}

if (searchCriteria.containsKey("outcomeCode")) {
criteria = criteria.add(Restrictions.eq("outcomeCode", searchCriteria.get("outcomeCode")));
flag = Boolean.TRUE;
}

if (searchCriteria.containsKey("applicationName")) {
criteria = criteria.add(Restrictions.eq("applicationName", searchCriteria.get("applicationName")));
flag = Boolean.TRUE;
}

if (searchCriteria.containsKey("beginDate")) {
criteria = criteria.add(Restrictions.ge("auditDate", searchCriteria.get("beginDate")));
flag = Boolean.TRUE;
}

if (searchCriteria.containsKey("endDate")) {
criteria = criteria.add(Restrictions.le("auditDate", searchCriteria.get("endDate")));
flag = Boolean.TRUE;
}

if (searchCriteria.containsKey("orgId")) {
criteria = criteria.add(Restrictions.eq("orgId", searchCriteria.get("orgId")));
flag = Boolean.TRUE;
}

if (searchCriteria.containsKey("action")) {
criteria = criteria.add(Restrictions.ilike("action", (String) searchCriteria.get("action"), MatchMode.ANYWHERE));
flag = Boolean.TRUE;
}

if (searchCriteria.containsKey("roleId")) {
criteria = criteria.add(Restrictions.eq("roleId", searchCriteria.get("roleId")));
flag = Boolean.TRUE;
}

}

if (flag) {
return criteria.list();
} else {
return Collections.EMPTY_LIST;
}

}


I get java heap space out of memory error due to the large volume of data being fetched, and which is understandable. I had a look at the scrollable result set option but I am not sure whether that would help my cause because the 'pdf' creation code is at a servlet level and it does have access to a hibernate session to clear/flush the session cache after processig a few records instead of me getting all the records in a list and sending it to the 'pdf' creation class.We use 'OpenSessionInViewInterceptor' to deal with the session creation/closing process and this code does not have access to the hibernate session . I might be wrong. Any hint would be helpful?

this is what we have configured,
<bean id="openSessionInViewInterceptor"
class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
<property name="sessionFactory" ref="sessionFactory" />
<property name="singleSession" value="true" />
<property name="flushModeName" value="FLUSH_AUTO" />
</bean>

regards
Aravias


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

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.