示例#1
0
 @Transactional
 public void storePet(Pet pet) throws DataAccessException {
   if (pet.isNew()) {
     Number newKey = this.insertPet.executeAndReturnKey(createPetParameterSource(pet));
     pet.setId(newKey.intValue());
   } else {
     this.simpleJdbcTemplate.update(
         "UPDATE pets SET name=:name, birth_date=:birth_date, type_id=:type_id, "
             + "owner_id=:owner_id WHERE id=:id",
         createPetParameterSource(pet));
   }
 }