Joins ActiveAndroid - how to get data from the second table

I use ActiveAndroid and run a query with an external connection:

List<NavigationState> models = new Select() .from(NavigationState.class) .leftJoin(BundleItem.class) .on("aColumnName = anotherColumnName") .execute(); 

So, obviously, what I want is NavigationStates, with any related BundleItems. What I actually get is NavigationStates. Here is the part of the ActiveAndroid code that fills the data with the cursor after running the request:

 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 all this, this is the processCursor method, here: https://github.com/pardom/ActiveAndroid/blob/df29214c9584d7b626f361e95b95daccb0c0114c/src/com/activeandroid/util/SQLiteUtils.java

So, as you can see, it is not trying to do anything except populate the type that was passed ( loadFromCursor does not populate anything from other tables). I even included it to request a list of BundleItem , and it apparently still returned the same.

The only thing AA documentation talks about getting β€œmany” records from many sides of the one-to-many relationship is calling Model.getMany , but it does its own query (one for each record as a result of set!), Therefore If I do this, it makes no sense to make a connection in the first request.

I missed something because it seems that joins are enabled with ActiveAndroid, but not useful, since you can only get results from one of the tables in the join? I can get around this in this case, but I wonder if I chose the wrong ORM because it seems like a pretty simple function that has broken.

+5
source share

All Articles