File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Advantage of ORM over JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Advantage of ORM over JDBC" Watch "Advantage of ORM over JDBC" New topic

Advantage of ORM over JDBC

Srinivas Redd

Joined: Mar 23, 2006
Posts: 17
Can any body clearly explain me what is the advantage of ORM over JDBC. I have an idea on ,how ORM works but I am not aware how JDBC works. Please explain the difference between these two .....

Thanks in advance,

Srinvasa Reddy Thamma,<br />Chennai,India.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
JDBC tutorial:

There is no emoticon for what I am feeling!
Peer Reynders

Joined: Aug 19, 2005
Posts: 2933
SQL was designed to query data stored in relational database management systems � as a tool it operates in the Relational paradigm.
Java is an Object-Oriented Programming Language � as a tool it operates in the Object-Oriented paradigm.

The task of reconstituting objects from pure data retrieved from an RDBMS and later distilling objects to pure data to be stored in the RDBMS can be a complex and onerous task, which is why the term Object-Relational Impedance Mismatch is usually associated with that task. In many cases the database does much more for the business then just serve as a persistent store for OO applications � so the DB Data-model and the OO Domain Model (which can vary from application to application) may not even align properly.

JDBC simply allows you to query and modify data in the database with SQL DML (including the escape syntax to use stored procedures) but is does not reconstitute or save Domain Objects.

Mapping Objects to Relational Databases: O/R Mapping In Detail

Object Relational Mapping (ORM) tools attempt to address the Object-Relational Impedance Mismatch by providing a general framework that through configuration knows how to map your Domain Objects to/from the Database so that you can concentrate on the Domain Model and it's business rules.

Just some articles that deal with the problems and solutions to the Object-Relational Impedance Mismatch before Object-Relational Mapping became more common:

Object-Oriented Concepts for Database Design
Patterns for Object / Relational Mapping and Access Layers
Relational Database Access Layers A Pattern Language: The Key Patterns
Relational Database Access Layers A Pattern Language
Object Identifiers for Relational Legacy Data
Crossing Chasms: The Architectural Patterns
Crossing Chasms: A Pattern Language for Object-RDBMS Integration "The Static Patterns"
[ April 12, 2006: Message edited by: Peer Reynders ]
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Nice post Peer.

What you also find out is that when you have JDBC code directly in your code, you write much more code, which costs money to maintain. Then you end up refactoring and refactoring to make it nicer and easier, and after a while you find that you start creating the same kind of design that an ORM tool already gives you, or you hope so.

With an ORM tool, you can concentrate more on business logic and not on lower levels like direct JDBC calls.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Pj Murray
Ranch Hand

Joined: Sep 24, 2004
Posts: 194
This explains the difference between JDBC DAOs and ORM:

Also, you should find this posting interesting:


PJ Murray -
I agree. Here's the link:
subject: Advantage of ORM over JDBC
It's not a secret anymore!