Jump to content
Changes to the Jaspersoft community edition download ×

Hibernate connection / performance


Recommended Posts



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?




Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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:


<!-- 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.properties

// now you need to extend the JR query executer
class MyHibernateQueryExecuter extends JRHibernateQueryExecuter {
public List list(int firstIndex, int resultCount) {
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.




Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...