Search in sources :

Example 1 with FromElement

use of org.hibernate.hql.internal.ast.tree.FromElement in project hibernate-orm by hibernate.

the class HqlSqlWalker method createFromElement.

@Override
protected AST createFromElement(String path, AST alias, AST propertyFetch) throws SemanticException {
    FromElement fromElement = currentFromClause.addFromElement(path, alias);
    fromElement.setAllPropertyFetch(propertyFetch != null);
    return fromElement;
}
Also used : FromElement(org.hibernate.hql.internal.ast.tree.FromElement) EntityJoinFromElement(org.hibernate.hql.internal.ast.tree.EntityJoinFromElement)

Example 2 with FromElement

use of org.hibernate.hql.internal.ast.tree.FromElement in project hibernate-orm by hibernate.

the class HqlSqlWalker method lookupAlias.

@Override
protected void lookupAlias(AST aliasRef) throws SemanticException {
    FromElement alias = currentFromClause.getFromElement(aliasRef.getText());
    FromReferenceNode aliasRefNode = (FromReferenceNode) aliasRef;
    aliasRefNode.setFromElement(alias);
}
Also used : FromReferenceNode(org.hibernate.hql.internal.ast.tree.FromReferenceNode) FromElement(org.hibernate.hql.internal.ast.tree.FromElement) EntityJoinFromElement(org.hibernate.hql.internal.ast.tree.EntityJoinFromElement)

Example 3 with FromElement

use of org.hibernate.hql.internal.ast.tree.FromElement in project hibernate-orm by hibernate.

the class HqlSqlWalker method beforeSelectClause.

@Override
protected void beforeSelectClause() throws SemanticException {
    // Turn off includeSubclasses on all FromElements.
    FromClause from = getCurrentFromClause();
    List fromElements = from.getFromElements();
    for (Iterator iterator = fromElements.iterator(); iterator.hasNext(); ) {
        FromElement fromElement = (FromElement) iterator.next();
        fromElement.setIncludeSubclasses(false);
    }
}
Also used : FromClause(org.hibernate.hql.internal.ast.tree.FromClause) FromElement(org.hibernate.hql.internal.ast.tree.FromElement) EntityJoinFromElement(org.hibernate.hql.internal.ast.tree.EntityJoinFromElement) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList)

Example 4 with FromElement

use of org.hibernate.hql.internal.ast.tree.FromElement in project hibernate-orm by hibernate.

the class SqlGenerator method nestedFromFragment.

@Override
protected void nestedFromFragment(AST d, AST parent) {
    // to determine if a comma is required between them
    if (d != null && hasText(d)) {
        if (parent != null && hasText(parent)) {
            // again, both should be FromElements
            FromElement left = (FromElement) parent;
            FromElement right = (FromElement) d;
            if (right.getRealOrigin() == left) {
                // right represents a joins originating from left...
                if (right.getJoinSequence() != null && right.getJoinSequence().isThetaStyle()) {
                    writeCrossJoinSeparator();
                } else {
                    out(" ");
                }
            } else {
                // not so sure this is even valid subtree.  but if it was, it'd
                // represent two unrelated table references...
                writeCrossJoinSeparator();
            }
        }
        out(d);
    }
}
Also used : FromElement(org.hibernate.hql.internal.ast.tree.FromElement)

Example 5 with FromElement

use of org.hibernate.hql.internal.ast.tree.FromElement in project hibernate-orm by hibernate.

the class LocalTemporaryTableBulkIdStrategy method buildDeleteHandler.

@Override
public DeleteHandler buildDeleteHandler(SessionFactoryImplementor factory, HqlSqlWalker walker) {
    final DeleteStatement updateStatement = (DeleteStatement) walker.getAST();
    final FromElement fromElement = updateStatement.getFromClause().getFromElement();
    final Queryable targetedPersister = fromElement.getQueryable();
    final IdTableInfoImpl tableInfo = getIdTableInfo(targetedPersister);
    return new TableBasedDeleteHandlerImpl(factory, walker, tableInfo) {

        @Override
        protected void prepareForUse(Queryable persister, SharedSessionContractImplementor session) {
            Helper.INSTANCE.createTempTable(tableInfo, ddlTransactionHandling, session);
        }

        @Override
        protected void releaseFromUse(Queryable persister, SharedSessionContractImplementor session) {
            Helper.INSTANCE.releaseTempTable(tableInfo, afterUseAction, ddlTransactionHandling, session);
        }
    };
}
Also used : TableBasedDeleteHandlerImpl(org.hibernate.hql.spi.id.TableBasedDeleteHandlerImpl) FromElement(org.hibernate.hql.internal.ast.tree.FromElement) Queryable(org.hibernate.persister.entity.Queryable) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) DeleteStatement(org.hibernate.hql.internal.ast.tree.DeleteStatement)

Aggregations

FromElement (org.hibernate.hql.internal.ast.tree.FromElement)22 EntityJoinFromElement (org.hibernate.hql.internal.ast.tree.EntityJoinFromElement)9 Queryable (org.hibernate.persister.entity.Queryable)8 ArrayList (java.util.ArrayList)5 List (java.util.List)5 QueryException (org.hibernate.QueryException)4 SharedSessionContractImplementor (org.hibernate.engine.spi.SharedSessionContractImplementor)4 AST (antlr.collections.AST)3 Iterator (java.util.Iterator)3 JoinSequence (org.hibernate.engine.internal.JoinSequence)3 DeleteStatement (org.hibernate.hql.internal.ast.tree.DeleteStatement)3 FromClause (org.hibernate.hql.internal.ast.tree.FromClause)3 UpdateStatement (org.hibernate.hql.internal.ast.tree.UpdateStatement)3 FromElementFactory (org.hibernate.hql.internal.ast.tree.FromElementFactory)2 FromReferenceNode (org.hibernate.hql.internal.ast.tree.FromReferenceNode)2 ImpliedFromElement (org.hibernate.hql.internal.ast.tree.ImpliedFromElement)2 QueryNode (org.hibernate.hql.internal.ast.tree.QueryNode)2 TableBasedDeleteHandlerImpl (org.hibernate.hql.spi.id.TableBasedDeleteHandlerImpl)2 TableBasedUpdateHandlerImpl (org.hibernate.hql.spi.id.TableBasedUpdateHandlerImpl)2 QueryableCollection (org.hibernate.persister.collection.QueryableCollection)2