[Demonstration 1]

[Buggy Method]
public Orchard save(JSONObject json) {
    Orchard orchard = new Orchard();
    try {
        orchard.setId(json.getLong("id"));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setYardName(json.getString("yardName"));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setStatus(json.getString("status"));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setMaxHives(json.getInt("maxHives"));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setOwner(ownerService.findOne(json.getLong("owner")));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setRentReceiver(personService.findOne(json.getLong("rentReceiver")));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setLatitude(json.getDouble("latitude"));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setLongitude(json.getDouble("longitude"));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setRegion(regionService.findByName(json.getString("region")));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setCombo(json.getString("combo"));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setAccessNotes(json.getString("accessNotes"));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    try {
        orchard.setAddress(addressService.save(json.getJSONObject("address")));
    } catch (JSONException je) {
        System.err.println(je.getMessage());
    }
    return save(orchard);
}

[Buggy Hunk]
orchard.setId(json.getLong("id"));

[Patch]
orchard = orchardRepository.findOne(json.getLong("id"));

[Demonstration 2]

[Buggy Method]
private void addCustomer(String strId, String name, String address, String phoneNum, String email) {
    // attempt to parse customer id integer from string
    int customerId = 0;
    boolean gotId = false;
    try {
        customerId = Integer.parseInt(strId);
        gotId = true;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "The customer id field must not contain any non numeric characters", "Invalid content", JOptionPane.ERROR_MESSAGE);
    }
    if (gotId) {
        // If the customer was added with auto-increment id, increment id for next customer
        if (customerId == idCounter)
            idCounter++;
        database.addCustomer(new Customer(customerId, name, address, phoneNum, email));
        confirmCustomerAdded(strId, name, address, phoneNum, email);
    }
}

[Buggy Hunk]
private void addCustomer(String strId, String name, String address, String phoneNum, String email) {

[Patch]
public void addCustomer(String strId, String name, String address, String phoneNum, String email) {

[Demonstration 3]

[Buggy Method]
private ArrayList<Product> getProducts(ArrayList<Product> results, PreparedStatement ps) throws SQLException {
    try (ResultSet resultSet = ps.executeQuery()) {
        while (resultSet.next()) {
            Product product = new Product();
            product.setPid(resultSet.getLong("p_id"));
            product.setTitle(resultSet.getString("title"));
            product.setDescription(resultSet.getString("description"));
            product.setPrice(resultSet.getDouble("price"));
            product.setImage(resultSet.getString("image"));
            product.setSold(resultSet.getBoolean("is_sold"));
            product.setDate(resultSet.getDate("datetime"));
            product.setExpiry(resultSet.getDate("expiry"));
            product.setUserID(resultSet.getLong("u_id"));
            product.setCatID(resultSet.getLong("cat_id"));
            product.setBidID(resultSet.getLong("bid_id"));
            results.add(product);
        }
    }
    return results;
}

[Buggy Hunk]
product.setPrice(resultSet.getDouble("price"));

[Patch]
product.setPrice(resultSet.getBigDecimal("price"));