greenDAO icon indicating copy to clipboard operation
greenDAO copied to clipboard

ToMany Problem

Open ehaahe opened this issue 5 years ago • 1 comments

This is my basic class:

class FamilyBean{
       String memberId;
       String sex;
       String fatherId;
       String motherId;

       List<FamilyBean> children;
}

when sex = man, the value of children's fatherId is parent's memberId , otherwise the value of children's motherId is parent's memberId , how can I define annotation to resolve this problem?

ehaahe avatar Jul 23 '19 03:07 ehaahe

It does not really make sense that male children only have a father and females only a parent?

Anyhow, sounds to me like you want two ToOne relationships of a child to its parents. http://greenrobot.org/greendao/documentation/relations/

-- Check out ObjectBox, our new fast, easy to use database!

greenrobot-team avatar Jul 23 '19 06:07 greenrobot-team