java - Android DroidDao Database Manager: My code or theirs? -


i using droiddao in android app persistent sqlite database.

i have connection table:

part_id gps_id sand_id 

i having issues 2 functions in library:

    /**get object clause*/     public t getbyclause(string clause, string[] clauseargs) {         t object = null;         cursor cursor = database.query(gettablename(), getarraycolumns(),                              clause, clauseargs, null, null, "1");         if(cursor.movetofirst()){             try {                 object = builddatafromcursor(cursor);             } catch (exception e) {                 e.printstacktrace();             }         }         if(! cursor.isclosed()){             cursor.close();         }                        return object;      } 

and:

    /**list items clause*/     public list<t> getallbyclause(string clause, string[] clauseargs, string groupby, string having, string orderby) {                           list<t> objectlist = new arraylist<t>();             cursor cursor = database.query(gettablename(), getarraycolumns(),                              clause, clauseargs, groupby, having, orderby);             if(cursor.movetofirst()){                     try {                             do{                                     t object = builddatafromcursor(cursor);                                     if(object != null){                                             objectlist.add(object);                                     }                             }                             while(cursor.movetonext());                      } catch (exception e) {                             e.printstacktrace();                     }             }             if(! cursor.isclosed()){                     cursor.close();             }                            return objectlist;     } 

i use them both so:

connection connection = myapp.getdatamanager().getconnectiondao().getbyclause("part_id = ?", new string[]{"44"}); list<connection> connections = myapp.getdatamanager().getconnectiondao().getallbyclause("part_id = ?", new string[]{"44"}, null, null, null); 

both of these functions return 0's part_id, gps_id, , sand_id. when insert id incorrect, function should return null, still return object zeros.

any ideas?

alright, figured out tracing code.

i thought: builddatafromcursor(cursor); function android database import method droiddao.java. issue didn't have setters in connection object builddatafromcursor(cursor); loads data object using setters.

your setter need have follow structure:

column name: part_id  setter: void setpart_id(int value)... 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -