use of sqlite.feature.contentprovider.kripton35.entities.City in project kripton by xcesco.
the class Person2DAOImpl method selectBean.
/**
* <h2>Select SQL:</h2>
*
* <pre>SELECT id, alias_parent_id, city, birth_city, birth_day, value, name, surname FROM person</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
* <dt>alias_parent_id</dt><dd>is associated to bean's property <strong>parentId</strong></dd>
* <dt>city</dt><dd>is associated to bean's property <strong>city</strong></dd>
* <dt>birth_city</dt><dd>is associated to bean's property <strong>birthCity</strong></dd>
* <dt>birth_day</dt><dd>is associated to bean's property <strong>birthDay</strong></dd>
* <dt>value</dt><dd>is associated to bean's property <strong>value</strong></dd>
* <dt>name</dt><dd>is associated to bean's property <strong>name</strong></dd>
* <dt>surname</dt><dd>is associated to bean's property <strong>surname</strong></dd>
* </dl>
*
* @return collection of bean or empty collection.
*/
@Override
public List<Person> selectBean() {
KriptonContentValues _contentValues = contentValues();
// query SQL is statically defined
String _sql = SELECT_BEAN_SQL1;
// add where arguments
String[] _sqlArgs = _contentValues.whereArgsAsArray();
try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
ArrayList<Person> resultList = new ArrayList<Person>(_cursor.getCount());
Person resultBean = null;
if (_cursor.moveToFirst()) {
int index0 = _cursor.getColumnIndex("id");
int index1 = _cursor.getColumnIndex("alias_parent_id");
int index2 = _cursor.getColumnIndex("city");
int index3 = _cursor.getColumnIndex("birth_city");
int index4 = _cursor.getColumnIndex("birth_day");
int index5 = _cursor.getColumnIndex("value");
int index6 = _cursor.getColumnIndex("name");
int index7 = _cursor.getColumnIndex("surname");
do {
resultBean = new Person();
resultBean.id = _cursor.getLong(index0);
if (!_cursor.isNull(index1)) {
resultBean.parentId = _cursor.getLong(index1);
}
if (!_cursor.isNull(index2)) {
resultBean.city = _cursor.getLong(index2);
}
if (!_cursor.isNull(index3)) {
resultBean.birthCity = _cursor.getString(index3);
}
if (!_cursor.isNull(index4)) {
resultBean.birthDay = DateUtils.read(_cursor.getString(index4));
}
if (!_cursor.isNull(index5)) {
resultBean.value = _cursor.getLong(index5);
}
if (!_cursor.isNull(index6)) {
resultBean.setName(_cursor.getString(index6));
}
if (!_cursor.isNull(index7)) {
resultBean.setSurname(_cursor.getString(index7));
}
resultList.add(resultBean);
} while (_cursor.moveToNext());
}
return resultList;
}
}
use of sqlite.feature.contentprovider.kripton35.entities.City in project kripton by xcesco.
the class Person2DAOImpl method selectAll.
/**
* <h2>Select SQL:</h2>
*
* <pre>SELECT id, alias_parent_id, city, birth_city, birth_day, value, name, surname FROM person WHERE #{DYNAMIC_WHERE} ORDER BY name asc, #{DYNAMIC_ORDER_BY}</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
* <dt>alias_parent_id</dt><dd>is associated to bean's property <strong>parentId</strong></dd>
* <dt>city</dt><dd>is associated to bean's property <strong>city</strong></dd>
* <dt>birth_city</dt><dd>is associated to bean's property <strong>birthCity</strong></dd>
* <dt>birth_day</dt><dd>is associated to bean's property <strong>birthDay</strong></dd>
* <dt>value</dt><dd>is associated to bean's property <strong>value</strong></dd>
* <dt>name</dt><dd>is associated to bean's property <strong>name</strong></dd>
* <dt>surname</dt><dd>is associated to bean's property <strong>surname</strong></dd>
* </dl>
*
* <h2>Method's parameters and associated dynamic parts:</h2>
* <dl>
* <dt>where</dt><dd>is part of where conditions resolved at runtime. In above SQL it is displayed as #{DYNAMIC_WHERE}</dd>
* <dt>order</dt>is part of order statement resolved at runtime. In above SQL it is displayed as #{DYNAMIC_ORDER_BY}</dd>
* </dl>
*
* @param where
* is used as <strong>dynamic WHERE statement</strong> and it is formatted by ({@link StringUtils#format})
* @param args
* is binded to <code>${args}</code>
* @param order
* is used as <strong>dynamic ORDER BY statement</strong> and it is formatted by ({@link StringUtils#format})
* @return collection of bean or empty collection.
*/
@Override
public List<Person> selectAll(String where, String[] args, String order) {
KriptonContentValues _contentValues = contentValues();
StringBuilder _sqlBuilder = sqlBuilder();
_sqlBuilder.append("SELECT id, alias_parent_id, city, birth_city, birth_day, value, name, surname FROM person");
// generation CODE_001 -- BEGIN
// initialize dynamic where
String _sqlDynamicWhere = where;
// initialize dynamic where args
String[] _sqlDynamicWhereArgs = args;
// generation CODE_001 -- END
String _sortOrder = order;
// manage WHERE arguments -- BEGIN
// manage WHERE statement
String _sqlWhereStatement = StringUtils.ifNotEmptyAppend(_sqlDynamicWhere, " WHERE ");
_sqlBuilder.append(_sqlWhereStatement);
// manage WHERE arguments -- END
if (StringUtils.hasText(_sqlDynamicWhere) && _sqlDynamicWhereArgs != null) {
for (String _arg : _sqlDynamicWhereArgs) {
_contentValues.addWhereArgs(_arg);
}
}
// generation order - BEGIN
String _sqlOrderByStatement = " ORDER BY name asc" + StringUtils.ifNotEmptyAppend(_sortOrder, ", ");
_sqlBuilder.append(_sqlOrderByStatement);
// generation order - END
String _sql = _sqlBuilder.toString();
// add where arguments
String[] _sqlArgs = _contentValues.whereArgsAsArray();
try (Cursor _cursor = database().rawQuery(_sql, _sqlArgs)) {
ArrayList<Person> resultList = new ArrayList<Person>(_cursor.getCount());
Person resultBean = null;
if (_cursor.moveToFirst()) {
int index0 = _cursor.getColumnIndex("id");
int index1 = _cursor.getColumnIndex("alias_parent_id");
int index2 = _cursor.getColumnIndex("city");
int index3 = _cursor.getColumnIndex("birth_city");
int index4 = _cursor.getColumnIndex("birth_day");
int index5 = _cursor.getColumnIndex("value");
int index6 = _cursor.getColumnIndex("name");
int index7 = _cursor.getColumnIndex("surname");
do {
resultBean = new Person();
resultBean.id = _cursor.getLong(index0);
if (!_cursor.isNull(index1)) {
resultBean.parentId = _cursor.getLong(index1);
}
if (!_cursor.isNull(index2)) {
resultBean.city = _cursor.getLong(index2);
}
if (!_cursor.isNull(index3)) {
resultBean.birthCity = _cursor.getString(index3);
}
if (!_cursor.isNull(index4)) {
resultBean.birthDay = DateUtils.read(_cursor.getString(index4));
}
if (!_cursor.isNull(index5)) {
resultBean.value = _cursor.getLong(index5);
}
if (!_cursor.isNull(index6)) {
resultBean.setName(_cursor.getString(index6));
}
if (!_cursor.isNull(index7)) {
resultBean.setSurname(_cursor.getString(index7));
}
resultList.add(resultBean);
} while (_cursor.moveToNext());
}
return resultList;
}
}
use of sqlite.feature.contentprovider.kripton35.entities.City in project kripton by xcesco.
the class CityDAOImpl method selectCityFromPerson.
/**
* <h2>Select SQL:</h2>
*
* <pre>select * from city where id = (select id from person where id=${personId} )</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
* <dt>name</dt><dd>is associated to bean's property <strong>name</strong></dd>
* </dl>
*
* <h2>Query's parameters:</h2>
* <dl>
* <dt>${personId}</dt><dd>is binded to method's parameter <strong>personId</strong></dd>
* </dl>
*
* @param personId
* is binded to <code>${personId}</code>
* @return selected bean or <code>null</code>.
*/
@Override
public City selectCityFromPerson(long personId) {
KriptonContentValues _contentValues = contentValues();
// query SQL is statically defined
String _sql = SELECT_CITY_FROM_PERSON_SQL2;
// add where arguments
_contentValues.addWhereArgs(String.valueOf(personId));
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
City resultBean = null;
if (_cursor.moveToFirst()) {
int index0 = _cursor.getColumnIndex("id");
int index1 = _cursor.getColumnIndex("name");
resultBean = new City();
resultBean.id = _cursor.getLong(index0);
if (!_cursor.isNull(index1)) {
resultBean.name = _cursor.getString(index1);
}
}
return resultBean;
}
}
use of sqlite.feature.contentprovider.kripton35.entities.City in project kripton by xcesco.
the class PersonDAOImpl method selectOne.
/**
* <h2>Select SQL:</h2>
*
* <pre>SELECT id, alias_parent_id, city, birth_city, birth_day, value, name, surname FROM person WHERE name like ${data.name} || '%' ORDER BY #{DYNAMIC_ORDER_BY}</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
* <dt>alias_parent_id</dt><dd>is associated to bean's property <strong>parentId</strong></dd>
* <dt>city</dt><dd>is associated to bean's property <strong>city</strong></dd>
* <dt>birth_city</dt><dd>is associated to bean's property <strong>birthCity</strong></dd>
* <dt>birth_day</dt><dd>is associated to bean's property <strong>birthDay</strong></dd>
* <dt>value</dt><dd>is associated to bean's property <strong>value</strong></dd>
* <dt>name</dt><dd>is associated to bean's property <strong>name</strong></dd>
* <dt>surname</dt><dd>is associated to bean's property <strong>surname</strong></dd>
* </dl>
*
* <h2>Method's parameters and associated dynamic parts:</h2>
* <dl>
* <dt>orderBy</dt>is part of order statement resolved at runtime. In above SQL it is displayed as #{DYNAMIC_ORDER_BY}</dd>
* </dl>
*
* <h2>Query's parameters:</h2>
* <dl>
* <dt>${data.name}</dt><dd>is binded to method's parameter <strong>bean.name</strong></dd>
* </dl>
*
* @param bean
* is used as ${data}
* @param orderBy
* is used as <strong>dynamic ORDER BY statement</strong> and it is formatted by ({@link StringUtils#format})
* @return collection of bean or empty collection.
*/
@Override
public List<Person> selectOne(Person bean, String orderBy) {
KriptonContentValues _contentValues = contentValues();
StringBuilder _sqlBuilder = sqlBuilder();
_sqlBuilder.append("SELECT id, alias_parent_id, city, birth_city, birth_day, value, name, surname FROM person");
// generation CODE_001 -- BEGIN
// generation CODE_001 -- END
String _sortOrder = orderBy;
// manage WHERE arguments -- BEGIN
// manage WHERE statement
String _sqlWhereStatement = " WHERE name like ? || '%'";
_sqlBuilder.append(_sqlWhereStatement);
// manage WHERE arguments -- END
// generation order - BEGIN
String _sqlOrderByStatement = StringUtils.ifNotEmptyAppend(_sortOrder, " ORDER BY ");
_sqlBuilder.append(_sqlOrderByStatement);
// generation order - END
String _sql = _sqlBuilder.toString();
// add where arguments
_contentValues.addWhereArgs(bean.getName());
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
ArrayList<Person> resultList = new ArrayList<Person>(_cursor.getCount());
Person resultBean = null;
if (_cursor.moveToFirst()) {
int index0 = _cursor.getColumnIndex("id");
int index1 = _cursor.getColumnIndex("alias_parent_id");
int index2 = _cursor.getColumnIndex("city");
int index3 = _cursor.getColumnIndex("birth_city");
int index4 = _cursor.getColumnIndex("birth_day");
int index5 = _cursor.getColumnIndex("value");
int index6 = _cursor.getColumnIndex("name");
int index7 = _cursor.getColumnIndex("surname");
do {
resultBean = new Person();
resultBean.id = _cursor.getLong(index0);
if (!_cursor.isNull(index1)) {
resultBean.parentId = _cursor.getLong(index1);
}
if (!_cursor.isNull(index2)) {
resultBean.city = _cursor.getLong(index2);
}
if (!_cursor.isNull(index3)) {
resultBean.birthCity = _cursor.getString(index3);
}
if (!_cursor.isNull(index4)) {
resultBean.birthDay = DateUtils.read(_cursor.getString(index4));
}
if (!_cursor.isNull(index5)) {
resultBean.value = _cursor.getLong(index5);
}
if (!_cursor.isNull(index6)) {
resultBean.setName(_cursor.getString(index6));
}
if (!_cursor.isNull(index7)) {
resultBean.setSurname(_cursor.getString(index7));
}
resultList.add(resultBean);
} while (_cursor.moveToNext());
}
return resultList;
}
}
use of sqlite.feature.contentprovider.kripton35.entities.City in project kripton by xcesco.
the class PersonDAOImpl method selectAll.
/**
* <h2>Select SQL:</h2>
*
* <pre>SELECT id, alias_parent_id, city, birth_city, birth_day, value, name, surname FROM person WHERE #{DYNAMIC_WHERE} ORDER BY name asc, #{DYNAMIC_ORDER_BY}</pre>
*
* <h2>Projected columns:</h2>
* <dl>
* <dt>id</dt><dd>is associated to bean's property <strong>id</strong></dd>
* <dt>alias_parent_id</dt><dd>is associated to bean's property <strong>parentId</strong></dd>
* <dt>city</dt><dd>is associated to bean's property <strong>city</strong></dd>
* <dt>birth_city</dt><dd>is associated to bean's property <strong>birthCity</strong></dd>
* <dt>birth_day</dt><dd>is associated to bean's property <strong>birthDay</strong></dd>
* <dt>value</dt><dd>is associated to bean's property <strong>value</strong></dd>
* <dt>name</dt><dd>is associated to bean's property <strong>name</strong></dd>
* <dt>surname</dt><dd>is associated to bean's property <strong>surname</strong></dd>
* </dl>
*
* <h2>Method's parameters and associated dynamic parts:</h2>
* <dl>
* <dt>where</dt><dd>is part of where conditions resolved at runtime. In above SQL it is displayed as #{DYNAMIC_WHERE}</dd>
* <dt>order</dt>is part of order statement resolved at runtime. In above SQL it is displayed as #{DYNAMIC_ORDER_BY}</dd>
* </dl>
*
* @param where
* is used as <strong>dynamic WHERE statement</strong> and it is formatted by ({@link StringUtils#format})
* @param args
* is binded to <code>${args}</code>
* @param order
* is used as <strong>dynamic ORDER BY statement</strong> and it is formatted by ({@link StringUtils#format})
* @return collection of bean or empty collection.
*/
@Override
public List<Person> selectAll(String where, String[] args, String order) {
KriptonContentValues _contentValues = contentValues();
StringBuilder _sqlBuilder = sqlBuilder();
_sqlBuilder.append("SELECT id, alias_parent_id, city, birth_city, birth_day, value, name, surname FROM person");
// generation CODE_001 -- BEGIN
// initialize dynamic where
String _sqlDynamicWhere = where;
// initialize dynamic where args
String[] _sqlDynamicWhereArgs = args;
// generation CODE_001 -- END
String _sortOrder = order;
// manage WHERE arguments -- BEGIN
// manage WHERE statement
String _sqlWhereStatement = StringUtils.ifNotEmptyAppend(_sqlDynamicWhere, " WHERE ");
_sqlBuilder.append(_sqlWhereStatement);
// manage WHERE arguments -- END
if (StringUtils.hasText(_sqlDynamicWhere) && _sqlDynamicWhereArgs != null) {
for (String _arg : _sqlDynamicWhereArgs) {
_contentValues.addWhereArgs(_arg);
}
}
// generation order - BEGIN
String _sqlOrderByStatement = " ORDER BY name asc" + StringUtils.ifNotEmptyAppend(_sortOrder, ", ");
_sqlBuilder.append(_sqlOrderByStatement);
// generation order - END
String _sql = _sqlBuilder.toString();
// 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
ArrayList<Person> resultList = new ArrayList<Person>(_cursor.getCount());
Person resultBean = null;
if (_cursor.moveToFirst()) {
int index0 = _cursor.getColumnIndex("id");
int index1 = _cursor.getColumnIndex("alias_parent_id");
int index2 = _cursor.getColumnIndex("city");
int index3 = _cursor.getColumnIndex("birth_city");
int index4 = _cursor.getColumnIndex("birth_day");
int index5 = _cursor.getColumnIndex("value");
int index6 = _cursor.getColumnIndex("name");
int index7 = _cursor.getColumnIndex("surname");
do {
resultBean = new Person();
resultBean.id = _cursor.getLong(index0);
if (!_cursor.isNull(index1)) {
resultBean.parentId = _cursor.getLong(index1);
}
if (!_cursor.isNull(index2)) {
resultBean.city = _cursor.getLong(index2);
}
if (!_cursor.isNull(index3)) {
resultBean.birthCity = _cursor.getString(index3);
}
if (!_cursor.isNull(index4)) {
resultBean.birthDay = DateUtils.read(_cursor.getString(index4));
}
if (!_cursor.isNull(index5)) {
resultBean.value = _cursor.getLong(index5);
}
if (!_cursor.isNull(index6)) {
resultBean.setName(_cursor.getString(index6));
}
if (!_cursor.isNull(index7)) {
resultBean.setSurname(_cursor.getString(index7));
}
resultList.add(resultBean);
} while (_cursor.moveToNext());
}
return resultList;
}
}
Aggregations