I have a sql written in a MyBatis mapper file which is something like this:
select a,b,c from tbl_name where d = ?
public static final String d = "d_value";
With the out of the box behavior of MyBatis, as far as I know, you can't.
You could try to write an interceptor for the ParameterHandler and inject the value there but this can't always be possible since you can play only with two methods on the parameter handler:
getParameterObjectwhich returns the parameter that was sent to the query (can be a constant, a String, a Map, a custom object or even null as it is the case of your example where you don't send a parameter)
setParameterswhere I guess you could try to set the parameter if you know where it is on the prepared statement (which most of the times you might not).
My suggestion is to pass it as parameter to your query. The interceptor features of MyBatis are not very well documented, so you might not get the correct working combination from the start and you can end up with more trouble than it's worth.