Sunday, July 24, 2011

OpenJPA Components

Earlier I have explained about the concept of openJPA & its usage in the programming environment. So before going into development, let me describe about the architectural components in openJPA.
if we consider a web based project using openJPA, it will have web pages, source packages, libraries & configuration files.a typical openJPA based netbeans project folder structure would look like this.

  1. In web pages we include all our views. that means in MVC architecture the View is the web pages. So .html, .jsp files goes to the web pages.
  2. In source packages you need to define the packages required. In standard openJPA based development environment, you need to have following packages.
  • DAO - Data Access Object
DAO means objects that provides an abstract interface to databases. Separate logic within 2 parts of application can be done using same DAO interface & then changes does not affect to DAO clients. Basically what it does is separating the data access logic from business logic. Also DAO provides CRUD operations (Create/ Read/ Update/ Delete).
  • Domain
 In the domain, we include the database object files. That means if we create a database having two tables, we need to import the table objects to the domain package. For example if we have a table called "employer" then in the domain package there will be a java file called employer.java containing the table objects.
  • Service
In services package we define the mapping between DAO to web pages.

  3.   In Libraries you need to include all the jar files & other libraries required for the project. For example, in OpenJPA based project it will contain MYSQL JDBC Driver, persistence ejb-persistence.jar, openjpa-all-2.1.0.jar, tomcat 6.0, etc.

  4.  In the configuration files the important file is the Persistence.xml which holds the entire openJPA structure. persistence.xml is to define the service providers & the services to be provided. basically it will contain following details.
So I just mentioned the important things you need to know before starting a openJPA project. In the next post let's try this out & develop a MVC based project.


No comments:

Post a Comment