This repo shows how Java Persistence API 2.2 is integrated with Java EE 8. Persistence becomes easier and more transparent for developers because the Java EE container automates most of the persistent and transactional tasks.
The code follows the Maven directory structure. The src/main/ directory contains the main source code while you will find the test class under src/test/. The pom.xml and assembly.xml files are Maven specific describes the project and its dependencies.
Once Maven, H2 Database and a JDK 8 are installed and the database is up and running, enter the following Maven commands:
mvn help:help: shows Maven helpmvn clean: cleans thetargetdirectorymvn compile: compiles the codemvn test: runs the test case (make sure the H2 database is up and running)mvn exec:java: executes the main class
This repo contains the web application that was used during all the demos. The structure of the application is:
-
Under the
src/main/javadirectory: -
The
modelpackage contains all the entities of our business model (Artist,Item...) -
The
restpackage contains the REST endpoints -
The
viewpackage contains the JSF backing beans -
Under the
src/main/resourcesdirectory you will find thepersistence.xmlconfiguration file for JPA as well as theinsert.sqlfile that loads data into the database -
Under the
src/main/webappdirectory you will find the Web resources -
The
resourcesdirectory contains the Facelets template and the CSS styles and favicon -
The
WEB-INFdirectory contains theweb.xml,beans.xml,faces-config.xmlfile
To run the demo you will need to package the application into a War file by running the Maven command mvn clean package. Then, make sure you are a H2 database and a Wildfly up and running. Deploy the war file and go to the URL http://localhost:8080/module07/.
To execute the Main classes, compile the code first using mvn compile and then use the mvn exec:java Maven goal. But make sure to choose the appropriate Main class in the pom.xml under the exec-maven-plugin configuration.