• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How JDBC is faster than hibernate?

 
Greenhorn
Posts: 9
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,
I am new to hibernate so can anybody give a brief idea about how JDBC is faster than hibernate?
Thanks,
Hims
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Who says that JDBC is faster than Hibernate? That isn't necessarily true.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
himashree rawat
Greenhorn
Posts: 9
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:And welcome to the Ranch



Thanks but in most of the blogs it has been written that one of the disadvantages of Hibernate over JDBC is that , hibernate is slower than JDBC as multiple queries run at runtime in hibernate,thats what i didn't understand,therefore came up with the question.
Details have not been provided as to how JDBC is faster, in one of the blogs it was practically proven by running the same set of queries in JDBC as well as hibernate and JDBC was much faster so just want to know how come JDBC is faster.
Thanks,
Hims


 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

himashree rawat wrote:Details have not been provided as to how JDBC is faster...


Well, one thing is that with native JDBC you can use PreparedStatements, which Hibernate may not be able to do as easily (or at all). It uses a hybrid query language called HQL, which probably gets translated to SQL as and when needed, which may make them more difficult to cache.

But the fact of the matter is: Do you care?

Speed is only something you should be worried about if/when you KNOW that your application is running too slowly; and since there are thousands of sites out there that have been running Hibernate perfectly happily for years, I wouldn't be "scared off" using it by the dire predictions of some theoretical geeks who live only to benchmark things in ivory tower labs.

Also: You should always consider the source of statements like this. Could it be that they're trying to sell you something? - for example, a "better" Hibernate?
"Send $199 by return of post, and we'll solve all your speed problems..."

Winston
 
Rancher
Posts: 43081
77
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, Hibernate is a layer on top of JDBC, so right from the start, it's reasonable to assume that it will be slower compared to meticulously hand-crafted JDBC code. And it is true that Hibernate runs a lot more SQL queries than hand-crafted SQL would, particularly ones that return very little data (single ID values, for example), and that is generally not good for network performance. But I think you would need to have a very large application before you started to notice an impact from that. And as Winston mentioned, many large applications are indeed using Hibernate successfully.
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And if have spotted a performance bottleneck, you can still consider repairing it (and only it) with native JDBC.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to speed up your application, make an abstract class that extends HashMap<Data> and make a class that can manage it and make queries with the keys and the data on the HashMap. As you know everything of your program, you can easily get it faster. But build it since the beginning. You can use java annotation interface like Hibernate, but with your own code.
reply
    Bookmark Topic Watch Topic
  • New Topic