title: Filtering data in a table - how to organize it correctly
body: <p>I study the spring+Hibernate bundle there Is an entity:</p>
  <pre><code>public class PersonEntity {
      private Long id;
      private String name;
      private Integer age;
      private City city;
      private Countrycountry;
  ...
  }
  </code></pre>
  <p>I need to perform filtering. data in this table to display in the browser window. I was thinking of making an implementation in the service of the following methods:</p>
  <pre><code>.findByName(name);
  .findByNameAndAge(name, age);
  .findByNameAndAge(name, age, city);
  .findByNameAndAge(name, city);
  ...
  </code></pre>
  <p>But it turns out that there are too many options for methods. How to make one universal method, i.e. something like a collection in which you can add as many parameters as you need. I started reading on this issue and got completely confused. Somewhere they write about @Filter, somewhere about Hibernate Search, there is also Spring Data Elasticsearch. Tell me the easiest and most relevant way to implement this. If there are links to real examples, I would be very grateful.</p>
  <p>Dao:</p>
  <pre><code>public interface PersonDao extends GeneralDAO&lt;PersonEntity&gt;{
      public List&lt;PersonEntity&gt; searchName(String name);
      public List&lt;PersonEntity&gt; searchAllFields(
              String name,
              Integer age,
              City city);
  }
  </code></pre>
  <p>GeneralDAO describes all standard methods such as get, save, etc. Repository:</p>
  <pre><code>@Repository
  public interface PersonRepository extends JpaRepository&lt;PersonEntity, Long&gt; {
      List&lt;PersonEntity&gt; findByNameIgnoreCase(String name);
      List&lt;PersonEntity&gt; findByNameAndAgeAndCity(
              String name,
              Integer age,
              City city);
  }
  </code></pre>
  <p>Service</p>
  <pre><code>@Service
  @Transactional
  public class PersonService implements PersonRepository {
      @Autowired
      private PersonRepository personRepository;
  
      ...
      описание всех стандартных методов чтения-записи в БД
  
      @Override
      public List&lt;PersonEntity&gt; searchName(String name) {
          return productTypeRepository.findByNameIgnoreCase(name);
      }
  
      @Override
      public List&lt;PersonEntity&gt; searchAllFields(
              String name,
              Integer age,
              City city) {
          return personRepository.findByNameAndAgeAndCity(
                  name,
                  age,
                  city);
      }
  }
  </code></pre>
  <p>In the ad and call controller:</p>
  <pre><code>@Autowired
  private PersonService personService;
  ...
  
  personService.searchAllFields(...);
  </code></pre>
  <p>The searchName method works fine, but searchAllFields doesn't. It always returns an empty list, even if I specify one name, the rest = null</p>
  <p>I tried to change the method in the service:</p>
  <pre><code>List&lt;PersonEntity&gt; findByNameIsNullAndAgeIsNullAndCityIsNull
  </code></pre>
  <p>Spring responds with an error:
  &quot;Error creating bean with name personRepository. At least 1 parameter(s) provided but only 0 parameter(s) present in query&quot;.</p>