Skip to content

Commit

Permalink
JpaFilterConverter is now a utility class (#4031)
Browse files Browse the repository at this point in the history
  • Loading branch information
peholmst authored Dec 19, 2024
1 parent 4ae76a7 commit 3f1bd78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@
public class ProductAdvancedDtoListService
implements ListService<ProductAdvancedDto> {
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
Expand All @@ -36,7 +33,7 @@ public List<ProductAdvancedDto> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
@AnonymousAllowed
public class ProductDtoListService implements ListService<ProductDto> {
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
Expand All @@ -33,7 +30,7 @@ public ProductDtoListService(ProductRepository productRepository,
// Use the Hilla JpaFilterConverter to create a JPA specification from
// the filter
Specification<Product> spec = filter != null
? jpaFilterConverter.toSpec(filter, Product.class)
? JpaFilterConverter.toSpec(filter, Product.class)
: Specification.anyOf();
// Query the JPA repository
Page<Product> products = productRepository.findAll(spec, pageable);
Expand Down

0 comments on commit 3f1bd78

Please sign in to comment.