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() { 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(); 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(); }
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."); } Vector employees = getSomeEmployees(); Employee emp = (Employee) employees.firstElement(); String ejbqlString; ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE "; ejbqlString = ejbqlString + emp.getFirstName().length(); ejbqlString = ejbqlString + " = LENGTH(emp.firstName)"; ejbqlString = ejbqlString + " AND "; ejbqlString = ejbqlString + emp.getLastName().length(); ejbqlString = ejbqlString + " = LENGTH(emp.lastName)"; setEjbqlString(ejbqlString); setOriginalOject(emp); super.setup(); }