Search in sources :

Example 11 with FromClause

use of org.hibernate.sql.ast.tree.from.FromClause in project hibernate-orm by hibernate.

the class EntityGraphLoadPlanBuilderTest method assertPluralAttributeJoinedGroup.

private void assertPluralAttributeJoinedGroup(SelectStatement sqlAst, String expectedPluralAttributeName, Consumer<TableGroup> tableGroupConsumer) {
    final FromClause fromClause = sqlAst.getQuerySpec().getFromClause();
    assertThat(fromClause.getRoots(), hasSize(1));
    final TableGroup root = fromClause.getRoots().get(0);
    assertThat(root.getTableGroupJoins(), hasSize(1));
    final TableGroup joinedGroup = CollectionUtils.getOnlyElement(root.getTableGroupJoins()).getJoinedGroup();
    assertThat(joinedGroup.getModelPart().getPartName(), is(expectedPluralAttributeName));
    assertThat(joinedGroup.getModelPart(), instanceOf(PluralAttributeMapping.class));
    tableGroupConsumer.accept(joinedGroup);
}
Also used : LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) StandardVirtualTableGroup(org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) FromClause(org.hibernate.sql.ast.tree.from.FromClause) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping)

Aggregations

FromClause (org.hibernate.sql.ast.tree.from.FromClause)11 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)11 LazyTableGroup (org.hibernate.sql.ast.tree.from.LazyTableGroup)9 StandardVirtualTableGroup (org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup)9 EntityValuedModelPart (org.hibernate.metamodel.mapping.EntityValuedModelPart)3 PluralAttributeMapping (org.hibernate.metamodel.mapping.PluralAttributeMapping)3 SqmQueryImplementor (org.hibernate.query.hql.spi.SqmQueryImplementor)2 StandardSqmTranslator (org.hibernate.query.sqm.sql.internal.StandardSqmTranslator)2 SqmSelectStatement (org.hibernate.query.sqm.tree.select.SqmSelectStatement)2 SqlSelection (org.hibernate.sql.ast.spi.SqlSelection)2 SelectClause (org.hibernate.sql.ast.tree.select.SelectClause)2 SelectStatement (org.hibernate.sql.ast.tree.select.SelectStatement)2 JdbcSelect (org.hibernate.sql.exec.spi.JdbcSelect)2 Test (org.junit.jupiter.api.Test)2 JdbcMappingContainer (org.hibernate.metamodel.mapping.JdbcMappingContainer)1 OrdinalEnumValueConverter (org.hibernate.metamodel.model.convert.internal.OrdinalEnumValueConverter)1 Gender (org.hibernate.orm.test.mapping.SmokeTests.Gender)1 NavigablePath (org.hibernate.query.spi.NavigablePath)1 ColumnReference (org.hibernate.sql.ast.tree.expression.ColumnReference)1 Expression (org.hibernate.sql.ast.tree.expression.Expression)1