return new QueryJoin(this, join);\r
}\r
\r
+ @SuppressWarnings({ "unchecked", "rawtypes" })\r
+ public <A> QueryJoin<T> leftJoin(A alias) {\r
+ TableDefinition<T> def = (TableDefinition<T>) db.define(alias.getClass());\r
+ SelectTable<T> join = new SelectTable(db, this, alias, true);\r
+ def.initSelectObject(join, alias, aliasMap);\r
+ joins.add(join);\r
+ return new QueryJoin(this, join);\r
+ }\r
+\r
Db getDb() {\r
return db;\r
}\r
assertEquals(2, users.get(0).id);
}
+ @Test
+ public void testLeftJoin() throws Exception {
+ final UserId u = new UserId();
+ final UserNote n = new UserNote();
+
+ List<UserId> notes = db.from(u).leftJoin(n).on(u.id).is(n.userId).where(u.id).is(4).select();
+ assertEquals(1, notes.size());
+ assertEquals(4, notes.get(0).id);
+ }
+
@IQTable
public static class UserId {
}
public static List<UserId> getList() {
- UserId[] list = { new UserId(1, "Tom"), new UserId(2, "Dick"), new UserId(3, "Harry") };
+ UserId[] list = { new UserId(1, "Tom"), new UserId(2, "Dick"), new UserId(3, "Harry"), new UserId(4, "Jack") };
return Arrays.asList(list);
}
}