Search in sources :

Example 1 with TableGroupJoin

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

the class CriteriaEntityGraphTest method testFetchSemanticsWithDeepSubgraph.

@Test
void testFetchSemanticsWithDeepSubgraph() {
    scope.inTransaction(session -> {
        final RootGraphImplementor<Cat> eg = session.createEntityGraph(Cat.class);
        eg.addSubgraph("owner", Person.class).addSubgraph("company", ExpressCompany.class);
        final SelectStatement sqlAst = buildSqlSelectAst(Cat.class, eg, GraphSemantic.FETCH, session);
        // Check the from-clause
        assertEntityValuedJoinedGroup(sqlAst, "owner", Person.class, tableGroup -> {
            List<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
            Map<String, Class<? extends TableGroup>> tableGroupByName = tableGroupJoins.stream().map(TableGroupJoin::getJoinedGroup).collect(Collectors.toMap(tg -> tg.getModelPart().getPartName(), TableGroup::getClass));
            Map<String, Class<? extends TableGroup>> expectedTableGroupByName = new HashMap<>();
            expectedTableGroupByName.put("homeAddress", StandardVirtualTableGroup.class);
            expectedTableGroupByName.put("company", LazyTableGroup.class);
            assertThat(tableGroupByName, is(expectedTableGroupByName));
        });
        // Check the domain-result graph
        assertDomainResult(sqlAst, Cat.class, "owner", Person.class, entityFetch -> {
            assertThat(entityFetch, instanceOf(EntityFetchJoinedImpl.class));
            final EntityResult ownerEntityResult = ((EntityFetchJoinedImpl) entityFetch).getEntityResult();
            final Map<String, Class<? extends Fetch>> fetchClassByAttributeName = ownerEntityResult.getFetches().stream().collect(Collectors.toMap(fetch -> fetch.getFetchedMapping().getPartName(), Fetch::getClass));
            final Map<String, Class<? extends Fetch>> expectedFetchClassByAttributeName = new HashMap<>();
            expectedFetchClassByAttributeName.put("homeAddress", EmbeddableFetchImpl.class);
            expectedFetchClassByAttributeName.put("pets", DelayedCollectionFetch.class);
            expectedFetchClassByAttributeName.put("company", EntityFetchJoinedImpl.class);
            assertThat(fetchClassByAttributeName, is(expectedFetchClassByAttributeName));
            Fetchable fetchable = getFetchable("company", Person.class);
            final Fetch companyFetch = ownerEntityResult.findFetch(fetchable);
            List<Fetch> fetches = ownerEntityResult.getFetches();
            assertThat(companyFetch, notNullValue());
            final EntityResult companyEntityResult = ((EntityFetchJoinedImpl) companyFetch).getEntityResult();
            assertThat(companyEntityResult.getFetches(), hasSize(1));
            final Fetch shipAddressesFetch = companyEntityResult.getFetches().get(0);
            assertThat(shipAddressesFetch.getFetchedMapping().getPartName(), is("shipAddresses"));
            assertThat(shipAddressesFetch, instanceOf(DelayedCollectionFetch.class));
        });
    });
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Entity(jakarta.persistence.Entity) AssignableMatcher.assignableTo(org.hibernate.testing.hamcrest.AssignableMatcher.assignableTo) EntityPersister(org.hibernate.persister.entity.EntityPersister) GraphSemantic(org.hibernate.graph.GraphSemantic) DelayedCollectionFetch(org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) EntityValuedModelPart(org.hibernate.metamodel.mapping.EntityValuedModelPart) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping) TestForIssue(org.hibernate.testing.TestForIssue) SqmQueryImplementor(org.hibernate.query.hql.spi.SqmQueryImplementor) SessionFactoryScopeAware(org.hibernate.testing.orm.junit.SessionFactoryScopeAware) Map(java.util.Map) EntityResult(org.hibernate.sql.results.graph.entity.EntityResult) FetchType(jakarta.persistence.FetchType) Fetchable(org.hibernate.sql.results.graph.Fetchable) EntityDelayedFetchImpl(org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchImpl) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) CollectionUtils(org.junit.platform.commons.util.CollectionUtils) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) Collection(java.util.Collection) DomainResult(org.hibernate.sql.results.graph.DomainResult) Set(java.util.Set) Id(jakarta.persistence.Id) DomainModel(org.hibernate.testing.orm.junit.DomainModel) QuerySqmImpl(org.hibernate.query.sqm.internal.QuerySqmImpl) Collectors(java.util.stream.Collectors) EmbeddableFetchImpl(org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) Test(org.junit.jupiter.api.Test) LoadQueryInfluencers(org.hibernate.engine.spi.LoadQueryInfluencers) List(java.util.List) SessionImplementor(org.hibernate.engine.spi.SessionImplementor) FromClause(org.hibernate.sql.ast.tree.from.FromClause) EmbeddedAttributeMapping(org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping) OneToMany(jakarta.persistence.OneToMany) ManyToOne(jakarta.persistence.ManyToOne) HashMap(java.util.HashMap) EnumSource(org.junit.jupiter.params.provider.EnumSource) Embedded(jakarta.persistence.Embedded) RootGraphImplementor(org.hibernate.graph.spi.RootGraphImplementor) QueryImplementor(org.hibernate.query.spi.QueryImplementor) CollectionMatchers.hasSize(org.hibernate.testing.hamcrest.CollectionMatchers.hasSize) StandardSqmTranslator(org.hibernate.query.sqm.sql.internal.StandardSqmTranslator) Embeddable(jakarta.persistence.Embeddable) CollectionMatchers.isEmpty(org.hibernate.testing.hamcrest.CollectionMatchers.isEmpty) ElementCollection(jakarta.persistence.ElementCollection) SqmTranslation(org.hibernate.query.sqm.sql.SqmTranslation) Fetch(org.hibernate.sql.results.graph.Fetch) Consumer(java.util.function.Consumer) EntityFetch(org.hibernate.sql.results.graph.entity.EntityFetch) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) CriteriaQuery(jakarta.persistence.criteria.CriteriaQuery) StandardVirtualTableGroup(org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup) SessionFactoryScope(org.hibernate.testing.orm.junit.SessionFactoryScope) CriteriaBuilder(jakarta.persistence.criteria.CriteriaBuilder) AttributeMapping(org.hibernate.metamodel.mapping.AttributeMapping) SessionFactory(org.hibernate.testing.orm.junit.SessionFactory) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) EntityFetchJoinedImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl) EntityFetchJoinedImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl) Fetchable(org.hibernate.sql.results.graph.Fetchable) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) StandardVirtualTableGroup(org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) HashMap(java.util.HashMap) EntityResult(org.hibernate.sql.results.graph.entity.EntityResult) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) DelayedCollectionFetch(org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch) Fetch(org.hibernate.sql.results.graph.Fetch) EntityFetch(org.hibernate.sql.results.graph.entity.EntityFetch) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) DelayedCollectionFetch(org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with TableGroupJoin

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

the class EntityGraphLoadPlanBuilderTest method testFetchLoadPlanBuildingWithDeepSubgraph.

@Test
void testFetchLoadPlanBuildingWithDeepSubgraph() {
    scope.inTransaction(em -> {
        final RootGraphImplementor<Cat> eg = em.createEntityGraph(Cat.class);
        eg.addSubgraph("owner", Person.class).addSubgraph("company", ExpressCompany.class);
        final SelectStatement sqlAst = buildSqlSelectAst(Cat.class, eg, GraphSemantic.FETCH, scope);
        // Check the from-clause
        assertEntityValuedJoinedGroup(sqlAst, "owner", Person.class, tableGroup -> {
            List<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
            Map<String, Class<? extends TableGroup>> tableGroupByName = tableGroupJoins.stream().map(TableGroupJoin::getJoinedGroup).collect(Collectors.toMap(tg -> tg.getModelPart().getPartName(), TableGroup::getClass));
            Map<String, Class<? extends TableGroup>> expectedTableGroupByName = new HashMap<>();
            expectedTableGroupByName.put("homeAddress", StandardVirtualTableGroup.class);
            expectedTableGroupByName.put("company", LazyTableGroup.class);
            assertThat(tableGroupByName, is(expectedTableGroupByName));
        });
        // Check the domain-result graph
        assertDomainResult(sqlAst, Cat.class, "owner", Person.class, entityFetch -> {
            assertThat(entityFetch, instanceOf(EntityFetchJoinedImpl.class));
            final EntityResult ownerEntityResult = ((EntityFetchJoinedImpl) entityFetch).getEntityResult();
            final Map<String, Class<? extends Fetch>> fetchClassByAttributeName = ownerEntityResult.getFetches().stream().collect(Collectors.toMap(fetch -> fetch.getFetchedMapping().getPartName(), Fetch::getClass));
            final Map<String, Class<? extends Fetch>> expectedFetchClassByAttributeName = new HashMap<>();
            expectedFetchClassByAttributeName.put("homeAddress", EmbeddableFetchImpl.class);
            expectedFetchClassByAttributeName.put("pets", DelayedCollectionFetch.class);
            expectedFetchClassByAttributeName.put("company", EntityFetchJoinedImpl.class);
            assertThat(fetchClassByAttributeName, is(expectedFetchClassByAttributeName));
            Fetchable fetchable = getFetchable("company", Person.class);
            final Fetch companyFetch = ownerEntityResult.findFetch(fetchable);
            assertThat(companyFetch, notNullValue());
            final EntityResult companyEntityResult = ((EntityFetchJoinedImpl) companyFetch).getEntityResult();
            assertThat(companyEntityResult.getFetches(), hasSize(1));
            final Fetch shipAddressesFetch = companyEntityResult.getFetches().get(0);
            assertThat(shipAddressesFetch.getFetchedMapping().getPartName(), is("shipAddresses"));
            assertThat(shipAddressesFetch, instanceOf(DelayedCollectionFetch.class));
        });
    });
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Entity(jakarta.persistence.Entity) AssignableMatcher.assignableTo(org.hibernate.testing.hamcrest.AssignableMatcher.assignableTo) EntityPersister(org.hibernate.persister.entity.EntityPersister) GraphSemantic(org.hibernate.graph.GraphSemantic) DelayedCollectionFetch(org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) EntityValuedModelPart(org.hibernate.metamodel.mapping.EntityValuedModelPart) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping) TestForIssue(org.hibernate.testing.TestForIssue) SessionFactoryScopeAware(org.hibernate.testing.orm.junit.SessionFactoryScopeAware) Map(java.util.Map) EntityResult(org.hibernate.sql.results.graph.entity.EntityResult) FetchType(jakarta.persistence.FetchType) Fetchable(org.hibernate.sql.results.graph.Fetchable) EntityDelayedFetchImpl(org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchImpl) LockOptions(org.hibernate.LockOptions) CollectionUtils(org.junit.platform.commons.util.CollectionUtils) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) Collection(java.util.Collection) DomainResult(org.hibernate.sql.results.graph.DomainResult) Set(java.util.Set) Id(jakarta.persistence.Id) DomainModel(org.hibernate.testing.orm.junit.DomainModel) Collectors(java.util.stream.Collectors) EmbeddableFetchImpl(org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) Test(org.junit.jupiter.api.Test) LoadQueryInfluencers(org.hibernate.engine.spi.LoadQueryInfluencers) List(java.util.List) FromClause(org.hibernate.sql.ast.tree.from.FromClause) EmbeddedAttributeMapping(org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping) OneToMany(jakarta.persistence.OneToMany) ManyToOne(jakarta.persistence.ManyToOne) HashMap(java.util.HashMap) EnumSource(org.junit.jupiter.params.provider.EnumSource) Embedded(jakarta.persistence.Embedded) RootGraphImplementor(org.hibernate.graph.spi.RootGraphImplementor) CollectionMatchers.hasSize(org.hibernate.testing.hamcrest.CollectionMatchers.hasSize) LoaderSelectBuilder(org.hibernate.loader.ast.internal.LoaderSelectBuilder) Embeddable(jakarta.persistence.Embeddable) CollectionMatchers.isEmpty(org.hibernate.testing.hamcrest.CollectionMatchers.isEmpty) ElementCollection(jakarta.persistence.ElementCollection) Fetch(org.hibernate.sql.results.graph.Fetch) Consumer(java.util.function.Consumer) EntityFetch(org.hibernate.sql.results.graph.entity.EntityFetch) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) StandardVirtualTableGroup(org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup) SessionFactoryScope(org.hibernate.testing.orm.junit.SessionFactoryScope) AttributeMapping(org.hibernate.metamodel.mapping.AttributeMapping) SessionFactory(org.hibernate.testing.orm.junit.SessionFactory) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) EffectiveEntityGraph(org.hibernate.engine.spi.EffectiveEntityGraph) EntityFetchJoinedImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl) EntityFetchJoinedImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl) Fetchable(org.hibernate.sql.results.graph.Fetchable) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) StandardVirtualTableGroup(org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) HashMap(java.util.HashMap) EntityResult(org.hibernate.sql.results.graph.entity.EntityResult) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) DelayedCollectionFetch(org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch) Fetch(org.hibernate.sql.results.graph.Fetch) EntityFetch(org.hibernate.sql.results.graph.entity.EntityFetch) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) DelayedCollectionFetch(org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with TableGroupJoin

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

the class HqlEntityGraphTest method testFetchSemanticsWithDeepSubgraph.

@Test
void testFetchSemanticsWithDeepSubgraph() {
    scope.inTransaction(session -> {
        final RootGraphImplementor<Cat> eg = session.createEntityGraph(Cat.class);
        eg.addSubgraph("owner", Person.class).addSubgraph("company", ExpressCompany.class);
        final SelectStatement sqlAst = buildSqlSelectAst(Cat.class, "select c from Cat as c", eg, GraphSemantic.FETCH, session);
        // Check the from-clause
        assertEntityValuedJoinedGroup(sqlAst, "owner", Person.class, tableGroup -> {
            List<TableGroupJoin> tableGroupJoins = tableGroup.getTableGroupJoins();
            Map<String, Class<? extends TableGroup>> tableGroupByName = tableGroupJoins.stream().map(TableGroupJoin::getJoinedGroup).collect(Collectors.toMap(tg -> tg.getModelPart().getPartName(), TableGroup::getClass));
            Map<String, Class<? extends TableGroup>> expectedTableGroupByName = new HashMap<>();
            expectedTableGroupByName.put("homeAddress", StandardVirtualTableGroup.class);
            expectedTableGroupByName.put("company", LazyTableGroup.class);
            assertThat(tableGroupByName, is(expectedTableGroupByName));
        });
        // Check the domain-result graph
        assertDomainResult(sqlAst, Cat.class, "owner", Person.class, entityFetch -> {
            assertThat(entityFetch, instanceOf(EntityFetchJoinedImpl.class));
            final EntityResult ownerEntityResult = ((EntityFetchJoinedImpl) entityFetch).getEntityResult();
            final Map<String, Class<? extends Fetch>> fetchClassByAttributeName = ownerEntityResult.getFetches().stream().collect(Collectors.toMap(fetch -> fetch.getFetchedMapping().getPartName(), Fetch::getClass));
            final Map<String, Class<? extends Fetch>> expectedFetchClassByAttributeName = new HashMap<>();
            expectedFetchClassByAttributeName.put("homeAddress", EmbeddableFetchImpl.class);
            expectedFetchClassByAttributeName.put("pets", DelayedCollectionFetch.class);
            expectedFetchClassByAttributeName.put("company", EntityFetchJoinedImpl.class);
            assertThat(fetchClassByAttributeName, is(expectedFetchClassByAttributeName));
            Fetchable fetchable = getFetchable("company", Person.class);
            final Fetch companyFetch = ownerEntityResult.findFetch(fetchable);
            assertThat(companyFetch, notNullValue());
            final EntityResult companyEntityResult = ((EntityFetchJoinedImpl) companyFetch).getEntityResult();
            assertThat(companyEntityResult.getFetches(), hasSize(1));
            final Fetch shipAddressesFetch = companyEntityResult.getFetches().get(0);
            assertThat(shipAddressesFetch.getFetchedMapping().getPartName(), is("shipAddresses"));
            assertThat(shipAddressesFetch, instanceOf(DelayedCollectionFetch.class));
        });
    });
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Entity(jakarta.persistence.Entity) AssignableMatcher.assignableTo(org.hibernate.testing.hamcrest.AssignableMatcher.assignableTo) EntityPersister(org.hibernate.persister.entity.EntityPersister) GraphSemantic(org.hibernate.graph.GraphSemantic) DelayedCollectionFetch(org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) EntityValuedModelPart(org.hibernate.metamodel.mapping.EntityValuedModelPart) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) Assert.assertThat(org.junit.Assert.assertThat) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping) TestForIssue(org.hibernate.testing.TestForIssue) SqmQueryImplementor(org.hibernate.query.hql.spi.SqmQueryImplementor) SessionFactoryScopeAware(org.hibernate.testing.orm.junit.SessionFactoryScopeAware) Map(java.util.Map) EntityResult(org.hibernate.sql.results.graph.entity.EntityResult) FetchType(jakarta.persistence.FetchType) Fetchable(org.hibernate.sql.results.graph.Fetchable) EntityDelayedFetchImpl(org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchImpl) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) CollectionUtils(org.junit.platform.commons.util.CollectionUtils) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) Collection(java.util.Collection) DomainResult(org.hibernate.sql.results.graph.DomainResult) Set(java.util.Set) Id(jakarta.persistence.Id) DomainModel(org.hibernate.testing.orm.junit.DomainModel) QuerySqmImpl(org.hibernate.query.sqm.internal.QuerySqmImpl) Collectors(java.util.stream.Collectors) EmbeddableFetchImpl(org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) Test(org.junit.jupiter.api.Test) LoadQueryInfluencers(org.hibernate.engine.spi.LoadQueryInfluencers) List(java.util.List) SessionImplementor(org.hibernate.engine.spi.SessionImplementor) FromClause(org.hibernate.sql.ast.tree.from.FromClause) EmbeddedAttributeMapping(org.hibernate.metamodel.mapping.internal.EmbeddedAttributeMapping) OneToMany(jakarta.persistence.OneToMany) ManyToOne(jakarta.persistence.ManyToOne) HashMap(java.util.HashMap) EnumSource(org.junit.jupiter.params.provider.EnumSource) Embedded(jakarta.persistence.Embedded) RootGraphImplementor(org.hibernate.graph.spi.RootGraphImplementor) QueryImplementor(org.hibernate.query.spi.QueryImplementor) CollectionMatchers.hasSize(org.hibernate.testing.hamcrest.CollectionMatchers.hasSize) StandardSqmTranslator(org.hibernate.query.sqm.sql.internal.StandardSqmTranslator) Embeddable(jakarta.persistence.Embeddable) CollectionMatchers.isEmpty(org.hibernate.testing.hamcrest.CollectionMatchers.isEmpty) ElementCollection(jakarta.persistence.ElementCollection) SqmTranslation(org.hibernate.query.sqm.sql.SqmTranslation) Fetch(org.hibernate.sql.results.graph.Fetch) Consumer(java.util.function.Consumer) EntityFetch(org.hibernate.sql.results.graph.entity.EntityFetch) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) StandardVirtualTableGroup(org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup) SessionFactoryScope(org.hibernate.testing.orm.junit.SessionFactoryScope) AttributeMapping(org.hibernate.metamodel.mapping.AttributeMapping) SessionFactory(org.hibernate.testing.orm.junit.SessionFactory) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) EntityFetchJoinedImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl) EntityFetchJoinedImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl) Fetchable(org.hibernate.sql.results.graph.Fetchable) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) StandardVirtualTableGroup(org.hibernate.sql.ast.tree.from.StandardVirtualTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) HashMap(java.util.HashMap) EntityResult(org.hibernate.sql.results.graph.entity.EntityResult) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) DelayedCollectionFetch(org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch) Fetch(org.hibernate.sql.results.graph.Fetch) EntityFetch(org.hibernate.sql.results.graph.entity.EntityFetch) SqmSelectStatement(org.hibernate.query.sqm.tree.select.SqmSelectStatement) SelectStatement(org.hibernate.sql.ast.tree.select.SelectStatement) DelayedCollectionFetch(org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with TableGroupJoin

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

the class ToOneAttributeMapping method generateFetch.

@Override
public EntityFetch generateFetch(FetchParent fetchParent, NavigablePath fetchablePath, FetchTiming fetchTiming, boolean selected, String resultVariable, DomainResultCreationState creationState) {
    final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
    final FromClauseAccess fromClauseAccess = sqlAstCreationState.getFromClauseAccess();
    final TableGroup parentTableGroup = fromClauseAccess.getTableGroup(fetchParent.getNavigablePath());
    final NavigablePath parentNavigablePath = fetchablePath.getParent();
    assert parentNavigablePath.equals(fetchParent.getNavigablePath()) || fetchParent.getNavigablePath() instanceof TreatedNavigablePath && parentNavigablePath.equals(fetchParent.getNavigablePath().getRealParent());
    if (fetchTiming == FetchTiming.IMMEDIATE && selected) {
        final TableGroup tableGroup;
        if (fetchParent instanceof EntityResultJoinedSubclassImpl && ((EntityPersister) fetchParent.getReferencedModePart()).findDeclaredAttributeMapping(getPartName()) == null) {
            final TableGroupJoin tableGroupJoin = createTableGroupJoin(fetchablePath, parentTableGroup, resultVariable, getJoinType(fetchablePath, parentTableGroup), true, false, creationState.getSqlAstCreationState());
            parentTableGroup.addTableGroupJoin(tableGroupJoin);
            tableGroup = tableGroupJoin.getJoinedGroup();
            fromClauseAccess.registerTableGroup(fetchablePath, tableGroup);
        } else {
            tableGroup = fromClauseAccess.resolveTableGroup(fetchablePath, np -> {
                final TableGroupJoin tableGroupJoin = createTableGroupJoin(fetchablePath, parentTableGroup, resultVariable, getDefaultSqlAstJoinType(parentTableGroup), true, false, creationState.getSqlAstCreationState());
                parentTableGroup.addTableGroupJoin(tableGroupJoin);
                return tableGroupJoin.getJoinedGroup();
            });
        }
        final boolean added = creationState.registerVisitedAssociationKey(foreignKeyDescriptor.getAssociationKey());
        AssociationKey additionalAssociationKey = null;
        if (cardinality == Cardinality.LOGICAL_ONE_TO_ONE && bidirectionalAttributeName != null) {
            final ModelPart bidirectionalModelPart = entityMappingType.findSubPart(bidirectionalAttributeName);
            // Add the inverse association key side as well to be able to resolve to a CircularFetch
            if (bidirectionalModelPart instanceof ToOneAttributeMapping) {
                assert bidirectionalModelPart.getPartMappingType() == declaringTableGroupProducer;
                final ToOneAttributeMapping bidirectionalAttribute = (ToOneAttributeMapping) bidirectionalModelPart;
                final AssociationKey secondKey = bidirectionalAttribute.getForeignKeyDescriptor().getAssociationKey();
                if (creationState.registerVisitedAssociationKey(secondKey)) {
                    additionalAssociationKey = secondKey;
                }
            }
        }
        final EntityFetchJoinedImpl entityFetchJoined = new EntityFetchJoinedImpl(fetchParent, this, tableGroup, fetchablePath, creationState);
        if (added) {
            creationState.removeVisitedAssociationKey(foreignKeyDescriptor.getAssociationKey());
        }
        if (additionalAssociationKey != null) {
            creationState.removeVisitedAssociationKey(additionalAssociationKey);
        }
        return entityFetchJoined;
    }
    /*
			1. No JoinTable
				Model:
					EntityA{
						@ManyToOne
						EntityB b
					}

					EntityB{
						@ManyToOne
						EntityA a
					}

				Relational:
					ENTITY_A( id )
					ENTITY_B( id, entity_a_id)

				1.1 EntityA -> EntityB : as keyResult we need ENTITY_B.id
				1.2 EntityB -> EntityA : as keyResult we need ENTITY_B.entity_a_id (FK referring column)

			2. JoinTable

		 */
    final ForeignKeyDescriptor.Nature resolvingKeySideOfForeignKey = creationState.getCurrentlyResolvingForeignKeyPart();
    final ForeignKeyDescriptor.Nature side;
    if (resolvingKeySideOfForeignKey == ForeignKeyDescriptor.Nature.KEY && this.sideNature == ForeignKeyDescriptor.Nature.TARGET) {
        // If we are currently resolving the key part of a foreign key we do not want to add joins.
        // So if the lhs of this association is the target of the FK, we have to use the KEY part to avoid a join
        side = ForeignKeyDescriptor.Nature.KEY;
    } else {
        side = this.sideNature;
    }
    final DomainResult<?> keyResult = foreignKeyDescriptor.createDomainResult(fetchablePath, parentTableGroup, side, creationState);
    final boolean selectByUniqueKey = isSelectByUniqueKey(side);
    if (fetchTiming == FetchTiming.IMMEDIATE) {
        return new EntityFetchSelectImpl(fetchParent, this, fetchablePath, keyResult, selectByUniqueKey, creationState);
    }
    return new EntityDelayedFetchImpl(fetchParent, this, fetchablePath, keyResult, selectByUniqueKey);
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister) Arrays(java.util.Arrays) EntityPersister(org.hibernate.persister.entity.EntityPersister) Property(org.hibernate.mapping.Property) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) TreatedNavigablePath(org.hibernate.query.spi.TreatedNavigablePath) PropertyAccess(org.hibernate.property.access.spi.PropertyAccess) EntityResultImpl(org.hibernate.sql.results.graph.entity.internal.EntityResultImpl) EntityMappingType(org.hibernate.metamodel.mapping.EntityMappingType) ToOne(org.hibernate.mapping.ToOne) SqlAstCreationContext(org.hibernate.sql.ast.spi.SqlAstCreationContext) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping) EntityAssociationMapping(org.hibernate.metamodel.mapping.EntityAssociationMapping) ForeignKeyDescriptor(org.hibernate.metamodel.mapping.ForeignKeyDescriptor) PersistentClass(org.hibernate.mapping.PersistentClass) FetchOptions(org.hibernate.sql.results.graph.FetchOptions) Join(org.hibernate.mapping.Join) TableGroupProducer(org.hibernate.sql.ast.tree.from.TableGroupProducer) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) EntityDelayedResultImpl(org.hibernate.sql.results.graph.entity.internal.EntityDelayedResultImpl) CollectionPart(org.hibernate.metamodel.mapping.CollectionPart) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection) CorrelatedTableGroup(org.hibernate.sql.ast.tree.from.CorrelatedTableGroup) EntityValuedFetchable(org.hibernate.sql.results.graph.entity.EntityValuedFetchable) EntityDelayedFetchImpl(org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchImpl) MappedByTableGroup(org.hibernate.sql.ast.tree.from.MappedByTableGroup) TableGroupJoinProducer(org.hibernate.sql.ast.tree.from.TableGroupJoinProducer) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) OneToOne(org.hibernate.mapping.OneToOne) VirtualModelPart(org.hibernate.metamodel.mapping.VirtualModelPart) NavigablePath(org.hibernate.query.spi.NavigablePath) StringHelper(org.hibernate.internal.util.StringHelper) DomainResult(org.hibernate.sql.results.graph.DomainResult) Set(java.util.Set) Value(org.hibernate.mapping.Value) Collection(org.hibernate.mapping.Collection) SqlAliasBase(org.hibernate.sql.ast.spi.SqlAliasBase) SqlExpressionResolver(org.hibernate.sql.ast.spi.SqlExpressionResolver) EntityIdentifierMapping(org.hibernate.metamodel.mapping.EntityIdentifierMapping) NavigableRole(org.hibernate.metamodel.model.domain.NavigableRole) ArrayHelper(org.hibernate.internal.util.collections.ArrayHelper) CircularBiDirectionalFetchImpl(org.hibernate.sql.results.internal.domain.CircularBiDirectionalFetchImpl) AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister) SelectableConsumer(org.hibernate.metamodel.mapping.SelectableConsumer) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) IndexedConsumer(org.hibernate.mapping.IndexedConsumer) FetchParent(org.hibernate.sql.results.graph.FetchParent) CircularFetchImpl(org.hibernate.sql.results.internal.domain.CircularFetchImpl) DomainResultCreationState(org.hibernate.sql.results.graph.DomainResultCreationState) SqlAliasBaseGenerator(org.hibernate.sql.ast.spi.SqlAliasBaseGenerator) EntityFetchSelectImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchSelectImpl) JdbcMapping(org.hibernate.metamodel.mapping.JdbcMapping) EntityResultJoinedSubclassImpl(org.hibernate.sql.results.graph.entity.internal.EntityResultJoinedSubclassImpl) SqlAliasStemHelper(org.hibernate.sql.ast.spi.SqlAliasStemHelper) EmbeddedComponentType(org.hibernate.type.EmbeddedComponentType) EntityType(org.hibernate.type.EntityType) Clause(org.hibernate.sql.ast.Clause) TableReference(org.hibernate.sql.ast.tree.from.TableReference) HashSet(java.util.HashSet) ModelPart(org.hibernate.metamodel.mapping.ModelPart) ComponentType(org.hibernate.type.ComponentType) CompositeType(org.hibernate.type.CompositeType) BiConsumer(java.util.function.BiConsumer) ManagedMappingType(org.hibernate.metamodel.mapping.ManagedMappingType) EntityIdentifierNavigablePath(org.hibernate.query.sqm.spi.EntityIdentifierNavigablePath) StandardTableGroup(org.hibernate.sql.ast.tree.from.StandardTableGroup) SqlAstCreationState(org.hibernate.sql.ast.spi.SqlAstCreationState) FetchTiming(org.hibernate.engine.FetchTiming) ManyToOne(org.hibernate.mapping.ManyToOne) LockMode(org.hibernate.LockMode) AssociationKey(org.hibernate.metamodel.mapping.AssociationKey) Predicate(org.hibernate.sql.ast.tree.predicate.Predicate) Iterator(java.util.Iterator) ModelPartContainer(org.hibernate.metamodel.mapping.ModelPartContainer) EmbeddableValuedFetchable(org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable) StateArrayContributorMetadataAccess(org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess) Fetch(org.hibernate.sql.results.graph.Fetch) Consumer(java.util.function.Consumer) QueryableCollection(org.hibernate.persister.collection.QueryableCollection) EntityFetch(org.hibernate.sql.results.graph.entity.EntityFetch) FetchStyle(org.hibernate.engine.FetchStyle) FromClauseAccess(org.hibernate.sql.ast.spi.FromClauseAccess) SqlAstJoinType(org.hibernate.sql.ast.SqlAstJoinType) Selectable(org.hibernate.mapping.Selectable) EmbeddableValuedModelPart(org.hibernate.metamodel.mapping.EmbeddableValuedModelPart) Collections(java.util.Collections) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) EntityFetchJoinedImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl) Type(org.hibernate.type.Type) EntityFetchJoinedImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl) AssociationKey(org.hibernate.metamodel.mapping.AssociationKey) CorrelatedTableGroup(org.hibernate.sql.ast.tree.from.CorrelatedTableGroup) MappedByTableGroup(org.hibernate.sql.ast.tree.from.MappedByTableGroup) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) StandardTableGroup(org.hibernate.sql.ast.tree.from.StandardTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) TreatedNavigablePath(org.hibernate.query.spi.TreatedNavigablePath) NavigablePath(org.hibernate.query.spi.NavigablePath) EntityIdentifierNavigablePath(org.hibernate.query.sqm.spi.EntityIdentifierNavigablePath) VirtualModelPart(org.hibernate.metamodel.mapping.VirtualModelPart) ModelPart(org.hibernate.metamodel.mapping.ModelPart) EmbeddableValuedModelPart(org.hibernate.metamodel.mapping.EmbeddableValuedModelPart) EntityResultJoinedSubclassImpl(org.hibernate.sql.results.graph.entity.internal.EntityResultJoinedSubclassImpl) EntityDelayedFetchImpl(org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchImpl) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) TreatedNavigablePath(org.hibernate.query.spi.TreatedNavigablePath) FromClauseAccess(org.hibernate.sql.ast.spi.FromClauseAccess) SqlAstCreationState(org.hibernate.sql.ast.spi.SqlAstCreationState) ForeignKeyDescriptor(org.hibernate.metamodel.mapping.ForeignKeyDescriptor) EntityFetchSelectImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchSelectImpl)

Example 5 with TableGroupJoin

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

the class ToOneAttributeMapping method createTableGroupJoin.

@Override
public TableGroupJoin createTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAstJoinType requestedJoinType, boolean fetched, boolean addsPredicate, SqlAliasBaseGenerator aliasBaseGenerator, SqlExpressionResolver sqlExpressionResolver, FromClauseAccess fromClauseAccess, SqlAstCreationContext creationContext) {
    // This is vital for the map key property check that comes next
    assert !(lhs instanceof PluralTableGroup);
    TableGroup parentTableGroup = lhs;
    ModelPartContainer parentContainer = lhs.getModelPart();
    StringBuilder embeddablePathSb = null;
    // Traverse up embeddable table groups until we find a table group for a collection part
    while (!(parentContainer instanceof CollectionPart)) {
        if (parentContainer instanceof EmbeddableValuedModelPart) {
            if (embeddablePathSb == null) {
                embeddablePathSb = new StringBuilder();
            }
            embeddablePathSb.insert(0, parentContainer.getPartName() + ".");
            parentTableGroup = fromClauseAccess.findTableGroup(parentTableGroup.getNavigablePath().getParent());
            parentContainer = parentTableGroup.getModelPart();
        } else {
            break;
        }
    }
    final SqlAstJoinType joinType;
    if (requestedJoinType == null) {
        joinType = SqlAstJoinType.INNER;
    } else {
        joinType = requestedJoinType;
    }
    // we check if this attribute is the map key property to reuse the existing index table group
    if (CollectionPart.Nature.ELEMENT.getName().equals(parentTableGroup.getNavigablePath().getUnaliasedLocalName()) && !addsPredicate && (joinType == SqlAstJoinType.INNER || joinType == SqlAstJoinType.LEFT)) {
        final PluralTableGroup pluralTableGroup = (PluralTableGroup) fromClauseAccess.findTableGroup(parentTableGroup.getNavigablePath().getParent());
        final String indexPropertyName = pluralTableGroup.getModelPart().getIndexMetadata().getIndexPropertyName();
        final String pathName;
        if (embeddablePathSb != null) {
            pathName = embeddablePathSb.append(getAttributeName()).toString();
        } else {
            pathName = getAttributeName();
        }
        if (pathName.equals(indexPropertyName)) {
            final TableGroup indexTableGroup = pluralTableGroup.getIndexTableGroup();
            // If this is the map key property, we can reuse the index table group
            initializeIfNeeded(lhs, requestedJoinType, indexTableGroup);
            return new TableGroupJoin(navigablePath, joinType, new MappedByTableGroup(navigablePath, this, indexTableGroup, fetched, pluralTableGroup, (np, tableExpression) -> {
                if (!canUseParentTableGroup) {
                    return false;
                }
                NavigablePath path = np.getParent();
                // Fast path
                if (path != null && navigablePath.equals(path)) {
                    return targetKeyPropertyNames.contains(np.getUnaliasedLocalName()) && identifyingColumnsTableExpression.equals(tableExpression);
                }
                final StringBuilder sb = new StringBuilder(np.getFullPath().length());
                sb.append(np.getUnaliasedLocalName());
                while (path != null && !navigablePath.equals(path)) {
                    sb.insert(0, '.');
                    sb.insert(0, path.getUnaliasedLocalName());
                    path = path.getParent();
                }
                return path != null && navigablePath.equals(path) && targetKeyPropertyNames.contains(sb.toString()) && identifyingColumnsTableExpression.equals(tableExpression);
            }), null);
        }
    }
    final LazyTableGroup lazyTableGroup = createRootTableGroupJoin(navigablePath, lhs, explicitSourceAlias, requestedJoinType, fetched, null, aliasBaseGenerator, sqlExpressionResolver, fromClauseAccess, creationContext);
    final TableGroupJoin join = new TableGroupJoin(navigablePath, joinType, lazyTableGroup, null);
    final TableReference lhsTableReference = lhs.resolveTableReference(navigablePath, identifyingColumnsTableExpression);
    lazyTableGroup.setTableGroupInitializerCallback(tableGroup -> join.applyPredicate(foreignKeyDescriptor.generateJoinPredicate(sideNature == ForeignKeyDescriptor.Nature.TARGET ? lhsTableReference : tableGroup.getPrimaryTableReference(), sideNature == ForeignKeyDescriptor.Nature.TARGET ? tableGroup.getPrimaryTableReference() : lhsTableReference, sqlExpressionResolver, creationContext)));
    return join;
}
Also used : Arrays(java.util.Arrays) EntityPersister(org.hibernate.persister.entity.EntityPersister) Property(org.hibernate.mapping.Property) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) TreatedNavigablePath(org.hibernate.query.spi.TreatedNavigablePath) PropertyAccess(org.hibernate.property.access.spi.PropertyAccess) EntityResultImpl(org.hibernate.sql.results.graph.entity.internal.EntityResultImpl) EntityMappingType(org.hibernate.metamodel.mapping.EntityMappingType) ToOne(org.hibernate.mapping.ToOne) SqlAstCreationContext(org.hibernate.sql.ast.spi.SqlAstCreationContext) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping) EntityAssociationMapping(org.hibernate.metamodel.mapping.EntityAssociationMapping) ForeignKeyDescriptor(org.hibernate.metamodel.mapping.ForeignKeyDescriptor) PersistentClass(org.hibernate.mapping.PersistentClass) FetchOptions(org.hibernate.sql.results.graph.FetchOptions) Join(org.hibernate.mapping.Join) TableGroupProducer(org.hibernate.sql.ast.tree.from.TableGroupProducer) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) EntityDelayedResultImpl(org.hibernate.sql.results.graph.entity.internal.EntityDelayedResultImpl) CollectionPart(org.hibernate.metamodel.mapping.CollectionPart) SqlSelection(org.hibernate.sql.ast.spi.SqlSelection) CorrelatedTableGroup(org.hibernate.sql.ast.tree.from.CorrelatedTableGroup) EntityValuedFetchable(org.hibernate.sql.results.graph.entity.EntityValuedFetchable) EntityDelayedFetchImpl(org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchImpl) MappedByTableGroup(org.hibernate.sql.ast.tree.from.MappedByTableGroup) TableGroupJoinProducer(org.hibernate.sql.ast.tree.from.TableGroupJoinProducer) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) OneToOne(org.hibernate.mapping.OneToOne) VirtualModelPart(org.hibernate.metamodel.mapping.VirtualModelPart) NavigablePath(org.hibernate.query.spi.NavigablePath) StringHelper(org.hibernate.internal.util.StringHelper) DomainResult(org.hibernate.sql.results.graph.DomainResult) Set(java.util.Set) Value(org.hibernate.mapping.Value) Collection(org.hibernate.mapping.Collection) SqlAliasBase(org.hibernate.sql.ast.spi.SqlAliasBase) SqlExpressionResolver(org.hibernate.sql.ast.spi.SqlExpressionResolver) EntityIdentifierMapping(org.hibernate.metamodel.mapping.EntityIdentifierMapping) NavigableRole(org.hibernate.metamodel.model.domain.NavigableRole) ArrayHelper(org.hibernate.internal.util.collections.ArrayHelper) CircularBiDirectionalFetchImpl(org.hibernate.sql.results.internal.domain.CircularBiDirectionalFetchImpl) AbstractEntityPersister(org.hibernate.persister.entity.AbstractEntityPersister) SelectableConsumer(org.hibernate.metamodel.mapping.SelectableConsumer) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) IndexedConsumer(org.hibernate.mapping.IndexedConsumer) FetchParent(org.hibernate.sql.results.graph.FetchParent) CircularFetchImpl(org.hibernate.sql.results.internal.domain.CircularFetchImpl) DomainResultCreationState(org.hibernate.sql.results.graph.DomainResultCreationState) SqlAliasBaseGenerator(org.hibernate.sql.ast.spi.SqlAliasBaseGenerator) EntityFetchSelectImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchSelectImpl) JdbcMapping(org.hibernate.metamodel.mapping.JdbcMapping) EntityResultJoinedSubclassImpl(org.hibernate.sql.results.graph.entity.internal.EntityResultJoinedSubclassImpl) SqlAliasStemHelper(org.hibernate.sql.ast.spi.SqlAliasStemHelper) EmbeddedComponentType(org.hibernate.type.EmbeddedComponentType) EntityType(org.hibernate.type.EntityType) Clause(org.hibernate.sql.ast.Clause) TableReference(org.hibernate.sql.ast.tree.from.TableReference) HashSet(java.util.HashSet) ModelPart(org.hibernate.metamodel.mapping.ModelPart) ComponentType(org.hibernate.type.ComponentType) CompositeType(org.hibernate.type.CompositeType) BiConsumer(java.util.function.BiConsumer) ManagedMappingType(org.hibernate.metamodel.mapping.ManagedMappingType) EntityIdentifierNavigablePath(org.hibernate.query.sqm.spi.EntityIdentifierNavigablePath) StandardTableGroup(org.hibernate.sql.ast.tree.from.StandardTableGroup) SqlAstCreationState(org.hibernate.sql.ast.spi.SqlAstCreationState) FetchTiming(org.hibernate.engine.FetchTiming) ManyToOne(org.hibernate.mapping.ManyToOne) LockMode(org.hibernate.LockMode) AssociationKey(org.hibernate.metamodel.mapping.AssociationKey) Predicate(org.hibernate.sql.ast.tree.predicate.Predicate) Iterator(java.util.Iterator) ModelPartContainer(org.hibernate.metamodel.mapping.ModelPartContainer) EmbeddableValuedFetchable(org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable) StateArrayContributorMetadataAccess(org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess) Fetch(org.hibernate.sql.results.graph.Fetch) Consumer(java.util.function.Consumer) QueryableCollection(org.hibernate.persister.collection.QueryableCollection) EntityFetch(org.hibernate.sql.results.graph.entity.EntityFetch) FetchStyle(org.hibernate.engine.FetchStyle) FromClauseAccess(org.hibernate.sql.ast.spi.FromClauseAccess) SqlAstJoinType(org.hibernate.sql.ast.SqlAstJoinType) Selectable(org.hibernate.mapping.Selectable) EmbeddableValuedModelPart(org.hibernate.metamodel.mapping.EmbeddableValuedModelPart) Collections(java.util.Collections) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) EntityFetchJoinedImpl(org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl) Type(org.hibernate.type.Type) CorrelatedTableGroup(org.hibernate.sql.ast.tree.from.CorrelatedTableGroup) MappedByTableGroup(org.hibernate.sql.ast.tree.from.MappedByTableGroup) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) StandardTableGroup(org.hibernate.sql.ast.tree.from.StandardTableGroup) TableGroup(org.hibernate.sql.ast.tree.from.TableGroup) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) TreatedNavigablePath(org.hibernate.query.spi.TreatedNavigablePath) NavigablePath(org.hibernate.query.spi.NavigablePath) EntityIdentifierNavigablePath(org.hibernate.query.sqm.spi.EntityIdentifierNavigablePath) PluralTableGroup(org.hibernate.sql.ast.tree.from.PluralTableGroup) MappedByTableGroup(org.hibernate.sql.ast.tree.from.MappedByTableGroup) TableGroupJoin(org.hibernate.sql.ast.tree.from.TableGroupJoin) TableReference(org.hibernate.sql.ast.tree.from.TableReference) LazyTableGroup(org.hibernate.sql.ast.tree.from.LazyTableGroup) SqlAstJoinType(org.hibernate.sql.ast.SqlAstJoinType) EmbeddableValuedModelPart(org.hibernate.metamodel.mapping.EmbeddableValuedModelPart) CollectionPart(org.hibernate.metamodel.mapping.CollectionPart) ModelPartContainer(org.hibernate.metamodel.mapping.ModelPartContainer)

Aggregations

TableGroupJoin (org.hibernate.sql.ast.tree.from.TableGroupJoin)39 TableGroup (org.hibernate.sql.ast.tree.from.TableGroup)34 LazyTableGroup (org.hibernate.sql.ast.tree.from.LazyTableGroup)17 PluralAttributeMapping (org.hibernate.metamodel.mapping.PluralAttributeMapping)14 PluralTableGroup (org.hibernate.sql.ast.tree.from.PluralTableGroup)14 NavigablePath (org.hibernate.query.spi.NavigablePath)13 SqlAstJoinType (org.hibernate.sql.ast.SqlAstJoinType)13 EntityPersister (org.hibernate.persister.entity.EntityPersister)11 CorrelatedTableGroup (org.hibernate.sql.ast.tree.from.CorrelatedTableGroup)11 QueryPartTableGroup (org.hibernate.sql.ast.tree.from.QueryPartTableGroup)10 TableGroupJoinProducer (org.hibernate.sql.ast.tree.from.TableGroupJoinProducer)10 VirtualTableGroup (org.hibernate.sql.ast.tree.from.VirtualTableGroup)10 Fetch (org.hibernate.sql.results.graph.Fetch)10 CorrelatedPluralTableGroup (org.hibernate.sql.ast.tree.from.CorrelatedPluralTableGroup)9 SelectStatement (org.hibernate.sql.ast.tree.select.SelectStatement)9 EntityValuedModelPart (org.hibernate.metamodel.mapping.EntityValuedModelPart)8 AbstractEntityPersister (org.hibernate.persister.entity.AbstractEntityPersister)8 DomainResult (org.hibernate.sql.results.graph.DomainResult)8 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)7 ModelPart (org.hibernate.metamodel.mapping.ModelPart)7