diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java index 68017a07fc2596a5a233440433bf05a1e83cad44..a707d78ff33b0bdf9b86ed127cffee7e0eca5637 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/config/DatabasePopulatorConfigUtils.java @@ -16,19 +16,18 @@ package org.springframework.jdbc.config; -import java.util.Arrays; import java.util.List; -import org.w3c.dom.Element; - import org.springframework.beans.BeanMetadataElement; import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.TypedStringValue; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.ManagedList; import org.springframework.jdbc.datasource.init.CompositeDatabasePopulator; import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator; import org.springframework.util.StringUtils; import org.springframework.util.xml.DomUtils; +import org.w3c.dom.Element; /** * @author Juergen Hoeller @@ -63,16 +62,15 @@ class DatabasePopulatorConfigUtils { delegate.addPropertyValue("ignoreFailedDrops", ignoreFailedDrops); delegate.addPropertyValue("continueOnError", continueOnError); - List locations = Arrays.asList(scriptElement.getAttribute("location")); // Use a factory bean for the resources so they can be given an order if a pattern is used BeanDefinitionBuilder resourcesFactory = BeanDefinitionBuilder.genericBeanDefinition(SortedResourcesFactoryBean.class); - resourcesFactory.addConstructorArgValue(locations); + resourcesFactory.addConstructorArgValue(new TypedStringValue(scriptElement.getAttribute("location"))); delegate.addPropertyValue("scripts", resourcesFactory.getBeanDefinition()); if (StringUtils.hasLength(scriptElement.getAttribute("encoding"))) { - delegate.addPropertyValue("sqlScriptEncoding", scriptElement.getAttribute("encoding")); + delegate.addPropertyValue("sqlScriptEncoding", new TypedStringValue(scriptElement.getAttribute("encoding"))); } if (StringUtils.hasLength(scriptElement.getAttribute("separator"))) { - delegate.addPropertyValue("separator", scriptElement.getAttribute("separator")); + delegate.addPropertyValue("separator", new TypedStringValue(scriptElement.getAttribute("separator"))); } delegates.add(delegate.getBeanDefinition()); } diff --git a/org.springframework.jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java b/org.springframework.jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java index eb46775db94e7eee8c6002254396577706771988..af62a7c6bf3bfd1bf6bc9587185fa75bbdabda4b 100644 --- a/org.springframework.jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java +++ b/org.springframework.jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java @@ -91,6 +91,13 @@ public class InitializeDatabaseIntegrationTests { assertCorrectSetup(dataSource); } + @Test + public void testScriptNameWithExpressions() throws Exception { + context = new ClassPathXmlApplicationContext("org/springframework/jdbc/config/jdbc-initialize-expression-config.xml"); + DataSource dataSource = context.getBean("dataSource", DataSource.class); + assertCorrectSetup(dataSource); + } + @Test public void testCacheInitialization() throws Exception { context = new ClassPathXmlApplicationContext("org/springframework/jdbc/config/jdbc-initialize-cache-config.xml"); diff --git a/org.springframework.jdbc/src/test/resources/org/springframework/jdbc/config/jdbc-initialize-expression-config.xml b/org.springframework.jdbc/src/test/resources/org/springframework/jdbc/config/jdbc-initialize-expression-config.xml new file mode 100644 index 0000000000000000000000000000000000000000..323a21072dac533a69887f1941df8f8adb9f321b --- /dev/null +++ b/org.springframework.jdbc/src/test/resources/org/springframework/jdbc/config/jdbc-initialize-expression-config.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + classpath:org/springframework/jdbc/config/db-schema.sql + classpath*:org/springframework/jdbc/config/*-data.sql + true + + +