4

Any one can give me the gist of the main advantage of using Hibernate?

Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
user496949
  • 83,087
  • 147
  • 309
  • 426
  • 3
    Advantages over other ORMs or advantages of using any ORM? – Claudio Redi Nov 12 '10 at 00:23
  • http://stackoverflow.com/questions/2754151/what-problem-does-nhibernate-solve – Mauricio Scheffer Nov 12 '10 at 02:10
  • 2
    Please, please, please do some research yourself on some of the questions you've been asking. Almost all of the topics you have questions on have been answered 1000 times if you would just look. Asking on SO is the lazy way out. – Chris Conway Nov 12 '10 at 02:51

7 Answers7

7

Hibernate lets you develop a maintainable data access layer with relative ease.

Hibernate is built on top of JDBC, so obviously it cannot do anything that plain JDBC cannot do. Hibernate is a large codebase; if you are building your own data access layer using plain JDBC, you will have lot more code to write to match its features. In simple reporting applications, it is relatively easy to code up the data access layer features you need; but as the application gets more complicated, the amount of code one has to write increases. Let me give you few examples that are non-trivial to implement by hand, but comes out of the box with Hibernate:

  1. Ensuring a global lock acquisition ordering
  2. Determining which fields of an object has changed and tailoring the query appropriately (may not be a good idea always)
  3. Flexibility to switch between various fetch strategies ("here I want the User and Address loaded together, but here I just want User only") in different usecases

As I hinted before, implementing these by hand is not impossible - afterall, Hibernate does it. But they take significant investment in time. In many (most?) applications, concentrating on the complexities of the business logic would be a better investment of developer time.

Please see my comment in another thread regarding Hibernate performance.

Community
  • 1
  • 1
Binil Thomas
  • 13,699
  • 10
  • 57
  • 70
1

I've found it useful if you need your application to work with several different databases. Hibernate will make it much easier to swap out a MySql DB with an Oracle one for example.

Joel
  • 724
  • 5
  • 12
0

Hibernate increases the productivity and maintainability of the project.
This is may help
http://mudassirshahzad.com/why-hibernate-should-be-chosen-for-projects-advantages-of-hibernate/

Mudassir Shahzad
  • 542
  • 2
  • 16
  • 32
0

Easier development, but only for simple applications.

See the answers in How can I design a Java web application without an ORM and without embedded SQL for more.

Community
  • 1
  • 1
EMP
  • 59,148
  • 53
  • 164
  • 220
0

Not having to write your own DAL.

There might be a steep learning curve initially but once you get the gist of it, it does lead to quicker development.

clyc
  • 2,420
  • 14
  • 15
0

It's is ORM Framework (Object relationship maping ) !

tiendv
  • 2,307
  • 7
  • 23
  • 34
0

ORMs (like Hibernate) make it possible to use POJOs / POCOs that have solid, reliable database backing with a minimum of fuss. (Note: quantity of fuss is not guaranteed to be zero, but usually less than with other solutions. YMMV.)

Paul Sonier
  • 38,903
  • 3
  • 77
  • 117