use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class DaoBean05Impl method selectOne.
/**
* <h2>Select SQL:</h2>
*
* <pre>SELECT pk, number, bean_type, text, content, creation_time FROM ws_bean WHERE pk=${id}</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>pk</dt><dd>is associated to bean's property <strong>pk</strong></dd>
* <dt>number</dt><dd>is associated to bean's property <strong>number</strong></dd>
* <dt>bean_type</dt><dd>is associated to bean's property <strong>beanType</strong></dd>
* <dt>text</dt><dd>is associated to bean's property <strong>text</strong></dd>
* <dt>content</dt><dd>is associated to bean's property <strong>content</strong></dd>
* <dt>creation_time</dt><dd>is associated to bean's property <strong>creationTime</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>
* @param listener
* is the Bean05 listener
*/
@Override
public void selectOne(long id, OnReadBeanListener<Bean05> listener) {
KriptonContentValues _contentValues = contentValues();
// query SQL is statically defined
String _sql = SELECT_ONE_SQL9;
// 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
Bean05 resultBean = new Bean05();
if (_cursor.moveToFirst()) {
int index0 = _cursor.getColumnIndex("pk");
int index1 = _cursor.getColumnIndex("number");
int index2 = _cursor.getColumnIndex("bean_type");
int index3 = _cursor.getColumnIndex("text");
int index4 = _cursor.getColumnIndex("content");
int index5 = _cursor.getColumnIndex("creation_time");
int rowCount = _cursor.getCount();
do {
// reset mapping
// pk does not need reset
resultBean.setNumber(0L);
resultBean.setBeanType(null);
resultBean.setText(null);
resultBean.setContent(null);
resultBean.setCreationTime(null);
// generate mapping
resultBean.setPk(_cursor.getLong(index0));
if (!_cursor.isNull(index1)) {
resultBean.setNumber(_cursor.getLong(index1));
}
if (!_cursor.isNull(index2)) {
resultBean.setBeanType(BeanType.valueOf(_cursor.getString(index2)));
}
if (!_cursor.isNull(index3)) {
resultBean.setText(_cursor.getString(index3));
}
if (!_cursor.isNull(index4)) {
resultBean.setContent(_cursor.getBlob(index4));
}
if (!_cursor.isNull(index5)) {
resultBean.setCreationTime(DateUtils.read(_cursor.getString(index5)));
}
listener.onRead(resultBean, _cursor.getPosition(), rowCount);
} while (_cursor.moveToNext());
}
}
}
use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class DaoBean05Impl method getOne.
/**
* <h2>Select SQL:</h2>
*
* <pre>SELECT content FROM ws_bean WHERE pk=${id}</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>content</dt><dd>is associated to bean's property <strong>content</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 single value extracted by query.
*/
@Override
public byte[] getOne(long id) {
KriptonContentValues _contentValues = contentValues();
// query SQL is statically defined
String _sql = GET_ONE_SQL10;
// 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
byte[] result = null;
if (_cursor.moveToFirst()) {
if (_cursor.isNull(0)) {
return null;
}
result = _cursor.getBlob(0);
}
return result;
}
}
use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class DaoBean05Impl method selectOne.
/**
* <h2>Select SQL:</h2>
*
* <pre>SELECT pk, number, bean_type, text, content, creation_time FROM ws_bean WHERE pk=${id}</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>pk</dt><dd>is associated to bean's property <strong>pk</strong></dd>
* <dt>number</dt><dd>is associated to bean's property <strong>number</strong></dd>
* <dt>bean_type</dt><dd>is associated to bean's property <strong>beanType</strong></dd>
* <dt>text</dt><dd>is associated to bean's property <strong>text</strong></dd>
* <dt>content</dt><dd>is associated to bean's property <strong>content</strong></dd>
* <dt>creation_time</dt><dd>is associated to bean's property <strong>creationTime</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 Bean05 selectOne(Long id) {
KriptonContentValues _contentValues = contentValues();
// query SQL is statically defined
String _sql = SELECT_ONE_SQL1;
// add where arguments
_contentValues.addWhereArgs((id == null ? "" : 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
Bean05 resultBean = null;
if (_cursor.moveToFirst()) {
int index0 = _cursor.getColumnIndex("pk");
int index1 = _cursor.getColumnIndex("number");
int index2 = _cursor.getColumnIndex("bean_type");
int index3 = _cursor.getColumnIndex("text");
int index4 = _cursor.getColumnIndex("content");
int index5 = _cursor.getColumnIndex("creation_time");
resultBean = new Bean05();
resultBean.setPk(_cursor.getLong(index0));
if (!_cursor.isNull(index1)) {
resultBean.setNumber(_cursor.getLong(index1));
}
if (!_cursor.isNull(index2)) {
resultBean.setBeanType(BeanType.valueOf(_cursor.getString(index2)));
}
if (!_cursor.isNull(index3)) {
resultBean.setText(_cursor.getString(index3));
}
if (!_cursor.isNull(index4)) {
resultBean.setContent(_cursor.getBlob(index4));
}
if (!_cursor.isNull(index5)) {
resultBean.setCreationTime(DateUtils.read(_cursor.getString(index5)));
}
}
return resultBean;
}
}
use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class DaoBean05Impl method deleteOne.
/**
* <h2>SQL delete:</h2>
* <pre>DELETE FROM ws_bean WHERE pk=${bean.pk} and text=${bean.text} and creation_time=${bean.creationTime}</pre>
*
* <h2>Parameters used in where conditions:</h2>
* <dl>
* <dt>${bean.pk}</dt><dd>is mapped to method's parameter <strong>bean.pk</strong></dd>
* <dt>${bean.text}</dt><dd>is mapped to method's parameter <strong>bean.text</strong></dd>
* <dt>${bean.creationTime}</dt><dd>is mapped to method's parameter <strong>bean.creationTime</strong></dd>
* </dl>
*
* @param bean
* is used as ${bean}
*
* @return number of deleted records
*/
@Override
public long deleteOne(Bean05 bean) {
if (deleteOnePreparedStatement4 == null) {
// generate static SQL for statement
String _sql = "DELETE FROM ws_bean WHERE pk=? and text=? and creation_time=?";
deleteOnePreparedStatement4 = KriptonDatabaseWrapper.compile(_context, _sql);
}
KriptonContentValues _contentValues = contentValuesForUpdate(deleteOnePreparedStatement4);
_contentValues.addWhereArgs(String.valueOf(bean.getPk()));
_contentValues.addWhereArgs((bean.getText() == null ? "" : bean.getText()));
_contentValues.addWhereArgs((bean.getCreationTime() == null ? "" : DateUtils.write(bean.getCreationTime())));
// log section BEGIN
if (_context.isLogEnabled()) {
// display log
Logger.info("DELETE FROM ws_bean WHERE pk=? and text=? and creation_time=?");
// 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(deleteOnePreparedStatement4, _contentValues);
return result;
}
use of com.abubusoft.kripton.android.sqlite.KriptonContentValues in project kripton by xcesco.
the class BeanDaoImpl method selectOne.
/**
* <h2>Select SQL:</h2>
*
* <pre>SELECT id, value, value2 FROM bean_bean</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
* <dt>value</dt><dd>is associated to bean's property <strong>value</strong></dd>
* <dt>value2</dt><dd>is associated to bean's property <strong>value2</strong></dd>
* </dl>
*
* @return selected bean or <code>null</code>.
*/
@Override
public BeanBean selectOne() {
KriptonContentValues _contentValues = contentValues();
// query SQL is statically defined
String _sql = SELECT_ONE_SQL1;
// add where arguments
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
BeanBean resultBean = null;
if (_cursor.moveToFirst()) {
int index0 = _cursor.getColumnIndex("id");
int index1 = _cursor.getColumnIndex("value");
int index2 = _cursor.getColumnIndex("value2");
resultBean = new BeanBean();
resultBean.setId(_cursor.getLong(index0));
if (!_cursor.isNull(index1)) {
resultBean.setValue(BeanBeanTable.parseValue(_cursor.getBlob(index1)));
}
if (!_cursor.isNull(index2)) {
resultBean.setValue2(BeanBeanTable.parseValue2(_cursor.getBlob(index2)));
}
}
return resultBean;
}
}
Aggregations