The problem is that (unfortunately) calling new SelectArg(String) calls the SelectArg(Object) constructor , which sets the value, not the column name. You must define the arguments as follows:
new SelectArg("date", null);
To go back, javadocs for Where.raw() :
args - Optional arguments that match any? specified in rawStatement. Each of the arguments must have either the corresponding columnName or a set of sql types.
You can also use SqlType constructors. I improved the Javadocs documentation on SelectArg to help with this. See this change on github .
Also, as I said before, I think you want to do something like:
SelectArg dateArg = new SelectArg("date", null); SelectArg endDateArg = new SelectArg("endDate", null); carsQB.where().raw("CASE WHEN future = true THEN date > ? ELSE endDate > ? END", dateArg, endDateArg); ... dateArg.setValue(...); endDateArg.setValue(...);
source share