Jump to: navigation, search


< EclipseLink‎ | Examples
Revision as of 09:30, 10 August 2012 by Douglas.clarke.oracle.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

EclipseLink JPA-RS Example: Dynamic Hello World

This example illustrates the basic usage of EclipseLink's JPA-RS component combined with dynamic persistence to illustrate how JPA can be exposed over REST without requiring any code on the server. This example documents the construction of the example application using Eclipse Juno's Java EE distribution.


The basic steps for this constructing this demo from scratch are:

  1. Create a new Maven project
  2. Configure EclipseLink repository and dependency
    1. Enable and configure as dynamic web facet
  3. Configure EclipseLink
    1. Enable and configure JPA facet with EclipseLink library
    2. Add JPA-RS fragment to application
    3. Configure persistence.xml

Define Dynamic Entity

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings version="2.4" xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
	xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_4.xsd">
	<named-query name="Person.findLike">
		<query>SELECT p FROM Person p WHERE p.firstName LIKE :PATTERN OR p.lastName LIKE :PATTERN</query>
	<entity class="model.Person" access="VIRTUAL">
			<id name="id" attribute-type="int" />
			<basic name="firstName" attribute-type="String">
				<column name="F_NAME" />
			<basic name="lastName" attribute-type="String">
				<column name="L_NAME" />