public static BinaryOperatorWithParameterTest
      getNumericParameterDivideTestWithBracketsAfterComparison() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Divide with parameter test with brackets after comparison");

    String parameterName = "amountToDivide";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterName);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        ExpressionBuilder.fromConstant(new Integer(20000), builder)
            .greaterThan(
                ExpressionMath.divide(
                    builder.get("salary"), (builder.getParameter(parameterName))));
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE 20000 > (emp.salary / ?1)";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    theTest.setArgumentNames(myArgumentNames);

    theTest.setArguments(new Vector());
    theTest.getArguments().addElement(new Integer(2));

    return theTest;
  }
  public void setup() {
    Employee emp1;
    Employee emp2;
    Employee emp3;
    emp1 = (Employee) getSomeEmployees().firstElement();
    emp2 = (Employee) getSomeEmployees().elementAt(1);
    emp3 = (Employee) getSomeEmployees().elementAt(2);

    ExpressionBuilder builder = new ExpressionBuilder();

    Vector idVector = new Vector();
    idVector.add(emp1.getId());
    idVector.add(emp2.getId());
    idVector.add(emp3.getId());

    Expression whereClause = builder.get("id").notIn(idVector);

    ReadAllQuery raq = new ReadAllQuery();
    raq.setReferenceClass(Employee.class);
    raq.setSelectionCriteria(whereClause);

    setOriginalOject(getSession().executeQuery(raq));
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();

    String ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE emp.id NOT IN (";
    ejbqlString = ejbqlString + emp1.getId().toString() + ", ";
    ejbqlString = ejbqlString + emp2.getId().toString() + ", ";
    ejbqlString = ejbqlString + emp3.getId().toString();
    ejbqlString = ejbqlString + ")";

    setEjbqlString(ejbqlString);

    super.setup();
  }
  public static BinaryOperatorWithParameterTest
      getNumericParameterMultiplyTestWithBracketsBeforeComparison() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Multiply with parameter test with brackets before comparison");

    String parameterName = "amountToMultiply";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterName);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        ExpressionMath.multiply(builder.get("salary"), (builder.getParameter(parameterName)))
            .lessThanEqual(100000);
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE (emp.salary * ?1) <= 100000";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    theTest.setArgumentNames(myArgumentNames);

    theTest.setArguments(new Vector());
    theTest.getArguments().addElement(new Integer(2));

    return theTest;
  }
  /**
   * INTERNAL: This methods clones all the fields and ensures that each collection refers to the
   * same clones.
   */
  @Override
  public Object clone() {
    VariableOneToOneMapping clone = (VariableOneToOneMapping) super.clone();
    Map setOfKeys = new HashMap(getSourceToTargetQueryKeyNames().size());
    Map sourceToTarget = new HashMap(getSourceToTargetQueryKeyNames().size());
    Vector foreignKeys =
        org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(
            getForeignKeyFields().size());

    if (getTypeField() != null) {
      clone.setTypeField((DatabaseField) this.getTypeField().clone());
    }

    for (Iterator enumtr = getSourceToTargetQueryKeyNames().keySet().iterator();
        enumtr.hasNext(); ) {
      // Clone the SourceKeyFields
      DatabaseField field = (DatabaseField) enumtr.next();
      DatabaseField clonedField = (DatabaseField) field.clone();
      setOfKeys.put(field, clonedField);
      // on the next line I'm cloning the query key names
      sourceToTarget.put(clonedField, getSourceToTargetQueryKeyNames().get(field));
    }

    for (Enumeration enumtr = getForeignKeyFields().elements(); enumtr.hasMoreElements(); ) {
      DatabaseField field = (DatabaseField) enumtr.nextElement();
      foreignKeys.addElement(setOfKeys.get(field));
    }
    clone.setSourceToTargetQueryKeyFields(sourceToTarget);
    clone.setForeignKeyFields(foreignKeys);
    clone.setTypeIndicatorTranslation(new HashMap(this.getTypeIndicatorTranslation()));
    return clone;
  }
  protected void buildExpectedResults() {
    Vector employees = getSession().readAllObjects(Employee.class);

    Object[] result = new Object[1];
    result[0] = new java.math.BigDecimal(employees.size());
    addResult(result, null);
  }
  public void setup() {
    Vector employees = getSomeEmployees();
    // Bug 223005: Verify that we have at least 1 employee with the required field length otherwise
    // an EclipseLinkException will be thrown
    Employee emp = getEmployeeWithRequiredNameLength(employees, MIN_FIRSTNAME_LENGTH, getName());

    String partialFirstName = "%" + emp.getFirstName().substring(0, 3) + "%";

    ReadAllQuery raq = new ReadAllQuery();
    raq.setReferenceClass(Employee.class);

    Vector parameters = new Vector();
    parameters.add(partialFirstName);

    ExpressionBuilder eb = new ExpressionBuilder();
    Expression whereClause = eb.get("firstName").like(partialFirstName);
    raq.setSelectionCriteria(whereClause);
    employees = (Vector) getSession().executeQuery(raq);

    String ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName LIKE ?1";

    setEjbqlString(ejbqlString);
    setOriginalOject(employees);
    setArguments(parameters);

    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    setArgumentNames(myArgumentNames);

    super.setup();
  }
  /**
   * Return the first employee that has a long enough name for the test. If no match is found throw
   * a warning exception. See bug 223005
   *
   * @param vectorOfEmployees
   * @param minFirstNameLength
   * @param testName
   * @return
   */
  public Employee getEmployeeWithRequiredNameLength(
      Vector vectorOfEmployees, int minFirstNameLength, String testName) {
    Employee empMatch = null;
    Vector<Employee> employees = vectorOfEmployees;
    String firstName;
    StringBuffer partialFirstName;

    // Loop through the collection of employees to find one that matches our test requirements
    for (int i = 0; i < employees.size(); i++) {
      empMatch = employees.get(i);
      firstName = empMatch.getFirstName();
      // Verify length criteria
      if (firstName.length() >= minFirstNameLength) {
        // exit the for loop - return the last empMatch
        i = employees.size();
      }
    }

    // If we could not find a proper employee for testing - throw a warning
    if (null == empMatch) {
      throw new RuntimeException(
          testName
              + " Setup Failed: unable to find an Employee with firstName size of at least  "
              + minFirstNameLength);
    } else {
      return empMatch;
    }
  }
  /**
   * INTERNAL: This method is used when computing the nested queries for batch read mappings. It
   * recurses computing the nested mapping queries.
   */
  protected void computeNestedQueriesForBatchReadExpressions(Vector batchReadExpressions) {
    for (int index = 0; index < batchReadExpressions.size(); index++) {
      ObjectExpression objectExpression = (ObjectExpression) batchReadExpressions.get(index);

      // Expression may not have been initialized.
      ExpressionBuilder builder = objectExpression.getBuilder();
      builder.setSession(getSession().getRootSession(null));
      builder.setQueryClass(getReferenceClass());

      // PERF: Cache join attribute names.
      ObjectExpression baseExpression = objectExpression;
      while (!baseExpression.getBaseExpression().isExpressionBuilder()) {
        baseExpression = (ObjectExpression) baseExpression.getBaseExpression();
      }
      this.batchReadAttributes.add(baseExpression.getName());

      // Ignore nested
      if (objectExpression.getBaseExpression().isExpressionBuilder()) {
        DatabaseMapping mapping = objectExpression.getMapping();
        if ((mapping != null) && mapping.isForeignReferenceMapping()) {
          // A nested query must be built to pass to the descriptor that looks like the real query
          // execution would.
          ReadQuery nestedQuery = ((ForeignReferenceMapping) mapping).prepareNestedBatchQuery(this);
          // Register the nested query to be used by the mapping for all the objects.
          getBatchReadMappingQueries().put(mapping, nestedQuery);
        }
      }
    }
  }
 /** A clean way to specify which tests run on which platforms. */
 public boolean isPlatformSupported(DatabasePlatform platform) {
   boolean supported = false;
   boolean notSupported = false;
   if ((unsupportedPlatforms == null) && (supportedPlatforms == null)) {
     return true;
   }
   if (supportedPlatforms != null) {
     for (Iterator iterator = supportedPlatforms.iterator(); iterator.hasNext(); ) {
       Class platformClass = (Class) iterator.next();
       if (platformClass.isInstance(platform)) {
         supported = true;
       }
     }
   } else {
     supported = true;
   }
   if (unsupportedPlatforms != null) {
     for (Iterator iterator = unsupportedPlatforms.iterator(); iterator.hasNext(); ) {
       Class platformClass = (Class) iterator.next();
       if (platformClass.isInstance(platform)) {
         notSupported = true;
       }
     }
   }
   return supported && (!notSupported);
 }
  /** INTERNAL: Transform the object-level value into a database-level value */
  public Object getFieldValue(Object objectValue, AbstractSession session) {
    DatabaseMapping mapping = getMapping();
    Object fieldValue = objectValue;
    if ((mapping != null)
        && (mapping.isDirectToFieldMapping() || mapping.isDirectCollectionMapping())) {
      // CR#3623207, check for IN Collection here not in mapping.
      if (objectValue instanceof Collection) {
        // This can actually be a collection for IN within expressions... however it would be better
        // for expressions to handle this.
        Collection values = (Collection) objectValue;
        Vector fieldValues = new Vector(values.size());
        for (Iterator iterator = values.iterator(); iterator.hasNext(); ) {
          Object value = iterator.next();
          if (!(value instanceof Expression)) {
            value = getFieldValue(value, session);
          }
          fieldValues.add(value);
        }
        fieldValue = fieldValues;
      } else {
        if (mapping.isDirectToFieldMapping()) {
          fieldValue = ((AbstractDirectMapping) mapping).getFieldValue(objectValue, session);
        } else if (mapping.isDirectCollectionMapping()) {
          fieldValue = ((DirectCollectionMapping) mapping).getFieldValue(objectValue, session);
        }
      }
    }

    return fieldValue;
  }
  public static BinaryOperatorWithParameterTest getNumericParameterDivideTest() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Divide with parameter test");

    String parameterName = "amountToDivide";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterName);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        ExpressionMath.divide(builder.get("salary"), (builder.getParameter(parameterName)))
            .lessThanEqual(20000);
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE emp.salary / ?1 <= 20000";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    theTest.setArgumentNames(myArgumentNames);

    theTest.setArguments(new Vector());
    theTest.getArguments().addElement(new Integer(2));

    return theTest;
  }
 /**
  * INTERNAL: Execute the query building the objects directly from the database result-set.
  *
  * @exception DatabaseException - an error has occurred on the database
  * @return object - the first object found or null if none.
  */
 protected Object executeObjectLevelReadQueryFromResultSet() throws DatabaseException {
   UnitOfWorkImpl unitOfWork = (UnitOfWorkImpl) getSession();
   DatabaseAccessor accessor = (DatabaseAccessor) unitOfWork.getAccessor();
   DatabasePlatform platform = accessor.getPlatform();
   DatabaseCall call = (DatabaseCall) getCall().clone();
   call.setQuery(this);
   call.translate(this.translationRow, null, unitOfWork);
   Statement statement = null;
   ResultSet resultSet = null;
   boolean exceptionOccured = false;
   try {
     accessor.incrementCallCount(unitOfWork);
     statement = call.prepareStatement(accessor, this.translationRow, unitOfWork);
     resultSet = accessor.executeSelect(call, statement, unitOfWork);
     ResultSetMetaData metaData = resultSet.getMetaData();
     Vector results = new Vector();
     ObjectBuilder builder = this.descriptor.getObjectBuilder();
     while (resultSet.next()) {
       results.add(
           builder.buildWorkingCopyCloneFromResultSet(
               this,
               this.joinedAttributeManager,
               resultSet,
               unitOfWork,
               accessor,
               metaData,
               platform));
     }
     return results;
   } catch (SQLException exception) {
     exceptionOccured = true;
     DatabaseException commException =
         accessor.processExceptionForCommError(session, exception, call);
     if (commException != null) throw commException;
     throw DatabaseException.sqlException(exception, call, accessor, unitOfWork, false);
   } finally {
     try {
       if (resultSet != null) {
         resultSet.close();
       }
       if (statement != null) {
         accessor.releaseStatement(statement, call.getSQLString(), call, unitOfWork);
       }
     } catch (SQLException exception) {
       if (!exceptionOccured) {
         // in the case of an external connection pool the connection may be null after the
         // statement release
         // if it is null we will be unable to check the connection for a comm error and
         // therefore must return as if it was not a comm error.
         DatabaseException commException =
             accessor.processExceptionForCommError(session, exception, call);
         if (commException != null) throw commException;
         throw DatabaseException.sqlException(exception, call, accessor, session, false);
       }
     }
   }
 }
  /**
   * PUBLIC: Return the foreign key field names associated with the mapping. These are only the
   * source fields that are writable.
   */
  public Vector getForeignKeyFieldNames() {
    Vector fieldNames = new Vector(getForeignKeyFields().size());
    for (Enumeration fieldsEnum = getForeignKeyFields().elements();
        fieldsEnum.hasMoreElements(); ) {
      fieldNames.addElement(((DatabaseField) fieldsEnum.nextElement()).getQualifiedName());
    }

    return fieldNames;
  }
  protected void setup() {
    beginTransaction();

    // Acquire a unit of work with a class read-only.
    Vector readOnlyClasses = new Vector();
    readOnlyClasses.addElement(Country.class);
    uow = getSession().acquireUnitOfWork();
    uow.removeAllReadOnlyClasses();
    uow.addReadOnlyClasses(readOnlyClasses);
  }
  /**
   * INTERNAL: Returns the first field from each of the owned tables, used for fine-grained
   * pessimistic locking.
   */
  protected Vector getForUpdateOfFields() {
    Vector allFields = getFields();
    int expected = getTableAliases().size();
    Vector firstFields = new Vector(expected);
    DatabaseTable lastTable = null;
    DatabaseField field = null;
    int i = 0;

    // The following loop takes O(n*m) time.  n=# of fields. m=#tables.
    // However, in the m=1 case this will take one pass only.
    // Also assuming that fields are generally sorted by table, this will
    // take O(n) time.
    // An even faster way may be to go getDescriptor().getAdditionalPrimaryKeyFields.
    while ((i < allFields.size()) && (firstFields.size() < expected)) {
      field = (DatabaseField) allFields.elementAt(i++);
      if ((lastTable == null) || !field.getTable().equals(lastTable)) {
        lastTable = field.getTable();
        int j = 0;
        while (j < firstFields.size()) {
          if (lastTable.equals(((DatabaseField) firstFields.elementAt(j)).getTable())) {
            break;
          }
          j++;
        }
        if (j == firstFields.size()) {
          firstFields.addElement(field);
        }
      }
    }
    return firstFields;
  }
 /** PUBLIC: Set a collection of the source to target query key/field associations. */
 public void setSourceToTargetQueryKeyFieldAssociations(
     Vector sourceToTargetQueryKeyFieldAssociations) {
   setSourceToTargetQueryKeyFields(
       new HashMap(sourceToTargetQueryKeyFieldAssociations.size() + 1));
   for (Enumeration associationsEnum = sourceToTargetQueryKeyFieldAssociations.elements();
       associationsEnum.hasMoreElements(); ) {
     Association association = (Association) associationsEnum.nextElement();
     Object sourceField = new DatabaseField((String) association.getKey());
     String targetQueryKey = (String) association.getValue();
     getSourceToTargetQueryKeyNames().put(sourceField, targetQueryKey);
   }
 }
  /** PUBLIC: Return a collection of the field to query key associations. */
  public Vector getSourceToTargetQueryKeyFieldAssociations() {
    Vector associations = new Vector(getSourceToTargetQueryKeyNames().size());
    Iterator sourceFieldEnum = getSourceToTargetQueryKeyNames().keySet().iterator();
    Iterator targetQueryKeyEnum = getSourceToTargetQueryKeyNames().values().iterator();
    while (sourceFieldEnum.hasNext()) {
      Object fieldValue = ((DatabaseField) sourceFieldEnum.next()).getQualifiedName();
      Object attributeValue = targetQueryKeyEnum.next();
      associations.addElement(new Association(fieldValue, attributeValue));
    }

    return associations;
  }
  /**
   * PUBLIC: Return the foreign key field names associated with the mapping. These are only the
   * source fields that are writable.
   */
  public void setForeignKeyFieldNames(Vector fieldNames) {
    Vector fields =
        org.eclipse.persistence.internal.helper.NonSynchronizedVector.newInstance(
            fieldNames.size());
    for (Enumeration fieldNamesEnum = fieldNames.elements(); fieldNamesEnum.hasMoreElements(); ) {
      fields.addElement(new DatabaseField((String) fieldNamesEnum.nextElement()));
    }

    setForeignKeyFields(fields);
    if (!fields.isEmpty()) {
      setIsForeignKeyRelationship(true);
    }
  }
  protected void buildExpectedResults() {
    Vector projects = getSession().readAllObjects(LargeProject.class);

    for (Enumeration e = projects.elements(); e.hasMoreElements(); ) {
      LargeProject project = (LargeProject) e.nextElement();
      if (project.getBudget() > 4000) {
        Object[] result = new Object[2];
        result[0] = project.getName();
        result[1] = new Double(project.getBudget());
        addResult(result, null);
      }
    }
  }
  /** INTERNAL: Return all the fields populated by this mapping. */
  @Override
  protected Vector collectFields() {
    DatabaseField type = getTypeField();

    // Get a shallow copy of the Vector
    if (type != null) {
      Vector sourceFields = (Vector) getForeignKeyFields().clone();
      sourceFields.addElement(type);
      return sourceFields;
    } else {
      return getForeignKeyFields();
    }
  }
  /**
   * INTERNAL: Return the value for in memory comparison. This is only valid for valueable
   * expressions.
   */
  public Object valueFromObject(
      Object object,
      AbstractSession session,
      AbstractRecord translationRow,
      int valueHolderPolicy,
      boolean isObjectUnregistered) {
    // The expression may be across a relationship, in which case it must be traversed.
    if ((!getBaseExpression().isExpressionBuilder())
        && getBaseExpression().isQueryKeyExpression()) {
      object =
          getBaseExpression()
              .valueFromObject(
                  object, session, translationRow, valueHolderPolicy, isObjectUnregistered);

      // toDo: Null means the join filters out the row, returning null is not correct if an inner
      // join,
      // outer/inner joins need to be fixed to filter correctly.
      if (object == null) {
        return null;
      }

      // If from an anyof the object will be a collection of values,
      // A new vector must union the object values and the values extracted from it.
      if (object instanceof Vector) {
        Vector comparisonVector = new Vector(((Vector) object).size() + 2);
        for (Enumeration valuesToIterate = ((Vector) object).elements();
            valuesToIterate.hasMoreElements(); ) {
          Object vectorObject = valuesToIterate.nextElement();
          if (vectorObject == null) {
            comparisonVector.addElement(vectorObject);
          } else {
            Object valueOrValues =
                valuesFromCollection(
                    vectorObject, session, valueHolderPolicy, isObjectUnregistered);

            // If a collection of values were extracted union them.
            if (valueOrValues instanceof Vector) {
              for (Enumeration nestedValuesToIterate = ((Vector) valueOrValues).elements();
                  nestedValuesToIterate.hasMoreElements(); ) {
                comparisonVector.addElement(nestedValuesToIterate.nextElement());
              }
            } else {
              comparisonVector.addElement(valueOrValues);
            }
          }
        }
        return comparisonVector;
      }
    }
    return valuesFromCollection(object, session, valueHolderPolicy, isObjectUnregistered);
  }
 /** PUBLIC: Set the class indicator associations. */
 public void setClassIndicatorAssociations(Vector classIndicatorAssociations) {
   setTypeIndicatorNameTranslation(new HashMap(classIndicatorAssociations.size() + 1));
   setTypeIndicatorTranslation(new HashMap((classIndicatorAssociations.size() * 2) + 1));
   for (Enumeration associationsEnum = classIndicatorAssociations.elements();
       associationsEnum.hasMoreElements(); ) {
     Association association = (Association) associationsEnum.nextElement();
     Object classValue = association.getKey();
     if (classValue instanceof Class) {
       // 904 projects will be a class type.
       addClassIndicator((Class) association.getKey(), association.getValue());
     } else {
       addClassNameIndicator((String) association.getKey(), association.getValue());
     }
   }
 }
  /**
   * INTERNAL: Return the class indicator associations for XML. List of class-name/value
   * associations.
   */
  public Vector getClassIndicatorAssociations() {
    Vector associations = new Vector();
    Iterator classesEnum = getTypeIndicatorNameTranslation().keySet().iterator();
    Iterator valuesEnum = getTypeIndicatorNameTranslation().values().iterator();
    while (classesEnum.hasNext()) {
      Object className = classesEnum.next();

      // If the project was built in runtime is a class, MW is a string.
      if (className instanceof Class) {
        className = ((Class) className).getName();
      }
      Object value = valuesEnum.next();
      associations.addElement(new TypedAssociation(className, value));
    }

    return associations;
  }
 /** INTERNAL: Return if the attribute is specified for batch reading. */
 public boolean isAttributeBatchRead(String attributeName) {
   if (!hasBatchReadAttributes()) {
     return false;
   }
   Vector batchReadAttributeExpressions = getBatchReadAttributeExpressions();
   int size = batchReadAttributeExpressions.size();
   for (int index = 0; index < size; index++) {
     QueryKeyExpression expression = (QueryKeyExpression) batchReadAttributeExpressions.get(index);
     while (!expression.getBaseExpression().isExpressionBuilder()) {
       expression = (QueryKeyExpression) expression.getBaseExpression();
     }
     if (expression.getName().equals(attributeName)) {
       return true;
     }
   }
   return false;
 }
  public Vector getAttributeFromAll(String attributeName, Vector objects) {
    ClassDescriptor descriptor = getSession().getClassDescriptor(getReferenceClass());
    DirectToFieldMapping mapping =
        (DirectToFieldMapping) descriptor.getMappingForAttributeName(attributeName);

    Vector attributes = new Vector();
    Object currentObject;
    for (int i = 0; i < objects.size(); i++) {
      currentObject = objects.elementAt(i);
      if (currentObject.getClass() == ReportQueryResult.class) {
        attributes.addElement(((ReportQueryResult) currentObject).get(attributeName));
      } else {
        attributes.addElement(mapping.getAttributeValueFromObject(currentObject));
      }
    }
    return attributes;
  }
  public ReadAllBindAllParametersTest() {
    v = new Vector(2);
    v.addElement(new BigDecimal(1001));
    v.addElement(new BigDecimal(1002));

    setName("ReadAllBindAllParametersTest");
    setDescription(
        "Tests all combinations of shouldBindAllParameters attributes on Session and Query");
  }
  /** INTERNAL: */
  public Vector getOwnedTables() {
    if ((getMapping() != null) && getMapping().isNestedTableMapping()) {
      Vector nestedTable = null;
      if (shouldQueryToManyRelationship()) {
        nestedTable = (Vector) super.getOwnedTables().clone();
      } else {
        nestedTable = new Vector(1);
      }

      nestedTable.addElement(new NestedTable(this));
      return nestedTable;
    }
    if ((getMapping() != null)
        && (getMapping().isReferenceMapping() || getMapping().isStructureMapping())) {
      return null;
    }

    return super.getOwnedTables();
  }
  protected void test() {
    for (int i = 0; i <= 1; i++) {
      getSession().getPlatform().setShouldBindAllParameters(i != 0);
      for (int j = 0; j <= 2; j++) {
        query = new ReadAllQuery(Employee.class);
        ExpressionBuilder builder = new ExpressionBuilder();
        Vector vExp = new Vector(2);
        vExp.add(builder.getParameter("p1"));
        query.addArgument("p1");
        vExp.add(builder.getParameter("p2"));
        query.addArgument("p2");
        Expression exp = builder.get("id").in(vExp);
        query.setSelectionCriteria(exp);

        switch (j) {
          case 0:
            // nothing to do - just test the default:
            // query.bindAllParameters == Undefined
            break;
          case 1:
            // query.bindAllParameters == False
            query.setShouldBindAllParameters(false);
            break;
          case 2:
            // query.bindAllParameters == True
            query.setShouldBindAllParameters(true);
            break;
        }

        // clear the writer's buffer
        ((StringWriter) getSession().getLog()).getBuffer().setLength(0);
        try {
          getSession().executeQuery(query, v);
        } catch (DatabaseException e) {
          throw new TestProblemException("executeQuery threw DatabaseException");
        }
        if (shouldBind() != wasBound()) {
          return;
        }
      }
    }
  }
  private void setArgumentsForTestUsing(Vector employees) {
    setArguments(new Vector());

    Enumeration names = getExpressionParameters().elements();
    Enumeration employeeEnum = employees.elements();
    while (names.hasMoreElements()) {
      Employee emp = (Employee) employeeEnum.nextElement();
      getArguments().add(emp.getId());
      names.nextElement();
    }
  }
  public static BinaryOperatorWithParameterTest
      getNumericTwoParameterMultipleOperatorsWithBracketsAroundMultiply() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Multiple operators with two parameters with brackets around multiply");

    String parameterNameForDivide = "amountToDivide";
    String parameterNameForMultiply = "amountToMultiply";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterNameForDivide);
    theTest.getExpressionParameters().add(parameterNameForMultiply);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        builder
            .get("salary")
            .greaterThan(
                ExpressionMath.subtract(
                    ExpressionMath.add(
                        ExpressionBuilder.fromConstant(new Integer(50000), builder), 10000),
                    ExpressionMath.divide(
                        ExpressionBuilder.fromConstant(new Integer(10000), builder),
                        ExpressionMath.multiply(
                            builder.getParameter(parameterNameForMultiply),
                            builder.getParameter(parameterNameForDivide)))));
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString =
        "SELECT OBJECT(emp) FROM Employee emp WHERE emp.salary > (50000 + 10000 - 10000 / (?1 * ?2))";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    myArgumentNames.add("2");
    theTest.setArgumentNames(myArgumentNames);

    theTest.setArguments(new Vector());
    theTest.getArguments().addElement(new Integer(2));
    theTest.getArguments().addElement(new Integer(5));

    return theTest;
  }