[jOOQ/jOOQ#10046] Add DSLContext.batchMerge()

This commit is contained in:
Lukas Eder 2020-04-06 14:23:11 +02:00
parent 2c430c57e3
commit 1c1da86f76
3 changed files with 45 additions and 5 deletions

View File

@ -8438,6 +8438,28 @@ public interface DSLContext extends Scope , AutoCloseable {
@Support
Batch batchUpdate(Collection<? extends UpdatableRecord<?>> records);
/**
* Create a batch statement to execute a set of <code>MERGE</code> queries
* in batch mode (with bind values) according to
* {@link UpdatableRecord#merge()} semantics.
*
* @see UpdatableRecord#merge()
* @see java.sql.Statement#executeBatch()
*/
@Support
Batch batchMerge(UpdatableRecord<?>... records);
/**
* Create a batch statement to execute a set of <code>MERGE</code> queries
* in batch mode (with bind values) according to
* {@link UpdatableRecord#merge()} semantics.
*
* @see UpdatableRecord#merge()
* @see java.sql.Statement#executeBatch()
*/
@Support
Batch batchMerge(Collection<? extends UpdatableRecord<?>> records);
/**
* Create a batch statement to execute a set of <code>DELETE</code> queries
* in batch mode (with bind values) according to

View File

@ -202,6 +202,9 @@ final class BatchCRUD extends AbstractBatch {
case UPDATE:
((UpdatableRecord<?>) records[i]).update();
break;
case MERGE:
((UpdatableRecord<?>) records[i]).merge();
break;
case DELETE:
((UpdatableRecord<?>) records[i]).delete();
break;
@ -223,27 +226,32 @@ final class BatchCRUD extends AbstractBatch {
}
/**
* The action to be performed by this operation
* The action to be performed by this operation.
*/
enum Action {
/**
* Corresponds to {@link UpdatableRecord#store()}
* Corresponds to {@link UpdatableRecord#store()}.
*/
STORE,
/**
* Corresponds to {@link UpdatableRecord#insert()}
* Corresponds to {@link UpdatableRecord#insert()}.
*/
INSERT,
/**
* Corresponds to {@link UpdatableRecord#update()}
* Corresponds to {@link UpdatableRecord#update()}.
*/
UPDATE,
/**
* Corresponds to {@link UpdatableRecord#delete()}
* Corresponds to {@link UpdatableRecord#merge()}.
*/
MERGE,
/**
* Corresponds to {@link UpdatableRecord#delete()}.
*/
DELETE
}

View File

@ -2893,6 +2893,16 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return batchUpdate(records.toArray(EMPTY_UPDATABLE_RECORD));
}
@Override
public Batch batchMerge(UpdatableRecord<?>... records) {
return new BatchCRUD(configuration(), Action.MERGE, records);
}
@Override
public Batch batchMerge(Collection<? extends UpdatableRecord<?>> records) {
return batchMerge(records.toArray(EMPTY_UPDATABLE_RECORD));
}
@Override
public Batch batchDelete(UpdatableRecord<?>... records) {
return new BatchCRUD(configuration(), Action.DELETE, records);