Announcement Announcement Module
Collapse
No announcement yet.
How SessionFactory is wired in Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How SessionFactory is wired in

    I am trying to understand how SessionFactory object is being wired in a Spring/Hibernate application.
    Consider the example from book Spring Live (also available on: http://www.sourcebeat.com/downloads/...-completed.zip)
    According to applicationContext.xml:

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource"><ref local="dataSource"/></property>
    .
    .
    .
    </bean>

    <bean id="userDAO" class="org.appfuse.dao.hibernate.UserDAOHibernate" >
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>

    class UserDAOHibernate must have method setSessionFactory(...) which it does not, however I have looked in
    HibernateDaoSupport which UserDAOHibernate extends and found the method but it has different signature -
    the parameter is of different type: SessionFactory instead of LocalSessionFactoryBean.
    I am lost at this point.
    Please shed some light on it.

    Thank you.

  • #2
    FactoryBean that creates a local Hibernate SessionFactory instance
    (javadoc quote).

    Read the javadoc of LocalSessionFactoryBean - the class implements some interfaces which provide hooks for the factory initialization, thus at the wiring time it will return the needed SessionFactory.

    Comment

    Working...
    X