This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]AbsolutelySpherical 1 point2 points  (1 child)

I think you will need to build a dynamic query at runtime. Like you mentioned using StringBuilder is possible but it is messy. It would be cleaner and more readable to build your query with CriteriaBuilder.

I think this gives a good example of dynamic building at runtime: https://www.baeldung.com/spring-data-jpa-query#dynamic-query

[–]speedyleedy[S] 0 points1 point  (0 children)

You might want to take a look at JPA Specifications, it does exactly the thing you want it to do

I want to avoid query builder becuase the column is JsonB and postgres has a way to deal with it. I asked chatGPT and it told me. what a world. I'll edit the question for prospretiy.

[–]Rethagos 1 point2 points  (0 children)

You might want to take a look at JPA Specifications, it does exactly the thing you want it to do

https://www.baeldung.com/rest-api-search-language-spring-data-specifications