title: Jooq batch update with records in MySql
body: <p>What is the proper way to do batch updates with JOOQ?</p>
  
  <p>I have the following:</p>
  
  <pre><code>public void updateScores(Map&lt;String, Integer&gt; teamScores) {
      writeContext().transaction(config -&gt; {
          DSLContext dslContext = DSL.using(config);
          dslContext.batchUpdate(Maps.transformEntries(teamScores, (id, score) -&gt; {
              TeamScoresRecord record = new TeamScoresRecord();
              record.setTeamId(id);
              record.setScore(score);
              return record;
          }).values()).execute();
      });
  }
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>public void updateScores(Map&lt;String, Integer&gt; teamScores) {
      writeContext().transaction(config -&gt; {
          DSLContext dslContext = DSL.using(config);
          dslContext.batchUpdate(
                  dslContext.selectFrom(TEAM_SCORES)
                            .where(TEAM_SCORES.TEAM_ID.in(teamScores.keySet()))
                            .forUpdate()
                            .fetch()
                            .stream()
                            .peek(record -&gt; record.setScore(teamScores.get(record.getTeamId())))
                            .collect(Collectors.toList())
          ).execute();
      });
  }
  </code></pre>
  
  <p>Which of these is the recommended way to do batch updates?</p>