use of org.hibernate.sql.ast.tree.from.StandardTableGroup in project hibernate-orm by hibernate.
the class InformixSqmToSqlAstConverter method visitQuerySpec.
@Override
public QuerySpec visitQuerySpec(SqmQuerySpec<?> sqmQuerySpec) {
final boolean needsDummy = this.needsDummyTableGroup;
this.needsDummyTableGroup = false;
try {
final QuerySpec querySpec = super.visitQuerySpec(sqmQuerySpec);
if (this.needsDummyTableGroup) {
querySpec.getFromClause().addRoot(new StandardTableGroup(true, null, null, null, new NamedTableReference("(select 1)", "dummy_(x)", false, getCreationContext().getSessionFactory()), null, getCreationContext().getSessionFactory()));
}
return querySpec;
} finally {
this.needsDummyTableGroup = needsDummy;
}
}
use of org.hibernate.sql.ast.tree.from.StandardTableGroup in project hibernate-orm by hibernate.
the class SybaseSqmToSqlAstConverter method visitQuerySpec.
@Override
public QuerySpec visitQuerySpec(SqmQuerySpec<?> sqmQuerySpec) {
final boolean needsDummy = this.needsDummyTableGroup;
this.needsDummyTableGroup = false;
try {
final QuerySpec querySpec = super.visitQuerySpec(sqmQuerySpec);
if (this.needsDummyTableGroup) {
querySpec.getFromClause().addRoot(new StandardTableGroup(true, null, null, null, new NamedTableReference("(select 1)", "dummy_(x)", false, getCreationContext().getSessionFactory()), null, getCreationContext().getSessionFactory()));
}
return querySpec;
} finally {
this.needsDummyTableGroup = needsDummy;
}
}
use of org.hibernate.sql.ast.tree.from.StandardTableGroup in project hibernate-orm by hibernate.
the class IngresSqmToSqlAstConverter method visitQuerySpec.
@Override
public QuerySpec visitQuerySpec(SqmQuerySpec<?> sqmQuerySpec) {
final boolean needsDummy = this.needsDummyTableGroup;
this.needsDummyTableGroup = false;
try {
final QuerySpec querySpec = super.visitQuerySpec(sqmQuerySpec);
if (this.needsDummyTableGroup) {
querySpec.getFromClause().addRoot(new StandardTableGroup(true, null, null, null, new NamedTableReference("(select 1)", "dummy_(x)", false, getCreationContext().getSessionFactory()), null, getCreationContext().getSessionFactory()));
}
return querySpec;
} finally {
this.needsDummyTableGroup = needsDummy;
}
}
use of org.hibernate.sql.ast.tree.from.StandardTableGroup in project hibernate-orm by hibernate.
the class ExecuteWithoutIdTableHelper method createIdMatchingSubQuerySpec.
public static QuerySpec createIdMatchingSubQuerySpec(NavigablePath navigablePath, TableReference rootTableReference, Predicate predicate, EntityPersister rootEntityPersister, SqlExpressionResolver sqlExpressionResolver, SessionFactoryImplementor sessionFactory) {
/*
* `select root_id from root_table where {predicate}
*/
final QuerySpec matchingIdSelect = new QuerySpec(false, 1);
final StandardTableGroup matchingIdSelectTableGroup = new StandardTableGroup(true, navigablePath, rootEntityPersister, rootTableReference.getIdentificationVariable(), rootTableReference, null, sessionFactory);
matchingIdSelect.getFromClause().addRoot(matchingIdSelectTableGroup);
rootEntityPersister.getIdentifierMapping().forEachSelectable((columnIndex, selection) -> {
final ColumnReference columnReference = (ColumnReference) sqlExpressionResolver.resolveSqlExpression(SqlExpressionResolver.createColumnReferenceKey(rootTableReference, selection.getSelectionExpression()), sqlAstProcessingState -> new ColumnReference(rootTableReference, selection, sessionFactory));
final SqlSelection sqlSelection = new SqlSelectionImpl(// irrelevant
0, 0, columnReference);
matchingIdSelect.getSelectClause().addSqlSelection(sqlSelection);
});
matchingIdSelect.applyPredicate(predicate);
return matchingIdSelect;
}
use of org.hibernate.sql.ast.tree.from.StandardTableGroup in project hibernate-orm by hibernate.
the class ExecuteWithTemporaryTableHelper method createIdTableSelectQuerySpec.
public static QuerySpec createIdTableSelectQuerySpec(TemporaryTable idTable, ModelPart fkModelPart, Function<SharedSessionContractImplementor, String> sessionUidAccess, EntityMappingType entityDescriptor, ExecutionContext executionContext) {
final QuerySpec querySpec = new QuerySpec(false);
final NamedTableReference idTableReference = new NamedTableReference(idTable.getTableExpression(), TemporaryTable.DEFAULT_ALIAS, true, executionContext.getSession().getFactory());
final TableGroup idTableGroup = new StandardTableGroup(true, new NavigablePath(idTableReference.getTableExpression()), entityDescriptor, null, idTableReference, null, executionContext.getSession().getFactory());
querySpec.getFromClause().addRoot(idTableGroup);
applyIdTableSelections(querySpec, idTableReference, idTable, fkModelPart, executionContext);
applyIdTableRestrictions(querySpec, idTableReference, idTable, sessionUidAccess, executionContext);
return querySpec;
}
Aggregations