I have the following entity structure:
public class Car {
private String make;
private Integer price;
private Integer year;
}
I want to search for all cars made by HONDA whose price is higher than 50,000 or made in 2019.
The query I need to come up with is as follows:
SELECT * FROM car WHERE make='HONDA' AND (price>50000 OR year=2019);
I tried the following method but it produces the query without the brackets and hence producing the incorrect results.
List<Car> findAllByMakeAndPriceGreaterThanOrMake(String make, Integer price, Integer year);
Alternatively, I can use @Query
to write my own query but wanted to see if there's an existing way to achieve my requirement.