December 10, 2018

POJO and Hibernate

Hibernate uses the Plain Old Java Object (POJO) programming model to represent database tables in memory. The columns of the table are represented by the fields of the java class. The class-to-table, field-to-column information is kept in XML files. Let’s see how to map the database table object to the Java POJO object. Suppose we want to represent a hypothetical “Customer” for a business domain model.

SOURCE CODE (/giuseu/struts-mvc)

git clone

First of all, we create the customer DB table

Create the customer POJO
– Customer

Create the hibernate Customer.hbm.xml mapping

Define the POJO’s mapping resource in hibernate.cfg.xml file


Create the customer DAO interface and its implementation

– CustomerDAO

 – CustomerHibernateDAO


Update the Hibernate Factory layer to get the customer’s DAO

 – DAOFactory


– DAOHibernateFactory 

Here the project layout



Related posts

Leave a Reply

Your email address will not be published.