Guest User

Untitled

a guest
Feb 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public Actor findActor(long id) {
  2. String sql = "select id, first_name, last_name from T_ACTOR where id = ?";
  3.  
  4. ParameterizedRowMapper<Actor> mapper = new ParameterizedRowMapper<Actor>() {
  5.  
  6. // notice the return type with respect to Java 5 covariant return types
  7. public Actor mapRow(ResultSet rs, int rowNum) throws SQLException {
  8. Actor actor = new Actor();
  9. actor.setId(rs.getLong("id"));
  10. actor.setFirstName(rs.getString("first_name"));
  11. actor.setLastName(rs.getString("last_name"));
  12. return actor;
  13. }
  14. };
  15.  
  16. return this.simpleJdbcTemplate.queryForObject(sql, mapper, id);
  17. }
Add Comment
Please, Sign In to add comment