Search in sources :

Example 11 with AssociationType

use of org.hibernate.type.AssociationType in project hibernate-orm by hibernate.

the class FetchStrategyHelperTest 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.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 12 with AssociationType

use of org.hibernate.type.AssociationType in project hibernate-orm by hibernate.

the class FetchStrategyHelperTest method determineAssociationType.

private AssociationType determineAssociationType(Class<?> entityClass, String path) {
    OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getEntityPersister(entityClass.getName());
    int index = ((UniqueKeyLoadable) entityPersister).getPropertyIndex(path);
    return (AssociationType) entityPersister.getSubclassPropertyType(index);
}
Also used : OuterJoinLoadable(org.hibernate.persister.entity.OuterJoinLoadable) AssociationType(org.hibernate.type.AssociationType) UniqueKeyLoadable(org.hibernate.persister.entity.UniqueKeyLoadable)

Example 13 with AssociationType

use of org.hibernate.type.AssociationType in project hibernate-orm by hibernate.

the class FetchStrategyHelperTest 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());
    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 14 with AssociationType

use of org.hibernate.type.AssociationType in project hibernate-orm by hibernate.

the class NoProxyFetchStrategyHelperTest method testManyToOneJoinFetch.

@Test
public void testManyToOneJoinFetch() {
    final AssociationType associationType = determineAssociationType(AnEntity.class, "otherEntityJoin");
    final org.hibernate.FetchMode fetchMode = determineFetchMode(AnEntity.class, "otherEntityJoin");
    assertSame(org.hibernate.FetchMode.JOIN, fetchMode);
    final FetchStyle fetchStyle = FetchStrategyHelper.determineFetchStyleByMetadata(fetchMode, associationType, sessionFactory());
    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 15 with AssociationType

use of org.hibernate.type.AssociationType in project hibernate-orm by hibernate.

the class BatchFetchStrategyHelperTest method testCollectionDefaultFetch.

@Test
public void testCollectionDefaultFetch() {
    final AssociationType associationType = determineAssociationType(AnEntity.class, "colorsDefault");
    final org.hibernate.FetchMode fetchMode = determineFetchMode(AnEntity.class, "colorsDefault");
    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)

Aggregations

AssociationType (org.hibernate.type.AssociationType)43 Type (org.hibernate.type.Type)18 FetchStyle (org.hibernate.engine.FetchStyle)17 FetchTiming (org.hibernate.engine.FetchTiming)17 Test (org.junit.Test)17 CompositeType (org.hibernate.type.CompositeType)12 EntityType (org.hibernate.type.EntityType)10 JoinType (org.hibernate.sql.JoinType)9 QueryableCollection (org.hibernate.persister.collection.QueryableCollection)6 EntityPersister (org.hibernate.persister.entity.EntityPersister)5 OuterJoinLoadable (org.hibernate.persister.entity.OuterJoinLoadable)5 UniqueKeyLoadable (org.hibernate.persister.entity.UniqueKeyLoadable)4 CollectionType (org.hibernate.type.CollectionType)4 VersionType (org.hibernate.type.VersionType)4 Iterator (java.util.Iterator)3 ManagedType (javax.persistence.metamodel.ManagedType)3 QueryException (org.hibernate.QueryException)3 Joinable (org.hibernate.persister.entity.Joinable)3 AssociationKey (org.hibernate.persister.walking.spi.AssociationKey)3 Serializable (java.io.Serializable)2