I have the following Jooq code:
if (...) {
query = query.where(...);
}
query = query.and(...);
The problem is that I don't know whether the where() statement will be added or not.
If not, the and() part will be added without a prior where(), which should be wrong.
I am wondering how to solve that.
Must I write it as follows?
if (...) {
query = query.where(...);
}
else {
query = query.where(true); // This will make sure there is always a where statement, but it looks hacky...
}
query = query.and(...);
Or, must I adjust the statements' order?
What if I want to keep the order?
Thanks!