Search in sources :

Example 11 with KriptonContentValues

use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.

the class EmployeeBeanDaoImpl method update.

/**
 * <h2>SQL update:</h2>
 * <pre>UPDATE employees SET last_name=:lastName, first_name=:firstName, birth_date=:birthDate, hire_date=:hireDate, address=:address, field_boolean=:fieldBoolean, field_byte=:fieldByte, field_character=:fieldCharacter, field_short=:fieldShort, field_integer=:fieldInteger, field_long=:fieldLong, field_float=:fieldFloat, field_double=:fieldDouble, field_string=:fieldString, field_byte_array=:fieldByteArray WHERE id=${bean.id} and field_byte=${bean.fieldByte} and field_character=${bean.fieldCharacter} and field_short=${bean.fieldShort} and field_integer=${bean.fieldInteger} and field_long=${bean.fieldLong} and field_float=${bean.fieldFloat} and field_double=${bean.fieldDouble} and field_string=${bean.fieldString} and field_byte_array=${bean.fieldByteArray}</pre>
 *
 * <h2>Updated columns:</h2>
 * <dl>
 * 	<dt>last_name</dt><dd>is mapped to <strong>${bean.lastName}</strong></dd>
 * 	<dt>first_name</dt><dd>is mapped to <strong>${bean.firstName}</strong></dd>
 * 	<dt>birth_date</dt><dd>is mapped to <strong>${bean.birthDate}</strong></dd>
 * 	<dt>hire_date</dt><dd>is mapped to <strong>${bean.hireDate}</strong></dd>
 * 	<dt>address</dt><dd>is mapped to <strong>${bean.address}</strong></dd>
 * 	<dt>field_boolean</dt><dd>is mapped to <strong>${bean.fieldBoolean}</strong></dd>
 * 	<dt>field_byte</dt><dd>is mapped to <strong>${bean.fieldByte}</strong></dd>
 * 	<dt>field_character</dt><dd>is mapped to <strong>${bean.fieldCharacter}</strong></dd>
 * 	<dt>field_short</dt><dd>is mapped to <strong>${bean.fieldShort}</strong></dd>
 * 	<dt>field_integer</dt><dd>is mapped to <strong>${bean.fieldInteger}</strong></dd>
 * 	<dt>field_long</dt><dd>is mapped to <strong>${bean.fieldLong}</strong></dd>
 * 	<dt>field_float</dt><dd>is mapped to <strong>${bean.fieldFloat}</strong></dd>
 * 	<dt>field_double</dt><dd>is mapped to <strong>${bean.fieldDouble}</strong></dd>
 * 	<dt>field_string</dt><dd>is mapped to <strong>${bean.fieldString}</strong></dd>
 * 	<dt>field_byte_array</dt><dd>is mapped to <strong>${bean.fieldByteArray}</strong></dd>
 * </dl>
 *
 * <h2>Parameters used in where conditions:</h2>
 * <dl>
 * 	<dt>${bean.id}</dt><dd>is mapped to method's parameter <strong>bean.id</strong></dd>
 * 	<dt>${bean.fieldByte}</dt><dd>is mapped to method's parameter <strong>bean.fieldByte</strong></dd>
 * 	<dt>${bean.fieldCharacter}</dt><dd>is mapped to method's parameter <strong>bean.fieldCharacter</strong></dd>
 * 	<dt>${bean.fieldShort}</dt><dd>is mapped to method's parameter <strong>bean.fieldShort</strong></dd>
 * 	<dt>${bean.fieldInteger}</dt><dd>is mapped to method's parameter <strong>bean.fieldInteger</strong></dd>
 * 	<dt>${bean.fieldLong}</dt><dd>is mapped to method's parameter <strong>bean.fieldLong</strong></dd>
 * 	<dt>${bean.fieldFloat}</dt><dd>is mapped to method's parameter <strong>bean.fieldFloat</strong></dd>
 * 	<dt>${bean.fieldDouble}</dt><dd>is mapped to method's parameter <strong>bean.fieldDouble</strong></dd>
 * 	<dt>${bean.fieldString}</dt><dd>is mapped to method's parameter <strong>bean.fieldString</strong></dd>
 * 	<dt>${bean.fieldByteArray}</dt><dd>is mapped to method's parameter <strong>bean.fieldByteArray</strong></dd>
 * </dl>
 *
 * @param bean
 * 	is used as ${bean}
 *
 * @return number of updated records
 */
@Override
public long update(Employee bean) {
    if (updatePreparedStatement2 == null) {
        // generate static SQL for statement
        String _sql = "UPDATE employees SET 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=? WHERE id=? and field_byte=? and field_character=? and field_short=? and field_integer=? and field_long=? and field_float=? and field_double=? and field_string=? and field_byte_array=?";
        updatePreparedStatement2 = KriptonDatabaseWrapper.compile(_context, _sql);
    }
    KriptonContentValues _contentValues = contentValuesForUpdate(updatePreparedStatement2);
    _contentValues.put("last_name", bean.lastName);
    _contentValues.put("first_name", bean.firstName);
    _contentValues.put("birth_date", SQLDateUtils.write(bean.birthDate));
    _contentValues.put("hire_date", SQLDateUtils.write(bean.hireDate));
    _contentValues.put("address", SQLTypeAdapterUtils.toData(TypeAdapterAddress.class, bean.address));
    _contentValues.put("field_boolean", SQLTypeAdapterUtils.toData(TypeAdapterBoolean.class, bean.fieldBoolean));
    _contentValues.put("field_byte", SQLTypeAdapterUtils.toData(TypeAdapterByte.class, bean.fieldByte));
    _contentValues.put("field_character", SQLTypeAdapterUtils.toData(TypeAdapterChar.class, bean.fieldCharacter));
    _contentValues.put("field_short", SQLTypeAdapterUtils.toData(TypeAdapterShort.class, bean.fieldShort));
    _contentValues.put("field_integer", SQLTypeAdapterUtils.toData(TypeAdapterInteger.class, bean.fieldInteger));
    _contentValues.put("field_long", SQLTypeAdapterUtils.toData(TypeAdapterLong.class, bean.fieldLong));
    _contentValues.put("field_float", SQLTypeAdapterUtils.toData(TypeAdapterFloat.class, bean.fieldFloat));
    _contentValues.put("field_double", SQLTypeAdapterUtils.toData(TypeAdapterDouble.class, bean.fieldDouble));
    _contentValues.put("field_string", SQLTypeAdapterUtils.toData(TypeAdapterString.class, bean.fieldString));
    _contentValues.put("field_byte_array", SQLTypeAdapterUtils.toData(TypeAdapterByteArray.class, bean.fieldByteArray));
    _contentValues.addWhereArgs(String.valueOf(bean.id));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterByte.class, bean.fieldByte));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterChar.class, bean.fieldCharacter));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterShort.class, bean.fieldShort));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterInteger.class, bean.fieldInteger));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterLong.class, bean.fieldLong));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterFloat.class, bean.fieldFloat));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterDouble.class, bean.fieldDouble));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterString.class, bean.fieldString));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterByteArray.class, bean.fieldByteArray));
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // display log
        Logger.info("UPDATE employees SET last_name=:last_name, first_name=:first_name, birth_date=:birth_date, hire_date=:hire_date, address=:address, field_boolean=:field_boolean, field_byte=:field_byte, field_character=:field_character, field_short=:field_short, field_integer=:field_integer, field_long=:field_long, field_float=:field_float, field_double=:field_double, field_string=:field_string, field_byte_array=:field_byte_array WHERE id=? and field_byte=? and field_character=? and field_short=? and field_integer=? and field_long=? and field_float=? and field_double=? and field_string=? and field_byte_array=?");
        // log for content values -- BEGIN
        Triple<String, Object, KriptonContentValues.ParamType> _contentValue;
        for (int i = 0; i < _contentValues.size(); i++) {
            _contentValue = _contentValues.get(i);
            if (_contentValue.value1 == null) {
                Logger.info("==> :%s = <null>", _contentValue.value0);
            } else {
                Logger.info("==> :%s = '%s' (%s)", _contentValue.value0, StringUtils.checkSize(_contentValue.value1), _contentValue.value1.getClass().getCanonicalName());
            }
        }
        // log for content values -- END
        // 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
    int result = KriptonDatabaseWrapper.updateDelete(updatePreparedStatement2, _contentValues);
    return result;
}
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) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) 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 12 with KriptonContentValues

use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.

the class EmployeeBeanInsertSelectDaoImpl method insertJQL.

/**
 * <p>SQL insert:</p>
 * <pre>INSERT INTO employees (field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array) select field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array  from employees where field_boolean=${bean.fieldBoolean} and field_byte=${bean.fieldByte} and field_character=${bean.fieldCharacter} and field_short=${bean.fieldShort} and field_integer=${bean.fieldInteger} and field_long=${bean.fieldLong} and field_float=${bean.fieldFloat} and field_double=${bean.fieldDouble} and field_string=${bean.fieldString} and field_byte_array=${bean.fieldByteArray}</pre>
 *
 * <p><code>bean.id</code> is automatically updated because it is the primary key</p>
 *
 * <p><strong>Inserted columns:</strong></p>
 * <dl>
 * 	<dt>field_boolean</dt><dd>is mapped to <strong>${bean.fieldBoolean}</strong></dd>
 * 	<dt>field_byte</dt><dd>is mapped to <strong>${bean.fieldByte}</strong></dd>
 * 	<dt>field_character</dt><dd>is mapped to <strong>${bean.fieldCharacter}</strong></dd>
 * 	<dt>field_short</dt><dd>is mapped to <strong>${bean.fieldShort}</strong></dd>
 * 	<dt>field_integer</dt><dd>is mapped to <strong>${bean.fieldInteger}</strong></dd>
 * 	<dt>field_long</dt><dd>is mapped to <strong>${bean.fieldLong}</strong></dd>
 * 	<dt>field_float</dt><dd>is mapped to <strong>${bean.fieldFloat}</strong></dd>
 * 	<dt>field_double</dt><dd>is mapped to <strong>${bean.fieldDouble}</strong></dd>
 * 	<dt>field_string</dt><dd>is mapped to <strong>${bean.fieldString}</strong></dd>
 * 	<dt>field_byte_array</dt><dd>is mapped to <strong>${bean.fieldByteArray}</strong></dd>
 * </dl>
 *
 * @param bean
 * 	is mapped to parameter <strong>bean</strong>
 */
@Override
public void insertJQL(Employee bean) {
    KriptonContentValues _contentValues = contentValuesForUpdate();
    _contentValues.put("field_boolean", SQLTypeAdapterUtils.toData(TypeAdapterBoolean.class, bean.fieldBoolean));
    _contentValues.put("field_byte", SQLTypeAdapterUtils.toData(TypeAdapterByte.class, bean.fieldByte));
    _contentValues.put("field_character", SQLTypeAdapterUtils.toData(TypeAdapterChar.class, bean.fieldCharacter));
    _contentValues.put("field_short", SQLTypeAdapterUtils.toData(TypeAdapterShort.class, bean.fieldShort));
    _contentValues.put("field_integer", SQLTypeAdapterUtils.toData(TypeAdapterInteger.class, bean.fieldInteger));
    _contentValues.put("field_long", SQLTypeAdapterUtils.toData(TypeAdapterLong.class, bean.fieldLong));
    _contentValues.put("field_float", SQLTypeAdapterUtils.toData(TypeAdapterFloat.class, bean.fieldFloat));
    _contentValues.put("field_double", SQLTypeAdapterUtils.toData(TypeAdapterDouble.class, bean.fieldDouble));
    _contentValues.put("field_string", SQLTypeAdapterUtils.toData(TypeAdapterString.class, bean.fieldString));
    _contentValues.put("field_byte_array", SQLTypeAdapterUtils.toData(TypeAdapterByteArray.class, bean.fieldByteArray));
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // log for insert -- BEGIN
        Logger.info("INSERT INTO employees (field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array) select field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array  from employees where field_boolean=? and field_byte=? and field_character=? and field_short=? and field_integer=? and field_long=? and field_float=? and field_double=? and field_string=? and field_byte_array=?");
        // log for content values -- BEGIN
        Triple<String, Object, KriptonContentValues.ParamType> _contentValue;
        for (int i = 0; i < _contentValues.size(); i++) {
            _contentValue = _contentValues.get(i);
            if (_contentValue.value1 == null) {
                Logger.info("==> :%s = <null>", _contentValue.value0);
            } else {
                Logger.info("==> :%s = '%s' (%s)", _contentValue.value0, StringUtils.checkSize(_contentValue.value1), _contentValue.value1.getClass().getCanonicalName());
            }
        }
        // log for content values -- END
        // log for insert -- END
        // 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
    // insert operation
    // generate SQL for insert
    String _sql = String.format("INSERT INTO employees (%s) select field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array  from employees where field_boolean=? and field_byte=? and field_character=? and field_short=? and field_integer=? and field_long=? and field_float=? and field_double=? and field_string=? and field_byte_array=?", _contentValues.keyList());
    long result = KriptonDatabaseWrapper.insert(_context, _sql, _contentValues);
    if (result > 0) {
        subject.onNext(SQLiteEvent.createInsert(result));
    }
    bean.id = result;
}
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) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) 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) TypeAdapterByte(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)

Example 13 with KriptonContentValues

use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.

the class EmployeeRawDaoImpl method insert.

/**
 * <h2>SQL insert</h2>
 * <pre>INSERT INTO employees (field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array) VALUES (${fieldBoolean}, ${fieldByte}, ${fieldCharacter}, ${fieldShort}, ${fieldInteger}, ${fieldLong}, ${fieldFloat}, ${fieldDouble}, ${fieldString}, ${fieldByteArray})</pre>
 *
 * <h2>Inserted columns:</strong></h2>
 * <dl>
 * 	<dt>fieldBoolean</dt><dd>is binded to query's parameter <strong>${fieldBoolean}</strong> and method's parameter <strong>fieldBoolean</strong></dd>
 * 	<dt>fieldByte</dt><dd>is binded to query's parameter <strong>${fieldByte}</strong> and method's parameter <strong>fieldByte</strong></dd>
 * 	<dt>fieldCharacter</dt><dd>is binded to query's parameter <strong>${fieldCharacter}</strong> and method's parameter <strong>fieldCharacter</strong></dd>
 * 	<dt>fieldShort</dt><dd>is binded to query's parameter <strong>${fieldShort}</strong> and method's parameter <strong>fieldShort</strong></dd>
 * 	<dt>fieldInteger</dt><dd>is binded to query's parameter <strong>${fieldInteger}</strong> and method's parameter <strong>fieldInteger</strong></dd>
 * 	<dt>fieldLong</dt><dd>is binded to query's parameter <strong>${fieldLong}</strong> and method's parameter <strong>fieldLong</strong></dd>
 * 	<dt>fieldFloat</dt><dd>is binded to query's parameter <strong>${fieldFloat}</strong> and method's parameter <strong>fieldFloat</strong></dd>
 * 	<dt>fieldDouble</dt><dd>is binded to query's parameter <strong>${fieldDouble}</strong> and method's parameter <strong>fieldDouble</strong></dd>
 * 	<dt>fieldString</dt><dd>is binded to query's parameter <strong>${fieldString}</strong> and method's parameter <strong>fieldString</strong></dd>
 * 	<dt>fieldByteArray</dt><dd>is binded to query's parameter <strong>${fieldByteArray}</strong> and method's parameter <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * @param fieldBoolean
 * 	is binded to column value <strong>field_boolean</strong>
 * @param fieldByte
 * 	is binded to column value <strong>field_byte</strong>
 * @param fieldCharacter
 * 	is binded to column value <strong>field_character</strong>
 * @param fieldShort
 * 	is binded to column value <strong>field_short</strong>
 * @param fieldInteger
 * 	is binded to column value <strong>field_integer</strong>
 * @param fieldLong
 * 	is binded to column value <strong>field_long</strong>
 * @param fieldFloat
 * 	is binded to column value <strong>field_float</strong>
 * @param fieldDouble
 * 	is binded to column value <strong>field_double</strong>
 * @param fieldString
 * 	is binded to column value <strong>field_string</strong>
 * @param fieldByteArray
 * 	is binded to column value <strong>field_byte_array</strong>
 *
 * @return <strong>id</strong> of inserted record
 */
@Override
public long insert(String fieldBoolean, String fieldByte, String fieldCharacter, String fieldShort, String fieldInteger, String fieldLong, String fieldFloat, String fieldDouble, String fieldString, String fieldByteArray) {
    if (insertPreparedStatement0 == null) {
        // generate static SQL for statement
        String _sql = "INSERT INTO employees (field_boolean, field_byte, field_character, field_short, field_integer, field_long, field_float, field_double, field_string, field_byte_array) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
        insertPreparedStatement0 = KriptonDatabaseWrapper.compile(_context, _sql);
    }
    KriptonContentValues _contentValues = contentValuesForUpdate(insertPreparedStatement0);
    _contentValues.put("field_boolean", SQLTypeAdapterUtils.toData(TypeAdapterBoolean.class, fieldBoolean));
    _contentValues.put("field_byte", SQLTypeAdapterUtils.toData(TypeAdapterByte.class, fieldByte));
    _contentValues.put("field_character", SQLTypeAdapterUtils.toData(TypeAdapterChar.class, fieldCharacter));
    _contentValues.put("field_short", SQLTypeAdapterUtils.toData(TypeAdapterShort.class, fieldShort));
    _contentValues.put("field_integer", SQLTypeAdapterUtils.toData(TypeAdapterInteger.class, fieldInteger));
    _contentValues.put("field_long", SQLTypeAdapterUtils.toData(TypeAdapterLong.class, fieldLong));
    _contentValues.put("field_float", SQLTypeAdapterUtils.toData(TypeAdapterFloat.class, fieldFloat));
    _contentValues.put("field_double", SQLTypeAdapterUtils.toData(TypeAdapterDouble.class, fieldDouble));
    _contentValues.put("field_string", SQLTypeAdapterUtils.toData(TypeAdapterString.class, fieldString));
    _contentValues.put("field_byte_array", SQLTypeAdapterUtils.toData(TypeAdapterByteArray.class, fieldByteArray));
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // log for insert -- BEGIN
        StringBuffer _columnNameBuffer = new StringBuffer();
        StringBuffer _columnValueBuffer = new StringBuffer();
        String _columnSeparator = "";
        for (String columnName : _contentValues.keys()) {
            _columnNameBuffer.append(_columnSeparator + columnName);
            _columnValueBuffer.append(_columnSeparator + ":" + columnName);
            _columnSeparator = ", ";
        }
        Logger.info("INSERT INTO employees (%s) VALUES (%s)", _columnNameBuffer.toString(), _columnValueBuffer.toString());
        // log for content values -- BEGIN
        Triple<String, Object, KriptonContentValues.ParamType> _contentValue;
        for (int i = 0; i < _contentValues.size(); i++) {
            _contentValue = _contentValues.get(i);
            if (_contentValue.value1 == null) {
                Logger.info("==> :%s = <null>", _contentValue.value0);
            } else {
                Logger.info("==> :%s = '%s' (%s)", _contentValue.value0, StringUtils.checkSize(_contentValue.value1), _contentValue.value1.getClass().getCanonicalName());
            }
        }
        // log for content values -- END
        // log for insert -- END
        // 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
    // insert operation
    long result = KriptonDatabaseWrapper.insert(insertPreparedStatement0, _contentValues);
    return result;
}
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) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) 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) TypeAdapterByte(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)

Example 14 with KriptonContentValues

use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.

the class EmployeeRawDaoImpl method deleteJQLWithAdapter.

/**
 * <h2>SQL delete</h2>
 * <pre>DELETE 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>Where parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is mapped to method's parameter <strong>id</strong></dd>
 * 	<dt>${fieldBoolean}</dt><dd>is mapped to method's parameter <strong>fieldBoolean</strong></dd>
 * 	<dt>${fieldByte}</dt><dd>is mapped to method's parameter <strong>fieldByte</strong></dd>
 * 	<dt>${fieldCharacter}</dt><dd>is mapped to method's parameter <strong>fieldCharacter</strong></dd>
 * 	<dt>${fieldShort}</dt><dd>is mapped to method's parameter <strong>fieldShort</strong></dd>
 * 	<dt>${fieldInteger}</dt><dd>is mapped to method's parameter <strong>fieldInteger</strong></dd>
 * 	<dt>${fieldLong}</dt><dd>is mapped to method's parameter <strong>fieldLong</strong></dd>
 * 	<dt>${fieldFloat}</dt><dd>is mapped to method's parameter <strong>fieldFloat</strong></dd>
 * 	<dt>${fieldDouble}</dt><dd>is mapped to method's parameter <strong>fieldDouble</strong></dd>
 * 	<dt>${fieldString}</dt><dd>is mapped to method's parameter <strong>fieldString</strong></dd>
 * 	<dt>${fieldByteArray}</dt><dd>is mapped to method's parameter <strong>fieldByteArray</strong></dd>
 * </dl>
 *
 * @param id
 * 	is used as where parameter <strong>${id}</strong>
 * @param fieldBoolean
 * 	is used as where parameter <strong>${fieldBoolean}</strong>
 * @param fieldByte
 * 	is used as where parameter <strong>${fieldByte}</strong>
 * @param fieldCharacter
 * 	is used as where parameter <strong>${fieldCharacter}</strong>
 * @param fieldShort
 * 	is used as where parameter <strong>${fieldShort}</strong>
 * @param fieldInteger
 * 	is used as where parameter <strong>${fieldInteger}</strong>
 * @param fieldLong
 * 	is used as where parameter <strong>${fieldLong}</strong>
 * @param fieldFloat
 * 	is used as where parameter <strong>${fieldFloat}</strong>
 * @param fieldDouble
 * 	is used as where parameter <strong>${fieldDouble}</strong>
 * @param fieldString
 * 	is used as where parameter <strong>${fieldString}</strong>
 * @param fieldByteArray
 * 	is used as where parameter <strong>${fieldByteArray}</strong>
 *
 * @return number of deleted records
 */
@Override
public long deleteJQLWithAdapter(long id, String fieldBoolean, String fieldByte, String fieldCharacter, String fieldShort, String fieldInteger, String fieldLong, String fieldFloat, String fieldDouble, String fieldString, String fieldByteArray) {
    if (deleteJQLWithAdapterPreparedStatement6 == null) {
        // generate static SQL for statement
        String _sql = "DELETE FROM employees WHERE id=? and field_boolean=? and field_byte=? and field_character=? and field_short=? and field_integer=? and field_long=? and field_float=? and field_double=? and field_string=? and field_byte_array=?";
        deleteJQLWithAdapterPreparedStatement6 = KriptonDatabaseWrapper.compile(_context, _sql);
    }
    KriptonContentValues _contentValues = contentValuesForUpdate(deleteJQLWithAdapterPreparedStatement6);
    _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));
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // display log
        Logger.info("DELETE FROM employees WHERE id=? and field_boolean=? and field_byte=? and field_character=? and field_short=? and field_integer=? and field_long=? and field_float=? and field_double=? and field_string=? and field_byte_array=?");
        // 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
    int result = KriptonDatabaseWrapper.updateDelete(deleteJQLWithAdapterPreparedStatement6, _contentValues);
    return result;
}
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) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) 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) TypeAdapterByte(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)

Example 15 with KriptonContentValues

use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.

the class EmployeeRawDaoImpl method updateById.

/**
 * <h2>SQL update</h2>
 * <pre>UPDATE employees SET field_boolean=:fieldBoolean, field_byte=:fieldByte, field_character=:fieldCharacter, field_short=:fieldShort, field_integer=:fieldInteger, field_long=:fieldLong, field_float=:fieldFloat, field_double=:fieldDouble, field_string=:fieldString, field_byte_array=:fieldByteArray WHERE id=${id}</pre>
 *
 * <h2>Updated columns:</h2>
 * <ul>
 * 	<li>field_boolean</li>
 * 	<li>field_byte</li>
 * 	<li>field_character</li>
 * 	<li>field_short</li>
 * 	<li>field_integer</li>
 * 	<li>field_long</li>
 * 	<li>field_float</li>
 * 	<li>field_double</li>
 * 	<li>field_string</li>
 * 	<li>field_byte_array</li>
 * </ul>
 *
 * <h2>Where parameters:</h2>
 * <dl>
 * 	<dt>${id}</dt><dd>is mapped to method's parameter <strong>id</strong></dd>
 * </dl>
 *
 * @param id
 * 	is used as where parameter <strong>${id}</strong>
 * @param fieldBoolean
 * 	is used as updated field <strong>fieldBoolean</strong>
 * @param fieldByte
 * 	is used as updated field <strong>fieldByte</strong>
 * @param fieldCharacter
 * 	is used as updated field <strong>fieldCharacter</strong>
 * @param fieldShort
 * 	is used as updated field <strong>fieldShort</strong>
 * @param fieldInteger
 * 	is used as updated field <strong>fieldInteger</strong>
 * @param fieldLong
 * 	is used as updated field <strong>fieldLong</strong>
 * @param fieldFloat
 * 	is used as updated field <strong>fieldFloat</strong>
 * @param fieldDouble
 * 	is used as updated field <strong>fieldDouble</strong>
 * @param fieldString
 * 	is used as updated field <strong>fieldString</strong>
 * @param fieldByteArray
 * 	is used as updated field <strong>fieldByteArray</strong>
 *
 * @return number of updated records
 */
@Override
public long updateById(long id, String fieldBoolean, String fieldByte, String fieldCharacter, String fieldShort, String fieldInteger, String fieldLong, String fieldFloat, String fieldDouble, String fieldString, String fieldByteArray) {
    if (updateByIdPreparedStatement2 == null) {
        // generate static SQL for statement
        String _sql = "UPDATE employees SET field_boolean=?, field_byte=?, field_character=?, field_short=?, field_integer=?, field_long=?, field_float=?, field_double=?, field_string=?, field_byte_array=? WHERE id=?";
        updateByIdPreparedStatement2 = KriptonDatabaseWrapper.compile(_context, _sql);
    }
    KriptonContentValues _contentValues = contentValuesForUpdate(updateByIdPreparedStatement2);
    _contentValues.put("field_boolean", SQLTypeAdapterUtils.toData(TypeAdapterBoolean.class, fieldBoolean));
    _contentValues.put("field_byte", SQLTypeAdapterUtils.toData(TypeAdapterByte.class, fieldByte));
    _contentValues.put("field_character", SQLTypeAdapterUtils.toData(TypeAdapterChar.class, fieldCharacter));
    _contentValues.put("field_short", SQLTypeAdapterUtils.toData(TypeAdapterShort.class, fieldShort));
    _contentValues.put("field_integer", SQLTypeAdapterUtils.toData(TypeAdapterInteger.class, fieldInteger));
    _contentValues.put("field_long", SQLTypeAdapterUtils.toData(TypeAdapterLong.class, fieldLong));
    _contentValues.put("field_float", SQLTypeAdapterUtils.toData(TypeAdapterFloat.class, fieldFloat));
    _contentValues.put("field_double", SQLTypeAdapterUtils.toData(TypeAdapterDouble.class, fieldDouble));
    _contentValues.put("field_string", SQLTypeAdapterUtils.toData(TypeAdapterString.class, fieldString));
    _contentValues.put("field_byte_array", SQLTypeAdapterUtils.toData(TypeAdapterByteArray.class, fieldByteArray));
    _contentValues.addWhereArgs(String.valueOf(id));
    // log section BEGIN
    if (_context.isLogEnabled()) {
        // display log
        Logger.info("UPDATE employees SET field_boolean=:field_boolean, field_byte=:field_byte, field_character=:field_character, field_short=:field_short, field_integer=:field_integer, field_long=:field_long, field_float=:field_float, field_double=:field_double, field_string=:field_string, field_byte_array=:field_byte_array WHERE id=?");
        // log for content values -- BEGIN
        Triple<String, Object, KriptonContentValues.ParamType> _contentValue;
        for (int i = 0; i < _contentValues.size(); i++) {
            _contentValue = _contentValues.get(i);
            if (_contentValue.value1 == null) {
                Logger.info("==> :%s = <null>", _contentValue.value0);
            } else {
                Logger.info("==> :%s = '%s' (%s)", _contentValue.value0, StringUtils.checkSize(_contentValue.value1), _contentValue.value1.getClass().getCanonicalName());
            }
        }
        // log for content values -- END
        // 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
    int result = KriptonDatabaseWrapper.updateDelete(updateByIdPreparedStatement2, _contentValues);
    return result;
}
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) TypeAdapterShort(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort) 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) TypeAdapterByte(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte) TypeAdapterString(sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)

Aggregations

KriptonContentValues (com.abubusoft.kripton.android.sqlite.KriptonContentValues)1293 Cursor (android.database.Cursor)574 ArrayList (java.util.ArrayList)174 BigInteger (java.math.BigInteger)70 KriptonRuntimeException (com.abubusoft.kripton.exception.KriptonRuntimeException)68 BigDecimal (java.math.BigDecimal)68 TypeAdapterString (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterString)27 TypeAdapterByte (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByte)22 TypeAdapterByteArray (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterByteArray)22 TypeAdapterChar (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterChar)22 TypeAdapterDouble (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterDouble)22 TypeAdapterFloat (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterFloat)22 TypeAdapterInteger (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterInteger)22 TypeAdapterLong (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterLong)22 TypeAdapterShort (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterShort)22 TypeAdapterBoolean (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterBoolean)19 Person (sqlite.feature.javadoc.Person)15 TypeAdapterAddress (sqlite.feature.typeadapter.kripton180.adapters.TypeAdapterAddress)15 Employee (sqlite.feature.typeadapter.kripton180.Employee)10 Person (sqlite.feature.contentprovider.kripton35.entities.Person)8