Skip to content

Commit

Permalink
Merge branch '2.3.x'
Browse files Browse the repository at this point in the history
Closes gh-24401
  • Loading branch information
snicoll committed Dec 8, 2020
2 parents 7b2f24a + 06671aa commit 93d8334
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
Expand Up @@ -96,13 +96,12 @@ private static final class BootstrapExecutorCondition extends AnyNestedCondition
}

@ConditionalOnProperty(prefix = "spring.data.jpa.repositories", name = "bootstrap-mode",
havingValue = "deferred", matchIfMissing = true)
havingValue = "deferred")
static class DeferredBootstrapMode {

}

@ConditionalOnProperty(prefix = "spring.data.jpa.repositories", name = "bootstrap-mode", havingValue = "lazy",
matchIfMissing = false)
@ConditionalOnProperty(prefix = "spring.data.jpa.repositories", name = "bootstrap-mode", havingValue = "lazy")
static class LazyBootstrapMode {

}
Expand Down
Expand Up @@ -57,7 +57,7 @@ protected RepositoryConfigurationExtension getRepositoryConfigurationExtension()

@Override
protected BootstrapMode getBootstrapMode() {
return (this.bootstrapMode == null) ? BootstrapMode.DEFERRED : this.bootstrapMode;
return (this.bootstrapMode == null) ? BootstrapMode.DEFAULT : this.bootstrapMode;
}

@Override
Expand Down
Expand Up @@ -622,7 +622,7 @@
"name": "spring.data.jpa.repositories.bootstrap-mode",
"type": "org.springframework.data.repository.config.BootstrapMode",
"description": "Bootstrap mode for JPA repositories.",
"defaultValue": "deferred"
"defaultValue": "default"
},
{
"name": "spring.data.jpa.repositories.enabled",
Expand Down
Expand Up @@ -126,13 +126,12 @@ void whenBootstrapModeIsDefaultBootstrapExecutorIsNotConfigured() {
}

@Test
void bootstrapModeIsDeferredByDefault() {
void bootstrapModeIsDefaultByDefault() {
this.contextRunner.withUserConfiguration(MultipleAsyncTaskExecutorConfiguration.class)
.withConfiguration(AutoConfigurations.of(TaskExecutionAutoConfiguration.class,
TaskSchedulingAutoConfiguration.class))
.run((context) -> assertThat(
context.getBean(LocalContainerEntityManagerFactoryBean.class).getBootstrapExecutor())
.isEqualTo(context.getBean("applicationTaskExecutor")));
context.getBean(LocalContainerEntityManagerFactoryBean.class).getBootstrapExecutor()).isNull());
}

@Configuration(proxyBeanMethods = false)
Expand Down
Expand Up @@ -4263,6 +4263,8 @@ To enable deferred or lazy bootstrapping, set the configprop:spring.data.jpa.rep
When using deferred or lazy bootstrapping, the auto-configured `EntityManagerFactoryBuilder` will use the context's `AsyncTaskExecutor`, if any, as the bootstrap executor.
If more than one exists, the one named `applicationTaskExecutor` will be used.

NOTE: When using deferred or lazy bootstraping, make sure to defer any access to the JPA infrastructure after the application context bootstrap phase.

TIP: We have barely scratched the surface of Spring Data JPA.
For complete details, see the {spring-data-jdbc-docs}[Spring Data JPA reference documentation].

Expand Down
Expand Up @@ -103,11 +103,11 @@

/**
* The {@link BootstrapMode} for the test repository support. Defaults to
* {@link BootstrapMode#LAZY}.
* {@link BootstrapMode#DEFAULT}.
* @return the {@link BootstrapMode} to use for testing the repository
*/
@PropertyMapping("spring.data.jpa.repositories.bootstrap-mode")
BootstrapMode bootstrapMode() default BootstrapMode.LAZY;
BootstrapMode bootstrapMode() default BootstrapMode.DEFAULT;

/**
* Determines if default filtering should be used with
Expand Down
Expand Up @@ -109,9 +109,9 @@ void liquibaseAutoConfigurationWasImported() {
}

@Test
void bootstrapModeIsLazyByDefault() {
void bootstrapModeIsDefaultByDefault() {
assertThat(this.applicationContext.getEnvironment().getProperty("spring.data.jpa.repositories.bootstrap-mode"))
.isEqualTo(BootstrapMode.LAZY.name());
.isEqualTo(BootstrapMode.DEFAULT.name());
}

}

0 comments on commit 93d8334

Please sign in to comment.