Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Excerpt
hiddentrue

Getting Started

...

This page provides a short (5 minutes) quick start guide for OpenJPA using the example provided with the distribution. For further information, the documentation provides comprehensive documentation on all aspects of configuring and using OpenJPA.

Getting Started with OpenJPA in Eclipse

  1. Download the OpenJPA binary release from the downloads page and unpack it by double-clicking it.
  2. Launch Eclipse (this sample was tested with Eclipse 3.2.1, but any recent version should work)
  3. Select the File menu, traverse to the New sub-menu, and select Project
  4. On the Select a wizard page, select Java Project from Existing Ant Buildfile, then click the Next button
  5. Hit the Browse button next to the Ant Buildfile field, and navigate to the unpacked OpenJPA zip file on the desktop, then traverse through examples, then hellojpa, and select the build.xml file and hit the Open button.
  6. Hit the Finish button on the wizard
  7. A new project will open, containing the OpenJPA jar and all its dependencies
  8. On the Package Explorer, expand the top-level folder, then the examples folder, then hellojpa
  9. Select the build.xml file in the hellojpa folder (note that there is also a build.xml file in the parent folder, which should not be selected). Right-click the build.xml file, and select the Run As sub-menu, then select Ant Build.
  10. The database will be initialized (using the stand-alone Derby database, which is included with the OpenJPA distribution) and the Main.java class will be run. In the Console, you should see the text Hello Persistence!.
  11. Congratulations! You have run your first sample program using OpenJPA. Examine the Main.java example program, as well as the Message.java entity class, play with them by adding fields and working on new persistence operations. Have fun!

Getting Started with OpenJPA from the Console

with OpenJPA

Quick Start Guide

We know it can be hard to find the right help sometimes and search engines can be overwhelming, so we will try to put the most commonly asked for topics with some overview and links to more in-depth resources here for you to checkout, before wasting your time searching through our Documentation and Mailing Lists for help.

Runtime Dependencies

To use OpenJPA as a stand-alone Java component or with a lightweight non-Java EE framework, please refer to the following Build and Runtime Dependencies page for the supported levels of Java SE.

To use OpenJPA in a Java EE application server, please refer to the following Integration page for the known platforms that either include OpenJPA or have been tested with OpenJPA.

JPA Examples

OpenJPA provides some simple examples as part of the binary distribution on the Downloads page. The following Samples page provides quick start instructions on how to build and run these samples, along with pointers to other JPA samples from the Apache Geronimo project.

Enhancing Entities

The JPA spec requires some type of monitoring of Entity objects, but the spec does not define how to implement this monitoring. Some JPA providers auto-generate new subclasses or proxy objects that front the user's Entity objects at runtime, while others use byte-code weaving technologies to enhance the actual Entity class objects at build time. OpenJPA supports both enhancement methods, but strongly suggests only using the build time enhancement. The following Entity Enhancement page includes more details on both enhancement types, along with examples on how to setup build time enhancement in ANT, Maven and Eclipse environments.

Tools

OpenJPA provides several design-time and runtime tools, to perform such tasks as entity enhancement, schema mapping, generating metamodel classes and to help migrate from other JPA providers. Please checkout the Tools page for more details.

FAQ

Some common questions concerning the history, architecture and usage of OpenJPA can be found on the FAQ page.

Take the Red Pill

If you want to dive into the rabbit-hole (Hey, It's open source!), then checkout the Found a Bug page, which covers everything from posting questions to our mailing lists, to getting the source code and building it, and creating bug patches....

...