Print Properties
Hibernate

The version 1.2 of Inforama introduces the ability to use Hibernate generated POJOs as data sources. Hibernate POJOs can be accessed in the same way as in case of Java Beans data source. The steps below show how to create Hibernate Data Source. The screenshots and examples are taken from the sample HibernateSampleProject whic is attached to this wiki entry.

Setting up the Hibernate Data Source

Each Hibernate data source must point to a folder containing the Hibernate configuration file (hibernate.cfg.xml) and to a set of folder and jar files containing the required java classes (mapped entities). In order to set up a new data source go to Data->Connection/Data Sources, press the New button, choose the Hibernate as the type of data source that you want to add and finally choose the required jar files and folders containing your mapped entities and hibernate configuration file (hibernate.cfg.xml).
choosing Hibernate as a data source

The sample attached project is using (as its data source) classes and the Hibernate configuration file that are stored in the project's resources/SakilaHibernate folder. The POJOs being used are mapped to the Sakila database (see Setting up the sample projects wiki entry).

Creating Data Sets from a Hibernate Data Source

Data Sets associated with Hibernate Data Sources are defined by a HQL (Hibernate Query Language) query. The screenshot below shows the definition of a customer data set which is used in the document1 of the attached. project.
defining the data set with a HQL query
The data set from the screenshot above will return an org.sakila.Customer object wit the specified customerId parameter.

Sample Document

The document below ilustrates the usage of the customer data set in a Open Office template document. The document displays the information about a customer, specified by the customerId parameter, and lists all his rentals.
OO template using Hibernate data set
The output generated from this template looks like shown below.
the result PDF document
1102 Views, 1 Attachments 1 Attachments

  • Comments
Copyright © 2008 - 2010