select:
#### String Substitution
```
~~~
@Select("select * from user where id = #{id}")
User findById(@Param("id") long id);
@Select("select * from user where name = #{name}")
User findByName(@Param("name") String name);
@Select("select * from user where email = #{email}")
User findByEmail(@Param("email") String email);
// and more "findByXxx" method
~~~
```
you can just write:
~~~
@Select("select * from user where ${column} = #{value}")
User findByColumn(@Param("column") String column, @Param("value") String value);
~~~
in which the${column}will be substituted directly and the#{value}will be "prepared". Thus you can just do the same work by:
~~~
User userOfId1 = userMapper.findByColumn("id", 1L);
User userOfNameKid = userMapper.findByColumn("name", "kid");
User userOfEmail = userMapper.findByColumn("email", "noone@nowhere.com");
~~~
String Substitution also work in partial match:
```
<select id="selectDept4" resultType="hashmap">
select * from Dept where dname like "%"#{value}"%"
</select>
<select id="selectDept4" resultType="hashmap">
select * from Dept where dname like "%${value}%"
</select>
```
insert:
mapper xml:
```
<insert id="insertDept">
insert into Dept values (#{deptno},#{dname},#{loc})
</insert>
<insert id="insertDept2">
insert into Dept values (#{deptno},#{dname},#{loc})
</insert>
```
interfaces:
```
public void insertDept(@Param("deptno")int deptno,@Param("dname")String dname, @Param("loc")String loc);
//we can map object as well, and in mapper xml, use #{property}
public void insertDept2(Dept d);
```
deptno is auto-incremented
```
<insert id="insertDept3">
insert into Dept
values (null,#{dname},#{loc})
</insert>
<insert id="insertDept3">
insert into Dept (dname, loc)
values (#{dname},#{loc})
</insert>
<insert id="insertDept3" useGeneratedKeys="true"
keyProperty="deptno">
insert into Dept (dname, loc)
values (#{dname},#{loc})
</insert>
<insert id="insertDept4">
<selectKey keyProperty="deptno" resultType="int" order="BEFORE">
select rand()*1000000
</selectKey>
insert into Dept values (#{deptno},#{dname},#{loc})
</insert>
```