greenrobot / greenDAO

greenDAO is a light & fast ORM solution for Android that maps objects to SQLite databases.
http://greenrobot.org/greendao/
12.63k stars 2.89k forks source link

There's no value be returned with method 'update' & 'delete' #335

Open sandking opened 8 years ago

sandking commented 8 years ago

I want to get the number of rows affected by the sql statement execution. But i can't get the result in

greenDao where i do 'update' and 'delete'.

I search the source code , found that:

There are two method in SQLiteStatement ,they are executeUpdateDelete and execute.

executeUpdateDelete :

public int executeUpdateDelete() {
    acquireReference();
    try {
        return getSession().executeForChangedRowCount(
                getSql(), getBindArgs(), getConnectionFlags(), null);
    } catch (SQLiteDatabaseCorruptException ex) {
        onCorruption();
        throw ex;
    } finally {
        releaseReference();
    }
}

execute :

public void execute() {
    acquireReference();
    try {
        getSession().execute(getSql(), getBindArgs(), getConnectionFlags(), null);
    } catch (SQLiteDatabaseCorruptException ex) {
        onCorruption();
        throw ex;
    } finally {
        releaseReference();
    }
}

The source code in android used the executeUpdateDelete and then i can get the number.

But in greenDao , I can't .

Without the number ,i can't get the correct result for this sql statement execution.

greenrobot commented 8 years ago

This requires API level 11- http://developer.android.com/intl/pt-br/reference/android/database/sqlite/SQLiteStatement.html#executeUpdateDelete()