private void delete(Connection conn, ResultSet oldRow, ResultSet ignored) throws SQLException {
        Jdbi jdbi = Jdbi.create(conn);
        Long apiVersionId = oldRow.getLong("api_version_id");
        String planId = oldRow.getString("plan_id");
        String planVersion = oldRow.getString("version");

        FlatApiVersionBeanView av = jdbi.withHandle(h -> h
                        .createQuery("select avb.* FROM api_versions avb WHERE avb.id = :id")
                        .bind("id", apiVersionId))
                .mapToBean(FlatApiVersionBeanView.class)
                .first();

        jdbi.withHandle(h -> h.createUpdate(
                        "DELETE FROM discoverability d "
                                + "WHERE d.api_id = :apiId "
                                + "AND d.org_id = :orgId "
                                + "AND d.api_version = :apiVersion "
                                + "AND d.plan_id = :planId "
                                + "AND d.plan_version = :planVersion "))
                .bind("orgId", av.getApiOrgId())
                .bind("apiId", av.getApiId())
                .bind("apiVersion", av.getVersion())
                .bind("planId", planId)
                .bind("planVersion", planVersion)
                .execute();
    }
Synchronize DiscoverabilityEntity materialized view when any ApiPlan with a DiscoverabilityLevel is inserted, updated, or deleted.

@author Marc Savy {@literal <marc@blackparrotlabs.io>}
manager/api/jpa/src/main/java/io/apiman/manager/api/jpa/h2/ApiPlanDiscoverabilityTrigger.java