Project Structure :

pom.xml (Project Object Model):

  • It is an XML file that contains information about the project and configuration details used by Maven to build the project.
  • We will define required jars or wars or libraries as dependencies. Below is the pom.xml looks like.
  • All the required JPA and Hibernate dependencies will be defined here.

Update maven dependencies after project imported :

  • Right click on project –> select “maven” –> select “Update Project”. Follow below screen.
  • Select “Force Update…” check box –> click “OK”. This will update all dependencies to the project.

Run SQL script that provided in sample application:

  • Every download of sample application includes sql file also.
  • Copy provided sql script and execute using MySql workbench. Follow below screen.
  • Paste sql code in the editor –> select part of script or whole script that you want to execute –> issue command CTRL+SHIFT+ENTER (in windows, CMD+SHIFT+ENTER in Mac).

Persistence.xml :

  • Every sample application includes persistence.xml inside META-INF directory.
  • JPA uses the persistence.xml file to create the connection and setup the required environment. Provides information which is necessary for making database connections.
    • Persistence units are defined by the persistence.xml configuration file.
    • A persistence unit defines a set of all entity classes that are managed by EntityManager instances in an application. – main class to test the code :

  • All the entities are available under “domain” source directory.
  • You will find, use that class to run the test.