1 16 17 package org.springframework.jdbc.object; 18 19 import java.sql.ResultSet ; 20 import java.sql.SQLException ; 21 import java.util.Map ; 22 23 import javax.sql.DataSource ; 24 25 import org.springframework.jdbc.core.RowMapper; 26 27 38 public abstract class UpdatableSqlQuery extends SqlQuery { 39 40 43 public UpdatableSqlQuery() { 44 setUpdatableResults(true); 45 } 46 47 52 public UpdatableSqlQuery(DataSource ds, String sql) { 53 super(ds, sql); 54 setUpdatableResults(true); 55 } 56 57 61 protected RowMapper newRowMapper(Object [] parameters, Map context) { 62 return new RowMapperImpl(context); 63 } 64 65 80 protected abstract Object updateRow(ResultSet rs, int rowNum, Map context) throws SQLException ; 81 82 83 87 protected class RowMapperImpl implements RowMapper { 88 89 private final Map context; 90 91 public RowMapperImpl(Map context) { 92 this.context = context; 93 } 94 95 public Object mapRow(ResultSet rs, int rowNum) throws SQLException { 96 Object result = updateRow(rs, rowNum, this.context); 97 rs.updateRow(); 98 return result; 99 } 100 } 101 102 } 103 | Popular Tags |