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:
@@ -4877,6 +4877,25 @@ followed by a set of `CREATE` statements.
|
||||
The `ignore-failures` option can be set to `NONE` (the default), `DROPS` (ignore failed
|
||||
drops), or `ALL` (ignore all failures).
|
||||
|
||||
Each statement should be separated by `;` or a new line if the `;` character is not
|
||||
present at all in the script. You can control that globally or script by script, for
|
||||
example:
|
||||
|
||||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
<jdbc:initialize-database data-source="dataSource" **separator="@@"**>
|
||||
<jdbc:script location="classpath:com/foo/sql/db-schema.sql" **separator=";"**/>
|
||||
<jdbc:script location="classpath:com/foo/sql/db-test-data-1.sql"/>
|
||||
<jdbc:script location="classpath:com/foo/sql/db-test-data-2.sql"/>
|
||||
</jdbc:initialize-database>
|
||||
----
|
||||
|
||||
In this example, the two `test-data` scripts use `@@` as statement separator and only
|
||||
the `db-schema.sql` uses `;`. This configuration specifies that the default separator
|
||||
is `@@` and override that default for the `db-schema` script.
|
||||
|
||||
|
||||
If you need more control than you get from the XML namespace, you can simply use the
|
||||
`DataSourceInitializer` directly and define it as a component in your application.
|
||||
|
||||
|
||||
@@ -635,6 +635,11 @@ public @interface MyTestConfig {
|
||||
* Any SpEL expression used to specify the `condition` of an `@EventListener` can
|
||||
now refer to beans (i.e. `@beanName.method()`).
|
||||
|
||||
=== Data Access Improvements
|
||||
|
||||
* `jdbc:initialize-database` and `jdbc:embedded-database` support a configurable
|
||||
separator to be applied to each script.
|
||||
|
||||
=== Caching Improvements
|
||||
|
||||
Spring 4.3 allows concurrent calls on a given key to be synchronized so that the
|
||||
|
||||
Reference in New Issue
Block a user