Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<CrawlerTask> pushAll(
- Connection connection,
- Instant now,
- Provider provider,
- List<CrawlerTask> ts
- ) {
- Query q = connection.createQuery(
- "INSERT INTO crawler_task (\n" +
- " provider_id,\n" +
- " entity_type,\n" +
- " external_id,\n" +
- " status,\n" +
- " fire_time,\n" +
- " created_at,\n" +
- " updated_at\n" +
- ") VALUES (\n" +
- " :provider,\n" +
- " :entityType,\n" +
- " :externalId,\n" +
- " :status,\n" +
- " :fireTime,\n" +
- " :createdAt,\n" +
- " :updatedAt\n" +
- ") ON CONFLICT DO NOTHING;",
- true);
- ts.forEach(t -> {
- t.setProvider(provider);
- // t.setEntityType(); -- should be set by the caller
- // t.setExternalId(); -- should be set by the caller
- t.setStatus(CrawlerTaskStatus.New);
- t.setFireTime(now);
- t.setCreatedAt(now);
- t.setUpdatedAt(now);
- q.bind(t)
- .addToBatch();
- });
- Connection c = q.executeBatch();
- // int[] x = connection.getBatchResult();
- // Postgres does not support retrieving generated keys in batch mode.
- //
- return ts;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement