Skip to content
Advertisement

Working with multiple parameters in CriteriaBuilder

I have a need to use JpaSpecificationExecutor. Initially, I assumed that one parameter would be given as input and I would process it like this:

JavaScript

CarRepository :

JavaScript

However, I need to be able to work with:

JavaScript

And in response to me came all the options for suitable machines.

For example input:

JavaScript

At the output, I want to get all the machines whose properties fall under one of the following conditions:

JavaScript

How do I need to modify my code so that it works like I gave in the example? Or where can I read about it?

Advertisement

Answer

This article perfectly explains what you need.

You basically iterate through the List<Brand>, create a list of brand predicates then consider this list as one block of predicate.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement