Back Forum Reply New

How to give Session to subreport

I have a master report (company), and each master report has its own subreport (trades). Each company has several trades. In master report, I pass $F{companyID} to the parameter quot;companyIDquot; in subreport.

In subreport, I put a query in HQL quot;from trades where companyID=$P{companyID}quot;

But when Jasperreport engine tries to fill subreport, it gives me the following message:
WARN - JRHibernateQueryExecuter.lt;initgt;(108) | The supplied org.hibernate.Session object is null.

I am wondering how to set the session for subreport. If I could let Spring give a session to subreport, it can solve problem.

I have dealed with it for three days. And tried different methods to pass data to subreport, no success.

Any solutions are very appreicated

I tried anther two methods:
1. use model.put(quot;HIBERNATE_SESSIONquot;, this.getSession(); Here, the quot;thisquot; is the HibernateDaoSupport. The master report use a data source, which is the model passed through ModelAndView, but I hope the subreport can use HIBERNATE_SESSION parameter to get a Hibernate session.

2. write HQL in master report instead of using the data source. Using this method is for asking Spring to create a hibernate session for master report, then master report will pass its HIBERNATE_SESSION parameter to subreport. This method works when tested in iReport. The Connections properties in ireport is:
Type of connection/data source: Spring loaded Hibernate connection
Spring configuration: applicationContext.xml; project.hbm.xml
Session Factory Bean ID: sessionFactory.

two methods cannot work.
I still have quot;WARN - JRHibernateQueryExecuter.lt;initgt;(108) | The supplied org.hibernate.Session object is null.quot;

Need help as soon as possible!
¥
Back Forum Reply New