I think the best choice depends on your requests.
If possible, I recommend you switch to the first alternative. I often find that I implement DAO lookup methods that take many parameters with a null value. The DAO method itself creates restrictions on adding criteria objects if the corresponding method parameters are not set to NULL.
This is a simple example:
public List<SomeObject> findSomeObjects(String name, Integer categoryId, Date dateTimeFrom, Date dateTimeUntil) { if (name != null)
If there really are many different search operations, and the number of combinations is very large, you can also try the second alternative. Perhaps you can limit your clone "Clone" by simplifying and adapting it for your use cases.
source share