ORM Introduction

What is Object persistence?

Today most of the development is carried out in an object oriented manner using languages like java,C++ etc.

When thinking in terms of Java as the programming language,the business logic of an application works with Objects of different class types. However when dealing with the data store,it's important to note that the tables of a database are not objects,which becomes an issue. This is where the concept of Object Persistence comes in.

Object Persistence deals with persistence in object oriented program such as java.It means determining how objects and their relationships are persisted in a relational database.

What is Object persistence?

Today most of the development is carried out in an object oriented manner using languages like java,C++ etc.


When thinking in terms of Java as the programming language,the business logic of an application works with Objects of different class types. However when dealing with the data store,it's important to note that the tables of a database are not objects,which becomes an issue. This is where the concept of Object Persistence comes in.


Object Persistence deals with persistence in object oriented program such as java.It means determining how objects and their relationships are persisted in a relational database.




What is ORM ?

ORM Overview

Object Oriented Programming use Classes whereas Relational Database use tables.In programming this will creates a gap.This gap is called impedance mismatch.

We can bridge the gap between Object oriented model and Relational model is known as Object Relational Mapping(ORM).


The Object-Relational Impedance Mismatch:

Object-Relational Impedance Mismatch' (sometimes called the 'paradigm mismatch') is just a fancy way of saying that object models and relational models do not work very well together.RDBMSs represent data in a tabular format , whereas object-oriented languages, such as Java, represent it as an interconnected graph of objects.



Solution of Impedance Mismatch:

Use an ORM mapping tool which will provide a simple API for storing and retrieving Java objects directly from database.
There are several good ORM tools available in market that will do mapping between Objects and Database tables and solve the impedance mismatch.

Following are ORM tools:

  • Hibernate
  • OpenJPA
  • EJB Entity Bean
  • EclipseLink
  • TopLink

Java Persistence API:

JPA has been introduced in Enterprise Java Beans 3(EJB3).Java Persistence API is new way of communicating with the database.
The Java Persistence API (JPA) is a standard API for accessing databases from within Java applications. The main advantage of JPA over JDBC is that in JPA data is represented by classes and objects rather than by tables and records as in JDBC.

Java Persistence API as a specification:

JPA is just an specification from Sun, which is released under JEE 5 specification. JPA standardized the ORM persistence technology for Java developers. JPA is not a product and can't be used as it is for persistence. It needs an ORM implementation to work and persist the Java Objects. ORM frameworks that can be used with JPA are Hibernate, Toplink, Open JPA etc.



comments powered by Disqus