Class JpaFilterConverter

java.lang.Object
com.vaadin.hilla.crud.JpaFilterConverter

@Component public class JpaFilterConverter extends Object
Utility class for converting Hilla Filter specifications into JPA filter specifications. This class can be used to implement filtering for custom ListService or CrudService implementations that use JPA as the data source.

This class requires an EntityManager to be available as a Spring bean and thus should be injected into the bean that wants to use the converter. Manually creating new instances of this class will not work.

  • Constructor Details

    • JpaFilterConverter

      public JpaFilterConverter()
  • Method Details

    • toSpec

      public <T> org.springframework.data.jpa.domain.Specification<T> toSpec(Filter rawFilter, Class<T> entity)
      Converts the given Hilla filter specification into a JPA filter specification for the specified entity class.

      If the filter contains PropertyStringFilter instances, their properties, or nested property paths, need to match the structure of the entity class. Likewise, their filter values should be in a format that can be parsed into the type that the property is of.

      Type Parameters:
      T - the type of the entity
      Parameters:
      rawFilter - the filter to convert
      entity - the entity class
      Returns:
      a JPA filter specification for the given filter