Skip to content Skip to sidebar Skip to footer

Greendao Many To Many Relation

I use Greendao for my database mapping in Android. So far everything works great. But now I have the following problem: I have a Cluster and leaf Objects. A cluster contains many

Solution 1:

Let's start with a quote from the docs:

While greenDAO does not support n:m relations directly as of now, you can model the join table as a separate entity. In practice, you often have “relation entities” with additional properties, so you might want to do so anyway. In future releases, greenDAO might introduce direct support of n:m relations.

So, in your case you have to model an entity, that is between Cluster and Leaf. Let's call this entity ClusterLeaf. To query leafs for a cluster efficiently, I'd suggest raw queries because the QueryBuilder does not support joins yet.

Post a Comment for "Greendao Many To Many Relation"