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; 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() { 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(); }