i using ormlite , have object has foreign field.
the said object has getters , setters 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 assumed when call :
object testobject; object2 testobject2; testobject.setforeignfield(testobject2); getdao.update(testobject);
it automatically update testobject
in database new foreignfield's id, table not updating.
what doing wrong?
edit : reading actual documentation on ormlite, update(object)
method not update foreign objects or foreign collections.
http://ormlite.com/javadoc/ormlite-core/com/j256/ormlite/dao/dao.html#update(t)
note: not save changes made foreign objects or foreign collections.
and because of that, how update foreign object on table?
it automatically update testobject in database new foreignfield's id, table not updating.
it should be.
the update(...)
call doesn't compare object database sql update
statement will made. have tried turning on ormlite logging?
if updating object
same id object2 foreignfield
maybe id same? when call testobject.setforeignfield(testobject2)
, testobject2
should have been created in object2
table. needs have appropriate id
field gets stored in object
table.
if provide more details id field values , database has before , after update, may able more.
Comments
Post a Comment