Skip to content

Introduce database-name attribute in <jdbc:embedded-database /> [SPR-12835] #17432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Mar 20, 2015 · 1 comment
Assignees
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 20, 2015

Sam Brannen opened SPR-12835 and commented

Status Quo

Since its inception, the <jdbc:embedded-database /> XML namespace element (or more specifically the EmbeddedDatabaseBeanDefinitionParser) has set the name of the embedded database that it creates to the value of the id attribute. This makes it impossible to reuse an XML configuration file containing such a bean definition in multiple application contexts loaded within the same JVM -- for example, by importing the common test data source configuration into multiple contexts loaded by the Spring TestContext Framework.

Furthermore, the EmbeddedDatabaseBuilder already provides support for setting the name in Java Config.

Deliverables

  1. Introduce a database-name attribute in <jdbc:embedded-database /> to bring XML configuration of embedded databases on par with the support in Java Config.

Affects: 3.0 GA

Issue Links:

Referenced from: commits ab771df, c36c6cb

@spring-projects-issues
Copy link
Collaborator Author

Sam Brannen commented

Addressed in GitHub commit c36c6cb:

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data modules (jdbc, orm, oxm, tx) in: test Issues in the test module type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants