• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which is better option hibernate.cfg.xml file or Spring ORM Beans injection for Hibernate connection

 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Which is better to use Hibernate.cfg.xml or ORM fetures of Spring ?

and why ? and when to use each ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spring is so much more than just an ORM so I'm not sure there can be a direct comparison.
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i know spring has 7 Module and ORM Spring is one of module.

So my question is benefits of using ORM Spring instead of simply loading the Hibernate.cfg.xml or hibernate. properties
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prabhat Ranjan wrote:yes i know spring has 7 Module and ORM Spring is one of module.

So my question is benefits of using ORM Spring instead of simply loading the Hibernate.cfg.xml or hibernate. properties


1) no code to write, just xml configuration stuff. Meaning no "new Configuration();" etc
2) Automatic dependency injection. In case of JPA makes it easy to remove Hibernate and replace with another JPA implementation
3) Transaction and Resource management by Spring allows you to not write any transaction code or resource handling code. Spring does it automatically for you. You just configure a transactionManager

Just a few

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic