Java: incremental filtering in Spring/Hibernate
===

We're solving a problem where we need to fetch unique data from DB using a set of conditions. The idea is to fetch using the most general conditions first (as it's the fastest). If it returns only one item, great; if it returns multiple items, then we need to filter that data by incrementally applying more and more conditions until it gives us only one result.

Does Spring/Hibernate or any other library already provide something similar to what we want to do?