I have a ForeignCollection
field in my table below :
@DatabaseTable(tableName = "json_main")
public class JsonMain {
@DatabaseField( id = true)
int _id;
@DatabaseField
int likes_count;
@DatabaseField
String protected_visibility;
@ForeignCollectionField
ForeignCollection<JsonUser> jsonUser = null;
}
And Reference of this table here :
@DatabaseTable (tableName = "json_main_user")
public class JsonUser {
@DatabaseField(generatedId = true)
public int _id;
@DatabaseField(foreign = true, foreignAutoRefresh = true, columnName = "parent_id")
private JsonMain jsonMain;
}
I'm Building My Query to get The cursor here :
QueryBuilder<JsonMain, Integer> queryBuilder_main = dao_json_main.queryBuilder();
PreparedQuery<JsonMain> jsonMains_list =queryBuilder_main.orderBy("sort_id",false).prepare();
CloseableIterator<JsonMain> closeableIterator = dao_json_main.iterator(jsonMains_list);
AndroidDatabaseResults androidDatabaseResults= (AndroidDatabaseResults)closeableIterator.getRawResults();
Cursor cursor = androidDatabaseResults.getRawCursor();
I have inserted the Data Correctly into Database
I want to Know How could I get ForeignCollection
of json_main table using ormlite using Cursor
.Above is what I have tried .
Any Answer or Suggestion is Highly Appreciated