From b69152571e52c2fa2df015d63cf55fe7a9ca9da3 Mon Sep 17 00:00:00 2001 From: madorb Date: Mon, 24 Aug 2015 23:06:18 -0500 Subject: [PATCH 1/2] Consistently apply table prefix Make sure that if a custom table prefix is specified, it is set on the JobRepository as well. Closes gh-3798 --- .../boot/autoconfigure/batch/BasicBatchConfigurer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java index 28e93449be0..93fbc48fb44 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BasicBatchConfigurer.java @@ -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(); From bd15a0c03aa1a3aaa898865fa76b5fcaee50f993 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 27 Aug 2015 15:18:59 +0200 Subject: [PATCH 2/2] Polish contribution Closes gh-3818 --- .../autoconfigure/batch/BatchAutoConfigurationTests.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java index 04982072fce..a66e70982c1 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfigurationTests.java @@ -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 { 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