aspose file tools*
The moose likes Other Application Frameworks and the fly likes LocalSessionFactoryBean is not a sessionfactory instance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "LocalSessionFactoryBean is not a sessionfactory instance" Watch "LocalSessionFactoryBean is not a sessionfactory instance" New topic
Author

LocalSessionFactoryBean is not a sessionfactory instance

Erin Lee
Greenhorn

Joined: Dec 26, 2008
Posts: 2
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Erin Lee
Greenhorn

Joined: Dec 26, 2008
Posts: 2
Thanks Mark, It was helpful.
[ December 28, 2008: Message edited by: Erin Lee ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LocalSessionFactoryBean is not a sessionfactory instance