One to Many Relation
Closed this issue · 4 comments
ChristopheCVB commented
I thought ORMDroid can handle one to many relations as :
public class MyObjet extends Entity
{
// ...
private ArrayList<MyOtherObject> otherObjects;
}
public class MyOtherObject extends Entity
{
// ...
}
but not :
com.roscopeco.ormdroid.TypeMappingException: Model MyObjet has unmappable field: public java.util.ArrayList otherObjects
coolaworld commented
This is how I solved it:
public class ManyEntity extends Entity {
public int id;
public String child_name;
public ParentEntity parent;
public ManyEntity() {
this(null,null);
}
public ManyEntity(String child_name, ParentEntity parent) {
// TODO Auto-generated constructor stub
this.child_name = child_name;
this.parent = parent;
}
}
roscopeco commented
This is currently being worked on, with a new type mapping (for java.util.List) and some other code changes that will support this behaviour. In the meantime, it can be emulated with methods and non-persistent fields.
Queatz commented
+1 Just needed this.
ChristopheCVB commented
@roscopeco Can we actually close this ?