title: Unable to locate Attribute with the the given name
body: <p>In my project, I am trying to replace the existing entities with entities from another libraries. I a getting a weird problem with specifications, criteriabuilder and join stuff. Here I am having the following classes</p>
  
  <pre><code>    @Entity
  @Table(
      name = "company"
  )
  public class RoomEntity{
      @Id
      @Column(
          name = "id"
      )
      @GeneratedValue(
          generator = "seq-table",
          strategy = GenerationType.TABLE
      )
      private Integer id;
  
      @OneToMany(
      mappedBy = "parentCompany",
      fetch = FetchType.LAZY,
      orphanRemoval = false
  )
  private Set&lt;RoomHierarchyEntity&gt; children;
  </code></pre>
  
  <p>2</p>
  
  <pre><code>@Entity
  @Table(
      name = "room_hierarchy"
  )
  public class RoomHierarchyEntity {
      @Id
      @Column(
          name = "id"
      )
      @GeneratedValue(
          generator = "seq-table",
          strategy = GenerationType.TABLE
      )
      private Integer id;
      @ManyToOne(
          fetch = FetchType.LAZY,
          optional = false
      )
      @JoinColumn(
          name = "parent_id",
          foreignKey = @ForeignKey(
      name = "fk_Roomhierarchy_p_room"
  )
      )
      private RoomEntity parentRoom;
      @ManyToOne(
          fetch = FetchType.LAZY,
          optional = false
      )
      @JoinColumn(
          name = "child_id",
          foreignKey = @ForeignKey(
      name = "fk_Roomhierarchy_c_room"
  )
      )
      private RoomEntity childRoom;
      @Column(
          name = "distance",
          nullable = false
      )
      private Integer distance;
  </code></pre>
  
  <p>3</p>
  
  <pre><code>public class ResourceEntity {
      @Id
      @Column(
          name = "id"
      )
      @GeneratedValue(
          generator = "seq-table",
          strategy = GenerationType.TABLE
      )
      private Long id;
      @Column(
          name = "room_id",
          nullable = false
      )
      @NotNull
      private Integer RoomId;
  
  )
  </code></pre>
  
  <p>Service1.java</p>
  
  <pre><code>findByCompanyAnd(ResEntity.class, roomId);
  </code></pre>
  
  <p>Service2.java</p>
  
  <pre><code>public static &lt;T&gt; Specifications&lt;T&gt; findByRoomAnd(Class&lt;T&gt; queryClass, Integer companyId,
                                                                              ) {
      return findByCompany(queryClass, companyId));
  
  }
  </code></pre>
  
  <p>SpecificationsUtil.Java</p>
  
  <pre><code>public static &lt;T&gt; Specifications&lt;T&gt; findByCompany(Class&lt;T&gt; queryClass, Integer companyId) {
      return findByCompany(queryClass, companyId, COLUMNS.get(queryClass));
  }
  
  
  private static &lt;T&gt; Specifications&lt;T&gt; findByRoom(final Class&lt;T&gt; queryClass, final Integer RoomId,
                                                                               final Set&lt;String&gt; columnNames) {
         return Specifications.where(new Specification&lt;T&gt;() {
             @Override
             public Predicate toPredicate(Root&lt;T&gt; root, CriteriaQuery&lt;?&gt; query, CriteriaBuilder cb) {
                 Join&lt;RoomEntity, RoomHierarchyEntity&gt; chRoot = root.join("room").join("children");
  
                 Subquery&lt;Integer&gt; sq = query.subquery(Integer.class);
                 Root&lt;T&gt; sqRoot = sq.from(queryClass);
                 Join&lt;CompanyEntity, CompanyHierarchyEntity&gt; sqChRoot = sqRoot.join("room").join("children");
                 sq.select(sqChRoot.&lt;Integer&gt;get("distance"));
  
                 ...
             }
         });
     }
  </code></pre>
  
  <p>The difference between old ResEntity and new ResEntity is that, old one has entity RoomEntity as an object where as new one just has RoomId in it. I am getting a variety of errors when I put the new type of ResEntity.</p>
  
  <p>I am getting error at </p>
  
  <pre><code>Join&lt;RoomEntity, RoomHierarchyEntity&gt; chRoot = root.join("room").join("children");
  
  
  Unable to locate Attribute  with the the given name [children] on this ManagedType
  </code></pre>
  
  <p>How do I join the incoming entity (ResEntity) with RoomEntity and RoomHierarchy entity ?</p>
  
  <p>Above code is the legacy one and I really don't understand what it does. I just want to join those tables and I want to run those with out disturbing things.</p>