About : BIRT JPA or JDO Connector
- 1 Abstract
- 2 Participants
- 3 Planned Features
- 4 Community proposals
- 5 Getting the source
- 6 Implementation of JPA ODA plugin
- 7 JPA ODA UI Plug-in
- 8 References
The Java Persistence API (JPA)is the Java API for the management of persistence and object/relational mapping for Java EE and Java SE environments. The persistence consists of three areas:
- the API, defined in the javax.persistence package
- the Java Persistence Query Language
- object/relational metadata
The purpose of this project proposal is to implement a Connector JPA for BIRT framework, and so able to handle data source from the persistence API. Is so great the importance of the project because JPA is a specification that is being used widely in the development of applications, precisely from the advantages it.
The implementation is to make the JPA ODA driver, extending each one of the interface required in the Data Tools Plataform given in the package org.eclipse.datatools.connectivity.oda.
Finalizing it first part will be an improvement approaching also advanced options in regard to the parameters and also will be implemented JPA ODA IU extensions.
- Student: Victoriano Alfonso Phocco Diaz <email@example.com> -
- Mentor: Jason Weathersby <firstname.lastname@example.org> - http://www.blogger.com/profile/13114050439576571984 http://eclipse.sys-con.com/author/jasonweathersby.htm
- Project Hosting GSoC:
- Handling of configuration file: persistence.xml.
- JPA utilities for get current EntityManager and EntityManagerFactory
- JPQL queries validation.
- Get the metadata information such as column names, column types, column class for the query .
- Instantiation of ResulSetMetaData, DataSetMetaData, ResulSet.
- Soport in the preparement and execution of Queries.
- Working good with the implementations de JPA: Hibernate and TopLink.
- Handling of other configuration file: orm.xml
- Soport more advance of Parameters into queries.
Nice to have
- Soport JDO and JPA at the same time.
Feel free to add your comments and ideas.
Getting the source
Implementation of JPA ODA plugin
The "Statement" class
The "Statement" class, prepare the result set metadata of the query (containing column name, column type, and entity name that belong), execute the query, and fetches the data rows from the Data Source.
Problems founded developing whit JPA in this class:
1. To get attributes of the entities (field names and field types) found into the query e.g.:
SELECT d.departmentIdentifier, d.name FROM Department d
Was necessary know the complete path, like “jfabian.model.department.entity.Department”, an option was write this in the query as is possible in hibernate but this idea was discard becouse JPA not allow it.
The solution was getting the name of entity and searches the complete path into “persistence.xml” file, this implemented in “JPAUtil.findEntityOnPersistenceXML(entityName, classNodes)” function.
2. Other aspect to take into consideration are the entity alias, this to retrieve the corresponding column e.g.:
SELECT d.departmentIdentifier, d.name, e.employeeIdentifier , e.firstName FROM Department d, Employee e
In this query the alias for Department is “d”, and its columns are “departmentIdentifier” and “name”, to retrieve the columns types I need know the entity name (with path complete), and column or field name.
And the functionality should be correct if the column order is not the same to instance of the entities, e.g.:
SELECT e.firstName, d.name, e.employeeIdentifier, d.departmentIdentifier FROM Department d, Employee e
For this task was implemented “extractColumns(qry)”, that return a “List<List<String>>” containing the entity alias and column name. Other was “getReturnEntities( String query )”, that return a “List<List<String> >” containing entity name and entity alias.
A) Yet not support the recognition of alias with “as” like:
SELECT d.name FROM Department as d
B) Yet not support retrieve all columns of the entity (similarity to Selec *from department in JDBC):
SELECT d FROM Department as d
C) When a entity has a member variable to other entity, retrieve its metadata still is not possible:
SELECT d.director.firstName FROM Department d
In this case “director” is an entity “Employee”
D) Yet not distinguish some reserved words like:
SELECT DISTINCT d.name FROM Department d
E) Collection member declaration*
SELECT DISTINCT l.product FROM Order AS o, IN(o.lineItems) l
F) The possibility for retrieve metadata when use aggregate functions *
SELECT AVG(mag.price) FROM Magazine mag
- On JSR220: Enterprise Java Beans V3.0, Java Persistence API in Chapter
- In this video we are preparing all necesary for generate the report, like; install BIRT Runtime, deploy the ODA JPA plug-in, create the JPA test project, install the Sample database, configure the report, etc.:
- Here show the generation of report and the result:
JPA ODA UI Plug-in
To use the data retrieved by the JPA ODA driver in a BIRT report design, One must extend the DTP design UI. To implement the JPA ODA UI, extend the following extension points:
- Eclipse Resources:
- The plug-in extension examples from Integrating and Extending BIRT
- Book:Jason Weathersby, Don French, Tom Bondur, Jane Tatchell, Iana Chatalbasheva, "Integrating and Extending BIRT",Addison-Wesley.
- JPA specification:
- Documentation JPA API:
- GlassFish Project - Java Persistence Example:
- Master the New Persistence Paradigm with JPA
- Persistence Pays Offs: Advanced Mapping with JPA
- Using the Java Persistence API in Desktop Applications: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/persistenceapi/?feed=JSC
- Basic Java Persistence API Best Practices
- Book: Mike Keith, Merrick Schincariol, "Pro EJB 3: Java Persistence API", Apress.
Other Important References
- Documentation Hibernate API:
- Documentation TopLink API:
- JFire Project - BIRT datasource for JDO:
- OpenMRS - BIRT ODA Plugin User Guide:
- Example about JasperReports with JPA:
- Advanced somethings about JPA file configurations : http://netbeans.dzone.com/news/netbeans-and-jpa-with-multiple