MBMyBatis Converter
MyBatis is the most widely used SQL mapper framework in the Java ecosystem. MyBatis queries contain parameter bindings like #{param} and ${param} along with dynamic tags like <if>, <where>, and <choose>, making it hard to run them directly in a DB client. This tool evaluates dynamic tags based on parameter values to produce executable SQL, and can also generate MyBatis XML mapper templates from plain SQL.
How to Use
- 1Select Tab
Use 'MyBatis โ SQL' to evaluate dynamic tags and replace parameters with actual values. Use 'SQL โ MyBatis XML' to convert plain SQL into MyBatis XML mapper format.
- 2Enter Query
Paste your MyBatis/iBatis query or plain SQL into the input area. #{param} is auto-detected as MyBatis 3 and #param# as iBatis 2.
- 3Set Parameters (MyBatis โ SQL)
Configure the type (string/number) and value for each detected parameter. Dynamic tag conditions are evaluated automatically โ blocks whose condition is not met are removed from the output.
- 4Review & Copy
Review the converted SQL or MyBatis XML and copy it to your clipboard.
Tips
- ๐กMyBatis 3 dynamic tags supported: <if test="x != null">, <where>, <set>, <choose>/<when>/<otherwise>, <trim>, <foreach>.
- ๐กiBatis 2 dynamic tags supported: <isNotEmpty>, <isEmpty>, <isNotNull>, <isNull>, <isEqual>, <isGreaterThan>, etc., and <dynamic prepend="WHERE">.
- ๐กFilling in a parameter value includes its condition block; leaving it empty removes the block. <![CDATA[...]]> wrappers are also stripped automatically.
- ๐ก#{param} uses PreparedStatement binding (values are quoted). ${param} is string substitution (inserted as-is).
- ๐กAll processing happens in your browser, so sensitive queries are never sent to a server.