java - Problems with one-to-one, one-to-many and multithreading in Android (GreenDAO) -


good day. i'm new in using greendao, problems may seem silly you.

i'm working on project contact server , save responses database through greendao. requests server made through service runs in separate thread. so, problem when put data in database in service well. but, when try them out of database through presenter of activity, fields annotation @toone or @tomany in responsenetermin = null. put logs in end of post, can helps understand problem here of entities:

@entity(active = true)  public class responseethermine implements iresponse, serializable {      @id(autoincrement = true)     private long id;      @serializedname("address")     @expose     private string address;      private long workersid;     @serializedname("workers")     @expose     @toone(joinproperty = "workersid")     private workersethermine workers;     @serializedname("unpaid")     @expose     private long unpaid;      @serializedname("rounds")     @expose     @tomany(referencedjoinproperty = "responseid")     private list<roundethermine> rounds;      private long settingsid;     @serializedname("settings")     @expose     @toone(joinproperty = "settingsid")     private settingsethermine settings;     @serializedname("hashrate")     @expose     private string hashrate;     @serializedname("avghashrate")     @expose     private double avghashrate;     @serializedname("reportedhashrate")     @expose     private string reportedhashrate;      private long minerstatsid;     @serializedname("minerstats")     @expose     @toone(joinproperty = "minerstatsid")     private minerstatsethermine minerstats;     @serializedname("ethpermin")     @expose     private double ethpermin;     @serializedname("usdpermin")     @expose     private double usdpermin;     @serializedname("btcpermin")     @expose     private double btcpermin; }  @entity(active = true)  public class settingsethermine implements serializable{      @id(autoincrement = true)     private long id;      @serializedname("miner")     @expose     private string miner;     @serializedname("email")     @expose     private string email;     @serializedname("monitor")     @expose     private long monitor;     @serializedname("minpayout")     @expose     private long minpayout;      private final static long serialversionuid = 1164269290012137915l; }  @entity(active = true)  public class workersethermine implements serializable{      @id(autoincrement = true)     private long id;      @expose     @tomany(referencedjoinproperty = "workersid")     private list<workerethermine> workersethermine;      private final static long serialversionuid = 2224269290012137915l; }  @entity(active = true)  public class workerethermine implements itemsrecyclerview, serializable {      @id(autoincrement = true)     private long id;      @serializedname("worker")     @expose     private string worker;     @serializedname("hashrate")     @expose     private string hashrate;     @serializedname("reportedhashrate")     @expose     private string reportedhashrate;     @serializedname("validshares")     @expose     private long validshares;     @serializedname("invalidshares")     @expose     private long invalidshares;     @serializedname("staleshares")     @expose     private long staleshares;     @serializedname("workerlastsubmittime")     @expose     private long workerlastsubmittime;     @serializedname("invalidshareratio")     @expose     private long invalidshareratio;      private long workersid;      private final static long serialversionuid = -5303263359818635190l; } 

the service stores data in database this:

databasehelper databasehelper = databasehelper.getinstance(); for(responseethermine response : lastresponsesethermine) {             databasehelper.putresponseetherminetodatabase(response);         } 

and check result of this:

log.d(log_tag, "test. after adding database. list of responses database: "); responseethermine> list = databasehelper.getlastresponsesethermine(); for(responseethermine response : list)             response.checkresponse(); 

as can see it's checking of data of object.

public void checkresponse(){         string log_tag = "my_log " + responseethermine.class.getsimplename();         log.d(log_tag, "id = " + id + ",\n"                 + "address = " + address + ",\n"                 + "unpaid = " + unpaid + ",\n"                 + "settings = " + settings + ",\n"                 + "hashrate = " + hashrate + ",\n"                 + "avghashrate = " + avghashrate + ",\n"                 + "workers = " + workers + ",\n"                 + "rounds = " + rounds + ",\n"                 + "minerstats = " + minerstats);     } 

here logs can helps understand problems.

myservice: test. before adding database responses looks like:  service d/my_log responseethermine: id = null,                     address = 8f7ae5c3883f1079a8c3280ef97aabdd5e9a7960,                                         unpaid = 49120026614693020,                     settings = com.example.denis.miningproject20.models.ethermine.settingsethermine@52e3650,                     hashrate = 31.9 gh/s,                     avghashrate = 3.1756177469135803e10,                     workers = com.example.denis.miningproject20.models.ethermine.workersethermine@b19b049,                     rounds = [com.example.denis.miningproject20.models.ethermine.roundethermine@f1c7d4e, ...  service d/my_log responseethermine: id = null,                     address = de088812a9c5005b0dc8447b37193c9e8b67a1ff,                     unpaid = 0,                                         settings = com.example.denis.miningproject20.models.ethermine.settingsethermine@2fd922b,                     hashrate = 25.6 gh/s,                     avghashrate = 2.5205229938271606e10,                     workers = com.example.denis.miningproject20.models.ethermine.workersethermine@c28688,                     rounds = [com.example.denis.miningproject20.models.ethermine.roundethermine@d00e821, ... 

then put responses database. , print in logs:

list<responseethermine> list = databasehelper.getlastresponsesethermine();         for(responseethermine response : list)             response.checkresponse(); 

and logs:

service d/my_log: myservice: test. after adding database. list of responses database: service d/my_log responseethermine: id = 12,                     address = 8f7ae5c3883f1079a8c3280ef97aabdd5e9a7960,                     unpaid = 49120026614693020,                                         settings = com.example.denis.miningproject20.models.ethermine.settingsethermine@52e3650,                                         hashrate = 31.9 gh/s,                     avghashrate = 3.1756177469135803e10,                     workers = com.example.denis.miningproject20.models.ethermine.workersethermine@b19b049,                     rounds = [com.example.denis.miningproject20.models.ethermine.roundethermine@f1c7d4e,... service d/my_log responseethermine: id = 13,                     address = de088812a9c5005b0dc8447b37193c9e8b67a1ff,                     unpaid = 0,                     settings = com.example.denis.miningproject20.models.ethermine.settingsethermine@2fd922b,                     hashrate = 25.6 gh/s,                     avghashrate = 2.5205229938271606e10,                     workers = com.example.denis.miningproject20.models.ethermine.workersethermine@c28688,                     rounds = [com.example.denis.miningproject20.models.ethermine.roundethermine@d00e821,... 

at current stage, checked tables settings table, runs, workers , size 0.

logs:

service d/my_log: myservice: test, number of items in settingsethermine: 0 service d/my_log: myservice: test, number of items in roundsethermine: 0 service d/my_log: myservice: test, number of items in workersethermine: 0 

after send message presenter of activity. in presenter use code this:

log.d(log_tag, "this message lastresponsesethermine. number of last responses ethermine: "     + databasehelper.getinstance().getlastresponsesethermine().size()); log.d(log_tag, "number of items in table rounds ethermine: "     + databasehelper.getinstance().getlistofroundsethermine().size()); log.d(log_tag, "rounds ethermine: "     + databasehelper.getinstance().getlastresponsesethermine().get(0).getrounds());  databasehelper.getinstance().getlastresponsesethermine().get(0).checkresponse(); 

and logs:

d/my_log: mainpresenter: message lastresponsesethermine. number of last responses ethermine: 2 d/my_log: mainpresenter: number of items in table rounds ethermine: 0 d/my_log: databasehelper: last responses ethermine. d/my_log responseethermine: id = 12,                 address = 8f7ae5c3883f1079a8c3280ef97aabdd5e9a7960,                                 unpaid = 49120026614693020,                                 settings = null,                                 hashrate = 31.9 gh/s,                                 avghashrate = 3.1756177469135803e10,                                 workers = null,                                 rounds = [],                                 minerstats = null d/my_log responseethermine: id = 13,                 address = de088812a9c5005b0dc8447b37193c9e8b67a1ff,                 unpaid = 0,                                 settings = null,                                 hashrate = 25.6 gh/s,                                 avghashrate = 2.5205229938271606e10,                                 workers = null,                                 rounds = [],                                 minerstats = null d/my_log: mainpresenter: rounds ethermine: [] 

as can see fields annotation @tomany , @toone empty. please me advice or example. thank attention.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -