Comment 3 for bug 782242

Revision history for this message
Lieven Doclo (lieven-doclo-jintec) wrote :

Then perhaps you should provide null-safe variants of the methods. My case in point is when you're using filter objects. When you have a filter object with 10+ filter criteria this would result in at least 10 if-structures checking on null (=when that filter field is not used). Using null-safe variants would imply that the predicate is only applied when the value passed to that predicate is not null.
Currently, I've solved the issue by implementing a static utility method:

query.from(QProduct.product).where(Predicates.applyIfNotNull(filter.getProductName(), QProduct.product.name.eq(filter.getProductName())));

However, this would be nicer:

query.from(QProduct.product).where(QProduct.product.name.nullSafeEq(filter.getProductName()))