@Override public Contact mapRow(ResultSet rs, int rowNum) throws SQLException { return new Contact( rs.getLong("id"), rs.getString("firstname"), rs.getString("lastname"), rs.getDate("birth") ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { jdbcTemplate.update( "insert into contact (firstname,lastname,birth) values (?,?,?)", item.getFirstname(),item.getLastname(),item.getBirth() ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { jdbcTemplate.update( "insert into contact (id,firstname,lastname,birth,ssn) values (?,?,?,?,?)", item.getId(),item.getFirstname(),item.getLastname(),item.getBirth(),item.getSsn() ); } }
@Override public Contact process(Contact item) throws Exception { DOMSource source = restTemplate.getForObject(url, DOMSource.class, item.getFirstname(),item.getLastname()); String ssn = extractSsnFromXml(item, source); item.setSsn(ssn); return item; }
@Override public void write(List<? extends RegistrationConfirmation> items) throws Exception { // TODO 03 take a look at the writer: it inserts the confirmations inside the database for(RegistrationConfirmation item : items) { jdbcTemplate.update( "insert into registration_confirmation (number,contact_id,accepted) values (?,?,?)", item.getNumber(),item.getContact().getId(),item.isAccepted() ); } }
@Override public void write(List<? extends RegistrationConfirmation> items) throws Exception { for(RegistrationConfirmation item : items) { jdbcTemplate.update( "insert into registration_confirmation (number,contact_id,accepted) values (?,?,?)", item.getNumber(),item.getContact().getId(),item.isAccepted() ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { jdbcTemplate.update( "insert into contact (firstname,lastname,birth) values (?,?,?)", item.getFirstname(),item.getLastname(),item.getBirth() ); } }
@Override public Contact mapRow(ResultSet rs, int rowNum) throws SQLException { // TODO 02 take a look at the ContactRowMapper // it implements the logic to convert the JDBC ResultSet into a domain object // the item reader will use it return new Contact( rs.getLong("id"), rs.getString("firstname"), rs.getString("lastname"), rs.getDate("birth") ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { jdbcTemplate.update( "insert into contact (id,firstname,lastname,birth,ssn) values (?,?,?,?,?)", item.getId(),item.getFirstname(),item.getLastname(),item.getBirth(),item.getSsn() ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { jdbcTemplate.update( "insert into contact (firstname,lastname,birth) values (?,?,?)", item.getFirstname(),item.getLastname(),item.getBirth() ); } }
@Override public Contact mapFieldSet(FieldSet fieldSet) throws BindException { return new Contact( fieldSet.readString("firstname"), fieldSet.readString("lastname"), fieldSet.readDate("birth","yyyy-MM-dd") ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { jdbcTemplate.update( "insert into contact (firstname,lastname,birth) values (?,?,?)", item.getFirstname(),item.getLastname(),item.getBirth() ); } }
@Override public Contact mapFieldSet(FieldSet fieldSet) throws BindException { return new Contact( fieldSet.readString("firstname"), fieldSet.readString("lastname"), fieldSet.readDate("birth","yyyy-MM-dd") ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { Long id = jdbcTemplate.queryForObject("select contact_seq.nextval from dual",Long.class).longValue(); jdbcTemplate.update( "insert into contact (id,firstname,lastname,birth) values (?,?,?,?)", id,item.getFirstname(),item.getLastname(),item.getBirth() ); } }
@Override public Contact mapFieldSet(FieldSet fieldSet) throws BindException { return new Contact( fieldSet.readString("firstname"), fieldSet.readString("lastname"), fieldSet.readDate("birth","yyyy-MM-dd") ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { Long id = jdbcTemplate.queryForObject("select contact_seq.nextval from dual",Long.class).longValue(); jdbcTemplate.update( "insert into contact (id,firstname,lastname,birth) values (?,?,?,?)", id,item.getFirstname(),item.getLastname(),item.getBirth() ); } }
@Override public Contact mapFieldSet(FieldSet fieldSet) throws BindException { return new Contact( fieldSet.readString("firstname"), fieldSet.readString("lastname"), fieldSet.readDate("birth","yyyy-MM-dd") ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { Long id = jdbcTemplate.queryForObject("select contact_seq.nextval from dual",Long.class).longValue(); jdbcTemplate.update( "insert into contact (id,firstname,lastname,birth) values (?,?,?,?)", id,item.getFirstname(),item.getLastname(),item.getBirth() ); } }
@Override public Contact mapFieldSet(FieldSet fieldSet) throws BindException { return new Contact( fieldSet.readString("firstname"), fieldSet.readString("lastname"), fieldSet.readDate("birth","yyyy-MM-dd") ); } }
@Override public void write(List<? extends Contact> items) throws Exception { for(Contact item : items) { Long id = jdbcTemplate.queryForObject("select contact_seq.nextval from dual",Long.class).longValue(); jdbcTemplate.update( "insert into contact (id,firstname,lastname,birth) values (?,?,?,?)", id,item.getFirstname(),item.getLastname(),item.getBirth() ); } }