android - Get list from database using ActiveAndroid -


new activeandroid (and overall android database). read documentation, have 1 problem.

i have route.class , latlngposition.class. route made of more latlngposition nodes.

so implementation is:

@table(name="route") public class route extends model {  @column(name="name") private string name; @column(name="time") private mytime time;   public route(string name, mytime time) {     super();     this.name = name;     this.time = time; }  public route(){     super(); }  public list<latlngposition> getlatlnglist(){     return getmany(latlngposition.class, "route"); } ... } 

and latlngposition class:

@table(name="latlng") public class latlngposition extends model { @column(name = "latitude") double latitude; @column(name = "longitude") double longitude; @column(name = "route", onupdate = column.foreignkeyaction.cascade, ondelete = column.foreignkeyaction.cascade) route route;  public latlngposition(double latitude, double longitude, route route) {     super();     this.latitude = latitude;     this.longitude = longitude;     this.route = route; } public latlngposition(){     super(); } ... } 

i save data test if works:

route1 = new route("first", new mytime(1,1,10,10)); latlngposition pos1 = new latlngposition(10,10, route1); latlngposition pos2 = new latlngposition(10,15, route1); pos1.save(); pos2.save(); route1.save(); 

and why trying database:

route route = route.load(route.class, 1); 

i can call route.getname(), , return name properly. when call route.getlatlnglist(), nothing, size of list 0.

why don't work? implementing right way 1-n relation?

this may seem bit dumb but... have tried saving (inserting) route before using other class? i'm guessing when insert it's when class gets id used foreign key in other classes.

route1 = new route("first", new mytime(1,1,10,10)); route1.save(); latlngposition pos1 = new latlngposition(10,10, route1); latlngposition pos2 = new latlngposition(10,15, route1); pos1.save(); pos2.save(); on side note: realize model couldn't have intersecting routes, you?


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -