Access public static final string in mybatis sql in mapper files

Viewed 9010

I have a sql written in a MyBatis mapper file which is something like this:

<select id="somesql">
   select a,b,c from tbl_name where d = ?
</select>

The placeholder value for d is supposed to be a constant declared in a file called Constants.java as:

public static final String d = "d_value";

How do I replace the placeholder with the value without actually passing a parameter in the <select> construct? I tried #{com.pkg.name.Constants.d} but it didn't work.

No hard coding!!!

2 Answers
Related