I'm currently working on a batch import feature that sits on top of Hibernate and MySQL. My goal is to have Upsert functionality for several tables. I'm finding myself writing a lot of code to deal with seeing if the row exists by key and branching to right method. I was wondering if there might be a better way, i.e. something analogous to the tools that开发者_运维技巧 come with SQL-Server SSIS but for Hibernate and MySQL. What tools or elegant solutions have you used to handle bulk Upserts with hibernate and/or MySQL?
You might look into MySQL's ON DUPLICATE KEY UPDATE feature:
https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html
精彩评论