EclipseLink JPA Employee Examples
This set of examples uses a common employee domain model and relational schema with various configuration approaches.
- Annotations: JPA using standard and extended annotations
- XML: JPA using extended eclipselink-orm.xml mapping file
- Dynamic: Dynamic persistence (no Java classes) mapped using API and eclipselink-orm.xml
Try them Out
To try out these examples you can download from the project's GIT repository or you can download the packaged projects.
You can check the 2.1 versions of the example projects out of GIT from dev.eclipse.org:
- /svnroot/rt/org.eclipse.persistence/branches/2.1/trunk/examples/jpa.employee/ to get all of the examples
- /svnroot/rt/org.eclipse.persistence/branches/2.1/trunk/examples/jpa.employee/eclipselink.example.jpa.employee.annotations/ - annotations version
- /svnroot/rt/org.eclipse.persistence/branches/2.1/trunk/examples/jpa.employee/eclipselink.example.jpa.employee.xml/ - XML version
- /svnroot/rt/org.eclipse.persistence/branches/2.1/trunk/examples/jpa.employee/eclipselink.example.jpa.employee.dynamic/ - dynamic version
Understanding the Examples
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.
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.gendermapped 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.
- ORM XML
- EclipseLink ORM
- JPA ORM + EclipseLink ORM