Android ORMLite not setting foreign when saving or not refreshing -
introduction
i have 2 entities :
traitement
@databasetable(tablename = "traitement", daoclass = traitementnettoyagedao.class) public class traitemententity implements parcelable { @databasefield(generatedid = true) private int id; @foreigncollectionfield(eager = true) private collection<anomalienettoyageentity> mlistanomalienettoyage; public traitemententity() { } // omitting getter/setter , parcelable job }
anomalie
@databasetable(tablename = "anomalies", daoclass = anomaliedao.class) public class anomalieentity implements parcelable { @databasefield(generatedid = true) private int id; @databasefield private string midanomalie; @databasefield(foreign = true, columnname = "traitementforeignid", foreignautorefresh = true, canbenull = false) private traitemententity traitementforeign; // omitting getter/setter , parcelable job }
i'm saving traitement in database using :
function void save(traitemententity obj){ (anomalieentity n : obj.getmlistanomalie()) { n.settraitementforeign(obj); } create(obj); }
problem
the problem when need save traitement in local db, seems have nothing :
log.i("object anomalie size", obj.getmlistanomalie().size() + ""); // gives 3 save(obj); list<traitemententity> liste = mservicelocal.getalllocaltraitements(); (traitemententity n : liste) log.i("object anomalie size 2", n.getmlistanomalie().size() + ""); // gives 0 /* getmlisteanomalie() corresponds standard try/catch queryforall(), nothing else */
the traitement saved, not foreign anomalies. it's working partially, , dont know why have behaviour.
can me ?
confirm question.
in traitemententity class not contain getmlistanomalie() method different :
for ( n anomalieentity : obj.getmlistanomalie ())
would not be
for ( anomalienettoyageentity n : obj.mlistanomalienettoyage ()) { n.settraitementforeign ( obj) ; }
other options. load database sqllite in managed, example (sqllite browser) , checking tables populated !
please confirm, test !
Comments
Post a Comment