|
|
This document presents an overview of JPA features available in
MyEclipse.
To
get a better feel for MyEclipse and learning more about it,
please check out our product
Documentation for more
material.
|
|
a) Persistence Providers
MyEclipse provides support for the
Toplink Essentials, OpenJPA and Hibernate 3.x JPA providers.
Figure 2.1. Adding JPA Capabilities
b) Database Configuration
Create a persistence unit and associate your project with a
database and schema for design-time tool support. The project in
the next screenshot is being associated with the database driver
for the local
MyEclipse Derby database.
Figure 2.2. Configure the datasource
The Enable dynamic DB table creation is a runtime configuration option that when checked, instructs the application's persistence provider to automatically create any missing database tables required to support the persistent entities of your application.
This features makes testing your application against a temporary database much easier and faster,
allowing you to deploy your application quickly with minimal database configuration.
You may change a JPA project's database driver association at any
time using the
Java Persistence properties page. To invoke this
page, right click on the project and select Properties from the
context menu. From the Properties dialog shown below, expand the
MyEclipse node and select Java Persistence.
Figure 2.3. Java Persistence properties page
|
a) Entity Generation
Initiate Entity generation from the context menu of a JPA project.
This will launch the JPA Reverse Engineering Wizard.
Figure 3.1. Entity generation from JPA project
Entity generation can also be initiated from the Database
Browser view.
Figure 3.2. Entity generation from DB Table
The reverse engineering process is fully customizable. Using the
JPA Reverse Engineering Wizard you can choose the artifacts to
generate and the database tables from which the artifacts will be
based.
Figure 3.3. Customize reverse engineering
MyEclipse can also generate DAOs with result pagination support for findBy<property> queries. The generated result pagination API provides DAO clients fine-grained programmatic control to position to a specific row number of a resultset and fetch 'n' entities.
Following are several sample snippets of the code generated by the
Reverse Engineering Processor.
Figure 3.4. Sample snippets
|
a) MyEclipse Java Persistence Perspective
The MyEclipse Java Persistence Perspective provides an optimal
editor and view layout for JPA oriented tasks.
Figure 4.1. MyEclipse Persistence perspective
b) JPA Details View
The JPA Details view makes it easy to edit entity annotations.
Figure 4.2. JPA Details view- Select table
Figure 4.3. JPA Details view - Edit detail
c) JPA Annotation Table and Column Content Assist
Figure 4.4. Table Content Assist
Figure 4.5. JPA annotation column content assist
d) JPA Entity Validation
Errors in your mapping are detected and displayed in the editor
and problems view.
Figure 4.6. JPA validation errors shown in Java editor
The
JPA Entity Validator can be enabled or disabled
at the project level.
Figure 4.7. JPA Validation preferences
|
a) Spring 2 Support
When adding JPA Capabilities to a project that already has Spring
capabilities or vice versa, you can choose advanced Spring-JPA
support. This level of support enables JPA tools to work with your
project's Spring artifacts. Following is a screenshot of the
Spring-JPA project configuration wizard.
Figure 5.1. Adding Spring Capabilities Wizard
Select your primary bean configuration file and customize bean Ids
and transaction support.
Figure 5.2. Configure Spring-JPA support
b) Reverse Engineering Entities and Spring DAOs from Database
For projects that are configured to support advanced Spring-JPA
capabilities, in addition to generating Entity classes from a
database schema, Spring compatible DAOs can be generated. During
the reverse-engineering process the Spring application context
file is updated with generated bean entries for each DOA class.
Figure 5.3. Generate Spring DAOs.
Figure 5.4. Generated Spring application context file.
Figure 5.5. Generated Spring DAO extends from Spring's
JpaDaoSupport.
|
|
We would like to hear from you! If you liked this overview, have
some suggestions or even some corrections for us please let us
know. We track all user feedback about our learning material in
our
Documentation Forum.
Please be sure to let us know which piece of MyEclipse material
you are commenting on so we can quickly pinpoint any issues that
arise.
|