public void testExecuteQuery() throws Exception {
Schema schema = _dataContext.getSchemaByName("HR");
Table employeeTable = schema.getTableByName("EMPLOYEES");
Table departmentsTable = schema.getTableByName("DEPARTMENTS");
Relationship relationship = employeeTable
.getRelationships(departmentsTable)[0];
assertEquals(
"Relationship[primaryTable=EMPLOYEES,primaryColumns={EMPLOYEE_ID},foreignTable=DEPARTMENTS,foreignColumns={MANAGER_ID}]",
relationship.toString());
Query q = new Query().from(new FromItem(JoinType.INNER, relationship))
.select(employeeTable.getColumnByName("EMAIL"),
departmentsTable.getColumnByName("DEPARTMENT_NAME"));
q.getSelectClause().getItem(0).setAlias("e-mail");