Search in sources :

Example 1 with BasicExecutor

use of org.hibernate.hql.internal.ast.exec.BasicExecutor in project hibernate-orm by hibernate.

the class QueryTranslatorImpl method buildAppropriateStatementExecutor.

private StatementExecutor buildAppropriateStatementExecutor(HqlSqlWalker walker) {
    final Statement statement = (Statement) walker.getAST();
    if (walker.getStatementType() == HqlSqlTokenTypes.DELETE) {
        final FromElement fromElement = walker.getFinalFromClause().getFromElement();
        final Queryable persister = fromElement.getQueryable();
        if (persister.isMultiTable()) {
            return new MultiTableDeleteExecutor(walker);
        } else {
            return new DeleteExecutor(walker, persister);
        }
    } else if (walker.getStatementType() == HqlSqlTokenTypes.UPDATE) {
        final FromElement fromElement = walker.getFinalFromClause().getFromElement();
        final Queryable persister = fromElement.getQueryable();
        if (persister.isMultiTable()) {
            // TODO : decide if it is better performance-wise to doAfterTransactionCompletion that check, or to simply use the MultiTableUpdateDelegate
            return new MultiTableUpdateExecutor(walker);
        } else {
            return new BasicExecutor(walker, persister);
        }
    } else if (walker.getStatementType() == HqlSqlTokenTypes.INSERT) {
        return new BasicExecutor(walker, ((InsertStatement) statement).getIntoClause().getQueryable());
    } else {
        throw new QueryException("Unexpected statement type");
    }
}
Also used : MultiTableDeleteExecutor(org.hibernate.hql.internal.ast.exec.MultiTableDeleteExecutor) DeleteExecutor(org.hibernate.hql.internal.ast.exec.DeleteExecutor) QueryException(org.hibernate.QueryException) Statement(org.hibernate.hql.internal.ast.tree.Statement) InsertStatement(org.hibernate.hql.internal.ast.tree.InsertStatement) FromElement(org.hibernate.hql.internal.ast.tree.FromElement) Queryable(org.hibernate.persister.entity.Queryable) MultiTableUpdateExecutor(org.hibernate.hql.internal.ast.exec.MultiTableUpdateExecutor) BasicExecutor(org.hibernate.hql.internal.ast.exec.BasicExecutor) MultiTableDeleteExecutor(org.hibernate.hql.internal.ast.exec.MultiTableDeleteExecutor) InsertStatement(org.hibernate.hql.internal.ast.tree.InsertStatement)

Aggregations

QueryException (org.hibernate.QueryException)1 BasicExecutor (org.hibernate.hql.internal.ast.exec.BasicExecutor)1 DeleteExecutor (org.hibernate.hql.internal.ast.exec.DeleteExecutor)1 MultiTableDeleteExecutor (org.hibernate.hql.internal.ast.exec.MultiTableDeleteExecutor)1 MultiTableUpdateExecutor (org.hibernate.hql.internal.ast.exec.MultiTableUpdateExecutor)1 FromElement (org.hibernate.hql.internal.ast.tree.FromElement)1 InsertStatement (org.hibernate.hql.internal.ast.tree.InsertStatement)1 Statement (org.hibernate.hql.internal.ast.tree.Statement)1 Queryable (org.hibernate.persister.entity.Queryable)1