Jump to content
We've recently updated our Privacy Statement, available here ×

PROPERTY_HIBERNATE_QUERY_LIST_PAGE_SIZE don\'t work in jasper reports 4.1.1


brouardbas

Recommended Posts

hi,

in my application, I use JasperReports library 4.1.1 to make reporting. I use hibernate connection and hql query. I want display in previewer a single page. So I want JasperReports to fill report on only one page. For that I write following source code :

But the parameter  code        "parameters.put(JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_LIST_PAGE_SIZE, 1);" is not read because I have all filled pages.

I saw in JRXML that the tag "<property name="net.sf.jasperreports.hql.query.list.page.size" value="1"/>" is missing.

 

Thank for your help.

 

P.S : sorry for my bad english language

Code:
 /**     * This method is used to fill a report and to show if an error occurred during the filling     */    public void fillReport()    {        logger.trace("filling of report");        reportPrinted = null;        JasperReport reportCompiled = getReportCompiled();        Session session = HibernateUtil.getSessionFactory().getCurrentSession();        Transaction transaction = session.beginTransaction();        Map<String, Object> reportParameters = getFillingReportParameters(session);        try        {            reportPrinted = JasperFillManager.fillReport(reportCompiled, reportParameters);            logger.trace("filling report done and it contains {} pages", getNumberOfPages());        } catch (JRException e)        {            logger.error("An error is occured while filling of report : {}", LoggerManager.getErrorMessage(e));        }        transaction.rollback();    }    /**     * @param session     *            the hibernate session     * @return the map of filling report parameters     */    private Map<String, Object> getFillingReportParameters(Session session)    {        Map<String, Object> parameters = new HashMap<String, Object>();        parameters.put(JRHibernateQueryExecuterFactory.PARAMETER_HIBERNATE_SESSION, session);        parameters.put(JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_RUN_TYPE,                       JRHibernateQueryExecuterFactory.VALUE_HIBERNATE_QUERY_RUN_TYPE_LIST);        parameters.put(JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_LIST_PAGE_SIZE, 1);        return parameters;    }
Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

brouardbas
Wrote:

But the parameter  code        "parameters.put(JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_QUERY_LIST_PAGE_SIZE, 1);" is not read because I have all filled pages.

If you go at http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/query/JRHibernateQueryExecuterFactory.html#PROPERTY_HIBERNATE_QUERY_LIST_PAGE_SIZE and read what that property is used for, you'll find out that it has nothing to do with report pages.

If you want to fill the report in a single page, use JRParameter.html.IS_IGNORE_PAGINATION

Regards,

Lucian

Link to comment
Share on other sites

Code:
Thank you for your reply, but I don't want to remove pagination, I want to limit the number of results at 100 for exemple. In SQL, we use instruction "limit 100" but it doesn't exist in hql.

With hibernate we can just use the instruction query.maxResult(100) but this is JasperReports that manage query execution so I can't use it.

How do you limit the number of results with JasperReports using hql query ?

Thank you
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...