Package com.webobjects.eoaccess

Examples of com.webobjects.eoaccess.EOSQLExpression


      return _broker;
    }
   
    protected long selectAndUpdateValue(Connection con, long increment) throws SQLException {
      long pk;
      EOSQLExpression selectExpression = _factory.expressionForEntity(null);

      String columnList = VALUE_COLUMN_NAME;
      String tableList = ERX_SEQUENCE_TABLE;
      String whereSelector = selectExpression.sqlStringForSelector(EOQualifier.QualifierOperatorEqual, name());
      String whereClause = NAME_COLUMN_NAME + " " + whereSelector + " '" + name() + "'";
      String lockClause = selectExpression.lockClause();

      String selectStatement = selectExpression.assembleSelectStatementWithAttributes(null, true, null, null, "SELECT ", columnList , tableList, whereClause, null, null, lockClause);
      ResultSet resultSet = con.createStatement().executeQuery(selectStatement);
       
        boolean hasNext = resultSet.next();
        if (hasNext) {
          String incrementString = EOSQLExpression.sqlStringForNumber(Long.valueOf(increment));
View Full Code Here


    public NSArray foreignKeyConstraintStatementsForRelationship(EORelationship relationship) {
        NSArray superResults;
        NSMutableArray results;
        int count;
        int i;
        EOSQLExpression expression;

        results = new NSMutableArray();
        superResults = super.foreignKeyConstraintStatementsForRelationship(relationship);

        count = superResults.count();
        for (i = 0; i < count; i++) {
            expression = (EOSQLExpression) superResults.objectAtIndex(i);
            String s = expression.statement();
            s = replaceStringByStringInString(") INITIALLY DEFERRED", ") ENFORCED", s);
            expression.setStatement(s);
            results.addObject(expression);
            // timc 2006-11-06 check for enableIdentifierQuoting
            String tableName = expression.sqlStringForSchemaObjectName(expression.entity().externalName());
            NSArray columnNames = ((NSArray) relationship.sourceAttributes().valueForKey("columnName"));
            StringBuilder sbColumnNames = new StringBuilder();
            for (int j = 0; j < columnNames.count(); j++) {
                sbColumnNames.append((j == 0 ? "" : ", ") + expression.sqlStringForSchemaObjectName((String) columnNames.objectAtIndex(j)));
            }
            String indexName = externalNameForEntityWithoutSchema(relationship.entity()) + "_" + columnNames.componentsJoinedByString("_") + "_idx";
            results.addObject(createExpression(expression.entity(), "CREATE INDEX " + indexName + " ON " + tableName + "( " + sbColumnNames.toString() + " )"));
        }
        return results;
    }
View Full Code Here

    @Override
    public NSArray createTableStatementsForEntityGroup(NSArray entityGroup) {
    NSMutableSet columnNames = new NSMutableSet();
    StringBuffer aStatement = new StringBuffer(128);
    if (entityGroup != null && entityGroup.count() > 0) {
      EOSQLExpression sqlExpr = _expressionForEntity((EOEntity) entityGroup.objectAtIndex(0));
      for (Iterator entityIterator = entityGroup.iterator(); entityIterator.hasNext();) {
        EOEntity entity = (EOEntity) entityIterator.next();
        Iterator attributeIterator = entity.attributes().iterator();
        while (attributeIterator.hasNext()) {
          EOAttribute attribute = (EOAttribute) attributeIterator.next();
          String columnName = attribute.columnName();
          if (!attribute.isDerived() && !attribute.isFlattened() && columnName != null && columnName.length() > 0 && !columnNames.contains(columnName)) {
            sqlExpr.appendItemToListString(_columnCreationClauseForAttribute(attribute), aStatement);
            columnNames.addObject(columnName);
          }
        }
      }
      return new NSArray(_expressionForString(new StringBuilder().append("CREATE TABLE ").append(formatTableName(((EOEntity) entityGroup.objectAtIndex(0)).externalName())).append(" (").append(aStatement.toString()).append(')').toString()));
View Full Code Here

            gidString = "<" +  kgid.entityName() + ": [" ;
            EOEntity entity = ERXEOAccessUtilities.entityNamed(null, kgid.entityName());
            NSArray pks = entity.primaryKeyAttributes();
            NSArray values = kgid.keyValuesArray();
            EOSQLExpressionFactory expressionFactory = context.database().adaptor().expressionFactory();
            EOSQLExpression expression = null;
            if (expressionFactory != null) {
              expression = expressionFactory.expressionForEntity(entity);
            }
            for(int i = 0; i < pks.count(); i++) {
                Object value = values.objectAtIndex(i);
                EOAttribute attribute = (EOAttribute) pks.objectAtIndex(i);
                // ak: only Postgres seems to return reasonable values here...
                String stringValue = "" + value;
                if (expression != null) {
                  stringValue = expression.formatValueForAttribute(value, attribute);
                }
                if("NULL".equals(stringValue)) {
                    stringValue = "" + value;
                }
                gidString += attribute.name() + ": \'" +  stringValue + "\'"
View Full Code Here

    EOSQLExpressionFactory factory = new EOSQLExpressionFactory(adaptor);
    NSArray<EOEntity> entities = EOModelGroup.defaultGroup().modelNamed(ERXTestSuite.ERXTEST_MODEL).entities();
    NSMutableDictionary<String,Number> counts = new NSMutableDictionary<String,Number>();

    for (EOEntity entity : entities) {
      EOSQLExpression sqlExp = factory.selectStatementForAttributes(entity.attributes(),
                false,
                new EOFetchSpecification(entity.name(), null, null),
                entity);
      NSArray rows = ERXEOAccessUtilities.rawRowsForSQLExpression(ec, ERXTestSuite.ERXTEST_MODEL, sqlExp);

      counts.setObjectForKey(rows.size(), entity.name());
    }

    ERXTestUtilities.createCompanyAnd3Employees();

    NSMutableSet<String> hasMore = new NSMutableSet<String>();

    for (EOEntity entity : entities) {
      EOSQLExpression sqlExp = factory.selectStatementForAttributes(entity.attributes(),
                false,
                new EOFetchSpecification(entity.name(), null, null),
                entity);
      NSArray rows = ERXEOAccessUtilities.rawRowsForSQLExpression(ec, ERXTestSuite.ERXTEST_MODEL, sqlExp);
View Full Code Here

TOP

Related Classes of com.webobjects.eoaccess.EOSQLExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.