imilina Posted January 15, 2007 Share Posted January 15, 2007 Hello, I was wondering about performance and memory issues with hibernate connection compared to jdbc when used in jasperreports. Hibernate is well known to perform poorly when fetching large amounts of data (100,000 records for example), mainly because of storing all objects in session cache. I don't know much on how exactly jasper uses hibernate, but I would expect those memory problems would be present here as well. What are your experiences when working with reports that require large amounts of data? Does jdbc connection and sql queries performs better? Regards,Igor. Link to comment Share on other sites More sharing options...
lucianc Posted January 17, 2007 Share Posted January 17, 2007 The session cache is not a problem since you can explicitly evict objects from it or completely clear it. Unfortunately the built-in JR Hibernate query executer/data sources do not perform any session cache cleaning. You can do that by yourself by extending the JR Hibernate query executer to perform a session cache clean-up each time a result chunk is fetched:Code:<!-- you can specify the result page size in your JRXML --><property name="net.sf.jasperreports.hql.query.list.page.size" value="5000"/># or you can specify it globally in jasperreports.propertiesnet.sf.jasperreports.hql.query.list.page.size=5000// now you need to extend the JR query executerclass MyHibernateQueryExecuter extends JRHibernateQueryExecuter { public List list(int firstIndex, int resultCount) { session.clear(); return super.list(firstIndex, resultCount); }} You would also need to extend JRHibernateQueryExecuterFactory so that it produces MyHibernateQueryExecuter instances. If you think this might be useful to others as well, you can open a [url=http://jasperforge.org/sf/tracker/do/listArtifacts/projects.jasperreports/tracker.feature_requests]Feature Request and we would consider including this functionality into JR. An alternative to clearing the session cache would be to write a query executer that works with org.hibernate.StatelessSession instances instead of org.hibernate.Session. Regards,Lucian Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now