Java JPA ORM Test is a test using a JPA, ORM (EclipseLink) and HttpServlets to read and write to a SQL database.
This project is written in Java using a PostgreSQL database and EclipseLink as a Java (ORM) persistence solution.
This strictly educational, proof of concept side project can be found in the Learning Java Web Development course at O'Reilly, under "JPA ORM Exercise".
Here's what you need to do to view this project:
- Install JDK, the Apache Tomcat web server and the Apache Ant build tool.
- Install PostgreSQL. Import the enclosed database (.sql file in the
data
folder) into a database called "skistuff". My database has a username of "rupert" and a password of "secret". If you change this, you will have to update the jsp/java files referencing the database. - Set up and start your Apache Tomcat server instance.
- Within Windows Command Prompt, navigate to the root directory and run the command
ant deploy -Dwar.name=jpaormtest
. - Open your browser and navigate to
http://localhost:8080/test
to view write example. ..* Open your browser and navigate tohttp://localhost:8080/test?id=1
to view read example. ..* Open your browser and navigate tohttp://localhost:8080/test?all
to view read all example.
Within the downloaded files, this is the relevant structure:
jpa-orm-test/
├── build.xml
└── META-INF
└── persistence.xml (This file has to wind up in WEB-INF/classes/META-INF in the deployable WAR file)
└── src
└── data/
└── skiStuff.sql
└── test/
├── Product.java
├── PersistenceManage.java
└── ProductsController.java
├── com.springsource.javax.servlet-2.5.0.jar (Not necessary if using Apache Tomcat)
├── postgresql-jdbc.jar
├── eclipselink.jar
├── org.eclipse.persistence.jpa.modelgen.jar
├── javax.persistence.jar
├── jstl-api.jar
├── jstl-impl.jar
├── WebListener.java
├── web.xml
└── *.jsp/html/css
Rupert Ong