From eafb271394bf518131b1d5437b1dd62a3243f1b3 Mon Sep 17 00:00:00 2001 From: Elmar Mammadov Date: Fri, 8 Jul 2022 01:35:31 +0200 Subject: [PATCH 1/9] BAEL-5545: prepared a simple demo to benchmark spring jdbc batch inserts --- persistence-modules/pom.xml | 1 + persistence-modules/spring-jdbc-batch/pom.xml | 60 +++++++++++++++++++ ...SpringJdbcBatchPerformanceApplication.java | 43 +++++++++++++ .../spring/jdbc/batch/config/AppConfig.java | 24 ++++++++ .../spring/jdbc/batch/model/Product.java | 54 +++++++++++++++++ .../batch/repo/BatchProductRepository.java | 33 ++++++++++ .../jdbc/batch/repo/ProductRepository.java | 9 +++ .../batch/repo/SimpleProductRepository.java | 29 +++++++++ .../jdbc/batch/service/ProductService.java | 54 +++++++++++++++++ .../batch/service/ProductServiceUnitTest.java | 26 ++++++++ 10 files changed, 333 insertions(+) create mode 100644 persistence-modules/spring-jdbc-batch/pom.xml create mode 100644 persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java create mode 100644 persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java create mode 100644 persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java create mode 100644 persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java create mode 100644 persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java create mode 100644 persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java create mode 100644 persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java create mode 100644 persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index ee4807933a..612070ea10 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -105,6 +105,7 @@ spring-jooq spring-mybatis spring-persistence-simple + spring-jdbc-batch diff --git a/persistence-modules/spring-jdbc-batch/pom.xml b/persistence-modules/spring-jdbc-batch/pom.xml new file mode 100644 index 0000000000..0401044be1 --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/pom.xml @@ -0,0 +1,60 @@ + + + + + 4.0.0 + + spring-jdbc-batch + 0.0.1-SNAPSHOT + spring-jdbc-batch + Demo project for Spring Boot Jdbc batch support + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + 11 + + + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.postgresql + postgresql + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + + + + + diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java new file mode 100644 index 0000000000..aef2100de8 --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java @@ -0,0 +1,43 @@ +package com.baeldung.spring.jdbc.batch; + +import com.baeldung.spring.jdbc.batch.service.ProductService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringJdbcBatchPerformanceApplication implements CommandLineRunner { + + @Autowired + @Qualifier("batchProductService") + private ProductService batchProductService; + @Autowired + @Qualifier("simpleProductService") + private ProductService simpleProductService; + + public static void main(String[] args) { + SpringApplication.run(SpringJdbcBatchPerformanceApplication.class, args); + } + + @Override + public void run(String... args) throws Exception { + int[] recordCounts = { 1, 10, 100, 1000, 10_000, 100_000, 1000_000 }; + + for (int recordCount : recordCounts) { + long regularElapsedTime = simpleProductService.createProducts(recordCount); + long batchElapsedTime = batchProductService.createProducts(recordCount); + + System.out.println("-".repeat(50)); + System.out.format("%-20s%-5s%-10s%-5s%8sms\n", "Regular inserts", "|", recordCount, "|", regularElapsedTime); + System.out.format("%-20s%-5s%-10s%-5s%8sms\n", "Batch inserts", "|", recordCount, "|", batchElapsedTime); + System.out.printf("Total gain: %d %s\n", calculateGainInPercent(regularElapsedTime, batchElapsedTime), "%"); + } + + } + + int calculateGainInPercent(long before, long after) { + return (int) Math.floor(100D * (before - after) / before); + } +} diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java new file mode 100644 index 0000000000..b0fd111ed2 --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java @@ -0,0 +1,24 @@ +package com.baeldung.spring.jdbc.batch.config; + +import com.baeldung.spring.jdbc.batch.repo.BatchProductRepository; +import com.baeldung.spring.jdbc.batch.repo.SimpleProductRepository; +import com.baeldung.spring.jdbc.batch.service.ProductService; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.time.Clock; +import java.util.Random; + +@Configuration +public class AppConfig { + + @Bean + public ProductService simpleProductService(SimpleProductRepository simpleProductRepository) { + return new ProductService(simpleProductRepository, new Random(), Clock.systemUTC()); + } + + @Bean + public ProductService batchProductService(BatchProductRepository batchProductRepository) { + return new ProductService(batchProductRepository, new Random(), Clock.systemUTC()); + } +} diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java new file mode 100644 index 0000000000..6454952fdc --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java @@ -0,0 +1,54 @@ +package com.baeldung.spring.jdbc.batch.model; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +public class Product { + private long id; + private String title; + private LocalDateTime createdTs; + private BigDecimal price; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public LocalDateTime getCreatedTs() { + return createdTs; + } + + public void setCreatedTs(LocalDateTime createdTs) { + this.createdTs = createdTs; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("Product{"); + sb.append("id=").append(id); + sb.append(", title='").append(title).append('\''); + sb.append(", createdTs=").append(createdTs); + sb.append(", price=").append(price); + sb.append('}'); + return sb.toString(); + } +} diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java new file mode 100644 index 0000000000..d4a4affd0a --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java @@ -0,0 +1,33 @@ +package com.baeldung.spring.jdbc.batch.repo; + +import com.baeldung.spring.jdbc.batch.model.Product; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.PreparedStatement; +import java.sql.Timestamp; +import java.util.List; + +@Repository +public class BatchProductRepository implements ProductRepository { + + private final JdbcTemplate jdbcTemplate; + + public BatchProductRepository(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } + + @Override + @Transactional + public void saveAll(List products) { + jdbcTemplate.batchUpdate("INSERT INTO PRODUCT (TITLE, CREATED_TS, PRICE) VALUES (?, ?, ?)", + products, + 100, + (PreparedStatement ps, Product product) -> { + ps.setString(1, product.getTitle()); + ps.setTimestamp(2, Timestamp.valueOf(product.getCreatedTs())); + ps.setBigDecimal(3, product.getPrice()); + }); + } +} diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java new file mode 100644 index 0000000000..ed193f87dd --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.spring.jdbc.batch.repo; + +import com.baeldung.spring.jdbc.batch.model.Product; + +import java.util.List; + +public interface ProductRepository { + void saveAll(List products); +} diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java new file mode 100644 index 0000000000..3dfb998cba --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java @@ -0,0 +1,29 @@ +package com.baeldung.spring.jdbc.batch.repo; + +import com.baeldung.spring.jdbc.batch.model.Product; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Repository; +import org.springframework.transaction.annotation.Transactional; + +import java.sql.Timestamp; +import java.util.List; + +@Repository +public class SimpleProductRepository implements ProductRepository { + + private final JdbcTemplate jdbcTemplate; + + public SimpleProductRepository(JdbcTemplate jdbcTemplate) { + this.jdbcTemplate = jdbcTemplate; + } + + @Override + @Transactional + public void saveAll(List products) { + for (Product product : products) { + jdbcTemplate.update("INSERT INTO PRODUCT (TITLE, CREATED_TS, PRICE) VALUES (?, ?, ?)", + product.getTitle(), Timestamp.valueOf(product.getCreatedTs()), product.getPrice()); + } + } + +} diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java new file mode 100644 index 0000000000..6a3758c07a --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java @@ -0,0 +1,54 @@ +package com.baeldung.spring.jdbc.batch.service; + +import com.baeldung.spring.jdbc.batch.model.Product; +import com.baeldung.spring.jdbc.batch.repo.ProductRepository; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.time.Clock; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class ProductService { + + private final ProductRepository productRepository; + private final Random random; + private final Clock clock; + + public ProductService(ProductRepository productRepository, Random random, Clock clock) { + this.productRepository = productRepository; + this.random = random; + this.clock = clock; + } + + @Transactional + public long createProducts(int count) { + List products = generate(count); + long startTime = clock.millis(); + productRepository.saveAll(products); + return clock.millis() - startTime; + } + + protected List generate(int count) { + final String[] titles = { "car", "plane", "house", "yacht" }; + final BigDecimal[] prices = { + new BigDecimal("12483.12"), + new BigDecimal("8539.99"), + new BigDecimal("88894"), + new BigDecimal("458694") + }; + + final List products = new ArrayList<>(count); + + for (int i = 0; i < count; i++) { + Product product = new Product(); + product.setCreatedTs(LocalDateTime.now()); + product.setPrice(prices[random.nextInt(4)]); + product.setTitle(titles[random.nextInt(4)]); + products.add(product); + } + return products; + } +} diff --git a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java new file mode 100644 index 0000000000..b242eaa335 --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.spring.jdbc.batch.service; + +import com.baeldung.spring.jdbc.batch.repo.ProductRepository; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +import java.time.Clock; +import java.util.Random; + +class ProductServiceUnitTest { + + @Mock + ProductRepository productRepository; + @Mock + Random random; + @Mock + Clock clock; + @InjectMocks + ProductService productService; + + @Test + void testWhenThen() { + + } +} \ No newline at end of file From b2ebd89c053660b8f96dadd8c951723a3831e338 Mon Sep 17 00:00:00 2001 From: Elmar Mammadov Date: Fri, 8 Jul 2022 02:11:40 +0200 Subject: [PATCH 2/9] BAEL-5545: added unit test for ProductService --- .../jdbc/batch/service/ProductService.java | 4 +- .../batch/service/ProductServiceUnitTest.java | 47 ++++++++++++++++++- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java index 6a3758c07a..6d8808c21b 100644 --- a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java +++ b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java @@ -31,7 +31,7 @@ public class ProductService { return clock.millis() - startTime; } - protected List generate(int count) { + private List generate(int count) { final String[] titles = { "car", "plane", "house", "yacht" }; final BigDecimal[] prices = { new BigDecimal("12483.12"), @@ -44,7 +44,7 @@ public class ProductService { for (int i = 0; i < count; i++) { Product product = new Product(); - product.setCreatedTs(LocalDateTime.now()); + product.setCreatedTs(LocalDateTime.now(clock)); product.setPrice(prices[random.nextInt(4)]); product.setTitle(titles[random.nextInt(4)]); products.add(product); diff --git a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java index b242eaa335..43719e986d 100644 --- a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java +++ b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java @@ -1,13 +1,30 @@ package com.baeldung.spring.jdbc.batch.service; +import com.baeldung.spring.jdbc.batch.model.Product; import com.baeldung.spring.jdbc.batch.repo.ProductRepository; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import java.math.BigDecimal; import java.time.Clock; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.util.List; import java.util.Random; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) class ProductServiceUnitTest { @Mock @@ -19,8 +36,34 @@ class ProductServiceUnitTest { @InjectMocks ProductService productService; - @Test - void testWhenThen() { + @Captor + ArgumentCaptor> proArgumentCaptor; + + @Test + void testWhenCreateProductsThenShouldSaveAndReturnElapsedTime() { + when(random.nextInt(4)) + .thenReturn(1, 3, 2, 0); + when(clock.instant()) + .thenReturn(Instant.parse("2022-04-09T10:15:30.00Z")); + when(clock.millis()) + .thenReturn(100L,500L); + when(clock.getZone()) + .thenReturn(ZoneId.systemDefault()); + + long actualElapsedTime = productService.createProducts(2); + + assertThat(actualElapsedTime) + .isEqualTo(400L); + verify(productRepository,times(1)) + .saveAll(proArgumentCaptor.capture()); + + assertThat(proArgumentCaptor.getValue()) + .hasSize(2) + .extracting("title","createdTs","price") + .containsExactly( + tuple("yacht", LocalDateTime.parse("2022-04-09T12:15:30"), new BigDecimal("8539.99")), + tuple("car", LocalDateTime.parse("2022-04-09T12:15:30"), new BigDecimal("88894")) + ); } } \ No newline at end of file From 551184076c26485898d43b145b40399c53a2467f Mon Sep 17 00:00:00 2001 From: Elmar Mammadov Date: Fri, 8 Jul 2022 02:24:58 +0200 Subject: [PATCH 3/9] BAEL-5545: fixed build issue for java 11 --- persistence-modules/pom.xml | 1 - pom.xml | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index 612070ea10..ee4807933a 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -105,7 +105,6 @@ spring-jooq spring-mybatis spring-persistence-simple - spring-jdbc-batch diff --git a/pom.xml b/pom.xml index 24aa678523..a10da85200 100644 --- a/pom.xml +++ b/pom.xml @@ -1260,6 +1260,7 @@ testing-modules/testing-assertions persistence-modules/fauna lightrun + persistence-modules/spring-jdbc-batch @@ -1327,6 +1328,7 @@ spring-boot-modules/spring-boot-camel testing-modules/testing-assertions persistence-modules/fauna + persistence-modules/spring-jdbc-batch lightrun From 0b5ffa01a70675c6047b8e69b93f46230046a103 Mon Sep 17 00:00:00 2001 From: Elmar Mammadov Date: Fri, 8 Jul 2022 12:56:50 +0200 Subject: [PATCH 4/9] BAEL-5545: fixed mockito mocking issue with Random class, added properties --- .../src/main/resources/application.properties | 5 +++++ .../batch/service/ProductServiceUnitTest.java | 17 +++++++++++++---- pom.xml | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 persistence-modules/spring-jdbc-batch/src/main/resources/application.properties diff --git a/persistence-modules/spring-jdbc-batch/src/main/resources/application.properties b/persistence-modules/spring-jdbc-batch/src/main/resources/application.properties new file mode 100644 index 0000000000..3f9b093013 --- /dev/null +++ b/persistence-modules/spring-jdbc-batch/src/main/resources/application.properties @@ -0,0 +1,5 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/sample-baeldung-db +spring.datasource.username=postgres +spring.datasource.password=root +spring.datasource.driver-class-name=org.postgresql.Driver +spring.datasource.hikari.data-source-properties.reWriteBatchedInserts=true diff --git a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java index 43719e986d..aaf9cd5f23 100644 --- a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java +++ b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java @@ -2,12 +2,14 @@ package com.baeldung.spring.jdbc.batch.service; import com.baeldung.spring.jdbc.batch.model.Product; import com.baeldung.spring.jdbc.batch.repo.ProductRepository; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.mockito.junit.jupiter.MockitoExtension; import java.math.BigDecimal; @@ -20,26 +22,33 @@ import java.util.Random; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.withSettings; @ExtendWith(MockitoExtension.class) class ProductServiceUnitTest { - @Mock ProductRepository productRepository; - @Mock Random random; - @Mock Clock clock; - @InjectMocks ProductService productService; @Captor ArgumentCaptor> proArgumentCaptor; + @BeforeEach + void setUp() { + this.productRepository = mock(ProductRepository.class); + this.random = mock(Random.class, withSettings().withoutAnnotations()); + this.clock = mock(Clock.class); + this.productService = new ProductService(this.productRepository, this.random, this.clock); + } + + @Test void testWhenCreateProductsThenShouldSaveAndReturnElapsedTime() { when(random.nextInt(4)) diff --git a/pom.xml b/pom.xml index a10da85200..23cc338d8b 100644 --- a/pom.xml +++ b/pom.xml @@ -1260,7 +1260,7 @@ testing-modules/testing-assertions persistence-modules/fauna lightrun - persistence-modules/spring-jdbc-batch + persistence-modules/spring-jdbc-batch From e934c96f6de468d9c5ca93ca74de3659336e820b Mon Sep 17 00:00:00 2001 From: Elmar Mammadov Date: Fri, 8 Jul 2022 16:17:37 +0200 Subject: [PATCH 5/9] BAEL-5545: fixed timezone issue --- .../batch/service/ProductServiceUnitTest.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java index aaf9cd5f23..12a0e70c1b 100644 --- a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java +++ b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java @@ -7,9 +7,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.mockito.junit.jupiter.MockitoExtension; import java.math.BigDecimal; @@ -55,24 +52,28 @@ class ProductServiceUnitTest { .thenReturn(1, 3, 2, 0); when(clock.instant()) .thenReturn(Instant.parse("2022-04-09T10:15:30.00Z")); + when(clock.getZone()) + .thenReturn(ZoneId.of("UTC")); + when(clock.millis()) .thenReturn(100L,500L); - when(clock.getZone()) - .thenReturn(ZoneId.systemDefault()); - long actualElapsedTime = productService.createProducts(2); + + final long actualElapsedTime = productService.createProducts(2); + assertThat(actualElapsedTime) .isEqualTo(400L); + verify(productRepository,times(1)) .saveAll(proArgumentCaptor.capture()); assertThat(proArgumentCaptor.getValue()) .hasSize(2) - .extracting("title","createdTs","price") + .extracting("title", "createdTs", "price") .containsExactly( - tuple("yacht", LocalDateTime.parse("2022-04-09T12:15:30"), new BigDecimal("8539.99")), - tuple("car", LocalDateTime.parse("2022-04-09T12:15:30"), new BigDecimal("88894")) + tuple("yacht", LocalDateTime.parse("2022-04-09T10:15:30"), new BigDecimal("8539.99")), + tuple("car", LocalDateTime.parse("2022-04-09T10:15:30"), new BigDecimal("88894")) ); } } \ No newline at end of file From bce765b9594cc38ffaff6fec1d68af379e68ee4f Mon Sep 17 00:00:00 2001 From: Elmar Mammadov Date: Wed, 20 Jul 2022 20:47:28 +0200 Subject: [PATCH 6/9] BAEL-5545: fixed formatting issue --- .../jdbc/batch/SpringJdbcBatchPerformanceApplication.java | 1 + .../spring/jdbc/batch/service/ProductServiceUnitTest.java | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java index aef2100de8..008bf55024 100644 --- a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java +++ b/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java @@ -1,6 +1,7 @@ package com.baeldung.spring.jdbc.batch; import com.baeldung.spring.jdbc.batch.service.ProductService; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.CommandLineRunner; diff --git a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java index 12a0e70c1b..26a5f64dc0 100644 --- a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java +++ b/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java @@ -2,6 +2,7 @@ package com.baeldung.spring.jdbc.batch.service; import com.baeldung.spring.jdbc.batch.model.Product; import com.baeldung.spring.jdbc.batch.repo.ProductRepository; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -36,7 +37,6 @@ class ProductServiceUnitTest { @Captor ArgumentCaptor> proArgumentCaptor; - @BeforeEach void setUp() { this.productRepository = mock(ProductRepository.class); @@ -45,7 +45,6 @@ class ProductServiceUnitTest { this.productService = new ProductService(this.productRepository, this.random, this.clock); } - @Test void testWhenCreateProductsThenShouldSaveAndReturnElapsedTime() { when(random.nextInt(4)) @@ -58,10 +57,8 @@ class ProductServiceUnitTest { when(clock.millis()) .thenReturn(100L,500L); - final long actualElapsedTime = productService.createProducts(2); - assertThat(actualElapsedTime) .isEqualTo(400L); From 5ea3e49db0baa019ac980476699feb01a003912f Mon Sep 17 00:00:00 2001 From: Elmar Mammadov Date: Tue, 26 Jul 2022 22:43:37 +0200 Subject: [PATCH 7/9] BAEL-5545: moved batch performance related classes into existing spring-jdbc module --- persistence-modules/spring-jdbc-batch/pom.xml | 60 ------------------- persistence-modules/spring-jdbc/pom.xml | 5 ++ ...SpringJdbcBatchPerformanceApplication.java | 7 ++- .../spring/jdbc/batch/config/AppConfig.java | 2 + .../spring/jdbc/batch/model/Product.java | 0 .../batch/repo/BatchProductRepository.java | 0 .../jdbc/batch/repo/ProductRepository.java | 0 .../batch/repo/SimpleProductRepository.java | 0 .../jdbc/batch/service/ProductService.java | 0 .../spring/jdbc/batch}/application.properties | 2 +- .../batch/service/ProductServiceUnitTest.java | 1 - pom.xml | 2 - 12 files changed, 13 insertions(+), 66 deletions(-) delete mode 100644 persistence-modules/spring-jdbc-batch/pom.xml rename persistence-modules/{spring-jdbc-batch => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java (88%) rename persistence-modules/{spring-jdbc-batch => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java (85%) rename persistence-modules/{spring-jdbc-batch => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java (100%) rename persistence-modules/{spring-jdbc-batch => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java (100%) rename persistence-modules/{spring-jdbc-batch => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java (100%) rename persistence-modules/{spring-jdbc-batch => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java (100%) rename persistence-modules/{spring-jdbc-batch => spring-jdbc}/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java (100%) rename persistence-modules/{spring-jdbc-batch/src/main/resources => spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch}/application.properties (96%) rename persistence-modules/{spring-jdbc-batch => spring-jdbc}/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java (99%) diff --git a/persistence-modules/spring-jdbc-batch/pom.xml b/persistence-modules/spring-jdbc-batch/pom.xml deleted file mode 100644 index 0401044be1..0000000000 --- a/persistence-modules/spring-jdbc-batch/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - 4.0.0 - - spring-jdbc-batch - 0.0.1-SNAPSHOT - spring-jdbc-batch - Demo project for Spring Boot Jdbc batch support - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - - - - - 11 - - - - - - org.springframework.boot - spring-boot-starter-jdbc - - - org.postgresql - postgresql - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - - - - - diff --git a/persistence-modules/spring-jdbc/pom.xml b/persistence-modules/spring-jdbc/pom.xml index 28a858dd43..08e43e8292 100644 --- a/persistence-modules/spring-jdbc/pom.xml +++ b/persistence-modules/spring-jdbc/pom.xml @@ -31,6 +31,11 @@ mysql-connector-java runtime + + org.postgresql + postgresql + runtime + \ No newline at end of file diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java similarity index 88% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java index 008bf55024..280f9cf2be 100644 --- a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java @@ -1,14 +1,17 @@ package com.baeldung.spring.jdbc.batch; import com.baeldung.spring.jdbc.batch.service.ProductService; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +import java.util.Collections; @SpringBootApplication +@ComponentScan(basePackages = "com.baeldung.spring.jdbc.batch") public class SpringJdbcBatchPerformanceApplication implements CommandLineRunner { @Autowired @@ -30,7 +33,7 @@ public class SpringJdbcBatchPerformanceApplication implements CommandLineRunner long regularElapsedTime = simpleProductService.createProducts(recordCount); long batchElapsedTime = batchProductService.createProducts(recordCount); - System.out.println("-".repeat(50)); + System.out.println(String.join("", Collections.nCopies(50, "-"))); System.out.format("%-20s%-5s%-10s%-5s%8sms\n", "Regular inserts", "|", recordCount, "|", regularElapsedTime); System.out.format("%-20s%-5s%-10s%-5s%8sms\n", "Batch inserts", "|", recordCount, "|", batchElapsedTime); System.out.printf("Total gain: %d %s\n", calculateGainInPercent(regularElapsedTime, batchElapsedTime), "%"); diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java similarity index 85% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java index b0fd111ed2..45d80f924a 100644 --- a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java @@ -5,11 +5,13 @@ import com.baeldung.spring.jdbc.batch.repo.SimpleProductRepository; import com.baeldung.spring.jdbc.batch.service.ProductService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import java.time.Clock; import java.util.Random; @Configuration +@PropertySource("classpath:com/baeldung/spring/jdbc/batch/application.properties") public class AppConfig { @Bean diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/resources/application.properties b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch/application.properties similarity index 96% rename from persistence-modules/spring-jdbc-batch/src/main/resources/application.properties rename to persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch/application.properties index 3f9b093013..9898ae022b 100644 --- a/persistence-modules/spring-jdbc-batch/src/main/resources/application.properties +++ b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch/application.properties @@ -2,4 +2,4 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/sample-baeldung-db spring.datasource.username=postgres spring.datasource.password=root spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.hikari.data-source-properties.reWriteBatchedInserts=true +spring.datasource.hikari.data-source-properties.reWriteBatchedInserts=true \ No newline at end of file diff --git a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java similarity index 99% rename from persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java rename to persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java index 26a5f64dc0..f19c2360f4 100644 --- a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java @@ -2,7 +2,6 @@ package com.baeldung.spring.jdbc.batch.service; import com.baeldung.spring.jdbc.batch.model.Product; import com.baeldung.spring.jdbc.batch.repo.ProductRepository; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/pom.xml b/pom.xml index 23cc338d8b..24aa678523 100644 --- a/pom.xml +++ b/pom.xml @@ -1260,7 +1260,6 @@ testing-modules/testing-assertions persistence-modules/fauna lightrun - persistence-modules/spring-jdbc-batch @@ -1328,7 +1327,6 @@ spring-boot-modules/spring-boot-camel testing-modules/testing-assertions persistence-modules/fauna - persistence-modules/spring-jdbc-batch lightrun From 95211496d23547f781f267c3dced4f80ccc740c4 Mon Sep 17 00:00:00 2001 From: Elmar Mammadov Date: Sat, 30 Jul 2022 14:27:43 +0200 Subject: [PATCH 8/9] BAEL-5545: fixed import organization --- .../spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java | 1 + .../java/com/baeldung/spring/jdbc/batch/config/AppConfig.java | 1 + .../baeldung/spring/jdbc/batch/repo/BatchProductRepository.java | 1 + .../baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java | 1 + .../com/baeldung/spring/jdbc/batch/service/ProductService.java | 1 + 5 files changed, 5 insertions(+) diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java index 280f9cf2be..d523717118 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java @@ -1,6 +1,7 @@ package com.baeldung.spring.jdbc.batch; import com.baeldung.spring.jdbc.batch.service.ProductService; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.CommandLineRunner; diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java index 45d80f924a..1dd7c63adc 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java @@ -3,6 +3,7 @@ package com.baeldung.spring.jdbc.batch.config; import com.baeldung.spring.jdbc.batch.repo.BatchProductRepository; import com.baeldung.spring.jdbc.batch.repo.SimpleProductRepository; import com.baeldung.spring.jdbc.batch.service.ProductService; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java index d4a4affd0a..9b4f0208ab 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java @@ -1,6 +1,7 @@ package com.baeldung.spring.jdbc.batch.repo; import com.baeldung.spring.jdbc.batch.model.Product; + import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java index 3dfb998cba..4a381dd8b9 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java @@ -1,6 +1,7 @@ package com.baeldung.spring.jdbc.batch.repo; import com.baeldung.spring.jdbc.batch.model.Product; + import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; diff --git a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java index 6d8808c21b..436764ffcf 100644 --- a/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java @@ -2,6 +2,7 @@ package com.baeldung.spring.jdbc.batch.service; import com.baeldung.spring.jdbc.batch.model.Product; import com.baeldung.spring.jdbc.batch.repo.ProductRepository; + import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; From e4c941c0dd98e9ca677a4097f9594caf0052f775 Mon Sep 17 00:00:00 2001 From: Elmar Mammadov Date: Sat, 30 Jul 2022 14:30:07 +0200 Subject: [PATCH 9/9] BAEL-5545: fixed import organization --- .../spring/jdbc/batch/service/ProductServiceUnitTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java index f19c2360f4..26a5f64dc0 100644 --- a/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java @@ -2,6 +2,7 @@ package com.baeldung.spring.jdbc.batch.service; import com.baeldung.spring.jdbc.batch.model.Product; import com.baeldung.spring.jdbc.batch.repo.ProductRepository; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith;