Hi Sulaiman, Thank you very much for your message.
Currently, there is no way for a batch store operation to implement the INSERT .. ON DUPLICATE KEY UPDATE or MERGE semantics that you intend for it to do. Batch store is simply a batch version of the ordinary UpdatableRecord.store() operation, which makes the decision whether to INSERT or UPDATE the record in the client, not the server. I suggest you actually run a set based INSERT .. ON DUPLICATE KEY UPDATE statement, or a MERGE statement instead. I hope this helps, Lukas 2017-09-14 11:21 GMT+02:00 Sulaiman Malik <[email protected]>: > I am trying to insert the records using batchStore using jooq. I need to > know how we can update the record on unique constraint, currently it is > throwing > an exception that the record already exists > > SQL Error [23505]: ERROR: duplicate key value violates unique > constraint > > Below is the code > > DSLContext create = getDSLContext(); > List<UserRecord> userRecordList = new ArrayList<>(); > for (Users user : model.getUsers()) { > User record = create.newRecord(user); > userRecordList.add(record); > } > create.batchStore(userRecordList).execute(); > > Currently it is inserting the records fine, but when duplicate record > found on the basis of unique constraint it should update the record > > -- > You received this message because you are subscribed to the Google Groups > "jOOQ User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
