Skip to content
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

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

Closed
spring-issuemaster opened this issue Mar 20, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

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:

  • #17431 Allow <jdbc:embedded-database /> to be declared as an anonymous bean ("depends on")
  • #13491 Introduce support for generating unique names for embedded databases ("is depended on by")
  • #12260 jdbc:datasource lacks 'name' attribute or related mechanism
  • #13560 Using multiple declarations of jdbc:embedded-database creates only one H2 instance per JVM ("supersedes")

Referenced from: commits ab771df, c36c6cb

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Mar 20, 2015

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
You can’t perform that action at this time.