packagecom.southwind.repository;importcom.southwind.entiry.User;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.jdbc.core.BeanPropertyRowMapper;importorg.springframework.jdbc.core.JdbcTemplate;importorg.springframework.stereotype.Repository;importjava.util.List;@RepositorypublicclassUserRepositoryImplimplementsUserRepository{@AutowiredprivateJdbcTemplate jdbcTemplate;@OverridepublicList<User>findAll(){return jdbcTemplate.query("select * from user",newBeanPropertyRowMapper<>(User.class));}@OverridepublicUserfindById(long id){return jdbcTemplate.queryForObject("select * from user where id = ?",newBeanPropertyRowMapper<>(User.class),id);}@Overridepublicvoidsave(User user){
jdbcTemplate.update("insert into user (id,name,score) values(?,?,?)",user.getId(),user.getName(),user.getScore());}@Overridepublicvoidupdate(User user){
jdbcTemplate.update("update user set name = ?,score=? where id=?",user.getName(),user.getScore(),user.getId());}@OverridepublicvoiddeleteById(long id){
jdbcTemplate.update("delete from user where id = ?",id);}}