Gets the join table idx.

@param _sqlSelect the sql select
@return the join table idx
@throws EFapsException the e faps exception
348423
@Override
    public TableIdx getJoinTableIdx(final SQLSelect _sqlSelect)
        throws EFapsException
    {
        final String linktoColName = this.attribute.getSqlColNames().get(0);
        final String tableName = ((SQLTable) getTable()).getSqlTable();
        final Attribute joinAttr = this.attribute.getLink().getAttribute("ID");
        final String joinTableName = joinAttr.getTable().getSqlTable();
        return _sqlSelect.getIndexer().getTableIdx(joinTableName, tableName, linktoColName);
    }
524561
private ColumnInfo getJoinColumn(TableInfo tableInfo, String joinColumnName, Class columnType)
    {
        ColumnInfo columnInfo = new ColumnInfo();
        columnInfo.setColumnName(joinColumnName);
        columnInfo.setIndexable(true);

        IndexInfo indexInfo = new IndexInfo(joinColumnName);
        tableInfo.addToIndexedColumnList(indexInfo);

        columnInfo.setType(columnType);
        return columnInfo;
    }
1324647
protected function getSelectColumnsSQL()
    {
        // Create the column list fragment only once
        if ($this->currentPersisterContext->selectColumnListSql !== null) {
            return $this->currentPersisterContext->selectColumnListSql;
        }

        $this->currentPersisterContext->rsm->addEntityResult($this->class->getClassName(), 'r');

        $columnList = [];

        // Add columns
        foreach ($this->class->getDeclaredPropertiesIterator() as $fieldName => $property) {
            if ($property instanceof FieldMetadata) {
                $columnList[] = $this->getSelectColumnSQL($fieldName, $property->getDeclaringClass());

                continue;
            }

            if (! ($property instanceof ToOneAssociationMetadata) || ! $property->isOwningSide()) {
                continue;
            }

            $targetClass = $this->em->getClassMetadata($property->getTargetEntity());

            foreach ($property->getJoinColumns() as $joinColumn) {
                /** @var JoinColumnMetadata $joinColumn */
                $referencedColumnName = $joinColumn->getReferencedColumnName();

                if (! $joinColumn->getType()) {
                    $joinColumn->setType(PersisterHelper::getTypeOfColumn($referencedColumnName, $targetClass, $this->em));
                }

                $columnList[] = $this->getSelectJoinColumnSQL($joinColumn);
            }
        }

        // Add discriminator column (DO NOT ALIAS, see AbstractEntityInheritancePersister#processSQLResult).
        $discrColumn      = $this->class->discriminatorColumn;
        $discrTableAlias  = $this->getSQLTableAlias($discrColumn->getTableName());
        $discrColumnName  = $discrColumn->getColumnName();
        $discrColumnType  = $discrColumn->getType();
        $resultColumnName = $this->platform->getSQLResultCasing($discrColumnName);
        $quotedColumnName = $this->platform->quoteIdentifier($discrColumn->getColumnName());

        $this->currentPersisterContext->rsm->setDiscriminatorColumn('r', $resultColumnName);
        $this->currentPersisterContext->rsm->addMetaResult('r', $resultColumnName, $discrColumnName, false, $discrColumnType);

        $columnList[] = $discrColumnType->convertToDatabaseValueSQL($discrTableAlias . '.' . $quotedColumnName, $this->platform);

        // sub tables
        foreach ($this->class->getSubClasses() as $subClassName) {
            $subClass = $this->em->getClassMetadata($subClassName);

            // Add columns
            foreach ($subClass->getDeclaredPropertiesIterator() as $fieldName => $property) {
                if ($subClass->isInheritedProperty($fieldName)) {
                    continue;
                }

                switch (true) {
                    case $property instanceof FieldMetadata:
                        $columnList[] = $this->getSelectColumnSQL($fieldName, $subClass);
                        break;

                    case $property instanceof ToOneAssociationMetadata && $property->isOwningSide():
                        $targetClass = $this->em->getClassMetadata($property->getTargetEntity());

                        foreach ($property->getJoinColumns() as $joinColumn) {
                            /** @var JoinColumnMetadata $joinColumn */
                            $referencedColumnName = $joinColumn->getReferencedColumnName();

                            if (! $joinColumn->getType()) {
                                $joinColumn->setType(PersisterHelper::getTypeOfColumn($referencedColumnName, $targetClass, $this->em));
                            }

                            $columnList[] = $this->getSelectJoinColumnSQL($joinColumn);
                        }

                        break;
                }
            }
        }

        $this->currentPersisterContext->selectColumnListSql = implode(', ', $columnList);

        return $this->currentPersisterContext->selectColumnListSql;
    }
402938
private Select selectFrom(TableDDL tableDDL) {
        return QueryBuilder.select()
                .column(tableDDL.getRowKeyColumnName())     // ROW_KEY_RESULT_SET_COLUMN
                .column(tableDDL.getChangeIdColumnName())   // CHANGE_ID_RESULT_SET_COLUMN
                .column(tableDDL.getValueColumnName())      // VALUE_RESULT_SET_COLUMN
                .from(tableDDL.getTableMetadata());
    }
293079
public String selectCount(MappedStatement ms) {
        Class<?> entityClass = getEntityClass(ms);
        StringBuilder sql = new StringBuilder();
        sql.append(SqlHelper.selectCount(entityClass));
        sql.append(SqlHelper.fromTable(entityClass, tableName(entityClass)));
        sql.append(SqlHelper.whereAllIfColumns(entityClass, isNotEmpty()));
        return sql.toString();
    }
631816
public QueryBuilder<T, ID> join(QueryBuilder<?, ?> joinedQueryBuilder, JoinType type, JoinWhereOperation operation)
			throws SQLException {
		addJoinInfo(type, null, null, joinedQueryBuilder, operation);
		return this;
	}
595385
protected function addDoSelectJoin(&$script)
    {
        $table = $this->getTable();
        $className = $this->getObjectClassname();
        $countFK = count($table->getForeignKeys());
        $join_behavior = $this->getJoinBehavior();

        if ($countFK >= 1) {

            foreach ($table->getForeignKeys() as $fk) {

                $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());

                if (!$joinTable->isForReferenceOnly()) {

                    // This condition is necessary because Propel lacks a system for
                    // aliasing the table if it is the same table.
                    if ($fk->getForeignTableName() != $table->getName()) {

                        $thisTableObjectBuilder = $this->getNewObjectBuilder($table);
                        $joinedTableObjectBuilder = $this->getNewObjectBuilder($joinTable);
                        $joinedTablePeerBuilder = $this->getNewPeerBuilder($joinTable);

                        $joinClassName = $joinedTableObjectBuilder->getObjectClassname();

                        $script .= "

    /**
     * Selects a collection of $className objects pre-filled with their $joinClassName objects.
     * @param      Criteria  \$criteria
     * @param      PropelPDO \$con
     * @param      String    \$join_behavior the type of joins to use, defaults to $join_behavior
     * @return array           Array of $className objects.
     * @throws PropelException Any exceptions caught during processing will be
     *		 rethrown wrapped into a PropelException.
     */
    public static function doSelectJoin" . $thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false) . "(Criteria \$criteria, \$con = null, \$join_behavior = $join_behavior)
    {
        \$criteria = clone \$criteria;

        // Set the correct dbName if it has not been overridden
        if (\$criteria->getDbName() == Propel::getDefaultDB()) {
            \$criteria->setDbName(" . $this->getPeerClassname() . "::DATABASE_NAME);
        }

        " . $this->getPeerClassname() . "::addSelectColumns(\$criteria);
        \$startcol = " . $this->getPeerClassname() . "::NUM_HYDRATE_COLUMNS;
        " . $joinedTablePeerBuilder->getPeerClassname() . "::addSelectColumns(\$criteria);
";

                        $script .= $this->addCriteriaJoin($fk, $table, $joinTable, $joinedTablePeerBuilder);

                        // apply behaviors
                        $this->applyBehaviorModifier('preSelect', $script);

                        $script .= "
        \$stmt = " . $this->basePeerClassname . "::doSelect(\$criteria, \$con);
        \$results = array();

        while (\$row = \$stmt->fetch(PDO::FETCH_NUM)) {
            \$key1 = " . $this->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, 0);
            if (null !== (\$obj1 = " . $this->getPeerClassname() . "::getInstanceFromPool(\$key1))) {
                // We no longer rehydrate the object, since this can cause data loss.
                // See http://www.propelorm.org/ticket/509
                // \$obj1->hydrate(\$row, 0, true); // rehydrate
            } else {
";
                        if ($table->getChildrenColumn()) {
                            $script .= "
                \$omClass = " . $this->getPeerClassname() . "::getOMClass(\$row, 0);
                \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1);
";
                        } else {
                            $script .= "
                \$cls = " . $this->getPeerClassname() . "::getOMClass();
";
                        }
                        $script .= "
                " . $this->buildObjectInstanceCreationCode('$obj1', '$cls') . "
                \$obj1->hydrate(\$row);
                " . $this->getPeerClassname() . "::addInstanceToPool(\$obj1, \$key1);
            } // if \$obj1 already loaded

            \$key2 = " . $joinedTablePeerBuilder->getPeerClassname() . "::getPrimaryKeyHashFromRow(\$row, \$startcol);
            if (\$key2 !== null) {
                \$obj2 = " . $joinedTablePeerBuilder->getPeerClassname() . "::getInstanceFromPool(\$key2);
                if (!\$obj2) {
";
                        if ($joinTable->getChildrenColumn()) {
                            $script .= "
                    \$omClass = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass(\$row, \$startcol);
                    \$cls = substr('.'.\$omClass, strrpos('.'.\$omClass, '.') + 1);
";
                        } else {
                            $script .= "
                    \$cls = " . $joinedTablePeerBuilder->getPeerClassname() . "::getOMClass();
";
                        }

                        $script .= "
                    " . $this->buildObjectInstanceCreationCode('$obj2', '$cls') . "
                    \$obj2->hydrate(\$row, \$startcol);
                    " . $joinedTablePeerBuilder->getPeerClassname() . "::addInstanceToPool(\$obj2, \$key2);
                } // if obj2 already loaded

                // Add the \$obj1 (" . $this->getObjectClassname() . ") to \$obj2 (" . $joinedTablePeerBuilder->getObjectClassname() . ")";
                        if ($fk->isLocalPrimaryKey()) {
                            $script .= "
                // one to one relationship
                \$obj1->set" . $joinedTablePeerBuilder->getObjectClassname() . "(\$obj2);";
                        } else {
                            $script .= "
                \$obj2->add" . $joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false) . "(\$obj1);";
                        }
                        $script .= "

            } // if joined row was not null

            \$results[] = \$obj1;
        }
        \$stmt->closeCursor();

        return \$results;
    }
";
                    } // if fk table name != this table name
                } // if ! is reference only
            } // foreach column
        } // if count(fk) > 1

    }
244215
public String selectCountByExample(MappedStatement ms) {
        Class<?> entityClass = getEntityClass(ms);
        StringBuilder sql = new StringBuilder("SELECT ");
        if (isCheckExampleEntityClass()) {
            sql.append(SqlHelper.exampleCheck(entityClass));
        }
        sql.append(SqlHelper.exampleCountColumn(entityClass));
        sql.append(SqlHelper.fromTable(entityClass, tableName(entityClass)));
        sql.append(SqlHelper.exampleWhereClause());
        sql.append(SqlHelper.exampleForUpdate());
        return sql.toString();
    }
1278086
public Instance execute()
        throws EFapsException
    {
        this.update = new Insert((IInsertStatement) getEQLStmt());
        StmtRunner.get().execute(this.update);
        return this.update.getInstance();
    }
518544
public ConnectionResource getConnectionResource()
        throws EFapsException
    {
        try {
            if (this.connectionResource == null) {
                this.connectionResource = new ConnectionResource(Context.DATASOURCE.getConnection());
            }
        } catch (final SQLException e) {
            throw new EFapsException(getClass(), "getConnectionResource.SQLException", e);
        }
        return this.connectionResource;
    }
662967
public AbstractPrintQuery addMsgPhrase(final SelectBuilder _selectBldr,
                                           final CIMsgPhrase... _ciMsgPhrases)
        throws EFapsException
    {
        final Set<MsgPhrase> msgPhrases = new HashSet<>();
        for (final CIMsgPhrase ciMsgPhrase : _ciMsgPhrases) {
            msgPhrases.add(ciMsgPhrase.getMsgPhrase());
        }
        return addMsgPhrase(_selectBldr, msgPhrases.toArray(new MsgPhrase[msgPhrases.size()]));
    }
96369
public final Connection getConnection() throws SQLException {

      final Timer.Context ctx = acquisitions.time();

      try {

         Connection conn;
         for(int i = 0; i < activeSegments; i++) {
            conn = segments[i].open();
            if(conn != null) {
               return conn;
            }
         }

         //All connections for active segments were in-use.
         //Send signal to attempt to activate a new segment then
         //try the active segments in-order (again) with the acquire time-out.

         signalActivateSegment();

         try {

            for(int i = 0; i < activeSegments; i++) {
               ConnectionPoolSegment segment = segments[i];
               conn = segment.open(segment.acquireTimeoutMillis, TimeUnit.MILLISECONDS);
               if(conn != null) {
                  return conn;
               }
            }

         } catch(InterruptedException ie) {
            Thread.currentThread().interrupt();
            throw new SQLException("Connection pool, '" + name + "' interrupted during acquire", JDBConnection.SQLSTATE_CONNECTION_EXCEPTION);
         }

         //Try all pools again with maximum acquire timeout.

         long maxTimeoutMillis = saturatedAcquireTimeoutMillis / activeSegments;

         try {

            for(int i = 0; i < activeSegments; i++) {
               ConnectionPoolSegment segment = segments[i];
               conn = segment.open(maxTimeoutMillis, TimeUnit.MILLISECONDS);
               if(conn != null) {
                  return conn;
               }
            }

         } catch(InterruptedException ie) {
            Thread.currentThread().interrupt();
            throw new SQLException("Connection pool, '" + name + "' interrupted during acquire", JDBConnection.SQLSTATE_CONNECTION_EXCEPTION);
         }

         //Done trying

         failedAcquisitions.mark();

         throw new SQLException(SATURATED_MESSAGE, JDBConnection.SQLSTATE_CONNECTION_FAILURE);

      } finally {
         ctx.stop();
      }
   }
600086
public String getSelectMNStatement(String table, String[] selectColumns, String[] columns)
    {
        SqlStatement sql;
        String result;

        sql = new SqlSelectMNStatement(table, selectColumns, columns, logger);
        result = sql.getStatement();

        if (logger.isDebugEnabled())
        {
            logger.debug("SQL:" + result);
        }
        return result;
    }
1206600
private Selection analyze(final IStmtProvider _stmtProvider)
        throws EFapsException
    {
        final Type type = evalMainType(_stmtProvider.getTypes());
        final IStatement<?> stmt = _stmtProvider.getStmt();
        for (final ISelect sel : ((IPrintStatement<?>) stmt).getSelection().getSelects()) {
            final Select select = Select.get(sel.getAlias());
            if (this.selects.isEmpty()) {
                this.instSelects.put(BASEPATH, Select.get().addElement(new InstanceElement(type)));
            }
            this.selects.add(select);
            Type currentType = type;
            for (final ISelectElement ele : sel.getElements()) {
                if (ele instanceof IAttributeSelectElement) {
                    final String attrName = ((IAttributeSelectElement) ele).getName();
                    final Attribute attr = currentType.getAttribute(attrName);
                    if (attr == null) {
                        LOG.error("Could not find Attribute '{}' on Type '{}'", attrName, currentType.getName());
                    }
                    final AttributeElement element = new AttributeElement().setAttribute(attr);
                    select.addElement(element);
                } else if (ele instanceof ILinktoSelectElement) {
                    final String attrName = ((ILinktoSelectElement) ele).getName();
                    final Attribute attr = currentType.getAttribute(attrName);
                    final LinktoElement element = new LinktoElement().setAttribute(attr);
                    select.addElement(element);
                    currentType = attr.getLink();
                    addInstSelect(select, element, attr, currentType);
                } else if (ele instanceof ILinkfromSelectElement) {
                    final String typeName = ((ILinkfromSelectElement) ele).getTypeName();
                    final String attrName = ((ILinkfromSelectElement) ele).getAttribute();
                    final Type linkFromType = Type.get(typeName);
                    final Attribute attr = linkFromType.getAttribute(attrName);
                    final LinkfromElement element = new LinkfromElement().setAttribute(attr).setStartType(currentType);
                    select.addElement(element);
                    addInstSelect(select, element, attr, currentType);
                    currentType = linkFromType;
                } else if (ele instanceof IClassSelectElement) {
                    final String typeName = ((IClassSelectElement) ele).getName();
                    final Classification classification = Classification.get(typeName);
                    final ClassElement element = new ClassElement().setClassification(classification)
                                    .setType(currentType);
                    select.addElement(element);
                    addInstSelect(select, element, classification, currentType);
                    currentType = classification;
                } else if (ele instanceof IAttributeSetSelectElement) {
                    final String attrSetName = ((IAttributeSetSelectElement) ele).getName();
                    final AttributeSet attributeSet = AttributeSet.find(currentType.getName(), attrSetName);
                    final AttributeSetElement element = new AttributeSetElement().setAttributeSet(attributeSet)
                                    .setType(currentType);
                    select.addElement(element);
                    addInstSelect(select, element, attributeSet, currentType);
                    currentType = attributeSet;
                } else if (ele instanceof IBaseSelectElement) {
                    switch (((IBaseSelectElement) ele).getElement()) {
                        case INSTANCE:
                            select.addElement(new InstanceElement(currentType));
                            break;
                        case OID:
                            select.addElement(new OIDElement(currentType));
                            break;
                        case STATUS:
                            select.addElement(new StatusElement(currentType));
                            break;
                        case TYPE:
                            select.addElement(new TypeElement(currentType));
                            break;
                        case KEY:
                            select.addElement(new KeyElement());
                            break;
                        case LABEL:
                            select.addElement(new LabelElement());
                            break;
                        case NAME:
                            select.addElement(new NameElement());
                            break;
                        case ID:
                            select.addElement(new IDElement());
                            break;
                        case UUID:
                            select.addElement(new UUIDElement());
                            break;
                        case FIRST:
                            select.addElement(new FirstElement());
                            break;
                        case LAST:
                            select.addElement(new LastElement());
                            break;
                        default:
                            break;
                    }
                } else if (ele instanceof IFormatSelectElement) {
                    final String pattern = ((IFormatSelectElement) ele).getPattern();
                    select.addElement(new FormatElement().setPattern(pattern));
                } else if (ele instanceof IExecSelectElement) {
                    select.addElement(new ExecElement(currentType)
                                    .setEsjp(((IExecSelectElement) ele).getClassName())
                                    .setParameters(((IExecSelectElement) ele).getParameters()));
                }
            }
        }
        return this;
    }
488735
public void addFileSelectPart()
        throws EFapsException
    {
        final Type type;
        // if a previous select exists it is based on the previous select,
        // else it is based on the basic table
        if (this.selectParts.size() > 0) {
            type = this.selectParts.get(this.selectParts.size() - 1).getType();
        } else {
            type = this.query.getMainType();
        }
        final FileSelectPart linkto = new FileSelectPart(type);
        this.selectParts.add(linkto);
    }
84768
public String getNote()
        throws EFapsException
    {
        String ret = "";
        final QueryBuilder queryBldr = new QueryBuilder(CIAdminUser.Abstract);
        queryBldr.addWhereAttrEqValue(CIAdminUser.Abstract.ID, getId());
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CIAdminUser.Abstract.Note);
        if (multi.execute()) {
            multi.next();
            ret = multi.getAttribute(CIAdminUser.Abstract.Note);
        }
        return ret;
    }
994833
public boolean next()
        throws EFapsException
    {
        initialize(false);
        boolean stepForward = true;
        boolean ret = true;
        while (stepForward && ret) {
            ret = step(this.selection.getAllSelects());
            stepForward = !this.access.hasAccess(inst());
        }
        return ret;
    }