title: Hibernate Criteria for Join Table
body: <p>Help me Hibernate Guru..
  i have 2 relationship class, let's call class A and B</p>
  
  <pre><code>@Entity
  @Table(name="A")
  public class A extends Serializable{
  
        @Id
        @Column(name="a_id")
        private int id;
        @Column(name="a_name")
        private String name;
  
       /*
        *.....Setter and Getter
        */
  }
  
  
  
  @Entity
  @Table(name="B")
  public class B extends Serializable{
  
        @Id
        @Column(name="b_id")
        private int id;
        @ManyToMany(
            fetch= FetchType.EAGER,
            targetEntity=package.A.class,
            cascade={CascadeType.ALL}
        )
        @JoinTable(
            name="B_A",
            joinColumns=@JoinColumn(name="b_id"),
            inverseJoinColumns=@JoinColumn(name="a_id")
        )
        @Fetch(FetchMode.SUBSELECT)
        private List&lt;A&gt; list;
  
       /*
        *.....Setter and Getter
        */
  }
  </code></pre>
  
  <p>Hibernate will generate 3 Table A, B, and B_A. with table B_A have 2 foreign key, one foreign key for primary key table A and one again foreign key for primary key table B,</p>
  
  <p>i want select data from table A, like query : </p>
  
  <pre><code>select * from A a inner join B_A ba on ba.a_id = a.id inner join B b on b.b_id = ba.b_id where b.id in(?, ?, ?, ?)
  </code></pre>
  
  <p>so how Criteria code i have to create???? and for expected list result List i want to use Transformer.</p>
  
  <p>Thanks</p>