In java we have two types of identity.
A. Identical (==): If two objects points the same memory location we says that two objects are identical.
e.g - Object ob1 = new String ("hello");
Hear ob2 & ob1 are reference to same object in a memory location so they are identical.
B. Equal (.equals ()): If we compare objects using equal () method if it returns true then that two objects are equal.
e.g - String s1 = new String ("hello"); String s2 = new String ("hello");
Hear s1 == s2 returns false. s1.equals(s2) returns true. So s1 & s2 are equal and not identical.
Primary Key: But in RDBMS we have single identity by using primary key. If two rows contain same primary key then they are identical and equal.
In Object Oriented Model we declare some common types in the form of objects like Address. We reuse that common objects in another complex objects like Customer in our entire application. But in RDBMS we can't map this reusable objects directly to the tables. We require declaring the individual columns for each simple type and map the common object fields to the individual columns in a table.
In object model we have inheritance concept here an object may have multilevel inheritance. But in RDBMS we can't have inheritance concept. We must have customer table along with all fields.
In Object model we have polymorphism concept. By using polymorphism at runtime we associate with an instance of any of the sub class of that base class.
Since RDBMS doesn't provide inheritance and polymorphism there is no mechanism for runtime insertion.
In RDBMS an association is represented as a foreign key column, with copies of key values in several tables. Here associations are bi-directional. Where as while representing these relations in the object model we require maintaining association between objects with the help of object references. But these references are unidirectional. So here we may require to maintaining two associations.
From the relational data which is retrieved from the RDBMS building the object tree is one issue, finding the exact part of the tree required and loading the corresponding data and the 2nd issue is navigating through the object tree and finding out the exact portion of the tree which is modified and making the changes to be effected into the RDBMS. Object graph navigation requires the joins between tables. The number of tables included in the join determines the depth of the object graph navigation.
ORM eliminates much of the database related code in you application. ORM saves and retrieves complex objects to and from database without single line of Jdbc code. So we more concentrate on the business problems rather than Jdbc code.
By using ORM our application contains fewer line of code (LOC). It makes the system more understandable.
An ORM abstracts our application from the underlying SQL database and SQL dialect
Hand-coded (JDBC) persistence can always be at least as fast than automated persistence (ORM). But the people implemented ORM concentrate much more time to investigate performance optimizations than us.