java - ORMLite: Foreign collection class does not contain a foreign field of class exception -


i'm trying understand little bit orm tools android persistence sqllite, decided write little test application. however, can't seem figure out. seem have done in account, orders example ormlite docs. however, keep getting same error:

foreign collection class com.example.dataobjects.locationobject field 'locations' column-name not contain foreign field of class com.example.dataobjects.tripobject

i'm trying make one-to-many relationship between locationobject , tripobject (one tripobject has many locationobjects)

locationobject:

@databasetable public class locationobject {  private static final string trip_id_field_name = "trip_id";  @databasefield(generatedid = true) private int id;  @databasefield private double latitude;  @databasefield private double longitude;  @databasefield(foreign = true, foreignautorefresh = true, columnname = trip_id_field_name) private tripobject trip;   public locationobject() {  }  public locationobject(tripobject trip, double latitude, double longitude) {     this.trip = trip;     this.latitude = latitude;     this.longitude = longitude; }   @override public string tostring() {     return "locationobject [id=" + id + ", latitude=" + latitude             + ", longitude=" + longitude + "]"; }  } 

tripobject:

@databasetable public class tripobject {  @databasefield(generatedid = true) private int id;  @databasefield private string description;  @databasefield private date createdat;  @databasefield private int noofpotholes;  @databasefield private int noofspeedbumps;  @foreigncollectionfield private foreigncollection<locationobject> locations;  public tripobject() {  }  public tripobject(string description, date createdat, int noofpotholes,         int noofspeedbumps) {     super();     this.description = description;     this.createdat = createdat;     this.noofpotholes = noofpotholes;     this.noofspeedbumps = noofspeedbumps;     this.createdat = new date(); }  public foreigncollection<locationobject> getlocations() {     return this.locations; }   @override public string tostring() {     return "tripobject [id=" + id + ", description=" + description             + ", createdat=" + createdat + ", noofpotholes=" +                   noofpotholes             + ", noofspeedbumps=" + noofspeedbumps + ", locations="             + locations + "]"; }  } 

what want test inserts , queries understand how tool works, seem stuck.

adding in activity:

private databasehelper dbhelper;  private void testaddretrieve() throws sqlexception {     dbhelper = openhelpermanager.gethelper(this, databasehelper.class);      runtimeexceptiondao<tripobject, integer> tripdao = dbhelper.gettripruntimeexceptiondao();     runtimeexceptiondao<locationobject, integer> locationdao = dbhelper.getlocationruntimeexceptiondao();       tripobject trip = new tripobject("test trip 1", new date(), 12, 2);     tripdao.create(trip);      tripobject queriedtrip = tripdao.querybuilder().where().eq("id", 1).queryforfirst();       toast.maketext(this,"trip added: " + queriedtrip.tostring(), toast.length_long).show();     system.out.println("trip added: " + queriedtrip.tostring());       // add     locationdao.create(new locationobject(trip, 25.5,32.4));     locationdao.create(new locationobject(trip, 23.5,41.4));     locationdao.create(new locationobject(trip, 12.5,34.4));      // query     list<locationobject> locations = locationdao.queryforall();      toast.maketext(this, "locations retrieved: " + locations.tostring(), toast.length_long).show();     system.out.println("locations retrieved: " + locations.tostring());      openhelpermanager.releasehelper(); } 


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -