package com.hida.configuration;

import java.util.Properties;
import javax.sql.DataSource; 
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 *
 * @author lruffin
 */
@Configuration
@EnableTransactionManagement
@ComponentScan({ "com.hida.dao" })
public class HibernateTestConfiguration {
    @Autowired
    private Environment environment;
 
    @Bean
    public LocalSessionFactoryBean sessionFactory() {
        LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
        sessionFactory.setDataSource(dataSource());
        sessionFactory.setPackagesToScan(new String[] { "com.hida.model" });
        sessionFactory.setHibernateProperties(hibernateProperties());
        return sessionFactory;
    }
 
    @Bean(name = "dataSource")
    public DataSource dataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
        dataSource.setUrl("jdbc:hsqldb:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
        dataSource.setUsername("");
        dataSource.setPassword("");      
        return dataSource;
    }
 
    private Properties hibernateProperties() {
        Properties properties = new Properties();
        properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
        properties.put("hibernate.hbm2ddl.auto", "create-drop");
        return properties;
    }        
 
    @Bean
    @Autowired
    public HibernateTransactionManager transactionManager(SessionFactory s) {
        HibernateTransactionManager txManager = new HibernateTransactionManager();
        txManager.setSessionFactory(s);
        return txManager;
    }
}

@@ -83,18 +83,17 @@
 aSource;
- 
 %0A
+
 import o
@@ -697,16 +697,69 @@
 t;%0A%0A/**%0A
+ * Used to create a test environment for test cases.%0A
  *%0A * @a
@@ -836,17 +836,16 @@
 ntScan(%7B
- 
 %22com.hid
@@ -850,17 +850,16 @@
 ida.dao%22
- 
 %7D)%0Apubli
@@ -895,16 +895,17 @@
 ation %7B%0A
+%0A
     @Aut
@@ -948,18 +948,17 @@
 onment;%0A
- 
 %0A
+
     @Bea
@@ -1202,11 +1202,9 @@
 ng%5B%5D
- %7B 
+%7B
 %22com
@@ -1215,17 +1215,16 @@
 a.model%22
- 
 %7D);%0A    
@@ -1322,26 +1322,25 @@
 tory;%0A    %7D%0A
- 
 %0A
+
     @Bean(na
@@ -1698,22 +1698,16 @@
 ord(%22%22);
-      
 %0A       
@@ -1732,18 +1732,17 @@
 ;%0A    %7D%0A
- 
 %0A
+
     priv
@@ -2013,18 +2013,9 @@
    %7D
-        %0A 
+%0A
 %0A   

Add javadocs to HibernateTestConfiguration