I am using Ormlite and I have an object that has a foreign field.
The said object also has getters and setters for it's fields.
public class Object {
@DatabaseField(foreign = true)
private Object2 foreignField;
Object() {
}
public Object2 getForeignField(){ return foreignField; }
public void setForeignField(Object2 foreignField){
this.foreignField = foreignField;
}
}
So I assumed that when I call :
Object testObject;
Object2 testObject2;
testObject.setForeignField(testObject2);
getDao.update(testObject);
It will automatically update the testObject
in the database with the new foreignfield's id, but my table is not updating.
What am I doing wrong?
EDIT : By reading the actual documentation on Ormlite, the update(Object)
method will not update any foreign objects or foreign collections.
NOTE: This will not save changes made to foreign objects or to foreign collections.
And now because of that, how do I update a foreign object on a table?
Aucun commentaire:
Enregistrer un commentaire