N
N
nikitosis2019-04-29 14:49:41
Java
nikitosis, 2019-04-29 14:49:41

How to apply multiple filters in Hibernate?

I have a Product class, and I want to get a selection of Product from the database, applying some filters to them (price, categories, etc.).
At first glance, you can create a method like
List getFilteredProducts(int minPrice,int maxPrice,Set categories,...)
But what if I do not want to specify some parameters (for example, I want to limit only the max price)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2019-04-29
Hasanly @azerphoenix

Hello!
After all, in fact, filtering is a search in the database. Accordingly, enable hibernate search. And there already is the possibility of indexing + the ability to set the necessary parameters, filters.
https://docs.jboss.org/hibernate/stable/search/ref...
You can also use ElasticSearch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question