APPENDIX C n HIBERNATE AND SPRING 303 n HIBERNATE AND SPRING 303 Listing C-6. Configuring Hibernate Purely from Spring
com/hibernatebook/spring/Paper.hbm.xml com/hibernatebook/spring/Article.hbm.xml
0
true
org.hibernate.dialect.HSQLDialect Note that in Listing C-6, purely in order to demonstrate the use of mapping files in a LocalSessionFactoryBean configuration, we omit the specification of a Hibernate AnnotationConfiguration for the configurationClass property, causing it to default to the normal (mapping file based) Hibernate Configuration object. Typically, the mappings themselves are specified in the conventional Hibernate manner through XML mapping files or Java annotations. It would be entirely possible to arrange to configure these externally, but no default Spring classes are provided to achieve this, and it is difficult to see any obvious benefit that would accrue from such an approach. Using Hibernate in Your Spring Beans With your session factory configured as a Spring bean, you can now go on to create DAOs that take advantage of Hibernate s functionality. Here, Spring really starts to come into its own, as it provides you with the invaluable HibernateDaoSupport class to form the basis of your DAOs (see Listing C-7). Listing C-7. Declaring the Interface for Our DAO package com.hibernatebook.spring.dao; import java.util.List; import com.hibernatebook.spring.Article; import com.hibernatebook.spring.Paper;
We recommend high quality webhost to host and run your jsp application: christian web host services.
This entry was posted
on Thursday, October 11th, 2007 at 10:11 pm and is filed under tomcat.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.