Search in sources :

Example 1 with CollectionLoaderSingleKey

use of org.hibernate.loader.ast.internal.CollectionLoaderSingleKey in project hibernate-orm by hibernate.

the class LoadPlanBuilderTest method testCollectionInitializerCase.

@Test
public void testCollectionInitializerCase(SessionFactoryScope scope) {
    final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
    final EntityPersister posterEntityDescriptor = sessionFactory.getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(Poster.class);
    final PluralAttributeMapping messages = (PluralAttributeMapping) posterEntityDescriptor.findAttributeMapping("messages");
    final CollectionLoaderSingleKey loader = new CollectionLoaderSingleKey(messages, LoadQueryInfluencers.NONE, sessionFactory);
    assertThat(loader.getSqlAst().getDomainResultDescriptors()).hasSize(1);
    assertThat(loader.getSqlAst().getDomainResultDescriptors().get(0)).isInstanceOf(CollectionDomainResult.class);
    final CollectionDomainResult domainResult = (CollectionDomainResult) loader.getSqlAst().getDomainResultDescriptors().get(0);
    DomainResultGraphPrinter.logDomainResultGraph(loader.getSqlAst().getDomainResultDescriptors());
    assertThat(domainResult.getFetches()).isEmpty();
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) CollectionDomainResult(org.hibernate.sql.results.graph.collection.internal.CollectionDomainResult) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) PluralAttributeMapping(org.hibernate.metamodel.mapping.PluralAttributeMapping) CollectionLoaderSingleKey(org.hibernate.loader.ast.internal.CollectionLoaderSingleKey) Test(org.junit.jupiter.api.Test)

Aggregations

SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)1 CollectionLoaderSingleKey (org.hibernate.loader.ast.internal.CollectionLoaderSingleKey)1 PluralAttributeMapping (org.hibernate.metamodel.mapping.PluralAttributeMapping)1 EntityPersister (org.hibernate.persister.entity.EntityPersister)1 CollectionDomainResult (org.hibernate.sql.results.graph.collection.internal.CollectionDomainResult)1 Test (org.junit.jupiter.api.Test)1