mybatis-plush存在则更新
示例:
@Insert(“INSERT INTO 数据库名字
.表名
( id
, name
, setup
, cut_before
, cut_after
, bar
, type
, cutter
, perrow
, offsetx
, offsety
, offset2x
, offset2y
, offset3x
, offset3y
) " +
" VALUES ( #{bartemplate.id}, #{bartemplate.name}, #{bartemplate.setup}, #{bartemplate.cutBefore},#{bartemplate.cutAfter}, #{bartemplate.bar}, #{bartemplate.type}, #{bartemplate.cutter}, #{bartemplate.perrow}, #{bartemplate.offsetx}, #{bartemplate.offsety}, #{bartemplate.offset2x}, #{bartemplate.offset2y}, #{bartemplate.offset3x}, #{bartemplate.offset3y}) " +
" on duplicate key update " +
“template_setup = values(setup),cut_before = values(cut_before),cut_after = values(cut_after),” +
" templatebar = values(templatebar),type = values(type),enable_cutter = values(cutter),” +
“perrow = values(perrow),offsetx = values(offsetx),offsety = values(offsety),” +
“offset2x = values(offset2x),offset2y = values(offset2y),offset3x = values(offset3x),offset3y = values(offset3y)”)
int saveOrUpdate(@Param(“bartemplate”) AfOrganizeBartemplate bartemplate);
on duplicate key update 后面的是存在重复,违反了这个主键或者唯一键,那么就更新,以及更新的字段