if (!refkey.getTableName().equals(from.getTableName())) { s_log.warn("generateSinglePropertyRemove: JoinPath for " + prop.getName() + " does not start in the primary table."); return null; }
Table table = from.getTable(); Column pkey = table.getPrimaryKey().getColumns()[0];
    protected Event generateSinglePropertyRemove(ObjectType type,                                                 Property prop) {        StringBuffer sb = new StringBuffer();        List path = prop.getJoinPath().getPath();        if (path.size() > 2) {            // this should probably be logged eventually            s_log.warn("generateSinglePropertyRemove: " + prop.getName() +                       " has a join path longer than 2");            return null;        }        Column refkey = type.getColumn();        if ((refkey == null) || (Utilities.getKeyProperty(type) == null)) {            return null;        }        if (path.size() == 1) {            Column from = ((JoinElement)path.get(0)).getFrom();            if (!refkey.getTableName().equals(from.getTableName())) {                s_log.warn("generateSinglePropertyRemove: JoinPath for " +                           prop.getName() +                           " does not start in the primary table.");                return null;            }            sb.append("update ")                .append(from.getTableName())                .append("\nset ")                .append(from.getColumnName())                .append(" = null\nwhere ")                .append(refkey.getTableName())                .append(".")                .append(refkey.getColumnName())                .append(" = :")                .append(Utilities.getKeyProperty(type).getName());        } else {            Column type1Ref = ((JoinElement)path.get(0)).getTo();            Column type2Ref = ((JoinElement)path.get(1)).getFrom();            Property type1Key = Utilities.getKeyProperty(type);            Property type2Key =                Utilities.getKeyProperty((ObjectType)prop.getType());            if ((type1Key == null) || (type2Key == null)) {                s_log.warn("generateSinglePropertyAdd: no key property " +                           "defined for either " + type.getName() + " or " +                           prop.getType().getName());                return null;            }            if (!type1Ref.getTableName().equals(type2Ref.getTableName())) {                s_log.warn("generateSinglePropertyAdd: JoinPath for " +                           prop.getName() + " is not continuous.");                return null;            }            sb.append("delete from ")                .append(type1Ref.getTableName())                .append("\nwhere ")                .append(type1Ref.getColumnName())                .append(" = :")                .append(type1Key.getName());        }        Event event = new Event();        event.setLineInfo(prop);        Operation op = new Operation(sb.toString());        op.setLineInfo(prop);        event.addOperation(op);        return event;    }