Frage

I'm trying to build self many to many relation for USER table to itself - USER table. The idea is that each user might have some friends users and vice versa.

I'm doing it with a junction function but then when I'm trying to compile it I'm getting the exception:

Exception in thread "main" java.lang.RuntimeException: Duplicate name for ToOne 'User' from UsersJoinFollowedUsers to User

at de.greenrobot.daogenerator.Entity.init3rdPassRelations(Entity.java:559)

at de.greenrobot.daogenerator.Entity.init3ndPass(Entity.java:550)

at de.greenrobot.daogenerator.Schema.init3ndPass(Schema.java:185)

at de.greenrobot.daogenerator.DaoGenerator.generateAll(DaoGenerator.java:94)

at de.greenrobot.daogenerator.DaoGenerator.generateAll(DaoGenerator.java:79)

at de.greenrobot.daogenerator.gentest.CodeGenerator.main(CodeGenerator.java:84)

It happens because the junction function points twice to the same entity - USER:

USER TABLE | JUNCTION_TABLE | USER TABLE

left relation: USER -> JUNCTION -> USER

right relation: USER<- JUNCTION <- USER

So I'm guessing that the question is how to create this kind of self Many-To-Many in GreenDao.

War es hilfreich?

Lösung

The message "Duplicate name for ToOne 'User' from UsersJoinFollowedUsers to User" indicates that this will help you: Multiple toMany relationships to a single table

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top