use of jakarta.persistence.EntityGraph in project hibernate-orm by hibernate.
the class BasicOrmNamedEntityGraphTest method testIt.
@Test
void testIt(SessionFactoryScope scope) {
scope.inTransaction(session -> {
EntityManager em = session.unwrap(EntityManager.class);
EntityGraph graph = em.getEntityGraph("Person");
assertThat(graph, notNullValue());
});
}
use of jakarta.persistence.EntityGraph in project hibernate-orm by hibernate.
the class SubgraphOrmNamedEntityGraphTest method testSubgraphsAreLoadedFromOrmXml.
@Test
@TestForIssue(jiraKey = "HHH-10633")
void testSubgraphsAreLoadedFromOrmXml(SessionFactoryScope scope) {
scope.inTransaction(session -> {
EntityManager entityManager = session.unwrap(EntityManager.class);
List<EntityGraph<? super Book>> lneg = entityManager.getEntityGraphs(Book.class);
assertThat(lneg, notNullValue());
assertThat(lneg, hasSize(2));
for (EntityGraph<? super Book> neg : lneg) {
if (neg.getName().equalsIgnoreCase("full")) {
assertThat(neg.getAttributeNodes(), notNullValue());
for (AttributeNode<?> n : neg.getAttributeNodes()) {
if (n.getAttributeName().equalsIgnoreCase("authors")) {
assertThat(n.getSubgraphs().entrySet(), hasSize(1));
List<AttributeNode<?>> attributeNodes = n.getSubgraphs().get(Author.class).getAttributeNodes();
assertThat(attributeNodes, notNullValue());
assertThat(attributeNodes, hasSize(3));
}
}
}
}
});
}
use of jakarta.persistence.EntityGraph in project hibernate-orm by hibernate.
the class BasicAnnNamedEntityGraphTest method testIt.
@Test
void testIt(SessionFactoryScope scope) {
scope.inTransaction(session -> {
EntityManager em = session.unwrap(EntityManager.class);
EntityGraph graph = em.getEntityGraph("Person");
assertThat(graph, notNullValue());
});
}
use of jakarta.persistence.EntityGraph in project eclipselink by eclipse-ee4j.
the class EntityManagerImpl method getEntityGraphs.
@Override
public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) {
ClassDescriptor descriptor = getAbstractSession().getDescriptor(entityClass);
if (descriptor == null || descriptor.isAggregateDescriptor()) {
throw new IllegalArgumentException(ExceptionLocalization.buildMessage("unknown_bean_class", new Object[] { entityClass.getName() }));
}
List<EntityGraph<? super T>> result = new ArrayList<EntityGraph<? super T>>();
for (AttributeGroup group : descriptor.getAttributeGroups().values()) {
result.add(new EntityGraphImpl<>(group));
}
if (descriptor.hasInheritance()) {
while (descriptor.getInheritancePolicy().getParentDescriptor() != null) {
descriptor = descriptor.getInheritancePolicy().getParentDescriptor();
for (AttributeGroup group : descriptor.getAttributeGroups().values()) {
result.add(new EntityGraphImpl<>(group));
}
}
}
return result;
}
Aggregations