views:

56

answers:

0

Hey StackOverflow,

could please anybody help me out with an example of batch update of an array of strings into one column ? This is an example of batch update of an array of objects having getters

public int[] batchUpdate(final List<Actor> actors) {
        SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(actors.toArray());
        int[] updateCounts = simpleJdbcTemplate.batchUpdate(
            "update t_actor set first_name = :firstName, last_name = :lastName where id = :id",
            batch);
        return updateCounts;
    }

And this is what I'd like to do, or something better:

public int[] batchUpdate(String[] ArrayOfStrings) {
    SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(ArrayOfStrings);
            int[] updateCounts = sjt.batchUpdate(
                "update t_actor set first_name = ? ", batch);
            return updateCounts;
        }

There is also a createBatch(Map[] maps) method accepting maps of "parameters and values" which I can't think of how they mean it ...

ANSWER: My apologies, I found out that there's no way how to update all values in a column without looping all rows...I though spring could do that...