302 APPENDIX C n HIBERNATE AND SPRING (Web host sites) APPENDIX

302 APPENDIX C n HIBERNATE AND SPRING APPENDIX C n HIBERNATE AND SPRING is not the appropriate location for its details to be stored. Moreover, a well-behaved web application will draw its database configuration from a JNDI-provided DataSource object so that connection details can be uniformly managed at deployment time. Spring allows data sources to be managed centrally as beans, and if a JndiObjectFactoryBean bean is used, it can in turn draw its details from JNDI. The LocalSessionFactoryBean therefore provides a dataSource property into which the appropriate Spring DataSource bean can be injected. Typically, to manage a data source from within the Spring configuration, but without deferring the details to a JNDI resource, you would use the DriverManagerDataSource bean (see Listing C-4). Listing C-4. Configuring a Typical BasicDataSource Bean
org.hsqldb.jdbcDriver jdbc:hsqldb:file:/spring/db/springdb;SHUTDOWN=true
Alternatively, if the data source resources are to be drawn from an existing JNDI-accessible data source, then the Spring JndiObjectFactoryBean should be used to represent the data source (see Listing C-5). Listing C-5. Configuring a Typical JndiObjectFactoryBean
It is not just the connection details that can be migrated from the Hibernate configuration file into the Spring configuration. The property attributes and the mappings (class names or mapping file names) can also be assigned during the configuration of a LocalSessionFactory bean (see Listing C-6).
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Leave a Reply