Announcement Announcement Module
Collapse
No announcement yet.
Possible error in "13.4.3 Batch operations with multiple batches" documentation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible error in "13.4.3 Batch operations with multiple batches" documentation

    Hello Guys

    In the section:

    13.4.2 Batch operations with a List of objects

    Has its example (showing a part)

    Code:
    public int[] batchUpdate(final List<Actor> actors) {
            List<Object[]> batch = new ArrayList<Object[]>();
            for (Actor actor : actors) {
                Object[] values = new Object[] {
                        actor.getFirstName(),
                        actor.getLastName(),
                        actor.getId()};
                batch.add(values);
            }
            int[] updateCounts = jdbcTemplate.batchUpdate(
                    "update t_actor set first_name = ?, last_name = ? where id = ?",
                    batch);
            return updateCounts;
        }
    we can see clearly that the batch variable is used

    Now, for the section
    13.4.3 Batch operations with multiple batches

    Has its example (showing a part)

    Code:
    public int[][] batchUpdate(final Collection<Actor> actors) {
            Collection<Object[]> batch = new ArrayList<Object[]>();
            for (Actor actor : actors) {
                Object[] values = new Object[] {
                        actor.getFirstName(),
                        actor.getLastName(),
                        actor.getId()};
                batch.add(values);
            }
            int[][] updateCounts = jdbcTemplate.batchUpdate(
                    "update t_actor set first_name = ?, last_name = ? where id = ?",
                    actors,
                    100,
                    new ParameterizedPreparedStatementSetter<Actor>() {
                        public void setValues(PreparedStatement ps, Actor argument) throws SQLException {
                            ps.setString(1, argument.getFirstName());
                            ps.setString(2, argument.getLastName());
                            ps.setLong(3, argument.getId().longValue());
     
                         }
                     } );
            return updateCounts;
        }
    Where is used the batch variable?. I am with the impression that the jdbcTemplate.batchUpdate is not well declared

    If I am right, I will arise a JIRA issue

  • #2
    I am with the impression that the jdbcTemplate.batchUpdate is not well declared
    It is declared properly... The batch property/for loop has to be removed (also this has been brought up before).

    Comment


    • #3
      Hi Marten

      The batch property/for loop has to be removed
      OK, agree.

      JIRA issue created

      Comment

      Working...
      X