package org.lanyonm.grabbag.config;

import javax.sql.DataSource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.annotation.EnableMyBatisMapperScanner;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;

@Configuration
//@Profile({"dev", "test"})
@EnableMyBatisMapperScanner(basePackages={"org.lanyonm.grabbag.persistence"})
public class DataConfig {

	@Bean
	public DataSource dataSource() {
		return new EmbeddedDatabaseBuilder()
				.setType(EmbeddedDatabaseType.H2)
				.addScript("database/schema.sql")
				.addScript("database/init.sql")
				.build();
	}

	@Bean
	public DataSourceTransactionManager transactionManager() {
		return new DataSourceTransactionManager(dataSource());
	}

	@Bean
	public SqlSessionFactory sqlSessionFactory() throws Exception {
		SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
		sessionFactory.setDataSource(dataSource());
		sessionFactory.setTypeAliasesPackage("org.lanyonm.grabbag.domain");
		return sessionFactory.getObject();
	}

}

@@ -191,15 +191,8 @@
 ing.
-mapper.
 anno
@@ -201,31 +201,24 @@
 tion.EnableM
-yBatisM
 apperScanner
@@ -215,18 +215,19 @@
 perScann
-er
+ing
 ;%0A%0Aimpor
@@ -671,15 +671,8 @@
 bleM
-yBatisM
 appe
@@ -681,25 +681,12 @@
 cann
-er(basePackages=%7B
+ing(
 %22org
@@ -714,17 +714,16 @@
 istence%22
-%7D
 )%0Apublic

update MapperScanner references