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!!!
<select id="getConvenienceStoreList" resultType ="Store">
SELECT * FROM Store
WHERE type = ${@foo.product.constant.StoreType@CONVENIENCE_STORE}
ORDER BY id
LIMIT #{start}, #{limit}
</select>
Reference: http://qiita.com/ApplePedlar/items/12dc389cc32f3db5557a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With