<insert id="insertStockOrderAbusingList" parameterType="java.util.List"> INSERT IGNORE INTO iruda_trade.stock_order_abusing ( market_day, uid, stock_account_id, order_number, symbol, conclusion_quantity, order_type, created_at ) VALUES <foreach collection="list" item="item" index="index" separator=","> ( #{item.transactionDate}, #{item.uid}, #{item.stockAccountId}, #{item.transactionNumber}, #{item.symbol}, #{item.filledVolume}, #{item.transactionType}, #{item.clientTimeStamp} ) </foreach> </insert>
I'm trying to insert data into mySQL DB. If the transactionDate, transactionNumber and uid in the parameters are also the same as the market_day, order_number, uid in the stock_order_abusing table column, then there will be no insertion or the insertion should be ignored. There is no pk (primary key) to compare. All methods in Google tell me that there should be primary key to prevent duplicate insertion. Is there any way to solve this problem?
If you want to take no action when duplicate records exist, you can use the INSERT IGNORE syntax.
Here is the complete grammar guide