public void test() {
   ExpressionBuilder eb = new ExpressionBuilder();
   ReportQuery rq = new ReportQuery(Employee.class, eb);
   rq.addAttribute("firstName");
   rq.addAttribute("lastName");
   Expression exp = eb.getFunction("dbms_random.value");
   exp.setSelectIfOrderedBy(false);
   rq.addOrdering(exp.ascending());
   rq.setSelectionCriteria(eb.anyOf("projects").get("teamLeader").isNull());
   results = (Vector) getSession().executeQuery(rq);
 }
  private void createEmployeeAndSearchExpression() {
    // Create the example employee
    employee =
        (org.eclipse.persistence.testing.models.employee.domain.Employee)
            new org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator()
                .basicEmployeeExample1();
    employee.setFirstName("Timugen");
    employee.setLastName("Singaera");
    employee.addResponsibility("Answer the phones.");

    // Create an expression to retreive the employee from the database
    ExpressionBuilder expressionBuilder = new ExpressionBuilder();
    Expression exp1;
    Expression exp2;
    Expression expression;

    exp1 = expressionBuilder.get("firstName").equal(employee.getFirstName());
    exp2 = expressionBuilder.get("lastName").equal(employee.getLastName());

    searchExpression = exp1.or(exp2);
  }
  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();
  }