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 void setup() {
    setReferenceClass(Employee.class);

    // add a mapping for addressId so we can use it in from "emp"
    //        DirectToFieldMapping addressIdMapping = new DirectToFieldMapping();
    //        addressIdMapping.setAttributeName("addressId");
    //        addressIdMapping.setFieldName("EMPLOYEE.ADDR_ID");
    //        addressIdMapping.setGetMethodName("getAddressId");
    //        addressIdMapping.setSetMethodName("setAddressId");
    //        addressIdMapping.setIsReadOnly(true);
    //        getSession().getDescriptor(Employee.class).addMapping(addressIdMapping);
    //        addressIdMapping.initialize(getSession());
    ExpressionBuilder builder = new ExpressionBuilder(Employee.class);
    ExpressionBuilder addressBuilder = new ExpressionBuilder(Address.class);
    Expression whereClause = builder.get("addressId").equal(addressBuilder.get("id"));
    Vector employees = getSession().readAllObjects(Employee.class, whereClause);

    setOriginalOject(employees);
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();

    String ejbqlString;
    ejbqlString =
        "SELECT OBJECT(emp) FROM Employee emp, Address address "
            + "WHERE emp.addressId = address.id";

    setEjbqlString(ejbqlString);
    super.setup();
  }
  public void setup() {
    Employee emp = (Employee) getSomeEmployees().firstElement();

    String partOne;
    String partTwo;
    String ejbqlString;

    partOne = emp.getFirstName();

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause = builder.get("firstName").concat("Smith").like(partOne + "Smith");

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

    Vector employees = (Vector) getSession().executeQuery(raq);

    ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE ";
    ejbqlString = ejbqlString + "CONCAT(emp.firstName,\"Smith\") LIKE ";
    ejbqlString = ejbqlString + "\"" + partOne + "Smith\"";

    setEjbqlString(ejbqlString);
    setOriginalOject(employees);
    super.setup();
  }
  public void setup() {
    Employee emp = (Employee) getSomeEmployees().firstElement();

    String ejbqlString;

    ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE ";
    ejbqlString = ejbqlString + emp.getSalary();
    ejbqlString = ejbqlString + " = ABS(emp.salary)";
    setEjbqlString(ejbqlString);
    setOriginalOject(emp);
    super.setup();
  }
Esempio n. 5
0
  public void setup() {
    if (getSession().getLogin().getPlatform().isSQLServer()
        || getSession().getLogin().getPlatform().isSybase()) {
      throw new TestWarningException(
          "This test is not supported on SQL Server and Sybase. Because 'MOD' is not a recognized function name on SQL Server and Sybase.");
    }

    ReadAllQuery raq = new ReadAllQuery();
    raq.setReferenceClass(getReferenceClass());
    raq.setSelectionCriteria(getOriginalObjectExpression());

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

    super.setup();
  }
  public void setup() {
    Employee emp;
    emp = (Employee) getSomeEmployees().firstElement();
    PhoneNumber empPhoneNumbers = (PhoneNumber) emp.getPhoneNumbers().elementAt(0);

    String ejbqlString =
        "SelecT OBJECT(emp) from Employee emp, in (emp.phoneNumbers) phone "
            + "Where phone.areaCode = \""
            + empPhoneNumbers.getAreaCode()
            + "\"";

    setEjbqlString(ejbqlString);
    setOriginalOject(emp);

    super.setup();
  }
  public void setup() {
    if ((getSession().getLogin().getPlatform().isSQLServer())) {
      throw new TestWarningException(
          "This test is not supported on SQL Server. Because 'LENGTH' is not a recognized function name on SQL Server.");
    }

    Employee emp = (Employee) getSomeEmployees().firstElement();

    String ejbqlString;
    ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE ";
    ejbqlString = ejbqlString + emp.getFirstName().length();
    ejbqlString = ejbqlString + " = LENGTH(emp.firstName)";

    setEjbqlString(ejbqlString);
    setOriginalOject(emp);
    super.setup();
  }
  public void setup() {
    setReferenceClass(Employee.class);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        builder.anyOf("managedEmployees").get("address").get("city").equal("Ottawa");
    Vector employees = getSession().readAllObjects(Employee.class, whereClause);

    setOriginalOject(employees);
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();

    String ejbqlString;
    ejbqlString =
        "SELECT OBJECT(emp) FROM Employee emp, IN(emp.managedEmployees) managedEmployees "
            + "WHERE managedEmployees.address.city = 'Ottawa'";

    setEjbqlString(ejbqlString);
    super.setup();
  }
  public void setup() {
    Employee emp = (Employee) getSomeEmployees().firstElement();

    PhoneNumber phone = (PhoneNumber) emp.getPhoneNumbers().firstElement();
    String areaCode = phone.getAreaCode();
    String firstName = emp.getFirstName();

    setReferenceClass(Employee.class);

    ExpressionBuilder employeeBuilder = new ExpressionBuilder();
    Expression phones = employeeBuilder.anyOf("phoneNumbers");
    Expression whereClause =
        phones
            .get("owner")
            .get("firstName")
            .equal(firstName)
            .and(phones.get("areaCode").equal(areaCode));

    ReportQuery rq = new ReportQuery();
    rq.setSelectionCriteria(whereClause);
    rq.addAttribute("number", phones.get("number"));
    rq.setReferenceClass(Employee.class);

    setOriginalOject(getAttributeFromAll("number", (Vector) getSession().executeQuery(rq)));
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();

    String ejbqlString;
    ejbqlString =
        "SELECT phone.number FROM Employee employee, IN(employee.phoneNumbers) phone "
            + "WHERE phone.owner.firstName = \""
            + firstName
            + "\" AND phone.areaCode = \""
            + areaCode
            + "\"";

    useReportQuery();
    setEjbqlString(ejbqlString);
    super.setup();
  }