app/src/main/java/db/juhaku/juhakudb/filter/QueryProcessor.java
/**
     * Create middle table join from root table to joined table. Middle table is searched from Schema
     * to maintain integrity. If middle table is not found exception will be thrown.
     *
     * @param rootAlias String alias or root table.
     * @param rootTable String name of root table join will be created from.
     * @param join instance of {@link Join} between root table and joined table.
     * @param sql {@link StringBuilder} containing current sql.
     *
     * @since 1.2.0
     *
     * @hide
     */
Create middle table join from root table to joined table. Middle table is searched from Schema
to maintain integrity. If middle table is not found exception will be thrown.

@param rootAlias String alias or root table.
@param rootTable String name of root table join will be created from.
@param join instance of  Join between root table and joined table.
@param sql  StringBuilder containing current sql.



@hide
Create middle table join from root table to joined table . Middle table is searched from Schema to maintain integrity . If middle table is not found exception will be thrown . @param rootAlias String alias or root table . @param rootTable String name of root table join will be created from . @param join instance of Join between root table and joined table . @param sql StringBuilder containing current sql . @hide
private void createMiddleTableJoin(String rootAlias, String rootTable, Join join, StringBuilder sql) {
        String targetTable = resolveName(join.getModel());
        Schema middleTable = findTableByName(rootTable.concat("_").concat(targetTable));
        if (middleTable == null) {
            middleTable = findTableByName(targetTable.concat("_").concat(rootTable));
        }
        if (middleTable == null) {
            throw new QueryBuildException("Failed to create join from table: " + rootTable + " to " + targetTable + ", no middle table found!");
        }
        String middleTableAlias = Alias.generateAlias(middleTable.getName());
        for (Reference reference : middleTable.getReferences()) {
            if (reference.getReferenceTableName().equals(rootTable)) {
                joinSql(sql, join.getJoinMode(), middleTable.getName(), NameResolver.ID_FIELD_SUFFIX,
                        rootAlias, reference.getColumnName(), middleTableAlias, false);
            }
            if (reference.getReferenceTableName().equals(targetTable)) {
                joinSql(sql, join.getJoinMode(), targetTable, reference.getColumnName(),
                        middleTableAlias, NameResolver.ID_FIELD_SUFFIX, Alias.forJoin(join), false);
            }
        }
    }
private void createMiddleTableJoin ( String rootAlias , String rootTable , Join join , StringBuilder sql ) { String targetTable = resolveName ( join . getModel ( ) ) ; Schema middleTable = findTableByName ( rootTable . concat ( "_" ) . concat ( targetTable ) ) ; if ( middleTable == null ) { middleTable = findTableByName ( targetTable . concat ( "_" ) . concat ( rootTable ) ) ; } if ( middleTable == null ) { throw new QueryBuildException ( "Failed to create join from table: " + rootTable + " to " + targetTable + ", no middle table found!" ) ; } String middleTableAlias = Alias . generateAlias ( middleTable . getName ( ) ) ; for ( Reference reference : middleTable . getReferences ( ) ) { if ( reference . getReferenceTableName ( ) . equals ( rootTable ) ) { joinSql ( sql , join . getJoinMode ( ) , middleTable . getName ( ) , NameResolver . ID_FIELD_SUFFIX , rootAlias , reference . getColumnName ( ) , middleTableAlias , false ) ; } if ( reference . getReferenceTableName ( ) . equals ( targetTable ) ) { joinSql ( sql , join . getJoinMode ( ) , targetTable , reference . getColumnName ( ) , middleTableAlias , NameResolver . ID_FIELD_SUFFIX , Alias . forJoin ( join ) , false ) ; } } }
Create middle table join from root table to joined table.
Create middle table join from root table to joined table .