Search in sources :

Example 11 with EntityGraph

use of javax.persistence.EntityGraph in project hibernate-orm by hibernate.

the class NamedEntityGraphsTest method testAttributeNodesAreAvailable.

@Test
public void testAttributeNodesAreAvailable() {
    EntityManager em = getOrCreateEntityManager();
    EntityGraph graph = em.getEntityGraph("name_salary_graph");
    assertNotNull(graph);
    List<AttributeNode<?>> list = graph.getAttributeNodes();
    assertNotNull(list);
    assertTrue("expected list.size() is two but actual list size is " + list.size(), 2 == list.size());
    AttributeNode attributeNode1 = list.get(0);
    AttributeNode attributeNode2 = list.get(1);
    assertNotNull(attributeNode1);
    assertNotNull(attributeNode2);
    assertTrue("node1 attribute name is expected to be either 'name' or 'salary' but actually is " + attributeNode1.getAttributeName(), "name".equals(attributeNode1.getAttributeName()) || "salary".equals(attributeNode1.getAttributeName()));
    assertTrue("node2 attribute name is expected to be either 'name' or 'salary' but actually is " + attributeNode2.getAttributeName(), "name".equals(attributeNode2.getAttributeName()) || "salary".equals(attributeNode2.getAttributeName()));
}
Also used : EntityGraph(javax.persistence.EntityGraph) EntityManager(javax.persistence.EntityManager) AttributeNode(javax.persistence.AttributeNode) Test(org.junit.Test)

Aggregations

EntityGraph (javax.persistence.EntityGraph)11 Test (org.junit.Test)8 EntityManager (javax.persistence.EntityManager)6 AliasResolutionContextImpl (org.hibernate.loader.plan.exec.internal.AliasResolutionContextImpl)4 Join (org.hibernate.loader.plan.spi.Join)4 LoadPlan (org.hibernate.loader.plan.spi.LoadPlan)4 QuerySpace (org.hibernate.loader.plan.spi.QuerySpace)4 AttributeNode (javax.persistence.AttributeNode)2 EntityGraphImplementor (org.hibernate.graph.spi.EntityGraphImplementor)2 ArrayList (java.util.ArrayList)1 NamedEntityGraph (javax.persistence.NamedEntityGraph)1 TestForIssue (org.hibernate.testing.TestForIssue)1