Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Hibernate Use Cases

 
Ranch Hand
Posts: 420
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am thinking if we need to decide whether we should go for Hibernate or not, then what are the decision criteria? Is hibernate always a good choice to build the DAO layer or there are some scenarios where Hibernate should be avoided?
 
Saloon Keeper
Posts: 21603
147
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're doing very simple database operations or running at low scale, the complexity and overhead of an ORM system such as Hibernate may not be cost-effective.

However, as your needs get more and more demanding, the benefits of an ORM really begin to shine. First of all, junior developers only really need to know Java and not the kinks of raw SQL, secondly, it's easier to get data into a form that the rest of the app can deal with without doing a lot of grunt work (Hibernate + Spring is even better for that). Third, you can often define a set of standard modules for database interfacing, which can save a lot of time and effort thanks to re-usable code and standard practices.

And finally, as the volume and complexity of your database operations scale up, Hibernate can actually run more efficiently than hand-coded SQL JDBC.

SQL, like assembly language is, in theory, the most efficient way of doing things, because it directly addresses the underlying hardware (or database, in this case). However, the sheer magnitude of work involved to manually re-tune everything based on application changes and measured workload becomes too expensive. Hibernate, being an automated system can do such things with relative ease, and so can out-perform hand-coded SQL in such cases. Benchmarks have measured as much as twice the throughput in some cases. But, returning to my first statement, that depends on your workload. At the lower ends, Hibernate's own overhead would cost more than simple SQL JDBC code.
 
I guess I've been abducted by space aliens. So unprofessional. They tried to probe me with this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!