Object Relational Mapping

object relational mapping means to map relational database in Objects.

so any one can answer my query, why do we need mapping of Relational Database into Java Object. And this Java Object need persistence overhead also.

What are the Major benefits of using java object.

[288 byte] By [yogeshjoshijia] at [2007-11-27 10:10:46]
# 1

If the JVM stops or crashes, how did you think to respawn those objects on the next start?

BalusCa at 2007-7-28 15:08:41 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

> why do we need

> mapping of Relational Database into Java Object.

You don't need it in the sense of it being absolutely essential. It's just very convenient if we can refer to persistent data in the database using the same (object oriented) approach as we do for normal application data.

For example, you want to display a product catalogue on a website, it's much more convenient to manipulate a ProductCatalog object than a ResultSet containing arbitrary columns.

> And

> this Java Object need persistence overhead also.

Indeed - but that's unavoidable regardless of whether you use an ORM product, or manage the persistence of Java objects using your own code. Generally speaking the ORM is likely to be more efficient though, since it often supports cacheing and other tricks to enhance the database access.

> What are the Major benefits of using java object.

The same as the major benefits of using java objects in any other context. They're a lot easier to model mentally, thus they lead to cleaner clearer code.

dcmintera at 2007-7-28 15:08:41 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

thanks dcminterfor u r reply,

can more clear one line, why ResultSet contain arbitrary column is much tedious to handle then ORM tool.

Thanks,

Yogesh Joshi

yogeshjoshijia at 2007-7-28 15:08:41 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

> thanks dcminterfor u r reply,

> can more clear one line, why ResultSet contain

> arbitrary column is much tedious to handle then ORM

> tool.

Because ORM tools ultimately work with ResultSet objects, but abstract away all of the tricky bits.

Hibernate:

UserAccount account = (UserAccount)session.get(UserAccount.class,pk);

// Do stuff with account...

ResultSet:

UserAccount account = null;

ps.setLong(1,pk);

ResultSet rs = ps.execute();

if(rs.next()) {

String username = rs.getString(1);

String email = rs.getString(2);

String note = rs.getString(2);

account = new UserAccount(pk,username,email,note);

}

// Do stuff with account...

Do it with a more complicated object that has associations with other objects (e.g. a UserAccount object that has a reference to a UserRole collection) and you'll really start to suffer.

And if you don't understand the above, you'll have to settle for "because."

dcmintera at 2007-7-28 15:08:41 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5

yes almost clear,

Thanks

yogeshjoshijia at 2007-7-28 15:08:41 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

You're almost welcome :-)

D.

dcmintera at 2007-7-28 15:08:41 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7

i would like to introduce myself.

i m amit jain,

i currently working on one of theupcoming best portal of india.

www.visitindia.com visit it and give some comments on it.

i expect comments not only in GUI but i need some technical comments on it to make it more powerfull

Thanks :D

yogeshjoshijia at 2007-7-28 15:08:41 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8

Renders rather slowly, too many adverts.

> i expect comments not only in GUI but i need some

> technical comments on it to make it more powerfull

Don't ask me. Do user testing. Specifically, get a copy of "Don't Make Me Think" by Steve Krug and do what that advises.

D.

dcmintera at 2007-7-28 15:08:41 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...