what I want is just like
我想要的就像
insert into #{tableName} (#{tableColumn1}, ...) values (#{value1}, ... )
in mapper.xml
if I but it went wrong even through I set
如果我,但即使通过我设置它也出错了
statementType="STATEMENT"
how can I make it ?
我该怎么做?
1 个解决方案
#1
1
Well I've get the key,
好吧,我得到了钥匙,
when using #{} it'll be "prepared" if you want use dynamic table name and table columns u need use ${}
当使用#{}时,如果你想使用动态表名和表列,它将被“准备好”你需要使用$ {}
e.g
INSERT INTO
${tableName}
<foreach collection="columns" item="column" open="(" close=")" separator=",">
${column}
</foreach>
VALUES
<foreach collection="values" item="value" open="(" close=")" separator=",">
'${value}'
</foreach>
If anyone have same question I hope it'll be useful!
如果有人有同样的问题,我希望它会有用!
#1
1
Well I've get the key,
好吧,我得到了钥匙,
when using #{} it'll be "prepared" if you want use dynamic table name and table columns u need use ${}
当使用#{}时,如果你想使用动态表名和表列,它将被“准备好”你需要使用$ {}
e.g
INSERT INTO
${tableName}
<foreach collection="columns" item="column" open="(" close=")" separator=",">
${column}
</foreach>
VALUES
<foreach collection="values" item="value" open="(" close=")" separator=",">
'${value}'
</foreach>
If anyone have same question I hope it'll be useful!
如果有人有同样的问题,我希望它会有用!