title: Hibernate - Get Child Accounts from by parent Id
body: <p>I have two entities:</p>
  <pre><code>@Entity
  @Table(name=&quot;Account&quot;)
  public class AccountEntity{
  
      @Id
      private Id;
  
  }
  
  @Entity
  @Table(name=&quot;AccountMap&quot;)
  public class AccountMapEntity {
      
      @Id 
      private Long Id;
  
      private Long parentId;
  
      private Long childId;
  }
  </code></pre>
  <p>How can I get the child Accounts by the parent Id? I would write a query for example</p>
  <pre><code>select acc from AccountEntity acc join AccountMapEntity map on acc.id = map.childId 
  where map.parentId = :parentId;
  </code></pre>
  <p>How can I do this with @OneToMany/@ManyToOne annotations, so I wouldn't have to write a join in my query?</p>
  <p>*Edited
  I edited the query to make it obvious that I only want records from AccountEntity.</p>