• A DAO can use an ORM framework for persistence tasks.
• ORM framework is written to reduce the efforts done by DAO classes, like database connectivity,
constructing sql queries etc.
• ORM also improve the performance of DAO layer by providing caching, query optimization etc.
• Even ORM take care of database independency that’s why we do not require using factory method and
abstract factory pattern at DAO layer for achieving the same.
• DAO was 2 step approach, ORM will be introduced as a 3rd step, see the figure below.
• ORM will provide n number of features that we will see shortly.

There are other options also TopLink, iBatis, JDO, EJB-Entity Beans etc but hibernate is much more powerful
and simple to use.
We want to persist a record that keep the information about a employee through Hibernate.
Step 1 – Entity class need to be persisted --> Employee.java ~= EmployeeTO.java
Step 2 – Hibernate requires
a mapping file (employee.hbm.xml), that keep the information like table belongs to
this employee class, column mapping and association of this entity with other existing entities.
Step 3 – framework configuration file (
hibernate.cfg.xml) keeping the information about the database
connection properties, mapping files locations of entities created in step 2 etc.
Step 4 – client program where we will take Hibernate’s SessionFactory and Session then will call save(),
update() etc. method to perform persistency.


