Search in sources :

Example 1 with CustomerRepresentative

use of org.apache.cayenne.testdo.inheritance_people.CustomerRepresentative 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));
}
Also used : SelectQuery(org.apache.cayenne.query.SelectQuery) ClientCompany(org.apache.cayenne.testdo.inheritance_people.ClientCompany) Employee(org.apache.cayenne.testdo.inheritance_people.Employee) CustomerRepresentative(org.apache.cayenne.testdo.inheritance_people.CustomerRepresentative) Test(org.junit.Test)

Aggregations

SelectQuery (org.apache.cayenne.query.SelectQuery)1 ClientCompany (org.apache.cayenne.testdo.inheritance_people.ClientCompany)1 CustomerRepresentative (org.apache.cayenne.testdo.inheritance_people.CustomerRepresentative)1 Employee (org.apache.cayenne.testdo.inheritance_people.Employee)1 Test (org.junit.Test)1