private Vehicle update(Vehicle vehicle) { template.update( "UPDATE vehicles SET manufacturer = ?, model = ? WHERE id = ?", vehicle.getManufacturer(), vehicle.getModel(), vehicle.getId()); return vehicle; }
private Vehicle insert(Vehicle vehicle) { SimpleJdbcInsert insert = new SimpleJdbcInsert(template).withTableName("vehicles").usingGeneratedKeyColumns("id"); SqlParameterSource parameters = new MapSqlParameterSource() .addValue("manufacturer", vehicle.getManufacturer()) .addValue("model", vehicle.getModel()); Number id = insert.executeAndReturnKey(parameters); vehicle.setId(id.intValue()); return vehicle; }