永続的な SQLite データベース用に Android アプリで DroidDao を使用しています。
私は接続テーブルを持っています:
PART_ID
GPS_ID
SAND_ID
このライブラリの 2 つの関数に問題があります。
/**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;
}
と:
/**List items by 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;
}
私は両方を次のように使用します。
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);
これらの関数は両方とも、PART_ID、GPS_ID、および SAND_ID に対して 0 を返します。関数が NULL を返すはずの場所に間違った ID を挿入しても、ゼロのオブジェクトが返されます。
何か案は?