Search in sources :

Example 1 with UnknownProfileException

use of org.hibernate.UnknownProfileException in project hibernate-orm by hibernate.

the class JoinFetchProfileTest method testBasicFetchProfileOperation.

@Test
public void testBasicFetchProfileOperation() {
    assertTrue("fetch profile not parsed properly", sessionFactory().containsFetchProfileDefinition("enrollment.details"));
    assertTrue("fetch profile not parsed properly", sessionFactory().containsFetchProfileDefinition("offering.details"));
    assertTrue("fetch profile not parsed properly", sessionFactory().containsFetchProfileDefinition("course.details"));
    Session s = openSession();
    SessionImplementor si = (SessionImplementor) s;
    s.enableFetchProfile("enrollment.details");
    assertTrue(si.getLoadQueryInfluencers().hasEnabledFetchProfiles());
    s.disableFetchProfile("enrollment.details");
    assertFalse(si.getLoadQueryInfluencers().hasEnabledFetchProfiles());
    try {
        s.enableFetchProfile("never-gonna-get-it");
        fail("expecting failure on undefined fetch-profile");
    } catch (UnknownProfileException expected) {
    }
    s.close();
}
Also used : UnknownProfileException(org.hibernate.UnknownProfileException) SessionImplementor(org.hibernate.engine.spi.SessionImplementor) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

Session (org.hibernate.Session)1 UnknownProfileException (org.hibernate.UnknownProfileException)1 SessionImplementor (org.hibernate.engine.spi.SessionImplementor)1 Test (org.junit.Test)1