[#3252] Relax bounds on <R> for DSLContext.batchInsert()

This commit is contained in:
Lukas Eder 2014-05-07 18:24:51 +02:00
parent 3cf66dd99d
commit 191f3f5597
3 changed files with 16 additions and 15 deletions

View File

@ -4666,7 +4666,7 @@ public interface DSLContext {
* @see Statement#executeBatch()
*/
@Support
Batch batchInsert(UpdatableRecord<?>... records);
Batch batchInsert(TableRecord<?>... records);
/**
* Execute a set of <code>INSERT</code> queries in batch mode (with bind
@ -4676,7 +4676,7 @@ public interface DSLContext {
* @see Statement#executeBatch()
*/
@Support
Batch batchInsert(Collection<? extends UpdatableRecord<?>> records);
Batch batchInsert(Collection<? extends TableRecord<?>> records);
/**
* Execute a set of <code>UPDATE</code> queries in batch mode (with bind

View File

@ -55,6 +55,7 @@ import org.jooq.Configuration;
import org.jooq.DSLContext;
import org.jooq.ExecuteContext;
import org.jooq.Query;
import org.jooq.TableRecord;
import org.jooq.UpdatableRecord;
import org.jooq.exception.ControlFlowSignal;
import org.jooq.exception.DataAccessException;
@ -67,14 +68,14 @@ class BatchCRUD implements Batch {
/**
* Generated UID
*/
private static final long serialVersionUID = -2935544935267715011L;
private static final long serialVersionUID = -2935544935267715011L;
private final DSLContext create;
private final Configuration configuration;
private final UpdatableRecord<?>[] records;
private final Action action;
private final DSLContext create;
private final Configuration configuration;
private final TableRecord<?>[] records;
private final Action action;
BatchCRUD(Configuration configuration, Action action, UpdatableRecord<?>[] records) {
BatchCRUD(Configuration configuration, Action action, TableRecord<?>[] records) {
this.create = DSL.using(configuration);
this.configuration = configuration;
this.action = action;
@ -206,16 +207,16 @@ class BatchCRUD implements Batch {
private void executeAction(int i) {
switch (action) {
case STORE:
records[i].store();
((UpdatableRecord<?>) records[i]).store();
break;
case INSERT:
records[i].insert();
break;
case UPDATE:
records[i].update();
((UpdatableRecord<?>) records[i]).update();
break;
case DELETE:
records[i].delete();
((UpdatableRecord<?>) records[i]).delete();
break;
}
}
@ -224,7 +225,7 @@ class BatchCRUD implements Batch {
// 1. Deleted records should be marked as changed, such that subsequent
// calls to store() will insert them again
// 2. Stored records should be marked as unchanged
for (UpdatableRecord<?> record : records) {
for (TableRecord<?> record : records) {
record.changed(action == Action.DELETE);
}
}

View File

@ -1524,13 +1524,13 @@ public class DefaultDSLContext implements DSLContext, Serializable {
}
@Override
public Batch batchInsert(UpdatableRecord<?>... records) {
public Batch batchInsert(TableRecord<?>... records) {
return new BatchCRUD(configuration, Action.INSERT, records);
}
@Override
public Batch batchInsert(Collection<? extends UpdatableRecord<?>> records) {
return batchInsert(records.toArray(new UpdatableRecord[records.size()]));
public Batch batchInsert(Collection<? extends TableRecord<?>> records) {
return batchInsert(records.toArray(new TableRecord[records.size()]));
}
@Override