Software Development

How to use Batoo JPA in a simple Application

Background

This article demonstrates how to use Batoo JPA 2.0.1.2 in a simple application.
[wp_ad_camp_1]

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 2.0.1.2

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

[wp_ad_camp_2]

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 BatooAppSample.java 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

https://www.dropbox.com/s/thpov3m86vlxkb3/jpabatoosample.zip?dl=0

[wp_ad_camp_5]

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like