// Path: ch07/springtobemulti/HibernateSub/src/main/java/info/thecodinglive/hiber/config/DbConfig.java
// @Configuration
// @EnableTransactionManagement
// @ComponentScan(basePackages ={"info.thecodinglive.hiber"})
// @PropertySource("classpath:application.properties")
// public class DbConfig{
// 	  private static final String PROPERTY_NAME_DATABASE_DRIVER = "db.driver";
// 	    private static final String PROPERTY_NAME_DATABASE_PASSWORD = "db.password";
// 	    private static final String PROPERTY_NAME_DATABASE_URL = "db.url";
// 	    private static final String PROPERTY_NAME_DATABASE_USERNAME = "db.username";
// 
// 	    private static final String PROPERTY_NAME_HIBERNATE_DIALECT = "hibernate.dialect";
// 	    private static final String PROPERTY_NAME_HIBERNATE_SHOW_SQL = "hibernate.show_sql";
// 	    private static final String PROPERTY_NAME_HIBERNATE_FORMAT_SQL = "hibernate.format_sql";
// 	    private static final String PROPERTY_NAME_HIBERNATE_hbm2ddl = "hibernate.hbm2ddl.auto";
// 	 
// 	    private static final String PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN = "entitymanager.packages.to.scan";
// 
// 	    @Resource
// 	    private Environment env;
// 
// 	    @Bean
// 	    public DataSource dataSource() {
// 	        DriverManagerDataSource dataSource = new DriverManagerDataSource();
// 
// 	        dataSource.setDriverClassName(env.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER));
// 	        dataSource.setUrl(env.getRequiredProperty(PROPERTY_NAME_DATABASE_URL));
// 	        dataSource.setUsername(env.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME));
// 	        dataSource.setPassword(env.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD));
// 	        
// 	        return dataSource;
// 	    }
// 
// 
// 	    @Bean
// 	    public LocalSessionFactoryBean sessionFactory() {
// 	        LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
// 	        sessionFactoryBean.setDataSource(dataSource());
// 	        sessionFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
// 	        sessionFactoryBean.setHibernateProperties(hibProperties());
// 	        
// 	        
// 	        return sessionFactoryBean;
// 	    }
// 
// 	    private Properties hibProperties() {
// 	        Properties properties = new Properties();
// 	        properties.put(PROPERTY_NAME_HIBERNATE_DIALECT, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
// 	        properties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
// 	        properties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
// 	        properties.put(PROPERTY_NAME_HIBERNATE_hbm2ddl, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_hbm2ddl));
// 	        
// 	        return properties;
// 	    }
// 
// 	    @Bean
// 	    public HibernateTransactionManager transactionManager() {
// 	        HibernateTransactionManager transactionManager = new HibernateTransactionManager();
// 	        transactionManager.setSessionFactory(sessionFactory().getObject());
// 	        return transactionManager;
// 	    }
// }


import info.thecodinglive.hiber.config.DbConfig;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
package info.thecodinglive.web.config;



public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{

	@Override
	protected Class<?>[] getRootConfigClasses() {
// Path: ch07/springtobemulti/HibernateSub/src/main/java/info/thecodinglive/hiber/config/DbConfig.java
// @Configuration
// @EnableTransactionManagement
// @ComponentScan(basePackages ={"info.thecodinglive.hiber"})
// @PropertySource("classpath:application.properties")
// public class DbConfig{
// 	  private static final String PROPERTY_NAME_DATABASE_DRIVER = "db.driver";
// 	    private static final String PROPERTY_NAME_DATABASE_PASSWORD = "db.password";
// 	    private static final String PROPERTY_NAME_DATABASE_URL = "db.url";
// 	    private static final String PROPERTY_NAME_DATABASE_USERNAME = "db.username";
// 
// 	    private static final String PROPERTY_NAME_HIBERNATE_DIALECT = "hibernate.dialect";
// 	    private static final String PROPERTY_NAME_HIBERNATE_SHOW_SQL = "hibernate.show_sql";
// 	    private static final String PROPERTY_NAME_HIBERNATE_FORMAT_SQL = "hibernate.format_sql";
// 	    private static final String PROPERTY_NAME_HIBERNATE_hbm2ddl = "hibernate.hbm2ddl.auto";
// 	 
// 	    private static final String PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN = "entitymanager.packages.to.scan";
// 
// 	    @Resource
// 	    private Environment env;
// 
// 	    @Bean
// 	    public DataSource dataSource() {
// 	        DriverManagerDataSource dataSource = new DriverManagerDataSource();
// 
// 	        dataSource.setDriverClassName(env.getRequiredProperty(PROPERTY_NAME_DATABASE_DRIVER));
// 	        dataSource.setUrl(env.getRequiredProperty(PROPERTY_NAME_DATABASE_URL));
// 	        dataSource.setUsername(env.getRequiredProperty(PROPERTY_NAME_DATABASE_USERNAME));
// 	        dataSource.setPassword(env.getRequiredProperty(PROPERTY_NAME_DATABASE_PASSWORD));
// 	        
// 	        return dataSource;
// 	    }
// 
// 
// 	    @Bean
// 	    public LocalSessionFactoryBean sessionFactory() {
// 	        LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean();
// 	        sessionFactoryBean.setDataSource(dataSource());
// 	        sessionFactoryBean.setPackagesToScan(env.getRequiredProperty(PROPERTY_NAME_ENTITYMANAGER_PACKAGES_TO_SCAN));
// 	        sessionFactoryBean.setHibernateProperties(hibProperties());
// 	        
// 	        
// 	        return sessionFactoryBean;
// 	    }
// 
// 	    private Properties hibProperties() {
// 	        Properties properties = new Properties();
// 	        properties.put(PROPERTY_NAME_HIBERNATE_DIALECT, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_DIALECT));
// 	        properties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_SHOW_SQL));
// 	        properties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_FORMAT_SQL));
// 	        properties.put(PROPERTY_NAME_HIBERNATE_hbm2ddl, env.getRequiredProperty(PROPERTY_NAME_HIBERNATE_hbm2ddl));
// 	        
// 	        return properties;
// 	    }
// 
// 	    @Bean
// 	    public HibernateTransactionManager transactionManager() {
// 	        HibernateTransactionManager transactionManager = new HibernateTransactionManager();
// 	        transactionManager.setSessionFactory(sessionFactory().getObject());
// 	        return transactionManager;
// 	    }
// }


// Path: ch07/springtobemulti/WebAppSub/src/main/java/info/thecodinglive/web/config/WebInitializer.java
import info.thecodinglive.hiber.config.DbConfig;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

package info.thecodinglive.web.config;



public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{

	@Override
	protected Class<?>[] getRootConfigClasses() {
		return new Class[]{DbConfig.class};