I'm using ActiveAndroid and running a query with an outer join:
List<NavigationState> models = new Select()
.from(NavigationState.class)
.leftJoin(BundleItem.class)
.on("aColumnName = anotherColumnName")
.execute();
So obviously what I want is NavigationStates, with any associated BundleItems. What I actually get is NavigationStates. Here's the part of the ActiveAndroid code that fills in the data from a cursor after running a query:
List<String> columnsOrdered = new ArrayList<String>(Arrays.asList(cursor.getColumnNames()));
do {
Model entity = Cache.getEntity(type, cursor.getLong(columnsOrdered.indexOf(idName)));
if (entity == null) {
entity = (T) entityConstructor.newInstance();
}
entity.loadFromCursor(cursor);
entities.add((T) entity);
}
while (cursor.moveToNext());
}
}
You can see the whole thing, it's the processCursor
method, here: https://github.com/pardom/ActiveAndroid/blob/df29214c9584d7b626f361e95b95daccb0c0114c/src/com/activeandroid/util/SQLiteUtils.java
So as you can see, it makes no attempt to do anything but fill in the type that was passed in (loadFromCursor
doesn't fill in anything from other tables either). I even switched it to ask for a list of BundleItem
and it apparently still returned the same thing.
The only thing the AA documentation says about getting the "many" records from the many side of a one-to-many relationship is to call Model.getMany
, but that runs its own query (one for each record in the result set!), so if I do that there's no point in doing a join in the first query.
Am I missing something, because it seems like joins are allowed with ActiveAndroid, but not useful, since you can only get results from one of the tables in the join? I can work around it in this case but I'm wondering if I picked the wrong ORM, because this seems like a pretty basic feature that's broken.