'Why sql wrapped with script tag?
Source code from Mybatis Plus 1.1.
I can not understand that why some sql statements wrapped with a script tag.
Why use the script tag? And what's the function of the script tag?
public enum SqlMethod {
/**
* 插入
*/
INSERT_ONE("insert", "插入一条数据", "<script>INSERT INTO %s %s VALUES %s</script>"),
INSERT_BATCH("insertBatch", "批量插入数据", "<script>INSERT INTO %s %s VALUES \n<foreach item=\"item\" index=\"index\" collection=\"list\" separator=\",\">%s\n</foreach></script>"),
/**
* 删除
*/
DELETE_ONE("deleteById", "根据ID 删除一条数据", "DELETE FROM %s WHERE %s=#{%s}"),
DELETE_BATCH("deleteBatchIds", "根据ID集合,批量删除数据", "<script>DELETE FROM %s WHERE %s IN (%s)</script>"),
/**
* 修改
*/
UPDATE_ONE("updateById", "根据ID 修改数据", "<script>UPDATE %s %s</script>"),
/**
* 查询
*/
SELECT_ONE("selectById", "根据ID 查询一条数据", "SELECT * FROM %s WHERE %s=#{%s}"),
SELECT_BATCH("selectBatchIds", "根据ID集合,批量查询数据", "<script>SELECT * FROM %s WHERE %s IN (%s)</script>"),
SELECT_ALL("selectAll", "查询满足条件所有数据", "SELECT * FROM %s");
private final String method;
private final String desc;
private final String sql;
// ... constructor and getter
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
