Spring and Hibernate simple configuration


/ Published in: Java
Save to your folder(s)

This spring context configures a simple hibernate session (for annotated classes).


Copy this code and paste it in your HTML
  1. <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
  2. lazy-init="true" parent="classesListContainer">
  3. <property name="dataSource">
  4. <ref bean="dataSource"/>
  5. </property>
  6. <property name="hibernateProperties">
  7. <props>
  8. <prop key="hibernate.dialect">org.hibernate.dialect.SybaseDialect</prop>
  9. <!--<prop key="hibernate.show_sql">true</prop>-->
  10. <!--<prop key="hibernate.format_sql">true</prop>-->
  11. <!--<prop key="hibernate.hbm2ddl.auto">validate</prop>-->
  12. </props>
  13. </property>
  14. <property name="annotatedClasses">
  15. <list>
  16. <value>com.dummy.DummyClass</value>
  17. <!-- list of all the annotated classes -->
  18. </list>
  19. </property>
  20. </bean>
  21.  
  22. <!-- A template which works with hbm -->
  23. <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate" lazy-init="true">
  24. <property name="sessionFactory" ref="sessionFactory"/>
  25. </bean>

URL: HibernateAndSpringConfiguration

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.