Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce database-name in <jdbc:embedded-database>
Prior to this commit, the EmbeddedDatabaseBeanDefinitionParser set the name of the embedded database that it configured to the value of its 'id'. This made it impossible to assign unique names to embedded databases if the same bean 'id' (e.g, 'dataSource') was used across multiple application contexts loaded within the same JVM, which is often the case within an integration test suite. In contrast, the EmbeddedDatabaseBuilder already provides support for setting the name in Java Config. Thus there is a disconnect between XML and Java configuration. This commit addresses this issue by introducing a 'database-name' attribute in <jdbc:embedded-database />. This allows developers to set unique names for embedded databases -- for example, via a SpEL expression or a property placeholder that is influenced by the current active bean definition profiles. Issue: SPR-12835
- Loading branch information
Showing
6 changed files
with
80 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
...-jdbc/src/test/resources/org/springframework/jdbc/config/jdbc-config-db-name-explicit.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans" xmlns="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.2.xsd"> | ||
|
||
<embedded-database id="dataSource" database-name="customDbName"> | ||
<script location="classpath:org/springframework/jdbc/config/db-schema.sql" /> | ||
<script location="classpath:org/springframework/jdbc/config/db-test-data.sql" /> | ||
</embedded-database> | ||
|
||
</beans:beans> |
12 changes: 12 additions & 0 deletions
12
...-jdbc/src/test/resources/org/springframework/jdbc/config/jdbc-config-db-name-implicit.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans" xmlns="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.2.xsd"> | ||
|
||
<embedded-database id="dataSource"> | ||
<script location="classpath:org/springframework/jdbc/config/db-schema.sql" /> | ||
<script location="classpath:org/springframework/jdbc/config/db-test-data.sql" /> | ||
</embedded-database> | ||
|
||
</beans:beans> |