File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
docs/sources/query-builder Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1515どのクエリビルダも、インスタンスは ``Config `` 型の引数をとる
1616``static `` な ``newInstance `` メソッドで生成できます。
1717インスタンスには、 ``sql `` メソッドでSQL文字列の断片を、
18- ``param `` メソッドでパラメータの型とパラメータを渡せます。
18+ ``param `` メソッドと ``literal `` メソッドでパラメータの型とパラメータを渡せます。
19+
20+ ``param `` メソッドで渡されたパラメータは ``PreparedStatement `` のバインド変数として扱われます。
21+
22+ ``literal `` メソッドで渡されたパラメータはSQLにリテラルとして埋め込まれます。
23+ このメソッドでパラメータが渡された場合、SQLインジェクション対策としてのエスケープ処理は実施されません。
24+ しかし、SQLインジェクションを防ぐためにパラメータの値にシングルクォテーションを含めることは禁止しています。
1925
2026検索
2127====
3339 builder. sql(" salary" );
3440 builder. sql(" from Emp" );
3541 builder. sql(" where" );
42+ builder. sql(" job_type = " ). literal(String . class, " fulltime" );
43+ builder. sql(" and" );
3644 builder. sql(" name like " ). param(String . class, " S%" );
3745 builder. sql(" and" );
3846 builder. sql(" age > " ). param(int . class, 20 );
You can’t perform that action at this time.
0 commit comments