title: embedded ids: primary key and foreign key
body: <p>Given entity with embedded id and embedded foreign key:</p>
  
  <pre><code>@Entity
  public class One {
  
    @EmbeddedId
    private ModelId id;
  
    @Embedded
    @AttributeOverride(name = "id", column = @Column(name = "two_id"))
    private ModelId twoId;
  }
  
  @Embeddable
  public class ModelId {
  
    private Integer id;
  }
  </code></pre>
  
  <p>when in JPQL:</p>
  
  <pre><code>SELECT o.id FROM One o WHERE o.twoId IN :twoId
  </code></pre>
  
  <p>then JPA generates SQL:</p>
  
  <pre><code>SELECT id FROM one WHERE id IN (?)
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>SELECT id FROM one WHERE two_id IN (?)
  </code></pre>
  
  <p>How to make it work?</p>