Created
February 13, 2012 08:45
-
-
Save krams915/1815111 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.krams.batch; | |
import java.util.List; | |
import org.krams.domain.User; | |
import org.springframework.batch.item.ItemWriter; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.jdbc.core.JdbcTemplate; | |
public class UserItemWriter implements ItemWriter<User> { | |
@Autowired | |
private JdbcTemplate jdbcTemplate; | |
public static final String INSERT_QUERY = "insert into user(firstName, " + | |
"lastName, " + | |
"password, " + | |
"username) " + | |
"values(?,?,?,?);"; | |
@Override | |
public void write(List<? extends User> users) throws Exception { | |
for (User user : users) { | |
jdbcTemplate.update(INSERT_QUERY, user.getFirstName(), user.getLastName(), user.getPassword(), user.getUsername()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment