java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [managers] on this ManagedType [org.hibernate.jpa.test.graphs.queryhint.QueryHintEntityGraphTest$Manager]

Hibernate JIRA | Brett Meyer | 4 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    {code} @Entity private static class Company implements Serializable { @Id @GeneratedValue public long id; @OneToMany public Set<Employee> employees; } @Entity @Inheritance( strategy = InheritanceType.TABLE_PER_CLASS ) private static class Employee { @Id @GeneratedValue public long id; @ManyToMany public Set<Manager> managers; } @Entity private static class Manager extends Employee { } {code} {code} Subgraph<Employee> subgraph1 = entityGraph.addSubgraph( "employees" ); subgraph1.addAttributeNodes( "managers" ); Subgraph<Employee> subgraph2 = subgraph1.addSubgraph( "managers" ); subgraph2.addAttributeNodes( "managers" ); {code} {code} java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [managers] on this ManagedType [org.hibernate.jpa.test.graphs.queryhint.QueryHintEntityGraphTest$Manager] at org.hibernate.jpa.internal.metamodel.AbstractManagedType.checkNotNull(AbstractManagedType.java:144) at org.hibernate.jpa.internal.metamodel.AbstractManagedType.getDeclaredAttribute(AbstractManagedType.java:137) at org.hibernate.jpa.graph.internal.SubgraphImpl.resolveAttribute(SubgraphImpl.java:124) at org.hibernate.jpa.graph.internal.AbstractGraphNode.buildAttributeNode(AbstractGraphNode.java:119) at org.hibernate.jpa.graph.internal.AbstractGraphNode.addAttribute(AbstractGraphNode.java:114) at org.hibernate.jpa.graph.internal.AbstractGraphNode.addAttributeNodes(AbstractGraphNode.java:109) at org.hibernate.jpa.graph.internal.SubgraphImpl.addAttributeNodes(SubgraphImpl.java:62) at org.hibernate.jpa.test.graphs.queryhint.QueryHintEntityGraphTest.testQueryHintEntityGraph(QueryHintEntityGraphTest.java:81) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:63) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74) {code}

    Hibernate JIRA | 4 years ago | Brett Meyer
    java.lang.IllegalArgumentException: Unable to locate Attribute with the the given name [managers] on this ManagedType [org.hibernate.jpa.test.graphs.queryhint.QueryHintEntityGraphTest$Manager]

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      Unable to locate Attribute with the the given name [managers] on this ManagedType [org.hibernate.jpa.test.graphs.queryhint.QueryHintEntityGraphTest$Manager]

      at org.hibernate.jpa.internal.metamodel.AbstractManagedType.checkNotNull()
    2. org.hibernate.jpa
      QueryHintEntityGraphTest.testQueryHintEntityGraph
      1. org.hibernate.jpa.internal.metamodel.AbstractManagedType.checkNotNull(AbstractManagedType.java:144)
      2. org.hibernate.jpa.internal.metamodel.AbstractManagedType.getDeclaredAttribute(AbstractManagedType.java:137)
      3. org.hibernate.jpa.graph.internal.SubgraphImpl.resolveAttribute(SubgraphImpl.java:124)
      4. org.hibernate.jpa.graph.internal.AbstractGraphNode.buildAttributeNode(AbstractGraphNode.java:119)
      5. org.hibernate.jpa.graph.internal.AbstractGraphNode.addAttribute(AbstractGraphNode.java:114)
      6. org.hibernate.jpa.graph.internal.AbstractGraphNode.addAttributeNodes(AbstractGraphNode.java:109)
      7. org.hibernate.jpa.graph.internal.SubgraphImpl.addAttributeNodes(SubgraphImpl.java:62)
      8. org.hibernate.jpa.test.graphs.queryhint.QueryHintEntityGraphTest.testQueryHintEntityGraph(QueryHintEntityGraphTest.java:81)
      8 frames
    3. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:601)
      4 frames
    4. JUnit
      FrameworkMethod.invokeExplosively
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      3 frames
    5. A Hibernate O/RM Module
      ExtendedFrameworkMethod.invokeExplosively
      1. org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:63)
      1 frame
    6. JUnit
      FailOnTimeout$StatementThread.run
      1. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      2. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      3. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      4. org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:74)
      4 frames