Dynamic query with Spring Data JPA and Search by Example of

Search all around!

The Problem 😠

I know i was doomed when the google forced me to head to the 2nd page of its search results 😯 and criteria api was the appropriate solution. It would do wonders for small set of vales to be queried on.

Checkout the complete code @ GitHub 💻

The Situation 😕

So implementing criteria api will be easy with with few CriteriaObjects methods and done!, add!, commit!, push!. Ready for prod ⏳.

Lets spice it up, the POJO is added with some more properties lets say Horse Power, Turning Radius and lot more stuff which are to stored in database and we are again making up the changes with CriteriaObjects and its results in cycle for every new change.

To the rescue 👍

Example.of also takes an matcher object where in we can specify to which columns we can ignore the case and search.

Time to Search ⏰

Next search is by make and year

Limitations 🔐

We cannot query for conditions like between two ranges, example car make year between years 2010 to 2020.

Reference and Documentations 📕

Java Developer