Search in sources :

Example 1 with AndroidCompiledStatement

use of com.j256.ormlite.android.AndroidCompiledStatement in project ormlite-android by j256.

the class AndroidDatabaseConnection method compileStatement.

@Override
public CompiledStatement compileStatement(String statement, StatementType type, FieldType[] argFieldTypes, int resultFlags, boolean cacheStore) {
    // resultFlags argument is not used in Android-land since the {@link Cursor} is bi-directional.
    CompiledStatement stmt = new AndroidCompiledStatement(statement, db, type, cancelQueriesEnabled, cacheStore);
    logger.trace("{}: compiled statement got {}: {}", this, stmt, statement);
    return stmt;
}
Also used : CompiledStatement(com.j256.ormlite.support.CompiledStatement)

Example 2 with AndroidCompiledStatement

use of com.j256.ormlite.android.AndroidCompiledStatement in project ormlite-android by j256.

the class OrmLiteCursorLoader method loadInBackground.

@Override
public Cursor loadInBackground() {
    Cursor cursor;
    try {
        DatabaseConnection connection = dao.getConnectionSource().getReadOnlyConnection(dao.getTableName());
        AndroidCompiledStatement statement = (AndroidCompiledStatement) query.compile(connection, SELECT);
        cursor = statement.getCursor();
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
    // fill the cursor with results
    cursor.getCount();
    return cursor;
}
Also used : SQLException(java.sql.SQLException) DatabaseConnection(com.j256.ormlite.support.DatabaseConnection) AndroidCompiledStatement(com.j256.ormlite.android.AndroidCompiledStatement) Cursor(android.database.Cursor)

Example 3 with AndroidCompiledStatement

use of com.j256.ormlite.android.AndroidCompiledStatement in project ormlite-android by j256.

the class OrmLiteCursorLoader method loadInBackground.

@Override
public Cursor loadInBackground() {
    Cursor cursor;
    try {
        DatabaseConnection connection = dao.getConnectionSource().getReadOnlyConnection(dao.getTableName());
        AndroidCompiledStatement statement = (AndroidCompiledStatement) query.compile(connection, SELECT);
        cursor = statement.getCursor();
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
    // fill the cursor with results
    cursor.getCount();
    return cursor;
}
Also used : SQLException(java.sql.SQLException) DatabaseConnection(com.j256.ormlite.support.DatabaseConnection) AndroidCompiledStatement(com.j256.ormlite.android.AndroidCompiledStatement) Cursor(android.database.Cursor)

Example 4 with AndroidCompiledStatement

use of com.j256.ormlite.android.AndroidCompiledStatement in project ormlite-android-extras by campnic.

the class AndroidBaseDaoImpl method getCursor.

public Cursor getCursor(PreparedQuery<T> query) throws SQLException {
    DatabaseConnection readOnlyConn = connectionSource.getReadOnlyConnection();
    AndroidCompiledStatement stmt = (AndroidCompiledStatement) query.compile(readOnlyConn, StatementBuilder.StatementType.SELECT);
    Cursor base = stmt.getCursor();
    String idColumnName = getTableInfo().getIdField().getColumnName();
    int idColumnIndex = base.getColumnIndex(idColumnName);
    NoIdCursorWrapper wrapper = new NoIdCursorWrapper(base, idColumnIndex);
    return wrapper;
}
Also used : DatabaseConnection(com.j256.ormlite.support.DatabaseConnection) AndroidCompiledStatement(com.j256.ormlite.android.AndroidCompiledStatement) Cursor(android.database.Cursor)

Example 5 with AndroidCompiledStatement

use of com.j256.ormlite.android.AndroidCompiledStatement in project ormlite-android-extras by campnic.

the class AndroidBaseDaoImpl method getCursor.

public Cursor getCursor(PreparedQuery<T> query) throws SQLException {
    DatabaseConnection readOnlyConn = connectionSource.getReadOnlyConnection();
    AndroidCompiledStatement stmt = (AndroidCompiledStatement) query.compile(readOnlyConn, StatementBuilder.StatementType.SELECT);
    Cursor base = stmt.getCursor();
    String idColumnName = getTableInfo().getIdField().getColumnName();
    int idColumnIndex = base.getColumnIndex(idColumnName);
    NoIdCursorWrapper wrapper = new NoIdCursorWrapper(base, idColumnIndex);
    return wrapper;
}
Also used : DatabaseConnection(com.j256.ormlite.support.DatabaseConnection) AndroidCompiledStatement(com.j256.ormlite.android.AndroidCompiledStatement) Cursor(android.database.Cursor)

Aggregations

Cursor (android.database.Cursor)4 AndroidCompiledStatement (com.j256.ormlite.android.AndroidCompiledStatement)4 DatabaseConnection (com.j256.ormlite.support.DatabaseConnection)4 SQLException (java.sql.SQLException)2 CompiledStatement (com.j256.ormlite.support.CompiledStatement)1