<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:jpa="http://www.springframework.org/schema/integration/jpa"
	xmlns:task="http://www.springframework.org/schema/task"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc"
	xmlns:integration="http://www.springframework.org/schema/integration"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/jdbc https://www.springframework.org/schema/jdbc/spring-jdbc.xsd
		http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
		http://www.springframework.org/schema/task https://www.springframework.org/schema/task/spring-task.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd
		http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd
		http://www.springframework.org/schema/integration/jpa https://www.springframework.org/schema/integration/jpa/spring-integration-jpa.xsd">

	<jdbc:embedded-database id="dataSource" type="H2"/>

	<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS" >
		<jdbc:script location="classpath:H2-DropTables.sql" />
		<jdbc:script location="classpath:H2-CreateTables.sql" />
		<jdbc:script location="classpath:H2-PopulateData.sql" />
	</jdbc:initialize-database>

	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
		<constructor-arg ref="dataSource"/>
	</bean>

	<tx:annotation-driven transaction-manager="transactionManager"/>

	<bean id="entityManagerFactory"
		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="persistenceUnitName" value="persistenceUnit" />
		<property name="jpaVendorAdapter" ref="vendorAdaptor" />
        <property name="jpaDialect" ref="jpaDialect"/>
	</bean>

	<bean id="abstractVendorAdaptor" abstract="true">
		<property name="generateDdl" value="true" />
		<property name="database" value="HSQL" />
	</bean>

	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
		<property name="entityManagerFactory" ref="entityManagerFactory" />
		<property name="dataSource" ref="dataSource"/>
	</bean>

	<bean id="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
		<property name="entityManagerFactory" ref="entityManagerFactory"/>
	</bean>
</beans>
