Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/Examples/JPA/Employee

< EclipseLink‎ | Examples‎ | JPA
Revision as of 11:41, 7 May 2013 by Douglas.clarke.oracle.com (Talk | contribs) (Build and Test)

EclipseLink JPA Employee Examples

This set of examples uses a common employee domain model and relational schema with various configuration approaches.

  • Model: JPA using standard and extended annotations along with eclipselink-orm.xml mapping file.
  • Model Web: JPA using standard and extended annotations along with eclipselink-orm.xml mapping file with a web interface.
  • Model Web JS: JPA using standard and extended annotations along with eclipselink-orm.xml mapping file with a web interface.

Try them Out

To try out these examples using GIT, Maven, and the Eclipse Java EE IDE. These example projects can be adapted for other development environments.

Check out the code

You can check the latest versions of all the example projects out of GIT from:

Build and Test

The model project comes with test cases that validate the JPA model and its services function correctly. It is configured to run on embedded derby by default so generally running 'mvn test' in the model project will run the examples and test cases and let you know that everything is working correctly.

Setup your Container

TODO:

  • Requires a data source named 'java:global/employeeDS' User required to set this up. a WLST example included.

Deploy and Try

TODO

  • add intro screen shot
  • highlight key operations
    • Admin to reset database and populate
    • Search and pagination options
    • Create
    • Delete

(very basic details only)

Understanding the Example

Employee Model

The employee model has existed in TopLink and EclipseLink since the mid 90's. The model has evolved a little over the years based on enhancements made available in the mappings.

EclipseLink Example Employee model.png

JPA 2.0 and Extended Features

When updated for EclipseLink 2.1 several JPA 2.0 features were introduced to the model and its mappings. These include:

  • PhoneNumber now mapped using derived identifiers so its primary key of EMP_ID and PTYPE are mapped with PhoneNumber.owner and PhoneNumber.type. The previous redundant mapping of PhoneNumber.id has been removed.

While the majority of the Employee examples use pure JPA mappings several extensions offered by EclipseLink are highlgted including:

  • Employee.gender mapped to the enum Gender using a converter to store a single char code in the database instead of the full enum's name or oridinal position.

Back to the top