java - How to modify mybatis if it exists in the database, and add if it does not exist
给我你的怀抱
给我你的怀抱 2017-05-17 10:04:15
0
3
579

I want to implement an insertion function. Before inserting, it is judged whether there is the same data as the key field in the database. If so, perform the modification operation. If not, perform the insert operation. I would like to ask for advice: Is there any way to do it? You can query and judge by yourself, can you complete the whole process by calling directly? Is there a similar method in mybatis?

给我你的怀抱
给我你的怀抱

reply all(3)
过去多啦不再A梦

There is on duplicate key update in mysql, just create a unique index for the key field

黄舟

mybatis应该没有这样的条件控制, 只能看数据库有没有类似的条件控制, 如果是oracle可以用merge into using (subquery) on (condition) when matched then update (update statement) when not matched then insert (insert statement)

刘奇

Can I use mysql’s replace into?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template