Realm Android Nested Query -
given below classes , relationships, need realmresults < model1 > satisfies following requirements:
model1
int id realmlist<model2>
model2
int id int model1fk int type realmlist<model3>
model3
int model2fk
i want query model1 entities that, specific model2 related instance type, model2 instance has @ least 1 model3 related instance.
in sql (haven't tested it):
select distinct model1.* model1 model1 join model2 model2 on model2.model1fk = model1.id join model3 model3 on model3.model2fk = model2.id model2.type = 'some type'
are these models stored in sqlite database in android or plain java objects?
if native objects, have reference directly. e.g.
class model1 { int id; realmlist<model2> list; } class model2 { int id; int type; model1 parent; }
you build hashmap you. depending on how these objects exist in android 1 can come strategy.
Comments
Post a Comment