app/src/main/java/db/juhaku/juhakudb/filter/QueryProcessor.java
/**
     * Create full sql query with parameters. Sql query is formatted to {@link Query} object containing
     * sql and parameters in correct order.
     *
     * @param modelClass Instance of {@link Class} of model class of database tables.
     * @param filter {@link Filter} to create select, joins and where statement.
     * @return newly created query.
     *
     * @since 1.2.0
     */
Create full sql query with parameters. Sql query is formatted to  Query object containing
sql and parameters in correct order.

@param modelClass Instance of  Class of model class of database tables.
@param filter  Filter to create select, joins and where statement.
@return newly created query.


Create full sql query with parameters . Sql query is formatted to Query object containing sql and parameters in correct order . @param modelClass Instance of Class of model class of database tables . @param filter Filter to create select joins and where statement . @return newly created query .
public Query createQuery(Class<?> modelClass, Filter filter) {
        Root<?> root = new Root<>(modelClass);
        PredicateBuilder builder = new PredicateBuilder();
        filter.filter(root, builder);
        StringBuilder sql = new StringBuilder();
        createSelect(root, sql); 
        createJoins(root, sql);
        if (!builder.getPredicates().isEmpty()) {
            sql.append("WHERE ");
        }
        String[] args = createWhere(root, sql, builder); 
        String order = builder.getSort();
        String page = builder.getPage();
        if (!StringUtils.isBlank(order)) {
            sql.append(order);
        }
        if (!StringUtils.isBlank(page)) {
            sql.append(page);
        }
        Alias.clearCache();
        Query query = new Query(sql.toString(), args);
        query.setRoot(root);
        return query;
    }
public Query createQuery ( Class < ? > modelClass , Filter filter ) { Root < ? > root = new Root < > ( modelClass ) ; PredicateBuilder builder = new PredicateBuilder ( ) ; filter . filter ( root , builder ) ; StringBuilder sql = new StringBuilder ( ) ; createSelect ( root , sql ) ; createJoins ( root , sql ) ; if ( ! builder . getPredicates ( ) . isEmpty ( ) ) { sql . append ( "WHERE " ) ; } String [ ] args = createWhere ( root , sql , builder ) ; String order = builder . getSort ( ) ; String page = builder . getPage ( ) ; if ( ! StringUtils . isBlank ( order ) ) { sql . append ( order ) ; } if ( ! StringUtils . isBlank ( page ) ) { sql . append ( page ) ; } Alias . clearCache ( ) ; Query query = new Query ( sql . toString ( ) , args ) ; query . setRoot ( root ) ; return query ; }
Create full sql query with parameters.
Create full sql query with parameters .
// initialize root and predicates for joins and restrictions // create joins and restrictions // create select statement from root // create where clause from predicates