• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

LocalSessionFactoryBean is not a sessionfactory instance

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm integrating Hibernate to Spring based on plain Hibernate3 and I have a understanding problem with DI.



My question is:
The method setSessionFactory has an argument of SessionFactory and what we are injecting as setter DI, is an instance of LocalSessionFactoryBean which is surely not implemeting org.hibernate.SessionFactory interface.
How things are working here?

I'll appreciate the help on that.

Thanks
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quite simple here. the LocalSessionFactoryBean implements FactoryBean, which is a special interface for Spring. Spring sees that the type of that class is a FactoryBean, so instead of creating the instance of LocalSessionFactoryBean, it calls the special public Object getObject() method, and the object that that returns is what is given out. It is the Factory pattern at work.

So LocalSessionFactoryBean's getObject() method returns a SessionFactory object.

Mark
 
Erin Lee
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mark, It was helpful.
[ December 28, 2008: Message edited by: Erin Lee ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic