Blog

Hilla 2.5: DTO support for CRUD components

By  
Marcus Hellberg
Marcus Hellberg
·
On Dec 13, 2023 12:00:00 AM
·
In Product

We're happy to announce the 2.5 release of Hilla. This release addresses a common question we've heard from you when it comes to the new CRUD components: what if I don't use JPA? Hilla 2.5 adds support for DTOs, which means you can now use the CRUD components with any data source.

More flexible data sources

You can now use AutoGrid, AutoForm, and AutoCrud with any Java object, not only JPA entities.

ListService for AutoGrid

In order to use AutoGrid with any data type, you need to provide an implementation of ListService<T>.

@BrowserCallable
@AnonymousAllowed
public class ProductDtoListService implements ListService<ProductDto> {

    @Override
    public List<ProductDto> list(Pageable pageable, @Nullable Filter filter) {
        // return appropriate list of ProductDto
    }
}

Read the full documentation for using ListService.

CrudService for AutoForm and AutoCrud

In order to use AutoForm and AutoCrud with any data type, you need to provide an implementation of CrudService<T, ID>.

@BrowserCallable
@AnonymousAllowed
public class ProductDtoCrudService implements CrudService<ProductDto, Long> {


    @Override
    public List<ProductDto> list(Pageable pageable, @Nullable Filter filter) {
        // return appropriate list of ProductDto
    }

    @Override
    public @Nullable ProductDto save(ProductDto value) {
        // save ProductDto
    }

    @Override
    public void delete(Long id) {
        // delete ProductDto
    }
}

Read the full documentation for using CrudService.

Upgrading to Hilla 2.5

To upgrade to Hilla 2.5, update the version in your project's pom.xml file:

<properties>
  <hilla.version>2.5.0</hilla.version>
</properties>

For new Hilla projects, use the CLI:

npx @hilla/cli create my-app

Full release notes

You can find the full release notes on GitHub.

Marcus Hellberg
Marcus Hellberg
Marcus is the VP of Developer Relations at Vaadin. His daily work includes everything from writing blogs and tech demos to attending events and giving presentations on all things Vaadin and web-related. You can reach out to him on Twitter @marcushellberg.
Other posts by Marcus Hellberg