wood burning stoves
The moose likes Spring and the fly likes Integrating Spring and Hibernate : Help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Integrating Spring and Hibernate : Help needed" Watch "Integrating Spring and Hibernate : Help needed" New topic

Integrating Spring and Hibernate : Help needed

Manikandan Swaminathan
Ranch Hand

Joined: Aug 10, 2008
Posts: 117
Hello ranchers,

I am bit confused in the integration of spring and hibernate.In one of our projects, they have used JSF,Spring IOC,EJB & hibernate.
So the code flow is something like this:

JSF --> valuebean/Managedbean --> EJB --> ServiceLayer (Interace & Impl class) --> DAO (Interface & Impl class) .
There are also screen objects & value objects which do the work of DTO's.

When i googled for spring & hibernate integration in the net, i got many examples which had examples like specifying the hibernate.proerties file in spring configuration file, usage of hibernate template etc. But i was not able to find anything like that in our project.But they have used some lookup configuration for EJB's in spring configuration file.

Suppose,if i am not using EJB's at all, in that case,is any other configuration required for integrating spring & hibernate? (Assuming i am using only spring IOC here..).Please advise me. I am confused on this.

Hussein Baghdadi
clojure forum advocate

Joined: Nov 08, 2003
Posts: 3479

Wrong forum to post, please wait for our moderators to move it kindly to an appropriate forum.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

Moving to Spring forum.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

To integrate Hibernate into Spring you would create a bean where the class is LocalSessionFactoryBean or AnnotationSessionFactoryBean, this would take place of your hibernate.cfg.xml. If using Hibernate 3.1 or higher, then you just inject your sessionFactory bean into your DAO/Repositories.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link: http://aspose.com/file-tools
subject: Integrating Spring and Hibernate : Help needed
It's not a secret anymore!