Java Reference
In-Depth Information
new HibernateQueryDemo().fillReport(args[0]);
}
public void fillReport(String countryCode)
{
String reportDirectory = "reports";
"reports";
reports";
session = createSession();
Map parameterMap = new HashMap();
parameterMap.put(JRHibernateQueryExecuterFactory.PARAMETER_
HIBERNATE_SESSION, session);
parameterMap.put("countryCode", countryCode);
"countryCode", countryCode);
countryCode", countryCode);
try
{
System.out.println("Filling report...");
Filling report...");
JasperFillManager.fillReportToFile(reportDirectory
+ "/HibernateQueryDemoReport.jasper", parameterMap);
"Filling report...");
/HibernateQueryDemoReport.jasper", parameterMap);
System.out.println("Done!");
"/HibernateQueryDemoReport.jasper", parameterMap);
"Done!");
Done!");
}
catch (JRException e)
{
System.out.println("There was an error filling the report.");
"There was an error filling the report.");
There was an error filling the report.");
e.printStackTrace();
}
}
private Session createSession()
{
SessionFactory sessionFactory = new Configuration().configure().
buildSessionFactory();
return sessionFactory.openSession();
}
}
Once again there is not much difference between filling a report using an embedded
HQL query and filling a report using an embedded SQL query or a report using a
datasource. The main difference is that an instance of org.hibernate.Session must
be passed to the report via a parameter named
 
Search WWH ::




Custom Search