Browse Source

Merge pull request #3818 from madorb/master

* pr/3818:
  Polish contribution
  Consistently apply table prefix
pull/3844/head
Stephane Nicoll 11 years ago
parent
commit
e9fe34e2fa
  1. 4
      spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java
  2. 6
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java

4
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java

@ -140,6 +140,10 @@ class BasicBatchConfigurer implements BatchConfigurer { @@ -140,6 +140,10 @@ class BasicBatchConfigurer implements BatchConfigurer {
logger.warn("JPA does not support custom isolation levels, so locks may not be taken when launching Jobs");
factory.setIsolationLevelForCreate("ISOLATION_DEFAULT");
}
String tablePrefix = this.properties.getTablePrefix();
if (StringUtils.hasText(tablePrefix)) {
factory.setTablePrefix(tablePrefix);
}
factory.setTransactionManager(getTransactionManager());
factory.afterPropertiesSet();
return factory.getObject();

6
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java

@ -68,6 +68,7 @@ import static org.junit.Assert.assertTrue; @@ -68,6 +68,7 @@ import static org.junit.Assert.assertTrue;
* Tests for {@link BatchAutoConfiguration}.
*
* @author Dave Syer
* @author Stephane Nicoll
*/
public class BatchAutoConfigurationTests {
@ -224,9 +225,12 @@ public class BatchAutoConfigurationTests { @@ -224,9 +225,12 @@ public class BatchAutoConfigurationTests {
PropertyPlaceholderAutoConfiguration.class);
this.context.refresh();
assertNotNull(this.context.getBean(JobLauncher.class));
assertNotNull(this.context.getBean(JobExplorer.class));
assertEquals(0, new JdbcTemplate(this.context.getBean(DataSource.class))
.queryForList("select * from PREFIX_JOB_EXECUTION").size());
JobExplorer jobExplorer = this.context.getBean(JobExplorer.class);
assertEquals(0, jobExplorer.findRunningJobExecutions("test").size());
JobRepository jobRepository = this.context.getBean(JobRepository.class);
assertNull(jobRepository.getLastJobExecution("test", new JobParameters()));
}
@Configuration

Loading…
Cancel
Save