Search in sources :

Example 1 with Queryable

use of org.hibernate.persister.entity.Queryable in project hibernate-orm by hibernate.

the class HqlSqlWalker method createIntoClause.

@Override
protected AST createIntoClause(String path, AST propertySpec) throws SemanticException {
    Queryable persister = (Queryable) getSessionFactoryHelper().requireClassPersister(path);
    IntoClause intoClause = (IntoClause) getASTFactory().create(INTO, persister.getEntityName());
    intoClause.setFirstChild(propertySpec);
    intoClause.initialize(persister);
    addQuerySpaces(persister.getQuerySpaces());
    return intoClause;
}
Also used : IntoClause(org.hibernate.hql.internal.ast.tree.IntoClause) Queryable(org.hibernate.persister.entity.Queryable)

Example 2 with Queryable

use of org.hibernate.persister.entity.Queryable in project hibernate-orm by hibernate.

the class FromElement method handlePropertyBeingDereferenced.

public void handlePropertyBeingDereferenced(Type propertySource, String propertyName) {
    if (getQueryableCollection() != null && CollectionProperties.isCollectionProperty(propertyName)) {
        // propertyName refers to something like collection.size...
        return;
    }
    if (propertySource.isComponentType()) {
        // property name is a sub-path of a component...
        return;
    }
    Queryable persister = getQueryable();
    if (persister != null) {
        try {
            Queryable.Declarer propertyDeclarer = persister.getSubclassPropertyDeclarer(propertyName);
            if (LOG.isTraceEnabled()) {
                LOG.tracev("Handling property dereference [{0} ({1}) -> {2} ({3})]", persister.getEntityName(), getClassAlias(), propertyName, propertyDeclarer);
            }
            if (propertyDeclarer == Queryable.Declarer.SUBCLASS) {
                dereferencedBySubclassProperty = true;
                includeSubclasses = true;
            } else if (propertyDeclarer == Queryable.Declarer.SUPERCLASS) {
                dereferencedBySuperclassProperty = true;
            }
        } catch (QueryException ignore) {
        // ignore it; the incoming property could not be found so we
        // cannot be sure what to do here.  At the very least, the
        // safest is to simply not apply any dereference toggling...
        }
    }
}
Also used : QueryException(org.hibernate.QueryException) Queryable(org.hibernate.persister.entity.Queryable)

Example 3 with Queryable

use of org.hibernate.persister.entity.Queryable in project hibernate-orm by hibernate.

the class FromElementFactory method addFromElement.

FromElement addFromElement() throws SemanticException {
    final FromClause parentFromClause = fromClause.getParentFromClause();
    if (parentFromClause != null) {
        // Look up class name using the first identifier in the path.
        final String pathAlias = PathHelper.getAlias(path);
        final FromElement parentFromElement = parentFromClause.getFromElement(pathAlias);
        if (parentFromElement != null) {
            return createFromElementInSubselect(path, pathAlias, parentFromElement, classAlias);
        }
    }
    final EntityPersister entityPersister = fromClause.getSessionFactoryHelper().requireClassPersister(path);
    final FromElement elem = createAndAddFromElement(path, classAlias, entityPersister, (EntityType) ((Queryable) entityPersister).getType(), null);
    // Add to the query spaces.
    fromClause.getWalker().addQuerySpaces(entityPersister.getQuerySpaces());
    return elem;
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) Queryable(org.hibernate.persister.entity.Queryable)

Example 4 with Queryable

use of org.hibernate.persister.entity.Queryable 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)

Example 5 with Queryable

use of org.hibernate.persister.entity.Queryable in project hibernate-orm by hibernate.

the class PersistentTableBulkIdStrategy method buildUpdateHandler.

@Override
public UpdateHandler buildUpdateHandler(SessionFactoryImplementor factory, HqlSqlWalker walker) {
    final UpdateStatement updateStatement = (UpdateStatement) walker.getAST();
    final FromElement fromElement = updateStatement.getFromClause().getFromElement();
    final Queryable targetedPersister = fromElement.getQueryable();
    return new UpdateHandlerImpl(factory, walker, getIdTableInfo(targetedPersister));
}
Also used : UpdateStatement(org.hibernate.hql.internal.ast.tree.UpdateStatement) FromElement(org.hibernate.hql.internal.ast.tree.FromElement) Queryable(org.hibernate.persister.entity.Queryable)

Aggregations

Queryable (org.hibernate.persister.entity.Queryable)35 QueryException (org.hibernate.QueryException)11 FromElement (org.hibernate.hql.internal.ast.tree.FromElement)8 Type (org.hibernate.type.Type)8 EntityType (org.hibernate.type.EntityType)6 CollectionType (org.hibernate.type.CollectionType)5 SharedSessionContractImplementor (org.hibernate.engine.spi.SharedSessionContractImplementor)4 UpdateStatement (org.hibernate.hql.internal.ast.tree.UpdateStatement)4 DeleteStatement (org.hibernate.hql.internal.ast.tree.DeleteStatement)3 QueryableCollection (org.hibernate.persister.collection.QueryableCollection)3 EntityPersister (org.hibernate.persister.entity.EntityPersister)3 JoinType (org.hibernate.sql.JoinType)3 AST (antlr.collections.AST)2 InsertStatement (org.hibernate.hql.internal.ast.tree.InsertStatement)2 ParameterNode (org.hibernate.hql.internal.ast.tree.ParameterNode)2 TableBasedDeleteHandlerImpl (org.hibernate.hql.spi.id.TableBasedDeleteHandlerImpl)2 TableBasedUpdateHandlerImpl (org.hibernate.hql.spi.id.TableBasedUpdateHandlerImpl)2 CollectionFilterKeyParameterSpecification (org.hibernate.param.CollectionFilterKeyParameterSpecification)2 NamedParameterSpecification (org.hibernate.param.NamedParameterSpecification)2 ParameterSpecification (org.hibernate.param.ParameterSpecification)2