iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library

13.07.2015 Views

iReport Ultimate GuideThe pattern used to recognize a timestamp (or date) object can be configured at the data source level by selecting the Usecustom date format check box option.11.6.8 Using JREmptyDataSourceUR provides a special data source named JREmptyDataSource.This source returns true to the next method for the record number (by default only one), and always returns null to every callof the getFieldValue method. It is like having records without fields, that is, an empty data source.The two constructors of this class are:public JREmptyDataSource(int count)public JREmptyDataSource()The first constructor indicates how many records to return, and the second sets the number of records to one.By default, iReport provides a pre-configured empty data source that returns a single record. To create a new empty datasource with more records, select Empty Datasource from the list of available connection types. You will prompted with thedialog shown in Figure 11-29.Figure 11-29 Empty data sourceSet the number or empty records that you need. Remember, whatever field you will add to the report, its value will be set tonull. Since this data source doesn’t care about field names or types, this is a perfect way to test any report (keeping in mindthat the fields will be always set to null).11.6.9 Using HQL and Hibernate ConnectionsUR provides a way to use HQL directly in your report. To do so, first set up a Hibernate connection. Expand yourclasspath to include all classes, JARs, and configuration files used by your Hibernate mapping. In other words, iReport must198

Data Sources and Query Executersbe able to access all the *.hbm.xml files you plan to use, the JavaBeans declared in those files, the hibernate.cfg.xml file,and any other JARs used (for example, JARs that access the database under Hibernate).To add these objects to the classpath, select Tools → Options and click the Classpath tab.Once you’ve expanded the classpath, open the Connections/Datasources dialog box, click the New button, and choose theHibernate connection as your data source type. This brings up the dialog box shown in Figure 11-30.Figure 11-30 Hibernate connectionClick the Test button to check the path resolution so that you can be certain that hibernate.cfg.xml is in the classpath.Currently, iReport works only with a single Hibernate configuration (that is, the first hibernate.cfg.xml file found in theclasspath).If you use the Spring framework, you can use a Spring configuration file to define your connection. In this case, you’ll need toset the configuration file name and the Session Factory Bean ID (see Figure 11-31).199

<strong>iReport</strong> <strong>Ultimate</strong> <strong>Guide</strong>The pattern used to recognize a timestamp (or date) object can be configured at the data source level by selecting the Usecustom date format check box option.11.6.8 Using JREmptyDataSourceUR provides a special data source named JREmptyDataSource.This source returns true to the next method for the record number (by default only one), and always returns null to every callof the getFieldValue method. It is like having records without fields, that is, an empty data source.The two constructors of this class are:public JREmptyDataSource(int count)public JREmptyDataSource()The first constructor indicates how many records to return, and the second sets the number of records to one.By default, <strong>iReport</strong> provides a pre-configured empty data source that returns a single record. To create a new empty datasource with more records, select Empty Datasource from the list of available connection types. You will prompted with thedialog shown in Figure 11-29.Figure 11-29 Empty data sourceSet the number or empty records that you need. Remember, whatever field you will add to the report, its value will be set tonull. Since this data source doesn’t care about field names or types, this is a perfect way to test any report (keeping in mindthat the fields will be always set to null).11.6.9 Using HQL and Hibernate ConnectionsUR provides a way to use HQL directly in your report. To do so, first set up a Hibernate connection. Expand yourclasspath to include all classes, JARs, and configuration files used by your Hibernate mapping. In other words, <strong>iReport</strong> must198

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!