Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not able to appreciate the use of O/R tool like HIbernate

 
Ramya Chowdary
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I know that O/R tool is used to fill up the space difference between Object oriented language and Relational database. But,thats trivial,right.

Why you should write a bunch of classes and configuration files to map the database tables, while the same can be achieved by a couple of SQL statements read through a XML files and executed through your JAVA CODE and have fill up your class variables or do whatever required processing.


What is the true worth of any O/R tool ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But,thats trivial,right.

No, far from it infact. Have a read about the Object-relational impedance mismatch to get an idea of the problems.
 
Ramya Chowdary
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even we use hibernate,still has to write significant amount of code.

Whats wrong with the following way.





OR



[ June 06, 2008: Message edited by: Pratap Chowdary ]
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing.
Hibernate / ORM is not the be-all-end-all solution for implementing the data access layer. Neither is the java.sql API.
[ June 06, 2008: Message edited by: Jelle Klap ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolutely. There is no perfect solution. However, the linked article gives you a bunch of reasons why you might use an ORM tool.
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the selling points that SolarMetric used to promote their JDO product was the claim that while there are Java experts and there are SQL experts, relatively few people are both. By using ORM, the need to be a SQL expert is reduced.

Another, more demonstrable reason is that in enterprise apps, use of an ORM framework may actually be more efficient than using straight JDBC. In fact, some benchmarks I've seen have shown twice the throughput of hand-coded JDBC.

This might seem counter-intuitive, since ORM uses JDBC to get the job done. But for years people claimed that assembly language was more efficient than high-level languages. Which was true at the micro level, but frequently false at the macro level. ORM technologies are not as lightweight as roll-your-own JDBC, but they offer efficiencies in caching, in load-balancing and other data strategies that make up for it. It's not so much that ORM is inherently more efficient raw JDBC, but by the time you re-created and re-debugged all the ORM features, you'd be overdue to retire, if not laid off.

And, of course, automated frameworks can efficiently redesign and re-optimize an app globally for every minor change, which would be prohibitive if done manually.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well said, Tim.

One small thing is the danger of doing SQL in Java code, and then having the SQL tables or column names change. Then you've got to go into all your queries. With something like Hibernate, it's just a few changes to your mapping files or your annotations, and the changes are done.

Structured data we find in databases and object models we find in Java programs are both very different. ORM tools allow Java programmers to think of their data in an object oriented way, and databases allow db admins and database modellers to think of the data in a structured way. This just makes for a more natural way for individuals to address their own problem domain, and that's a good thing.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic