use of org.hibernate.UnknownEntityTypeException in project hibernate-orm by hibernate.
the class EntityNonEntityTest method testGetAndFindNonEntityThrowsIllegalArgumentException.
@Test
@TestForIssue(jiraKey = "HHH-9856")
public void testGetAndFindNonEntityThrowsIllegalArgumentException() {
try {
sessionFactory().locateEntityPersister(Cellular.class);
} catch (UnknownEntityTypeException ignore) {
// expected
}
try {
sessionFactory().locateEntityPersister(Cellular.class.getName());
} catch (UnknownEntityTypeException ignore) {
// expected
}
Session s = openSession();
s.beginTransaction();
try {
s.get(Cellular.class, 1);
fail("Expecting a failure");
} catch (UnknownEntityTypeException ignore) {
// expected
} finally {
s.getTransaction().commit();
s.close();
}
s = openSession();
s.beginTransaction();
try {
s.get(Cellular.class.getName(), 1);
fail("Expecting a failure");
} catch (UnknownEntityTypeException ignore) {
// expected
} finally {
s.getTransaction().commit();
s.close();
}
}
use of org.hibernate.UnknownEntityTypeException in project hibernate-orm by hibernate.
the class DomainModelScope method withHierarchy.
default void withHierarchy(String rootTypeName, Consumer<RootClass> action) {
final PersistentClass entityBinding = getDomainModel().getEntityBinding(rootTypeName);
if (entityBinding == null) {
throw new UnknownEntityTypeException(String.format(Locale.ROOT, "Could not resolve `%s` as an entity type", rootTypeName));
}
action.accept(entityBinding.getRootClass());
}
use of org.hibernate.UnknownEntityTypeException in project hibernate-orm by hibernate.
the class EntityNonEntityTest method testGetAndFindNonEntityThrowsIllegalArgumentException.
@Test
@TestForIssue(jiraKey = "HHH-9856")
public void testGetAndFindNonEntityThrowsIllegalArgumentException() {
try {
sessionFactory().getMetamodel().locateEntityPersister(Cellular.class);
sessionFactory().getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(Cellular.class);
} catch (UnknownEntityTypeException ignore) {
// expected
}
try {
sessionFactory().getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(Cellular.class.getName());
} catch (UnknownEntityTypeException ignore) {
// expected
}
Session s = openSession();
s.beginTransaction();
try {
s.get(Cellular.class, 1);
fail("Expecting a failure");
} catch (UnknownEntityTypeException ignore) {
// expected
} finally {
s.getTransaction().commit();
s.close();
}
s = openSession();
s.beginTransaction();
try {
s.get(Cellular.class.getName(), 1);
fail("Expecting a failure");
} catch (UnknownEntityTypeException ignore) {
// expected
} finally {
s.getTransaction().commit();
s.close();
}
}
Aggregations