SQL injection

The plugin injects SQL language into various elements automatically which makes it easier to edit SQL. Injected SQL becomes much more powerful when integrated with Parameter Language. You can find more details about language injection here.

SQL dialect

Some features are available as soon as SQL dialect is configured, so you'd better configure the SQL dialect for your project. You can find more details about how to configure SQL dialect here.

Elements with SQL injected

  • Mapper XML
    • Text content of insert tag
    • Text content of update tag
    • Text content of delete tag
    • Text content of select tag
    • Text content of sql tag
  • Annotation
    • Value of org.apache.ibatis.annotations.Insert
    • Value of org.apache.ibatis.annotations.Update
    • Value of org.apache.ibatis.annotations.Delete
    • Value of org.apache.ibatis.annotations.Select
    • Value of org.apache.ibatis.annotations.Select
    • Value of org.apache.ibatis.annotations.SelectKey

SQL in annotation

You can write SQL in a annotation (e.g., @Insert) using a single string or using an array of strings. The plugin takes care of your choice. You can find more details at Annotation Folding.

SQL in mapper XML

When you extract a duplicated SQL segment into sql tag, for instance:

<sql id="count">

<select id="countAdmin" resultType="int">
  SELECT <include refid="count"/> FROM admin

<select id="countProject" resultType="int">
  SELECT <include refid="count"/> FROM project

There is an inspection error at count(*) saying that "<statement> or DELIMITER expected, got 'count'", that's because of count(*) is not a legal SQL statement itself. You can get rid of this error by following File → Settings → Language Injections → iBatis3 and remove sql from local name field:

remove sql local name

SQL will not be injected for sql tag automatically anymore after you do this. This is a solution to solve the issue mentioned above but it's not suggested to do so because it's not uncommon to write a legal SQL statement in sql tag, you will completely lose the opportunity to check your SQL syntax in sql tag.

Codes Magic © 2013-2018 · Terms