Batch Insert with generated keys deals duplicate entry on unique

I am using MySql with JDBC...the below is my table definition

CREATE TABLE `A` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `type` varchar(255) NOT NULL,
  `value` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unq` (`type`(50),`value`(50))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

At the moment i am using statement in order to batch insert rows to that table with RETURN_GENERATED_KEYS option in order to relate the id to other table.

I want the ability to perform that operation but when / if DUPLICATE ENTRY occur ( the same combination of type & value ) to continue with the transaction as like nothing happens but still to get the generated keys, and if DUPLICATE ENTRY occur retrieve the existing key.

Thanks


ANSWERS:


use IGNORE keyword

INSET IGNORE ....

as Quoted in Mysql

If you use the IGNORE keyword, errors that occur while executing the INSERT statement are treated as warnings instead. For example, without IGNORE, a row that duplicates an existing UNIQUE index or PRIMARY KEY value in the table causes a duplicate-key error and the statement is aborted. With IGNORE, the row still is not inserted, but no error is issued.

alternative syntax

INSERT ... ON DUPLICATE KEY UPDATE



 MORE:


 ? JAX-WS - where are web service generated classes?
 ? Generate sequence of numbers prefix with an alphabet
 ? Getting Generated Always Columns list from DB2
 ? How to save values generated from Random.Next method C#
 ? Generate goo.gl short URL for current URL automaticlly
 ? How to check how many times one number appears in the second number?
 ? How to check how many times one number appears in the second number?
 ? How to check how many times one number appears in the second number?
 ? How to make the stock "DigitalClock" randomly appear on screen in different location every minute
 ? How would I place a random generated number in a form field?