> For the complete documentation index, see [llms.txt](https://olavo-moreira.gitbook.io/studies/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://olavo-moreira.gitbook.io/studies/jpa-consultas-sql-e-jpql/dscommerce-consulta-de-produtos-por-nome/service.md).

# Service

Antes:

```java
    @Transactional(readOnly = true)
    public Page<ProductDto> findAll(Pageable pageable) {
        Page<Product> products = productRepository.findAll(pageable);

        //pode fazer .map direto pois Page já é uma stream
        return products.map(x -> new ProductDto(x));
    }
```

Depois:

```java
    @Transactional(readOnly = true)
    public Page<ProductDto> findAll(String name, Pageable pageable) {
        Page<Product> products = productRepository.searchByName(name, pageable);

        //pode fazer .map direto pois Page já é uma stream
        return products.map(x -> new ProductDto(x));
    }
```
