Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: for the plan.

Jump to: navigation, search


This version of the Employee example illustrates how EclipseLink JPA can be used using just XML to define the mappings and runtime options.

Example Details

The example maps a relatively simple domain model representing an Employee and the Projects they are involved with. All of the mapping is done using EclipseLink ORM.XML which is based on the JPA ORM.XML with some additional advanced features exposed.

This example illustrates the following EclipseLink JPA capabilities:

  • ORM Mapping using XML
    • EclipseLink's extended ORM.XML mapping file ( How To)
    • EclipseLink JPA Advanced Mapping
      • Cache Configuration
      • ObjectTypeConverter for database coded Enum values on Employee.gender
      • BasicCollection mapping for Employee.responsibilities
      • PrivateOwned relationships: Employee.address and Employee.phoneNumbers
  • Schema generation
  • Testing outside the container


This zip file contains an Eclipse Ganymede JPA project (using Dali). It can be imported into a workspace or if you are not using Eclipse you can simply setup a new environment based on the provided source files.


To run this example you will need the following libraries on your classpath:

Besides configuring your classpath with these necessary libraries you will also need to modify the /src/META-INF/persistence.xml to provide your JDBC driver, URL, and login credentials. The provided file appears as:

<?xml version="1.0" encoding="windows-1252" ?>
<persistence xmlns:xsi=""
	version="1.0" xmlns="">
	<persistence-unit name="employee" transaction-type="RESOURCE_LOCAL">
		<description>This is part of the Employee JPA example using just XML configuration.</description>
			<property name="eclipselink.logging.level" value="FINE"/>
			<property name="eclipselink.logging.thread" value="false"/>
			<property name="eclipselink.logging.session" value="false"/>
			<property name="eclipselink.logging.timestamp" value="false"/>
			<property name="eclipselink.logging.exceptions" value="false"/>
			<!-- The following properties should be customized to run the example -->
			<property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:ORCL"/>
			<property name="eclipselink.jdbc.user" value="scott"/>
			<property name="eclipselink.jdbc.password" value="tiger"/>
			<property name="eclipselink.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
			<property name="" value="Oracle"/>

Example Feedback

If you have any comments or suggestions on this example please open a bug or post a comment on the newsgroup

Back to the top