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

Difference between revisions of "EclipseLink/Examples/JPA/EmployeeXML"

(New page: 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 == === SVN Access === This...)
 
(Configuration)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[[Category:EclipseLink/Example/JPA|EmployeeXML]]
 +
 
This version of the Employee example illustrates how EclipseLink JPA can be used using just XML to define the mappings and runtime options.
 
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 ==
 
== Example Details ==
  
=== SVN Access ===
+
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 is being developed under [http://bugs.eclipse.org/217884 Bug 217884] and is available within the EclipseLink SVN repository at:
+
This example illustrates the following EclipseLink JPA capabilities:
  
<pre>dev.eclipse.org/svnroot/technology/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.employee.xml/</pre>
+
* ORM Mapping using XML
 +
** EclipseLink's extended ORM.XML mapping file ([[EclipseLink/Examples/JPA/EclipseLink-ORM.XML | 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
  
 
=== Download ===
 
=== Download ===
  
At present the example is under development and only available from SVN.  
+
[http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/branches/1.0/trunk/examples/org.eclipse.persistence.example.jpa.employee.xml/example-jpa-employee-xml.zip example-jpa-employee-xml.zip]
  
== Entity Model ==
+
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.
  
 +
=== Configuration ===
  
== Features ==
+
To run this example you will need the following libraries on your classpath:
  
This example illustrates the following EclipseLink JPA capabilities:
+
* EclipseLink (eclipselink.jar - [http://www.eclipse.org/eclipselink/downloads/ EclipselinkDownloads])
 +
* JPA 1.0 ([http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/branches/1.0/trunk/plugins/javax.persistence_1.0.0.jar persistence_1.0.0.jar])
 +
* JUnit v4
 +
* JDBC Driver
  
* Mapping model XML
+
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:
** EclipseLink's extended ORM.XML mapping file ([[EclipseLink/Examples/JPA/EclipseLink-ORM.XML | How To]])
+
 
** EclipseLink JPA Advanced Mapping
+
<source lang="xml">
*** ObjectTypeConverter for database coded Enum values on Employee.gender
+
<?xml version="1.0" encoding="windows-1252" ?>
*** BasicCollection mapping for Employee.responsibilities
+
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
 +
version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
 +
<persistence-unit name="employee" transaction-type="RESOURCE_LOCAL">
 +
<description>This is part of the Employee JPA example using just XML configuration.</description>
 +
<properties>
 +
<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="eclipselink.target-database" value="Oracle"/>
 +
</properties>
 +
</persistence-unit>
 +
</persistence>
 +
</source>
  
 
== Example Feedback ==
 
== Example Feedback ==
  
If you have any comments or suggestions on this example please comment on [http://bugs.eclipse.org/217884 Bug 217884].
+
If you have any comments or suggestions on this example please open a bug or post a comment on the [http://www.eclipse.org/newsportal/thread.php?group=eclipse.rt.eclipselink newsgroup]

Latest revision as of 10:06, 7 February 2011


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

Download

example-jpa-employee-xml.zip

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.

Configuration

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="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
	version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
	<persistence-unit name="employee" transaction-type="RESOURCE_LOCAL">
		<description>This is part of the Employee JPA example using just XML configuration.</description>
		<properties>
			<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="eclipselink.target-database" value="Oracle"/>
		</properties>
	</persistence-unit>
</persistence>

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