Search in sources :

Example 11 with FetchStyle

use of org.hibernate.engine.FetchStyle in project hibernate-orm by hibernate.

the class EntityBasedAssociationAttribute method determineFetchPlan.

@Override
public FetchStrategy determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
    final EntityPersister owningPersister = getSource().getEntityPersister();
    FetchStyle style = FetchStrategyHelper.determineFetchStyleByProfile(loadQueryInfluencers, owningPersister, propertyPath, attributeNumber());
    if (style == null) {
        style = FetchStrategyHelper.determineFetchStyleByMetadata(((OuterJoinLoadable) getSource().getEntityPersister()).getFetchMode(attributeNumber()), getType(), sessionFactory());
    }
    return new FetchStrategy(FetchStrategyHelper.determineFetchTiming(style, getType(), sessionFactory()), style);
}
Also used : EntityPersister(org.hibernate.persister.entity.EntityPersister) FetchStyle(org.hibernate.engine.FetchStyle) OuterJoinLoadable(org.hibernate.persister.entity.OuterJoinLoadable) FetchStrategy(org.hibernate.engine.FetchStrategy)

Example 12 with FetchStyle

use of org.hibernate.engine.FetchStyle in project hibernate-orm by hibernate.

the class BatchFetchStrategyHelperTest method testCollectionJoinFetch.

@Test
public void testCollectionJoinFetch() {
    final AssociationType associationType = determineAssociationType(AnEntity.class, "colorsJoin");
    final org.hibernate.FetchMode fetchMode = determineFetchMode(AnEntity.class, "colorsJoin");
    assertSame(org.hibernate.FetchMode.JOIN, fetchMode);
    final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(fetchMode, associationType, sessionFactory());
    // batch size is ignored with org.hibernate.FetchMode.JOIN
    assertSame(FetchStyle.JOIN, fetchStyle);
    final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(fetchStyle, associationType, sessionFactory());
    assertSame(FetchTiming.IMMEDIATE, fetchTiming);
}
Also used : FetchStyle(org.hibernate.engine.FetchStyle) AssociationType(org.hibernate.type.AssociationType) FetchTiming(org.hibernate.engine.FetchTiming) Test(org.junit.Test)

Example 13 with FetchStyle

use of org.hibernate.engine.FetchStyle in project hibernate-orm by hibernate.

the class BatchFetchStrategyHelperTest method testCollectionSelectFetch.

@Test
public void testCollectionSelectFetch() {
    final AssociationType associationType = determineAssociationType(AnEntity.class, "colorsSelect");
    final org.hibernate.FetchMode fetchMode = determineFetchMode(AnEntity.class, "colorsSelect");
    assertSame(org.hibernate.FetchMode.SELECT, fetchMode);
    final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(fetchMode, associationType, sessionFactory());
    assertSame(FetchStyle.BATCH, fetchStyle);
    final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(fetchStyle, associationType, sessionFactory());
    assertSame(FetchTiming.DELAYED, fetchTiming);
}
Also used : FetchStyle(org.hibernate.engine.FetchStyle) AssociationType(org.hibernate.type.AssociationType) FetchTiming(org.hibernate.engine.FetchTiming) Test(org.junit.Test)

Example 14 with FetchStyle

use of org.hibernate.engine.FetchStyle in project hibernate-orm by hibernate.

the class FetchStrategyHelperTest method testManyToOneSelectFetch.

@Test
public void testManyToOneSelectFetch() {
    final AssociationType associationType = determineAssociationType(AnEntity.class, "otherEntitySelect");
    final org.hibernate.FetchMode fetchMode = determineFetchMode(AnEntity.class, "otherEntitySelect");
    assertSame(org.hibernate.FetchMode.SELECT, fetchMode);
    final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(fetchMode, associationType, sessionFactory());
    assertSame(FetchStyle.SELECT, fetchStyle);
    final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(fetchStyle, associationType, sessionFactory());
    assertSame(FetchTiming.DELAYED, fetchTiming);
}
Also used : FetchStyle(org.hibernate.engine.FetchStyle) AssociationType(org.hibernate.type.AssociationType) FetchTiming(org.hibernate.engine.FetchTiming) Test(org.junit.Test)

Example 15 with FetchStyle

use of org.hibernate.engine.FetchStyle in project hibernate-orm by hibernate.

the class FetchStrategyHelperTest method testCollectionSubselectFetch.

@Test
public void testCollectionSubselectFetch() {
    final AssociationType associationType = determineAssociationType(AnEntity.class, "colorsSubselect");
    final org.hibernate.FetchMode fetchMode = determineFetchMode(AnEntity.class, "colorsSubselect");
    assertSame(org.hibernate.FetchMode.SELECT, fetchMode);
    final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(fetchMode, associationType, sessionFactory());
    assertSame(FetchStyle.SUBSELECT, fetchStyle);
    final FetchTiming fetchTiming = FetchStrategyHelper.determineFetchTiming(fetchStyle, associationType, sessionFactory());
    assertSame(FetchTiming.DELAYED, fetchTiming);
}
Also used : FetchStyle(org.hibernate.engine.FetchStyle) AssociationType(org.hibernate.type.AssociationType) FetchTiming(org.hibernate.engine.FetchTiming) Test(org.junit.Test)

Aggregations

FetchStyle (org.hibernate.engine.FetchStyle)19 FetchTiming (org.hibernate.engine.FetchTiming)17 AssociationType (org.hibernate.type.AssociationType)17 Test (org.junit.Test)17 FetchStrategy (org.hibernate.engine.FetchStrategy)2 EntityPersister (org.hibernate.persister.entity.EntityPersister)2 OuterJoinLoadable (org.hibernate.persister.entity.OuterJoinLoadable)1