i have problem with session close what impact during running this application and what if this goes in production.
i faceting two problem in my production server its consume lots off memory during application usage around 800MB to just start up.
after some time its give an outofmemory error and server crashes
i am using tomcat server for deploy my application
my code is this
@Transactional
public Collection list(String queryString, Object[] value) throws Exception {
Session session = this.sessionFactory.getCurrentSession();
Query query = session.createQuery(queryString);
return query.list();
}
@Transactional
public Collection list(String queryString, Object[] value) throws Exception {
Session session = this.sessionFactory.openSession();
Query query = session.createQuery(queryString);
return query.list();
}
if i do close the session then lazy initialization gives an error for session is already closed.
please help me to come out this problem. How we can take care about open session in hibernate with spring configuration i am using hibernate 3.6.1 and spring 3.0.6.
add VM arguments to your server to avoid outofmemory error
-Xms256m -Xmx1024m -XX:+DisableExplicitGC -Dcom.sun.management.jmxremote
-XX:PermSize=256m -XX:MaxPermSize=512m
and add
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
code above method to strictly handle transaction without worry about Session object