Home > Database > Mysql Tutorial > body text

mysql-mybatis 执行 INSERT … ON DUPLICATE KEY UPDATE

WBOY
Release: 2016-06-06 09:42:06
Original
3112 people have browsed it

mybatismysql

mybatis 在执行 INSERT … ON DUPLICATE KEY UPDATE 格式的语句的时候
没有报错,库表也没插入数据,数据库是mysql
用mysql客户端执行这条语句的时候却是能插入的
是因为myBatis不支持吗?
语句示例:
INSERT INTO test
(main_id,score,totalCount)
VALUES
(123,5.0,12345)
ON DUPLICATE KEY UPDATE
score=VALUES(score),
totalCount=VALUES(totalCount)
main_id是主键,以上语在mysql客户端执行能正确插入或更新

<code><insert id="insertOrUpdate" parametertype="这里就不写了">    INSERT INTO test    (main_id,score,totalCount)    VALUES    (456,5.0,12345) <!--这里有个参数是456,同上面一条的123不一样-->    ON DUPLICATE KEY UPDATE    score=VALUES(score),    totalCount=VALUES(totalCount)</insert></code>
Copy after login

这是mybatis里面执行的语句,为了直观些,我直接写了一条死语句进来。
同样的两条语句,在mybatis里面执行的时候也不报错,但是数据库却插不进去,也不能更新

求解!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template