Please help me,
I need custom primary key name and relationship.
My Models:
@Table(name = "Items", id = "ItemId")
public class Item extends Model {
@Column(name = "Name")
public String name;
@Column(name = "Category")
public Category category;
public Item() {
super();
}
public Item(String name, Category category) {
super();
this.name = name;
this.category = category;
}
}
@Table(name = "Categories")
public class Category extends Model {
@Column(name = "Name")
public String name;
public List<Item> items() {
return getMany(Item.class, "Category");
}
}
and my code:
List items = new Select().from(Item.class).execute();
Toast.makeText(this, items.get(0).name, Toast.LENGTH_LONG).show();
Result: Error: Invalid index 0, size is 0
I have modified primary key name on model and db from ItemId to Id:
@Table(name = "Items")
Result: OK
How do I fix this problem?
I've find the problem
please edit Model.java in com.activeandroid Line 260