Sunday, October 26, 2008

ORM: Object Relational Mapping Technology, JDO, JPA, SDO


ORM (Object Relational Mapping): This is a programming technique which eliminates the need of transforming the objects into scalar values while saving the objects into (and also while building the objects while retrieving) a relational database which can't directly store object values. This technique is also referred to as I/RM and O/R Mapping. Thus we see that ORM is a technique which makes objects persistent i.e., developers can save and retrieve objects directly the same as way as they can do with scalar values like int, string, etc. Example: suppose you have a Employee class having various field like name, dob, addresses, etc. Here the addresses may refer to a list of objects of type Address (another class encapsulating the address details). Now if a developer wants to make such an Employee object persistent, he probably can't do directly with most of the popular relational databases. ORM helps achieving this. Once you start using any ORM technology then you forget about how internally the data is transformed back and forth and you get a feeling that the objects are getting stored and retrieved the same way as numbers, for instance.

Challenges in the implementation of an ORM system?

Not that difficult to imagine, isn't it? There would be some mechanism of generating a set of SQL statements responsible for storing the various pieces of the object data and similarly another set of SQL statements to convert them back to form the object while retrieval. The challenges in generating a predictable and efficient set of SQL statements doing the trick are: Performance, Scalability, CRUD operation management, Maintainability, Flexibility, etc. to name a few. As you can see that these are infrastructure related challenges and hence an ORM system avoids the application developer's need of focusing on such things which consequently allows him to pay full attention on the implementation of the business logic. Clear separation of roles, right? In addition, such infrastructure related challenges are so vast and generic in nature that a specilalized set of people (involved in the ORM tools design and dev) will probably end up doing the task in far better manner compared to a set of application deveopers who are more skilled into the implementation of the business logic.

Currently available ORM implementations

We have three popular standards whose implementations serve as ORM tools used by majority of application development worldwide. These standards and few of their implementations are listed below:
  • JDO - Java Data Objects is a standard having many implementations by multiple vendors. This is a standard unlike another ORM implementation named EOF (Enterprise Objects Framework) developed by NeXT. Initially EOF was tightly tied to the NeXT's toolkit, OpenStep. EOF now comes in two different implementations: the Objective-C implementation which comes with Apple Developers Tools and the pure Java implementation comes in WebObjects which is the first object-oriented Web Application Server (developed by NeXT).
  • JPA - Java Persistence API is another popular standard for ORM. Hibernate being a popular implementation conforming to this standard.
  • EJB - Enterprise Java Beans is also popular ORM standard having implementation by multiple vendors. EJB3 is the latest release of this standard.
  • SDO - Service Data Objects is another standard gaining ground these days. It aims to deliver updatable datagraphs to business level components written in any programming language and the mapping is usually done with the help of an enterprise Metadata repository.

How can we avoid ORM while meeting the needs?

Is it possible? Yes.. it's certainly possible, but you got to use an OODBMS (Object Oriented Database Management System) in that case instead of the far more popular RDBMS (Relational Database Management System). OODBMS is also known as a Non-SQL DBMS as we don't use SQL queries to insert/update/manipulate data. SQL is a standard querying language designed for Relational Databases. This is one of the chief reasons why OODBMSs have not got popular so far as people as so habitual of using SQL for their data access needs that living without that seems quite difficult. For all those ORM technology is the best possible solution to facilitate them best of both the worlds.

Liked the article? You may like to Subscribe to this blog for regular updates. You may also like to follow the blog to manage the bookmark easily and to tell the world that you enjoy GeekExplains. You can find the 'Followers' widget in the rightmost sidebar.



Share/Save/Bookmark


No comments: