app/src/main/java/db/juhaku/juhakudb/core/android/transaction/QueryTransactionTemplate.java
/**
     * Perform given query.
     *
     * @param query Instance of {@link Query} to be performed.
     * @param rootClass Root class of the queried entity.
     * @param parentEntity Cascading query parent entity.
     * @param parentField Cascading query field.
     *
     * @since 2.0.0
     *
     * @hide
     */
Perform given query.
@param query Instance of  Query to be performed.
@param rootClass Root class of the queried entity.
@param parentEntity Cascading query parent entity.
@param parentField Cascading query field.



@hide
Perform given query . @param query Instance of Query to be performed . @param rootClass Root class of the queried entity . @param parentEntity Cascading query parent entity . @param parentField Cascading query field . @hide
private void query(Query query, Class<?> rootClass, Object parentEntity, Field parentField) {
        Cursor retVal = getDb().rawQuery(query.getSql(), query.getArgs());
        if (transformer != null) {
            List<ResultSet> result = getConverter().convertCursorToCustomResultSetList(retVal);
            setResult(transformer.transformResult(result));
            return;
        } else {
            List<?> result = getConverter().convertCursorToEntityList(retVal, query.getRoot());
            cascadeQuery(result, rootClass);
            /*
             * If query is performed for the root object set the final result. Otherwise add result
             * to the parent entity.
             */
            if (parentEntity != null) {
                if (parentField.isAnnotationPresent(ManyToMany.class) || parentField.isAnnotationPresent(OneToMany.class)) {
                    ReflectionUtils.setFieldValue(parentField, parentEntity, resultsToCollection(result, parentField.getType()));
                } else {
                    if (!result.isEmpty()) {
                        ReflectionUtils.setFieldValue(parentField, parentEntity, result.get(0));
                    }
                }
            } else {
                setResult(result);
            }
        }
    }
private void query ( Query query , Class < ? > rootClass , Object parentEntity , Field parentField ) { Cursor retVal = getDb ( ) . rawQuery ( query . getSql ( ) , query . getArgs ( ) ) ; if ( transformer != null ) { List < ResultSet > result = getConverter ( ) . convertCursorToCustomResultSetList ( retVal ) ; setResult ( transformer . transformResult ( result ) ) ; return ; } else { List < ? > result = getConverter ( ) . convertCursorToEntityList ( retVal , query . getRoot ( ) ) ; cascadeQuery ( result , rootClass ) ; /*
             * If query is performed for the root object set the final result. Otherwise add result
             * to the parent entity.
             */ if ( parentEntity != null ) { if ( parentField . isAnnotationPresent ( ManyToMany . class ) || parentField . isAnnotationPresent ( OneToMany . class ) ) { ReflectionUtils . setFieldValue ( parentField , parentEntity , resultsToCollection ( result , parentField . getType ( ) ) ) ; } else { if ( ! result . isEmpty ( ) ) { ReflectionUtils . setFieldValue ( parentField , parentEntity , result . get ( 0 ) ) ; } } } else { setResult ( result ) ; } } }
Perform given query.
Perform given query .
// For custom transformer perform a custom query and return after setting result // Cascade the query for fetches & provide root always. // Otherwise it will be one to one primary key association // Add only if has results