Support for global separator in JDBC namespace

Previously, if a database needs to be initialized with several scripts
and many (or all) use a custom separator, said separator must be repeated
for each script.

This commit introduces a `separator` property at the parent element level
that can be used to customize the default separator. This is available
for both the `initialize-database` and `embedded-database` elements.

Issue: SPR-13792
This commit is contained in:
Stephane Nicoll
2016-01-18 16:09:07 +01:00
parent eb49f3c225
commit 714ae2684c
7 changed files with 97 additions and 4 deletions

View File

@@ -0,0 +1,13 @@
<?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-4.3.xsd">
<jdbc:embedded-database id="dataSource" type="HSQL" separator="@@">
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema.sql" separator=";"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-test-data-endings.sql"/>
</jdbc:embedded-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-4.3.xsd">
<jdbc:embedded-database id="dataSource" type="HSQL"/>
<jdbc:initialize-database data-source="dataSource" separator="@@">
<jdbc:script location="classpath:org/springframework/jdbc/config/db-schema.sql" separator=";" encoding="ISO-8859-1"/>
<jdbc:script location="classpath:org/springframework/jdbc/config/db-test-data-endings.sql"/>
</jdbc:initialize-database>
</beans>