Пример #1
0
    public void prepareUpdateExpressionWithRow(NSDictionary row, EOQualifier qualifier) {
      EOAttribute attribute;
      Object value;
      for (Enumeration enumeration = row.keyEnumerator();
          enumeration.hasMoreElements();
          addUpdateListAttribute(attribute, value)) {
        String attributeName = (String) enumeration.nextElement();
        attribute = this.entity().anyAttributeNamed(attributeName);
        if (attribute == null)
          throw new IllegalStateException(
              "prepareUpdateExpressionWithRow: row argument contains key '"
                  + attributeName
                  + "' which does not have corresponding attribute on entity '"
                  + this.entity().name()
                  + "'");
        value = row.objectForKey(attributeName);
      }

      _whereClauseString =
          EOQualifierSQLGeneration.Support._sqlStringForSQLExpression(qualifier, this);
      String tableList = tableListWithRootEntity(_rootEntityForExpression());
      _statement =
          assembleUpdateStatementWithRow(
              row, qualifier, tableList, new String(_listString), _whereClauseString);
    }
Пример #2
0
    public void prepareInsertExpressionWithRow(NSDictionary row) {
      EOAttribute attribute;
      Object value;
      for (Enumeration enumeration = row.keyEnumerator();
          enumeration.hasMoreElements();
          this.addInsertListAttribute(attribute, value)) {
        String attributeName = (String) enumeration.nextElement();
        attribute = this.entity().anyAttributeNamed(attributeName);
        if (attribute == null)
          throw new IllegalStateException(
              "prepareInsertExpressionWithRow: row argument contains key '"
                  + attributeName
                  + "' which does not have corresponding attribute on entity '"
                  + this.entity().name()
                  + "'");
        value = row.objectForKey(attributeName);
      }

      String tableList = tableListWithRootEntity(_rootEntityForExpression());
      _statement =
          this.assembleInsertStatementWithRow(
              row, tableList, new String(_listString), new String(_valueListString));
    }