Software Development

How to use Batoo JPA in a simple Application


This article demonstrates how to use Batoo JPA in a simple application.

Software Environment

  • Windows 7 Professional SP1
  • Eclipse – Kepler Release
  • Java 1.7 (1.7.0_67 – Windows x86)
  • MySQL 5.6.16 – Community Server (GPL)
  • MySQL Java Connector 5.1.34
  • Batoo JPA

Create a Maven Project

First, create a maven project. You may follow the steps to do so on this article How to create Maven project in Eclipse.

Create a MySQL Database

Run the following DDL to create against an existing MySQL database. On this article, the database schema is named “turretadb”.

Maven pom.xml Dependecies

Add the following dependencies in your pom.xml

The persistence.xml


Take note of the namespase used in the XML. Without this, taboo will not be able to load the persistent unit “default” and fail upon create an EntityManagerFactory using Persistence.createEntityManagerFactory(“default”).

Sample JPA Application

The file contains the main method and can be ran from command line or Eclipse. Running the application from Eclipse is more convenient.

Sample Output

Download the Project


You Might Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *