Search in sources :

Example 6 with TypeAdapterByteArray

use of sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray in project kripton by xcesco.

the class EmployeeRawDaoImpl method selectByAllWithAdapter.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, last_name, first_name, birth_date, hire_date, address, field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array FROM employees WHERE id=${id} and field_boolean=${fieldBoolean} and field_byte=${fieldByte} and field_character=${fieldCharacter} and field_short=${fieldShort} and field_integer=${fieldInteger} and field_long=${fieldLong} and field_float=${fieldFloat} and field_double=${fieldDouble} and field_string=${fieldString} and field_byte_array=${fieldByteArray}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>last_name</dt><dd>is associated to bean's property <strong>lastName</strong></dd>
 * 	<dt>first_name</dt><dd>is associated to bean's property <strong>firstName</strong></dd>
 * 	<dt>birth_date</dt><dd>is associated to bean's property <strong>birthDate</strong></dd>
 * 	<dt>hire_date</dt><dd>is associated to bean's property <strong>hireDate</strong></dd>
 * 	<dt>address</dt><dd>is associated to bean's property <strong>address</strong></dd>
 * 	<dt>field_boolean</dt><dd>is associated to bean's property <strong>fieldBoolean</strong></dd>
 * 	<dt>field_byte</dt><dd>is associated to bean's property <strong>fieldByte</strong></dd>
 * 	<dt>field_character</dt><dd>is associated to bean's property <strong>fieldCharacter</strong></dd>
 * 	<dt>field_short</dt><dd>is associated to bean's property <strong>fieldShort</strong></dd>
 * 	<dt>field_integer</dt><dd>is associated to bean's property <strong>fieldInteger</strong></dd>
 * 	<dt>field_long</dt><dd>is associated to bean's property <strong>fieldLong</strong></dd>
 * 	<dt>field_float</dt><dd>is associated to bean's property <strong>fieldFloat</strong></dd>
 * 	<dt>field_double</dt><dd>is associated to bean's property <strong>fieldDouble</strong></dd>
 * 	<dt>field_string</dt><dd>is associated to bean's property <strong>fieldString</strong></dd>
 * 	<dt>field_byte_array</dt><dd>is associated to bean's property <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is binded to method's parameter <strong>id</strong></dd>
 * 	<dt>${fieldBoolean}</dt><dd>is binded to method's parameter <strong>fieldBoolean</strong></dd>
 * 	<dt>${fieldByte}</dt><dd>is binded to method's parameter <strong>fieldByte</strong></dd>
 * 	<dt>${fieldCharacter}</dt><dd>is binded to method's parameter <strong>fieldCharacter</strong></dd>
 * 	<dt>${fieldShort}</dt><dd>is binded to method's parameter <strong>fieldShort</strong></dd>
 * 	<dt>${fieldInteger}</dt><dd>is binded to method's parameter <strong>fieldInteger</strong></dd>
 * 	<dt>${fieldLong}</dt><dd>is binded to method's parameter <strong>fieldLong</strong></dd>
 * 	<dt>${fieldFloat}</dt><dd>is binded to method's parameter <strong>fieldFloat</strong></dd>
 * 	<dt>${fieldDouble}</dt><dd>is binded to method's parameter <strong>fieldDouble</strong></dd>
 * 	<dt>${fieldString}</dt><dd>is binded to method's parameter <strong>fieldString</strong></dd>
 * 	<dt>${fieldByteArray}</dt><dd>is binded to method's parameter <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * @param id
 * 	is binded to <code>${id}</code>
 * @param fieldBoolean
 * 	is binded to <code>${fieldBoolean}</code>
 * @param fieldByte
 * 	is binded to <code>${fieldByte}</code>
 * @param fieldCharacter
 * 	is binded to <code>${fieldCharacter}</code>
 * @param fieldShort
 * 	is binded to <code>${fieldShort}</code>
 * @param fieldInteger
 * 	is binded to <code>${fieldInteger}</code>
 * @param fieldLong
 * 	is binded to <code>${fieldLong}</code>
 * @param fieldFloat
 * 	is binded to <code>${fieldFloat}</code>
 * @param fieldDouble
 * 	is binded to <code>${fieldDouble}</code>
 * @param fieldString
 * 	is binded to <code>${fieldString}</code>
 * @param fieldByteArray
 * 	is binded to <code>${fieldByteArray}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public Employee selectByAllWithAdapter(long id, String fieldBoolean, String fieldByte, String fieldCharacter, String fieldShort, String fieldInteger, String fieldLong, String fieldFloat, String fieldDouble, String fieldString, String fieldByteArray) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ALL_WITH_ADAPTER_SQL3;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(id));
    _contentValues.addWhereArgs((fieldBoolean == null ? "" : fieldBoolean));
    _contentValues.addWhereArgs((fieldByte == null ? "" : fieldByte));
    _contentValues.addWhereArgs((fieldCharacter == null ? "" : fieldCharacter));
    _contentValues.addWhereArgs((fieldShort == null ? "" : fieldShort));
    _contentValues.addWhereArgs((fieldInteger == null ? "" : fieldInteger));
    _contentValues.addWhereArgs((fieldLong == null ? "" : fieldLong));
    _contentValues.addWhereArgs((fieldFloat == null ? "" : fieldFloat));
    _contentValues.addWhereArgs((fieldDouble == null ? "" : fieldDouble));
    _contentValues.addWhereArgs((fieldString == null ? "" : fieldString));
    _contentValues.addWhereArgs((fieldByteArray == null ? "" : fieldByteArray));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        Employee resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("last_name");
            int index2 = _cursor.getColumnIndex("first_name");
            int index3 = _cursor.getColumnIndex("birth_date");
            int index4 = _cursor.getColumnIndex("hire_date");
            int index5 = _cursor.getColumnIndex("address");
            TypeAdapterAddress addressAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterAddress.class);
            int index6 = _cursor.getColumnIndex("field_boolean");
            TypeAdapterBoolean fieldBooleanAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterBoolean.class);
            int index7 = _cursor.getColumnIndex("field_byte");
            TypeAdapterByte fieldByteAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByte.class);
            int index8 = _cursor.getColumnIndex("field_character");
            TypeAdapterChar fieldCharacterAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterChar.class);
            int index9 = _cursor.getColumnIndex("field_short");
            TypeAdapterShort fieldShortAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterShort.class);
            int index10 = _cursor.getColumnIndex("field_integer");
            TypeAdapterInteger fieldIntegerAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterInteger.class);
            int index11 = _cursor.getColumnIndex("field_long");
            TypeAdapterLong fieldLongAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterLong.class);
            int index12 = _cursor.getColumnIndex("field_float");
            TypeAdapterFloat fieldFloatAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterFloat.class);
            int index13 = _cursor.getColumnIndex("field_double");
            TypeAdapterDouble fieldDoubleAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterDouble.class);
            int index14 = _cursor.getColumnIndex("field_string");
            TypeAdapterString fieldStringAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterString.class);
            int index15 = _cursor.getColumnIndex("field_byte_array");
            TypeAdapterByteArray fieldByteArrayAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByteArray.class);
            resultBean = new Employee();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.lastName = _cursor.getString(index1);
            }
            if (!_cursor.isNull(index2)) {
                resultBean.firstName = _cursor.getString(index2);
            }
            if (!_cursor.isNull(index3)) {
                resultBean.birthDate = SQLDateUtils.read(_cursor.getString(index3));
            }
            if (!_cursor.isNull(index4)) {
                resultBean.hireDate = SQLDateUtils.read(_cursor.getString(index4));
            }
            if (!_cursor.isNull(index5)) {
                resultBean.address = addressAdapter.toJava(_cursor.getString(index5));
            }
            if (!_cursor.isNull(index6)) {
                resultBean.fieldBoolean = fieldBooleanAdapter.toJava(_cursor.getInt(index6) == 0 ? false : true);
            }
            if (!_cursor.isNull(index7)) {
                resultBean.fieldByte = fieldByteAdapter.toJava((byte) _cursor.getInt(index7));
            }
            if (!_cursor.isNull(index8)) {
                resultBean.fieldCharacter = fieldCharacterAdapter.toJava((char) _cursor.getInt(index8));
            }
            if (!_cursor.isNull(index9)) {
                resultBean.fieldShort = fieldShortAdapter.toJava(_cursor.getShort(index9));
            }
            if (!_cursor.isNull(index10)) {
                resultBean.fieldInteger = fieldIntegerAdapter.toJava(_cursor.getInt(index10));
            }
            if (!_cursor.isNull(index11)) {
                resultBean.fieldLong = fieldLongAdapter.toJava(_cursor.getLong(index11));
            }
            if (!_cursor.isNull(index12)) {
                resultBean.fieldFloat = fieldFloatAdapter.toJava(_cursor.getFloat(index12));
            }
            if (!_cursor.isNull(index13)) {
                resultBean.fieldDouble = fieldDoubleAdapter.toJava(_cursor.getDouble(index13));
            }
            if (!_cursor.isNull(index14)) {
                resultBean.fieldString = fieldStringAdapter.toJava(_cursor.getString(index14));
            }
            if (!_cursor.isNull(index15)) {
                resultBean.fieldByteArray = fieldByteArrayAdapter.toJava(_cursor.getBlob(index15));
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) TypeAdapterInteger(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterInteger) TypeAdapterChar(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterChar) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString) Cursor(android.database.Cursor) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) Employee(sqlite.feature.typeadapter.kripton180.Employee) TypeAdapterFloat(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterFloat) TypeAdapterBoolean(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterBoolean) TypeAdapterLong(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterLong) TypeAdapterByteArray(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray) TypeAdapterDouble(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterDouble) TypeAdapterAddress(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterAddress) TypeAdapterByte(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)

Example 7 with TypeAdapterByteArray

use of sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray in project kripton by xcesco.

the class EmployeeRawDaoImpl method selectByIdJQL.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, last_name, first_name, birth_date, hire_date, address, field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array FROM employees WHERE id=${id}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>last_name</dt><dd>is associated to bean's property <strong>lastName</strong></dd>
 * 	<dt>first_name</dt><dd>is associated to bean's property <strong>firstName</strong></dd>
 * 	<dt>birth_date</dt><dd>is associated to bean's property <strong>birthDate</strong></dd>
 * 	<dt>hire_date</dt><dd>is associated to bean's property <strong>hireDate</strong></dd>
 * 	<dt>address</dt><dd>is associated to bean's property <strong>address</strong></dd>
 * 	<dt>field_boolean</dt><dd>is associated to bean's property <strong>fieldBoolean</strong></dd>
 * 	<dt>field_byte</dt><dd>is associated to bean's property <strong>fieldByte</strong></dd>
 * 	<dt>field_character</dt><dd>is associated to bean's property <strong>fieldCharacter</strong></dd>
 * 	<dt>field_short</dt><dd>is associated to bean's property <strong>fieldShort</strong></dd>
 * 	<dt>field_integer</dt><dd>is associated to bean's property <strong>fieldInteger</strong></dd>
 * 	<dt>field_long</dt><dd>is associated to bean's property <strong>fieldLong</strong></dd>
 * 	<dt>field_float</dt><dd>is associated to bean's property <strong>fieldFloat</strong></dd>
 * 	<dt>field_double</dt><dd>is associated to bean's property <strong>fieldDouble</strong></dd>
 * 	<dt>field_string</dt><dd>is associated to bean's property <strong>fieldString</strong></dd>
 * 	<dt>field_byte_array</dt><dd>is associated to bean's property <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is binded to method's parameter <strong>id</strong></dd>
 * </dl>
 *
 * @param id
 * 	is binded to <code>${id}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public Employee selectByIdJQL(long id) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ID_J_Q_L_SQL2;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(id));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        Employee resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("last_name");
            int index2 = _cursor.getColumnIndex("first_name");
            int index3 = _cursor.getColumnIndex("birth_date");
            int index4 = _cursor.getColumnIndex("hire_date");
            int index5 = _cursor.getColumnIndex("address");
            TypeAdapterAddress addressAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterAddress.class);
            int index6 = _cursor.getColumnIndex("field_boolean");
            TypeAdapterBoolean fieldBooleanAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterBoolean.class);
            int index7 = _cursor.getColumnIndex("field_byte");
            TypeAdapterByte fieldByteAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByte.class);
            int index8 = _cursor.getColumnIndex("field_character");
            TypeAdapterChar fieldCharacterAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterChar.class);
            int index9 = _cursor.getColumnIndex("field_short");
            TypeAdapterShort fieldShortAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterShort.class);
            int index10 = _cursor.getColumnIndex("field_integer");
            TypeAdapterInteger fieldIntegerAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterInteger.class);
            int index11 = _cursor.getColumnIndex("field_long");
            TypeAdapterLong fieldLongAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterLong.class);
            int index12 = _cursor.getColumnIndex("field_float");
            TypeAdapterFloat fieldFloatAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterFloat.class);
            int index13 = _cursor.getColumnIndex("field_double");
            TypeAdapterDouble fieldDoubleAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterDouble.class);
            int index14 = _cursor.getColumnIndex("field_string");
            TypeAdapterString fieldStringAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterString.class);
            int index15 = _cursor.getColumnIndex("field_byte_array");
            TypeAdapterByteArray fieldByteArrayAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByteArray.class);
            resultBean = new Employee();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.lastName = _cursor.getString(index1);
            }
            if (!_cursor.isNull(index2)) {
                resultBean.firstName = _cursor.getString(index2);
            }
            if (!_cursor.isNull(index3)) {
                resultBean.birthDate = SQLDateUtils.read(_cursor.getString(index3));
            }
            if (!_cursor.isNull(index4)) {
                resultBean.hireDate = SQLDateUtils.read(_cursor.getString(index4));
            }
            if (!_cursor.isNull(index5)) {
                resultBean.address = addressAdapter.toJava(_cursor.getString(index5));
            }
            if (!_cursor.isNull(index6)) {
                resultBean.fieldBoolean = fieldBooleanAdapter.toJava(_cursor.getInt(index6) == 0 ? false : true);
            }
            if (!_cursor.isNull(index7)) {
                resultBean.fieldByte = fieldByteAdapter.toJava((byte) _cursor.getInt(index7));
            }
            if (!_cursor.isNull(index8)) {
                resultBean.fieldCharacter = fieldCharacterAdapter.toJava((char) _cursor.getInt(index8));
            }
            if (!_cursor.isNull(index9)) {
                resultBean.fieldShort = fieldShortAdapter.toJava(_cursor.getShort(index9));
            }
            if (!_cursor.isNull(index10)) {
                resultBean.fieldInteger = fieldIntegerAdapter.toJava(_cursor.getInt(index10));
            }
            if (!_cursor.isNull(index11)) {
                resultBean.fieldLong = fieldLongAdapter.toJava(_cursor.getLong(index11));
            }
            if (!_cursor.isNull(index12)) {
                resultBean.fieldFloat = fieldFloatAdapter.toJava(_cursor.getFloat(index12));
            }
            if (!_cursor.isNull(index13)) {
                resultBean.fieldDouble = fieldDoubleAdapter.toJava(_cursor.getDouble(index13));
            }
            if (!_cursor.isNull(index14)) {
                resultBean.fieldString = fieldStringAdapter.toJava(_cursor.getString(index14));
            }
            if (!_cursor.isNull(index15)) {
                resultBean.fieldByteArray = fieldByteArrayAdapter.toJava(_cursor.getBlob(index15));
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) TypeAdapterInteger(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterInteger) TypeAdapterChar(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterChar) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString) Cursor(android.database.Cursor) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) Employee(sqlite.feature.typeadapter.kripton180.Employee) TypeAdapterFloat(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterFloat) TypeAdapterBoolean(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterBoolean) TypeAdapterLong(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterLong) TypeAdapterByteArray(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray) TypeAdapterDouble(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterDouble) TypeAdapterAddress(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterAddress) TypeAdapterByte(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)

Example 8 with TypeAdapterByteArray

use of sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray in project kripton by xcesco.

the class EmployeeRawDaoImpl method selectByAll.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, last_name, first_name, birth_date, hire_date, address, field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array FROM employees WHERE id=${id} and field_boolean=${fieldBoolean} and field_byte=${fieldByte} and field_character=${fieldCharacter} and field_short=${fieldShort} and field_integer=${fieldInteger} and field_long=${fieldLong} and field_float=${fieldFloat} and field_double=${fieldDouble} and field_string=${fieldString} and field_byte_array=${fieldByteArray}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>last_name</dt><dd>is associated to bean's property <strong>lastName</strong></dd>
 * 	<dt>first_name</dt><dd>is associated to bean's property <strong>firstName</strong></dd>
 * 	<dt>birth_date</dt><dd>is associated to bean's property <strong>birthDate</strong></dd>
 * 	<dt>hire_date</dt><dd>is associated to bean's property <strong>hireDate</strong></dd>
 * 	<dt>address</dt><dd>is associated to bean's property <strong>address</strong></dd>
 * 	<dt>field_boolean</dt><dd>is associated to bean's property <strong>fieldBoolean</strong></dd>
 * 	<dt>field_byte</dt><dd>is associated to bean's property <strong>fieldByte</strong></dd>
 * 	<dt>field_character</dt><dd>is associated to bean's property <strong>fieldCharacter</strong></dd>
 * 	<dt>field_short</dt><dd>is associated to bean's property <strong>fieldShort</strong></dd>
 * 	<dt>field_integer</dt><dd>is associated to bean's property <strong>fieldInteger</strong></dd>
 * 	<dt>field_long</dt><dd>is associated to bean's property <strong>fieldLong</strong></dd>
 * 	<dt>field_float</dt><dd>is associated to bean's property <strong>fieldFloat</strong></dd>
 * 	<dt>field_double</dt><dd>is associated to bean's property <strong>fieldDouble</strong></dd>
 * 	<dt>field_string</dt><dd>is associated to bean's property <strong>fieldString</strong></dd>
 * 	<dt>field_byte_array</dt><dd>is associated to bean's property <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is binded to method's parameter <strong>id</strong></dd>
 * 	<dt>${fieldBoolean}</dt><dd>is binded to method's parameter <strong>fieldBoolean</strong></dd>
 * 	<dt>${fieldByte}</dt><dd>is binded to method's parameter <strong>fieldByte</strong></dd>
 * 	<dt>${fieldCharacter}</dt><dd>is binded to method's parameter <strong>fieldCharacter</strong></dd>
 * 	<dt>${fieldShort}</dt><dd>is binded to method's parameter <strong>fieldShort</strong></dd>
 * 	<dt>${fieldInteger}</dt><dd>is binded to method's parameter <strong>fieldInteger</strong></dd>
 * 	<dt>${fieldLong}</dt><dd>is binded to method's parameter <strong>fieldLong</strong></dd>
 * 	<dt>${fieldFloat}</dt><dd>is binded to method's parameter <strong>fieldFloat</strong></dd>
 * 	<dt>${fieldDouble}</dt><dd>is binded to method's parameter <strong>fieldDouble</strong></dd>
 * 	<dt>${fieldString}</dt><dd>is binded to method's parameter <strong>fieldString</strong></dd>
 * 	<dt>${fieldByteArray}</dt><dd>is binded to method's parameter <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * @param id
 * 	is binded to <code>${id}</code>
 * @param fieldBoolean
 * 	is binded to <code>${fieldBoolean}</code>
 * @param fieldByte
 * 	is binded to <code>${fieldByte}</code>
 * @param fieldCharacter
 * 	is binded to <code>${fieldCharacter}</code>
 * @param fieldShort
 * 	is binded to <code>${fieldShort}</code>
 * @param fieldInteger
 * 	is binded to <code>${fieldInteger}</code>
 * @param fieldLong
 * 	is binded to <code>${fieldLong}</code>
 * @param fieldFloat
 * 	is binded to <code>${fieldFloat}</code>
 * @param fieldDouble
 * 	is binded to <code>${fieldDouble}</code>
 * @param fieldString
 * 	is binded to <code>${fieldString}</code>
 * @param fieldByteArray
 * 	is binded to <code>${fieldByteArray}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public Employee selectByAll(long id, String fieldBoolean, String fieldByte, String fieldCharacter, String fieldShort, String fieldInteger, String fieldLong, String fieldFloat, String fieldDouble, String fieldString, String fieldByteArray) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ALL_SQL4;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(id));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterBoolean.class, fieldBoolean));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterByte.class, fieldByte));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterChar.class, fieldCharacter));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterShort.class, fieldShort));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterInteger.class, fieldInteger));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterLong.class, fieldLong));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterFloat.class, fieldFloat));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterDouble.class, fieldDouble));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterString.class, fieldString));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterByteArray.class, fieldByteArray));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        Employee resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("last_name");
            int index2 = _cursor.getColumnIndex("first_name");
            int index3 = _cursor.getColumnIndex("birth_date");
            int index4 = _cursor.getColumnIndex("hire_date");
            int index5 = _cursor.getColumnIndex("address");
            TypeAdapterAddress addressAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterAddress.class);
            int index6 = _cursor.getColumnIndex("field_boolean");
            TypeAdapterBoolean fieldBooleanAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterBoolean.class);
            int index7 = _cursor.getColumnIndex("field_byte");
            TypeAdapterByte fieldByteAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByte.class);
            int index8 = _cursor.getColumnIndex("field_character");
            TypeAdapterChar fieldCharacterAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterChar.class);
            int index9 = _cursor.getColumnIndex("field_short");
            TypeAdapterShort fieldShortAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterShort.class);
            int index10 = _cursor.getColumnIndex("field_integer");
            TypeAdapterInteger fieldIntegerAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterInteger.class);
            int index11 = _cursor.getColumnIndex("field_long");
            TypeAdapterLong fieldLongAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterLong.class);
            int index12 = _cursor.getColumnIndex("field_float");
            TypeAdapterFloat fieldFloatAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterFloat.class);
            int index13 = _cursor.getColumnIndex("field_double");
            TypeAdapterDouble fieldDoubleAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterDouble.class);
            int index14 = _cursor.getColumnIndex("field_string");
            TypeAdapterString fieldStringAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterString.class);
            int index15 = _cursor.getColumnIndex("field_byte_array");
            TypeAdapterByteArray fieldByteArrayAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByteArray.class);
            resultBean = new Employee();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.lastName = _cursor.getString(index1);
            }
            if (!_cursor.isNull(index2)) {
                resultBean.firstName = _cursor.getString(index2);
            }
            if (!_cursor.isNull(index3)) {
                resultBean.birthDate = SQLDateUtils.read(_cursor.getString(index3));
            }
            if (!_cursor.isNull(index4)) {
                resultBean.hireDate = SQLDateUtils.read(_cursor.getString(index4));
            }
            if (!_cursor.isNull(index5)) {
                resultBean.address = addressAdapter.toJava(_cursor.getString(index5));
            }
            if (!_cursor.isNull(index6)) {
                resultBean.fieldBoolean = fieldBooleanAdapter.toJava(_cursor.getInt(index6) == 0 ? false : true);
            }
            if (!_cursor.isNull(index7)) {
                resultBean.fieldByte = fieldByteAdapter.toJava((byte) _cursor.getInt(index7));
            }
            if (!_cursor.isNull(index8)) {
                resultBean.fieldCharacter = fieldCharacterAdapter.toJava((char) _cursor.getInt(index8));
            }
            if (!_cursor.isNull(index9)) {
                resultBean.fieldShort = fieldShortAdapter.toJava(_cursor.getShort(index9));
            }
            if (!_cursor.isNull(index10)) {
                resultBean.fieldInteger = fieldIntegerAdapter.toJava(_cursor.getInt(index10));
            }
            if (!_cursor.isNull(index11)) {
                resultBean.fieldLong = fieldLongAdapter.toJava(_cursor.getLong(index11));
            }
            if (!_cursor.isNull(index12)) {
                resultBean.fieldFloat = fieldFloatAdapter.toJava(_cursor.getFloat(index12));
            }
            if (!_cursor.isNull(index13)) {
                resultBean.fieldDouble = fieldDoubleAdapter.toJava(_cursor.getDouble(index13));
            }
            if (!_cursor.isNull(index14)) {
                resultBean.fieldString = fieldStringAdapter.toJava(_cursor.getString(index14));
            }
            if (!_cursor.isNull(index15)) {
                resultBean.fieldByteArray = fieldByteArrayAdapter.toJava(_cursor.getBlob(index15));
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) TypeAdapterInteger(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterInteger) TypeAdapterChar(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterChar) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString) Cursor(android.database.Cursor) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) TypeAdapterFloat(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterFloat) Employee(sqlite.feature.typeadapter.kripton180.Employee) TypeAdapterBoolean(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterBoolean) TypeAdapterLong(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterLong) TypeAdapterByteArray(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray) TypeAdapterDouble(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterDouble) TypeAdapterAddress(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterAddress) TypeAdapterByte(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)

Example 9 with TypeAdapterByteArray

use of sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray in project kripton by xcesco.

the class EmployeeRawDaoImpl method selectByAllJQLWithAdapter.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, last_name, first_name, birth_date, hire_date, address, field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array FROM employees WHERE id=${id} and field_boolean=${fieldBoolean} and field_byte=${fieldByte} and field_byte=${fieldByte} and field_character=${fieldCharacter} and field_short=${fieldShort} and field_integer=${fieldInteger} and field_long=${fieldLong} and field_float=${fieldFloat} and field_double=${fieldDouble} and field_string=${fieldString} and field_byte_array=${fieldByteArray}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>last_name</dt><dd>is associated to bean's property <strong>lastName</strong></dd>
 * 	<dt>first_name</dt><dd>is associated to bean's property <strong>firstName</strong></dd>
 * 	<dt>birth_date</dt><dd>is associated to bean's property <strong>birthDate</strong></dd>
 * 	<dt>hire_date</dt><dd>is associated to bean's property <strong>hireDate</strong></dd>
 * 	<dt>address</dt><dd>is associated to bean's property <strong>address</strong></dd>
 * 	<dt>field_boolean</dt><dd>is associated to bean's property <strong>fieldBoolean</strong></dd>
 * 	<dt>field_byte</dt><dd>is associated to bean's property <strong>fieldByte</strong></dd>
 * 	<dt>field_character</dt><dd>is associated to bean's property <strong>fieldCharacter</strong></dd>
 * 	<dt>field_short</dt><dd>is associated to bean's property <strong>fieldShort</strong></dd>
 * 	<dt>field_integer</dt><dd>is associated to bean's property <strong>fieldInteger</strong></dd>
 * 	<dt>field_long</dt><dd>is associated to bean's property <strong>fieldLong</strong></dd>
 * 	<dt>field_float</dt><dd>is associated to bean's property <strong>fieldFloat</strong></dd>
 * 	<dt>field_double</dt><dd>is associated to bean's property <strong>fieldDouble</strong></dd>
 * 	<dt>field_string</dt><dd>is associated to bean's property <strong>fieldString</strong></dd>
 * 	<dt>field_byte_array</dt><dd>is associated to bean's property <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is binded to method's parameter <strong>id</strong></dd>
 * 	<dt>${fieldBoolean}</dt><dd>is binded to method's parameter <strong>fieldBoolean</strong></dd>
 * 	<dt>${fieldByte}</dt><dd>is binded to method's parameter <strong>fieldByte</strong></dd>
 * 	<dt>${fieldByte}</dt><dd>is binded to method's parameter <strong>fieldByte</strong></dd>
 * 	<dt>${fieldCharacter}</dt><dd>is binded to method's parameter <strong>fieldCharacter</strong></dd>
 * 	<dt>${fieldShort}</dt><dd>is binded to method's parameter <strong>fieldShort</strong></dd>
 * 	<dt>${fieldInteger}</dt><dd>is binded to method's parameter <strong>fieldInteger</strong></dd>
 * 	<dt>${fieldLong}</dt><dd>is binded to method's parameter <strong>fieldLong</strong></dd>
 * 	<dt>${fieldFloat}</dt><dd>is binded to method's parameter <strong>fieldFloat</strong></dd>
 * 	<dt>${fieldDouble}</dt><dd>is binded to method's parameter <strong>fieldDouble</strong></dd>
 * 	<dt>${fieldString}</dt><dd>is binded to method's parameter <strong>fieldString</strong></dd>
 * 	<dt>${fieldByteArray}</dt><dd>is binded to method's parameter <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * @param id
 * 	is binded to <code>${id}</code>
 * @param fieldBoolean
 * 	is binded to <code>${fieldBoolean}</code>
 * @param fieldByte
 * 	is binded to <code>${fieldByte}</code>
 * @param fieldCharacter
 * 	is binded to <code>${fieldCharacter}</code>
 * @param fieldShort
 * 	is binded to <code>${fieldShort}</code>
 * @param fieldInteger
 * 	is binded to <code>${fieldInteger}</code>
 * @param fieldLong
 * 	is binded to <code>${fieldLong}</code>
 * @param fieldFloat
 * 	is binded to <code>${fieldFloat}</code>
 * @param fieldDouble
 * 	is binded to <code>${fieldDouble}</code>
 * @param fieldString
 * 	is binded to <code>${fieldString}</code>
 * @param fieldByteArray
 * 	is binded to <code>${fieldByteArray}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public Employee selectByAllJQLWithAdapter(long id, String fieldBoolean, String fieldByte, String fieldCharacter, String fieldShort, String fieldInteger, String fieldLong, String fieldFloat, String fieldDouble, String fieldString, String fieldByteArray) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ALL_J_Q_L_WITH_ADAPTER_SQL6;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(id));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterBoolean.class, fieldBoolean));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterByte.class, fieldByte));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterByte.class, fieldByte));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterChar.class, fieldCharacter));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterShort.class, fieldShort));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterInteger.class, fieldInteger));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterLong.class, fieldLong));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterFloat.class, fieldFloat));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterDouble.class, fieldDouble));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterString.class, fieldString));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterByteArray.class, fieldByteArray));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        Employee resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("last_name");
            int index2 = _cursor.getColumnIndex("first_name");
            int index3 = _cursor.getColumnIndex("birth_date");
            int index4 = _cursor.getColumnIndex("hire_date");
            int index5 = _cursor.getColumnIndex("address");
            TypeAdapterAddress addressAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterAddress.class);
            int index6 = _cursor.getColumnIndex("field_boolean");
            TypeAdapterBoolean fieldBooleanAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterBoolean.class);
            int index7 = _cursor.getColumnIndex("field_byte");
            TypeAdapterByte fieldByteAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByte.class);
            int index8 = _cursor.getColumnIndex("field_character");
            TypeAdapterChar fieldCharacterAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterChar.class);
            int index9 = _cursor.getColumnIndex("field_short");
            TypeAdapterShort fieldShortAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterShort.class);
            int index10 = _cursor.getColumnIndex("field_integer");
            TypeAdapterInteger fieldIntegerAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterInteger.class);
            int index11 = _cursor.getColumnIndex("field_long");
            TypeAdapterLong fieldLongAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterLong.class);
            int index12 = _cursor.getColumnIndex("field_float");
            TypeAdapterFloat fieldFloatAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterFloat.class);
            int index13 = _cursor.getColumnIndex("field_double");
            TypeAdapterDouble fieldDoubleAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterDouble.class);
            int index14 = _cursor.getColumnIndex("field_string");
            TypeAdapterString fieldStringAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterString.class);
            int index15 = _cursor.getColumnIndex("field_byte_array");
            TypeAdapterByteArray fieldByteArrayAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByteArray.class);
            resultBean = new Employee();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.lastName = _cursor.getString(index1);
            }
            if (!_cursor.isNull(index2)) {
                resultBean.firstName = _cursor.getString(index2);
            }
            if (!_cursor.isNull(index3)) {
                resultBean.birthDate = SQLDateUtils.read(_cursor.getString(index3));
            }
            if (!_cursor.isNull(index4)) {
                resultBean.hireDate = SQLDateUtils.read(_cursor.getString(index4));
            }
            if (!_cursor.isNull(index5)) {
                resultBean.address = addressAdapter.toJava(_cursor.getString(index5));
            }
            if (!_cursor.isNull(index6)) {
                resultBean.fieldBoolean = fieldBooleanAdapter.toJava(_cursor.getInt(index6) == 0 ? false : true);
            }
            if (!_cursor.isNull(index7)) {
                resultBean.fieldByte = fieldByteAdapter.toJava((byte) _cursor.getInt(index7));
            }
            if (!_cursor.isNull(index8)) {
                resultBean.fieldCharacter = fieldCharacterAdapter.toJava((char) _cursor.getInt(index8));
            }
            if (!_cursor.isNull(index9)) {
                resultBean.fieldShort = fieldShortAdapter.toJava(_cursor.getShort(index9));
            }
            if (!_cursor.isNull(index10)) {
                resultBean.fieldInteger = fieldIntegerAdapter.toJava(_cursor.getInt(index10));
            }
            if (!_cursor.isNull(index11)) {
                resultBean.fieldLong = fieldLongAdapter.toJava(_cursor.getLong(index11));
            }
            if (!_cursor.isNull(index12)) {
                resultBean.fieldFloat = fieldFloatAdapter.toJava(_cursor.getFloat(index12));
            }
            if (!_cursor.isNull(index13)) {
                resultBean.fieldDouble = fieldDoubleAdapter.toJava(_cursor.getDouble(index13));
            }
            if (!_cursor.isNull(index14)) {
                resultBean.fieldString = fieldStringAdapter.toJava(_cursor.getString(index14));
            }
            if (!_cursor.isNull(index15)) {
                resultBean.fieldByteArray = fieldByteArrayAdapter.toJava(_cursor.getBlob(index15));
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) TypeAdapterInteger(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterInteger) TypeAdapterChar(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterChar) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString) Cursor(android.database.Cursor) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) TypeAdapterFloat(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterFloat) Employee(sqlite.feature.typeadapter.kripton180.Employee) TypeAdapterBoolean(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterBoolean) TypeAdapterLong(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterLong) TypeAdapterByteArray(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray) TypeAdapterDouble(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterDouble) TypeAdapterAddress(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterAddress) TypeAdapterByte(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)

Example 10 with TypeAdapterByteArray

use of sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray in project kripton by xcesco.

the class EmployeeRawDaoImpl method selectByAllJQL.

/**
 * <h2>Select SQL:</h2>
 *
 * <pre>SELECT id, last_name, first_name, birth_date, hire_date, address, field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array FROM employees WHERE id=${id} and field_boolean=${fieldBoolean} and field_byte=${fieldByte} and field_byte=${fieldByte} and field_character=${fieldCharacter} and field_short=${fieldShort} and field_integer=${fieldInteger} and field_long=${fieldLong} and field_float=${fieldFloat} and field_double=${fieldDouble} and field_string=${fieldString} and field_byte_array=${fieldByteArray}</pre>
 *
 * <h2>Projected columns:</h2>
 * <dl>
 * 	<dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
 * 	<dt>last_name</dt><dd>is associated to bean's property <strong>lastName</strong></dd>
 * 	<dt>first_name</dt><dd>is associated to bean's property <strong>firstName</strong></dd>
 * 	<dt>birth_date</dt><dd>is associated to bean's property <strong>birthDate</strong></dd>
 * 	<dt>hire_date</dt><dd>is associated to bean's property <strong>hireDate</strong></dd>
 * 	<dt>address</dt><dd>is associated to bean's property <strong>address</strong></dd>
 * 	<dt>field_boolean</dt><dd>is associated to bean's property <strong>fieldBoolean</strong></dd>
 * 	<dt>field_byte</dt><dd>is associated to bean's property <strong>fieldByte</strong></dd>
 * 	<dt>field_character</dt><dd>is associated to bean's property <strong>fieldCharacter</strong></dd>
 * 	<dt>field_short</dt><dd>is associated to bean's property <strong>fieldShort</strong></dd>
 * 	<dt>field_integer</dt><dd>is associated to bean's property <strong>fieldInteger</strong></dd>
 * 	<dt>field_long</dt><dd>is associated to bean's property <strong>fieldLong</strong></dd>
 * 	<dt>field_float</dt><dd>is associated to bean's property <strong>fieldFloat</strong></dd>
 * 	<dt>field_double</dt><dd>is associated to bean's property <strong>fieldDouble</strong></dd>
 * 	<dt>field_string</dt><dd>is associated to bean's property <strong>fieldString</strong></dd>
 * 	<dt>field_byte_array</dt><dd>is associated to bean's property <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * <h2>Query's parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is binded to method's parameter <strong>id</strong></dd>
 * 	<dt>${fieldBoolean}</dt><dd>is binded to method's parameter <strong>fieldBoolean</strong></dd>
 * 	<dt>${fieldByte}</dt><dd>is binded to method's parameter <strong>fieldByte</strong></dd>
 * 	<dt>${fieldByte}</dt><dd>is binded to method's parameter <strong>fieldByte</strong></dd>
 * 	<dt>${fieldCharacter}</dt><dd>is binded to method's parameter <strong>fieldCharacter</strong></dd>
 * 	<dt>${fieldShort}</dt><dd>is binded to method's parameter <strong>fieldShort</strong></dd>
 * 	<dt>${fieldInteger}</dt><dd>is binded to method's parameter <strong>fieldInteger</strong></dd>
 * 	<dt>${fieldLong}</dt><dd>is binded to method's parameter <strong>fieldLong</strong></dd>
 * 	<dt>${fieldFloat}</dt><dd>is binded to method's parameter <strong>fieldFloat</strong></dd>
 * 	<dt>${fieldDouble}</dt><dd>is binded to method's parameter <strong>fieldDouble</strong></dd>
 * 	<dt>${fieldString}</dt><dd>is binded to method's parameter <strong>fieldString</strong></dd>
 * 	<dt>${fieldByteArray}</dt><dd>is binded to method's parameter <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * @param id
 * 	is binded to <code>${id}</code>
 * @param fieldBoolean
 * 	is binded to <code>${fieldBoolean}</code>
 * @param fieldByte
 * 	is binded to <code>${fieldByte}</code>
 * @param fieldCharacter
 * 	is binded to <code>${fieldCharacter}</code>
 * @param fieldShort
 * 	is binded to <code>${fieldShort}</code>
 * @param fieldInteger
 * 	is binded to <code>${fieldInteger}</code>
 * @param fieldLong
 * 	is binded to <code>${fieldLong}</code>
 * @param fieldFloat
 * 	is binded to <code>${fieldFloat}</code>
 * @param fieldDouble
 * 	is binded to <code>${fieldDouble}</code>
 * @param fieldString
 * 	is binded to <code>${fieldString}</code>
 * @param fieldByteArray
 * 	is binded to <code>${fieldByteArray}</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public Employee selectByAllJQL(long id, String fieldBoolean, String fieldByte, String fieldCharacter, String fieldShort, String fieldInteger, String fieldLong, String fieldFloat, String fieldDouble, String fieldString, String fieldByteArray) {
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ALL_J_Q_L_SQL5;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(id));
    _contentValues.addWhereArgs((fieldBoolean == null ? "" : fieldBoolean));
    _contentValues.addWhereArgs((fieldByte == null ? "" : fieldByte));
    _contentValues.addWhereArgs((fieldByte == null ? "" : fieldByte));
    _contentValues.addWhereArgs((fieldCharacter == null ? "" : fieldCharacter));
    _contentValues.addWhereArgs((fieldShort == null ? "" : fieldShort));
    _contentValues.addWhereArgs((fieldInteger == null ? "" : fieldInteger));
    _contentValues.addWhereArgs((fieldLong == null ? "" : fieldLong));
    _contentValues.addWhereArgs((fieldFloat == null ? "" : fieldFloat));
    _contentValues.addWhereArgs((fieldDouble == null ? "" : fieldDouble));
    _contentValues.addWhereArgs((fieldString == null ? "" : fieldString));
    _contentValues.addWhereArgs((fieldByteArray == null ? "" : fieldByteArray));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // manage log
        Logger.info(_sql);
        // log for where parameters -- BEGIN
        int _whereParamCounter = 0;
        for (String _whereParamItem : _contentValues.whereArgs()) {
            Logger.info("==> param%s: '%s'", (_whereParamCounter++), StringUtils.checkSize(_whereParamItem));
        }
    // log for where parameters -- END
    }
    // log section END
    try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        Employee resultBean = null;
        if (_cursor.moveToFirst()) {
            int index0 = _cursor.getColumnIndex("id");
            int index1 = _cursor.getColumnIndex("last_name");
            int index2 = _cursor.getColumnIndex("first_name");
            int index3 = _cursor.getColumnIndex("birth_date");
            int index4 = _cursor.getColumnIndex("hire_date");
            int index5 = _cursor.getColumnIndex("address");
            TypeAdapterAddress addressAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterAddress.class);
            int index6 = _cursor.getColumnIndex("field_boolean");
            TypeAdapterBoolean fieldBooleanAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterBoolean.class);
            int index7 = _cursor.getColumnIndex("field_byte");
            TypeAdapterByte fieldByteAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByte.class);
            int index8 = _cursor.getColumnIndex("field_character");
            TypeAdapterChar fieldCharacterAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterChar.class);
            int index9 = _cursor.getColumnIndex("field_short");
            TypeAdapterShort fieldShortAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterShort.class);
            int index10 = _cursor.getColumnIndex("field_integer");
            TypeAdapterInteger fieldIntegerAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterInteger.class);
            int index11 = _cursor.getColumnIndex("field_long");
            TypeAdapterLong fieldLongAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterLong.class);
            int index12 = _cursor.getColumnIndex("field_float");
            TypeAdapterFloat fieldFloatAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterFloat.class);
            int index13 = _cursor.getColumnIndex("field_double");
            TypeAdapterDouble fieldDoubleAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterDouble.class);
            int index14 = _cursor.getColumnIndex("field_string");
            TypeAdapterString fieldStringAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterString.class);
            int index15 = _cursor.getColumnIndex("field_byte_array");
            TypeAdapterByteArray fieldByteArrayAdapter = SQLTypeAdapterUtils.getAdapter(TypeAdapterByteArray.class);
            resultBean = new Employee();
            resultBean.id = _cursor.getLong(index0);
            if (!_cursor.isNull(index1)) {
                resultBean.lastName = _cursor.getString(index1);
            }
            if (!_cursor.isNull(index2)) {
                resultBean.firstName = _cursor.getString(index2);
            }
            if (!_cursor.isNull(index3)) {
                resultBean.birthDate = SQLDateUtils.read(_cursor.getString(index3));
            }
            if (!_cursor.isNull(index4)) {
                resultBean.hireDate = SQLDateUtils.read(_cursor.getString(index4));
            }
            if (!_cursor.isNull(index5)) {
                resultBean.address = addressAdapter.toJava(_cursor.getString(index5));
            }
            if (!_cursor.isNull(index6)) {
                resultBean.fieldBoolean = fieldBooleanAdapter.toJava(_cursor.getInt(index6) == 0 ? false : true);
            }
            if (!_cursor.isNull(index7)) {
                resultBean.fieldByte = fieldByteAdapter.toJava((byte) _cursor.getInt(index7));
            }
            if (!_cursor.isNull(index8)) {
                resultBean.fieldCharacter = fieldCharacterAdapter.toJava((char) _cursor.getInt(index8));
            }
            if (!_cursor.isNull(index9)) {
                resultBean.fieldShort = fieldShortAdapter.toJava(_cursor.getShort(index9));
            }
            if (!_cursor.isNull(index10)) {
                resultBean.fieldInteger = fieldIntegerAdapter.toJava(_cursor.getInt(index10));
            }
            if (!_cursor.isNull(index11)) {
                resultBean.fieldLong = fieldLongAdapter.toJava(_cursor.getLong(index11));
            }
            if (!_cursor.isNull(index12)) {
                resultBean.fieldFloat = fieldFloatAdapter.toJava(_cursor.getFloat(index12));
            }
            if (!_cursor.isNull(index13)) {
                resultBean.fieldDouble = fieldDoubleAdapter.toJava(_cursor.getDouble(index13));
            }
            if (!_cursor.isNull(index14)) {
                resultBean.fieldString = fieldStringAdapter.toJava(_cursor.getString(index14));
            }
            if (!_cursor.isNull(index15)) {
                resultBean.fieldByteArray = fieldByteArrayAdapter.toJava(_cursor.getBlob(index15));
            }
        }
        return resultBean;
    }
}
Also used : KriptonContentValues(com.abubusoft.kripton.android.sqlite.KriptonContentValues) TypeAdapterInteger(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterInteger) TypeAdapterChar(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterChar) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString) Cursor(android.database.Cursor) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) Employee(sqlite.feature.typeadapter.kripton180.Employee) TypeAdapterFloat(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterFloat) TypeAdapterBoolean(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterBoolean) TypeAdapterLong(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterLong) TypeAdapterByteArray(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray) TypeAdapterDouble(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterDouble) TypeAdapterAddress(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterAddress) TypeAdapterByte(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)

Aggregations

Cursor (android.database.Cursor)10 KriptonContentValues (com.abubusoft.kripton.android.sqlite.KriptonContentValues)10 Employee (sqlite.feature.typeadapter.kripton180.Employee)10 TypeAdapterAddress (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterAddress)10 TypeAdapterBoolean (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterBoolean)10 TypeAdapterByte (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte)10 TypeAdapterByteArray (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray)10 TypeAdapterChar (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterChar)10 TypeAdapterDouble (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterDouble)10 TypeAdapterFloat (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterFloat)10 TypeAdapterInteger (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterInteger)10 TypeAdapterLong (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterLong)10 TypeAdapterShort (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort)10 TypeAdapterString (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)10