From 3f1bd78176d2db35d3b645a0096e419f42e77927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petter=20Holmstr=C3=B6m?= Date: Thu, 19 Dec 2024 17:29:25 +0200 Subject: [PATCH] JpaFilterConverter is now a utility class (#4031) --- .../demo/fusion/crud/ProductAdvancedDtoListService.java | 7 ++----- .../com/vaadin/demo/fusion/crud/ProductDtoListService.java | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/vaadin/demo/fusion/crud/ProductAdvancedDtoListService.java b/src/main/java/com/vaadin/demo/fusion/crud/ProductAdvancedDtoListService.java index fe334d9d76..1de641608e 100644 --- a/src/main/java/com/vaadin/demo/fusion/crud/ProductAdvancedDtoListService.java +++ b/src/main/java/com/vaadin/demo/fusion/crud/ProductAdvancedDtoListService.java @@ -17,12 +17,9 @@ public class ProductAdvancedDtoListService implements ListService { private final ProductRepository productRepository; - private final JpaFilterConverter jpaFilterConverter; - public ProductAdvancedDtoListService(ProductRepository productRepository, - JpaFilterConverter jpaFilterConverter) { + public ProductAdvancedDtoListService(ProductRepository productRepository) { this.productRepository = productRepository; - this.jpaFilterConverter = jpaFilterConverter; } @Override @@ -36,7 +33,7 @@ public List list(Pageable pageable, .withMapping("supplierId", "supplier.id") .withMapping("supplierInfo", "supplier.supplierName"); // Create JPA specification from Hilla filter - var specification = jpaFilterConverter.toSpec(transformer.apply(filter), + var specification = JpaFilterConverter.toSpec(transformer.apply(filter), Product.class); // Fetch data from JPA repository return productRepository diff --git a/src/main/java/com/vaadin/demo/fusion/crud/ProductDtoListService.java b/src/main/java/com/vaadin/demo/fusion/crud/ProductDtoListService.java index c3eb83701d..03cb59dd75 100644 --- a/src/main/java/com/vaadin/demo/fusion/crud/ProductDtoListService.java +++ b/src/main/java/com/vaadin/demo/fusion/crud/ProductDtoListService.java @@ -18,12 +18,9 @@ @AnonymousAllowed public class ProductDtoListService implements ListService { private final ProductRepository productRepository; - private final JpaFilterConverter jpaFilterConverter; - public ProductDtoListService(ProductRepository productRepository, - JpaFilterConverter jpaFilterConverter) { + public ProductDtoListService(ProductRepository productRepository) { this.productRepository = productRepository; - this.jpaFilterConverter = jpaFilterConverter; } @Override @@ -33,7 +30,7 @@ public ProductDtoListService(ProductRepository productRepository, // Use the Hilla JpaFilterConverter to create a JPA specification from // the filter Specification spec = filter != null - ? jpaFilterConverter.toSpec(filter, Product.class) + ? JpaFilterConverter.toSpec(filter, Product.class) : Specification.anyOf(); // Query the JPA repository Page products = productRepository.findAll(spec, pageable);