use of org.apache.cayenne.testdo.inheritance_people.ClientCompany in project cayenne by apache.
the class SingleTableInheritanceIT method testSave.
@Test
public void testSave() throws Exception {
ClientCompany company = context.newObject(ClientCompany.class);
company.setName("Boeing");
CustomerRepresentative rep = context.newObject(CustomerRepresentative.class);
rep.setName("Joe Schmoe");
rep.setToClientCompany(company);
rep.setPersonType("C");
Employee employee = context.newObject(Employee.class);
employee.setName("Our Joe Schmoe");
employee.setPersonType("E");
context.commitChanges();
context.invalidateObjects(company, rep, employee);
SelectQuery query = new SelectQuery(CustomerRepresentative.class);
List<?> reps = context2.performQuery(query);
assertEquals(1, reps.size());
assertEquals(1, countObjectOfClass(reps, CustomerRepresentative.class));
}
use of org.apache.cayenne.testdo.inheritance_people.ClientCompany in project cayenne by apache.
the class SingleTableInheritanceIT method testRepCompany.
/**
* Tests that to-one relationship produces correct subclass.
*/
@Test
public void testRepCompany() throws Exception {
createRepCompanyDataSet();
List<?> companies = context.performQuery(new SelectQuery(ClientCompany.class));
assertEquals(1, companies.size());
ClientCompany company = (ClientCompany) companies.get(0);
List<?> reps = company.getRepresentatives();
assertEquals(1, reps.size());
assertSame(CustomerRepresentative.class, reps.get(0).getClass());
}
Aggregations