Himai Minh wrote:Hi, Must,
In your getSpecificShortAdvertisements() , the city is not a request parameter. So, even if you input city=LALA, it still returns you everything.
In your Advertisement builder, the city is null and it may return you everything?
Himai Minh wrote:Try this :
I think you don't need to build a query since Spring Data JPA will build a query for you.
Himai Minh wrote:If you only want to search by city, then create another method called findByCity.
If you have a very complicated query you can create something like this:
Dave Tolls wrote:Define a method for your repository which takes all the searchable parameters.
You'll then need to add an implementation, inside which use a CriteriaBuilder, adding criteria for each parameter that is supplied.
Something along those lines.
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.custom-implementations
https://www.baeldung.com/spring-data-jpa-query (section 9.2)
Himai Minh wrote:Hi, Must,
I think you may need a CustomAdvertisementRepository interface and its implementation:
Your service or controller can do this:
In your pom, put java persistence dependency
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |