RESOLVED - issue SPR-5917: DataSourceInitializer and namespace support for creating and populating databases

Moved populator to init package and added namespace features
This commit is contained in:
David Syer
2009-10-30 10:31:37 +00:00
parent ab403468f9
commit 0db68e1b57
24 changed files with 512 additions and 47 deletions

View File

@@ -0,0 +1 @@
drop table T_TEST;

View File

@@ -0,0 +1 @@
update T_TEST set NAME='Dave' where name='Keith';

View File

@@ -6,18 +6,18 @@
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<jdbc:embedded-database id="dataSource" type="HSQL">
<jdbc:script location="classpath:org/springframework/jdbc/datasource/embedded/db-schema.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/datasource/embedded/db-test-data.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-test-data.sql"/>
</jdbc:embedded-database>
<jdbc:embedded-database id="h2DataSource" type="H2">
<jdbc:script location="classpath:org/springframework/jdbc/datasource/embedded/db-schema.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/datasource/embedded/db-test-data.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-test-data.sql"/>
</jdbc:embedded-database>
<jdbc:embedded-database id="derbyDataSource" type="DERBY">
<jdbc:script location="classpath:org/springframework/jdbc/datasource/embedded/db-schema-derby.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/datasource/embedded/db-test-data.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema-derby.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-test-data.sql"/>
</jdbc:embedded-database>
</beans>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<jdbc:embedded-database id="dataSource" type="HSQL"/>
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-test-data.sql"/>
</jdbc:initialize-database>
<!-- This cache relies on data created in the initialize-database element. It works fine
if the bean definitions are registered in the right order. (Could possibly be fixed later.) -->
<bean class="org.springframework.jdbc.config.InitializeDatabaseIntegrationTest$CacheData">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<jdbc:embedded-database id="dataSource" type="HSQL"/>
<jdbc:initialize-database data-source="dataSource" enabled="#{systemProperties['ENABLED']}">
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-test-data.sql"/>
</jdbc:initialize-database>
</beans>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<jdbc:embedded-database id="dataSource" type="HSQL"/>
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
<jdbc:script location="classpath:org/springframework/jdbc/config/db-drops.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-test-data.sql"/>
</jdbc:initialize-database>
</beans>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd">
<jdbc:embedded-database id="dataSource" type="HSQL"/>
<jdbc:initialize-database data-source="dataSource">
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema.sql"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/*-data.sql"/>
</jdbc:initialize-database>
</beans>