use of org.hibernate.internal.AbstractSharedSessionContract in project hibernate-orm by hibernate.
the class LazyLoadingLoggingTest method testDisconnect.
@Test
@TestForIssue(jiraKey = "HHH-12484")
public void testDisconnect(SessionFactoryScope scope) {
scope.inTransaction(session -> {
Address address = session.load(Address.class, 1L);
AbstractSharedSessionContract sessionContract = (AbstractSharedSessionContract) session;
sessionContract.getJdbcCoordinator().close();
try {
address.getClient().getName();
fail("Should throw LazyInitializationException");
} catch (LazyInitializationException expected) {
assertEquals("could not initialize proxy " + "[org.hibernate.orm.test.lazyload.LazyLoadingLoggingTest$Address#1] " + "- the owning Session is disconnected", expected.getMessage());
}
session.getTransaction().markRollbackOnly();
});
}
Aggregations