Active many-to-many relationships for Android

Although this question is about ActiveAndroid, anyone familiar with ORM can probably answer this question.

ActiveAndroid doesn't seem to give you the ability to make many-to-many relationships out of the box. What I found while searching for a solution was a GitHub issue: https://github.com/pardom/ActiveAndroid/issues/46

I understand that he explicitly creates a relationship table, but I donโ€™t understand how the following part should do something useful:

public List<Foo> foos() { return getMany(Foo.class, "FooBar"); } public List<Bar> bars() { return getMany(Bar.class, "FooBar"); } 

This will result in a query like SELECT * FROM Foo where Foo.FooBar = FooBar.Id; . This will return no more than one row of Foo . Did I miss something?

You do not need a connection request?

+8
android sql activeandroid
source share
1 answer

Suppose you want to select all the Foos for one particular bar, you would do this:

 List<Foo> foos = ((Foo) new Select().from(FooBar.class) .where("Foo = ?", this.getId()) .executeSingle()).foos(); 
+4
source share

All Articles