Android DroidDao Database Manager: My code or theirs?
<p>I am using DroidDao in my Android App for a persistent SQLite database.</p>

<p>I have a Connection table:</p>

<pre><code>PART_ID
GPS_ID
SAND_ID
</code></pre>

<p>I am having issues with two functions in this library:</p>

<pre><code>    /**Get an Object by 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; 
    }
</code></pre>

<p>And:</p>

<pre><code>    /**List items by clause*/
    public List&lt;T&gt; getAllbyClause(String clause, String[] clauseArgs, String groupBy, String having, String orderBy) {              
            List&lt;T&gt; objectList = new ArrayList&lt;T&gt;();
            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;
    }
</code></pre>

<p>I use them both like so:</p>

<pre><code>Connection connection = myApp.getDataManager().getConnectionDao().getByClause("PART_ID = ?", new String[]{"44"});
List&lt;Connection&gt; connections = myApp.getDataManager().getConnectionDao().getAllbyClause("PART_ID = ?", new String[]{"44"}, null, null, null);
</code></pre>

<p>Both of these functions return 0's for PART_ID, GPS_ID, and SAND_ID. Even when I insert an ID that is incorrect, where the function should return NULL, it still return an object with zeros.</p>

<p>Any ideas?</p>
