1
私はApache Commons LangのStrSubstitutor
を使用して、プレフィックスのみを使用してマークされた文字列の変数を置き換えようとしています。 SQLクエリに:
というマーク付きの名前付きパラメータがあります。変数サフィックスが空のStrSubstitutorはどのように使用できますか?
私が使用しているコードスニペットは動作しません。
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.text.StrMatcher;
import org.apache.commons.lang3.text.StrSubstitutor;
Map<String,String> m = ImmutableMap.of("a", 1);
StrSubstitutor strSubstitutor = new StrSubstitutor(m)
.setVariablePrefix(":")
.setVariableSuffix("");
System.out.println(strSubstitutor.replace("select a from t where a = :a"));
// expect select a from t where a = 1
どうすればいいですか?
私はカスタムStrMatcher
を実装しようとしていますが、まだ失敗しています。 これまで誰も経験した経験がありますか?