Passing data to subreport

2019-08-27 14:27发布

问题:

I am a a beginner in this topic. In my Java code I create a HQL query:

List <User> listOfDetails = session.createQuery("from User").list();

I would like to fill my subreport using data form above query. How should I complete the following code:

<dataSourceExpression><![CDATA[]]></dataSourceExpression>

回答1:

Use <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{listOfDetails})]]></dataSourceExpression>.