public class UpdateMapperTemplate extends AbstractMapperTemplate
xmlLanguageDriver| Constructor and Description |
|---|
UpdateMapperTemplate() |
| Modifier and Type | Method and Description |
|---|---|
String |
updateByCondition(TableInfo tableInfo,
org.apache.ibatis.mapping.MappedStatement ms)
更新记录,生成 update 语句。
|
String |
updateByPrimaryKey(TableInfo tableInfo,
org.apache.ibatis.mapping.MappedStatement ms)
更新记录,生成 update 语句。
|
String |
updateByPrimaryKeyAllColumn(TableInfo tableInfo,
org.apache.ibatis.mapping.MappedStatement ms)
更新记录,生成 update 语句。
|
String |
updateUseMapByCondition(TableInfo tableInfo,
org.apache.ibatis.mapping.MappedStatement ms)
更新记录,生成 update 语句。
|
dynamicSql, getNodeContent, getWhereExtraConditionpublic String updateByPrimaryKey(TableInfo tableInfo, org.apache.ibatis.mapping.MappedStatement ms)
示例如下:
UPDATE table_name
<set>
<if test="id != null">
id = #{id},
</if>
</set>
<where>
AND id = #{id}
AND is_deleted = 'N'
</where>
tableInfo - 数据库表结构信息ms - sql语句节点信息,会将生成的sql语句替换掉原有的 MappedStatement.sqlSourceUpdateByPrimaryKeyMapper.updateByPrimaryKey(Object)public String updateByPrimaryKeyAllColumn(TableInfo tableInfo, org.apache.ibatis.mapping.MappedStatement ms)
示例如下:
UPDATE table_name
<set>
name = #{name},
</set>
<where>
AND id = #{id}
AND is_deleted = 'N'
</where>
tableInfo - 数据库表结构信息ms - sql语句节点信息,会将生成的sql语句替换掉原有的 MappedStatement.sqlSourceUpdateByPrimaryKeyAllColumnMapper.updateByPrimaryKeyAllColumn(Object)public String updateByCondition(TableInfo tableInfo, org.apache.ibatis.mapping.MappedStatement ms)
示例如下:
UPDATE table_name
<set>
<if test="record.name != null">
name = #{record.name},
</if>
</set>
<where>
<if test="condition.id != null">
and id = #{condition.id}
</if>
AND is_deleted = 'N'
</where>
tableInfo - 数据库表结构信息ms - sql语句节点信息,会将生成的sql语句替换掉原有的 MappedStatement.sqlSourceUpdateByConditionMapper.updateByCondition(Object, Object)public String updateUseMapByCondition(TableInfo tableInfo, org.apache.ibatis.mapping.MappedStatement ms)
示例如下:
UPDATE table_name
<set>
<foreach collection="record.keys" item="k" separator=",">
${k} = #{record[${k}]}
</foreach>
</set>
<where>
<if test="condition.id != null">
and id = #{condition.id}
</if>
AND is_deleted = 'N'
</where>
tableInfo - 数据库表结构信息ms - sql语句节点信息,会将生成的sql语句替换掉原有的 MappedStatement.sqlSourceUpdateUseMapByConditionMapper.updateUseMapByCondition(Map, Object)Copyright © 2018–2021. All rights reserved.