this.jdbcTemplate.update("delete from t_actor where id = ?",actorId);
改
@OverridepublicintupdateAccount(Account account){int result = jdbcTemplate.update("update account set balance=balance+? where accountid=?", account.getBalance(), account.getAccountid());return result;}
查
1.查寻出一条结果,并将结果保存到表对应类中
@OverridepublicAccountfindAccount(Integer accountid){Account account =this.jdbcTemplate.queryForObject("select * from account where accountid="+ accountid,(rs, rowNum)->{Account newAccount =newAccount();
newAccount.setAccountid(rs.getInt(1));
newAccount.setBalance(rs.getDouble(2));return newAccount;});return(Account) account;}------------------------------------------------2.查寻出多条结果,并将结果保存到表对应类中
publicList<OpRecord>findOpRecord(Integer accountid){List<OpRecord> list =this.jdbcTemplate.query("select * from oprecord where accountid="+ accountid,(rs, rowNum)->{//将查询返回的结果设置到OpRecord类中OpRecord opRecord =newOpRecord();
opRecord.setId(rs.getInt(1));
opRecord.setAccountid(rs.getInt(2));
opRecord.setOpmoney(rs.getDouble(3));
opRecord.setOptime(rs.getString(4));return opRecord;});return list;}