Search in sources :

Example 1 with Employee

use of org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_2.Employee in project kripton by xcesco.

the class EmployeeBeanDaoImpl 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=${bean.id}</pre>
 *
 * <h2>Mapped class:</h2>
 * {@link Employee}
 *
 * <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>:bean.id</dt><dd>is binded to method's parameter <strong>bean.id</strong></dd>
 * </dl>
 *
 * @param bean
 * 	is used as <code>:bean</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public Employee selectByIdJQL(Employee bean) {
    // common part generation - BEGIN
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ID_J_Q_L_SQL2;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(bean.id));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section for select 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 for select END
    try (Cursor _cursor = getDatabase().query(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        // common part generation - END
        // Specialized part - SelectBeanHelper - BEGIN
        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;
    }
// Specialized part - SelectBeanHelper - END
}
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 2 with Employee

use of org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_2.Employee in project kripton by xcesco.

the class EmployeeBeanDaoImpl 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=${bean.id} and field_byte=${bean.fieldByte} 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>Mapped class:</h2>
 * {@link Employee}
 *
 * <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>:bean.id</dt><dd>is binded to method's parameter <strong>bean.id</strong></dd>
 * 	<dt>:bean.fieldByte</dt><dd>is binded to method's parameter <strong>bean.fieldByte</strong></dd>
 * 	<dt>:bean.fieldByte</dt><dd>is binded to method's parameter <strong>bean.fieldByte</strong></dd>
 * 	<dt>:bean.fieldCharacter</dt><dd>is binded to method's parameter <strong>bean.fieldCharacter</strong></dd>
 * 	<dt>:bean.fieldShort</dt><dd>is binded to method's parameter <strong>bean.fieldShort</strong></dd>
 * 	<dt>:bean.fieldInteger</dt><dd>is binded to method's parameter <strong>bean.fieldInteger</strong></dd>
 * 	<dt>:bean.fieldLong</dt><dd>is binded to method's parameter <strong>bean.fieldLong</strong></dd>
 * 	<dt>:bean.fieldFloat</dt><dd>is binded to method's parameter <strong>bean.fieldFloat</strong></dd>
 * 	<dt>:bean.fieldDouble</dt><dd>is binded to method's parameter <strong>bean.fieldDouble</strong></dd>
 * 	<dt>:bean.fieldString</dt><dd>is binded to method's parameter <strong>bean.fieldString</strong></dd>
 * 	<dt>:bean.fieldByteArray</dt><dd>is binded to method's parameter <strong>bean.fieldByteArray</strong></dd>
 * </dl>
 *
 * @param bean
 * 	is used as <code>:bean</code>
 * @return selected bean or <code>null</code>.
 */
@Override
public Employee selectByAllJQL(Employee bean) {
    // common part generation - BEGIN
    KriptonContentValues _contentValues = contentValues();
    // query SQL is statically defined
    String _sql = SELECT_BY_ALL_J_Q_L_SQL4;
    // add where arguments
    _contentValues.addWhereArgs(String.valueOf(bean.id));
    _contentValues.addWhereArgs(SQLTypeAdapterUtils.toString(TypeAdapterByte.class, bean.fieldByte));
    _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));
    String[] _sqlArgs = _contentValues.whereArgsAsArray();
    // log section for select 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 for select END
    try (Cursor _cursor = getDatabase().query(_sql, _sqlArgs)) {
        // log section BEGIN
        if (_context.isLogEnabled()) {
            Logger.info("Rows found: %s", _cursor.getCount());
        }
        // log section END
        // common part generation - END
        // Specialized part - SelectBeanHelper - BEGIN
        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;
    }
// Specialized part - SelectBeanHelper - END
}
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 3 with Employee

use of org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_2.Employee in project kripton by xcesco.

the class EmployeeBeanDaoImpl method selectByAll.

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

use of org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_2.Employee in project eclipselink by eclipse-ee4j.

the class EmployeePopulator method employeeExample3.

public Employee employeeExample3() {
    if (containsObject(Employee.class, "0003")) {
        return (Employee) getObject(Employee.class, "0003");
    }
    Employee employee = basicEmployeeExample3();
    registerObject(Employee.class, employee, "0003");
    try {
        employee.addProject(smallProjectExample4());
        employee.addProject(largeProjectExample4());
        employee.addProject(largeProjectExample5());
    } catch (Exception exception) {
        throw new RuntimeException(exception.toString());
    }
    return employee;
}
Also used : Employee(org.eclipse.persistence.testing.models.jpa.composite.advanced.member_2.Employee)

Example 5 with Employee

use of org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_2.Employee in project eclipselink by eclipse-ee4j.

the class EmployeePopulator method employeeExample5.

public Employee employeeExample5() {
    if (containsObject(Employee.class, "0005")) {
        return (Employee) getObject(Employee.class, "0005");
    }
    Employee employee = basicEmployeeExample5();
    registerObject(Employee.class, employee, "0005");
    try {
        employee.addProject(smallProjectExample4());
        employee.addProject(largeProjectExample1());
        employee.addProject(largeProjectExample3());
    } catch (Exception exception) {
        throw new RuntimeException(exception.toString());
    }
    return employee;
}
Also used : Employee(org.eclipse.persistence.testing.models.jpa.composite.advanced.member_2.Employee)

Aggregations

Employee (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_2.Employee)152 EntityManager (jakarta.persistence.EntityManager)135 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)119 Employee (org.eclipse.persistence.testing.models.jpa.xml.composite.advanced.member_2.Employee)51 ArrayList (java.util.ArrayList)28 Address (org.eclipse.persistence.testing.models.jpa.composite.advanced.member_1.Address)26 EntityExistsException (jakarta.persistence.EntityExistsException)23 EntityNotFoundException (jakarta.persistence.EntityNotFoundException)23 PersistenceException (jakarta.persistence.PersistenceException)22 JpaQuery (org.eclipse.persistence.jpa.JpaQuery)22 OptimisticLockException (jakarta.persistence.OptimisticLockException)21 TransactionRequiredException (jakarta.persistence.TransactionRequiredException)21 List (java.util.List)21 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)21 Query (jakarta.persistence.Query)20 RollbackException (jakarta.persistence.RollbackException)20 EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)20 IntegrityException (org.eclipse.persistence.exceptions.IntegrityException)20 QueryException (org.eclipse.persistence.exceptions.QueryException)20 ValidationException (org.eclipse.persistence.exceptions.ValidationException)20