Spring - Hibernate

springmvc

How can we setup Session Factory to integrate Spring and Hibernate?

Hibernate SessionFactory can be configured as a spring bean:

<bean id="mySessionFactory" class="org.springframework.org.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource" ref="specificDataSource"/>
  <property name="mappingResources">
    <list>
      <value>tablename.hbm.xml</value>
    </list>
  </property>
  <property name="hibernateProperties">
    <value>
      hibernate.dialect=org.hibernate.dialect.HSQLDialect
    </value>
  </property>
</bean>

Datasource can be created from JNDI

<beans>
  <jee:jndi-lookup id=" specificDataSource " jndi-name="java:com/env/jdbc/specificds"/>
</beans>
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License