title: Mapping an @Embeddable in a separate table
body: <p>Two tables like:</p>
  
  <pre><code>CREATE TABLE foo (
    id INT PRIMARY KEY,
    x TEXT
  );
  
  CREATE TABLE bar (
    foo_id INT REFERENCES foo (id) ON DELETE CASCADE,
    y TEXT,
    z TEXT
  );
  </code></pre>
  
  <p>...can be mapped like so:</p>
  
  <pre><code>@Table(name = "foo")
  @SecondaryTable(name = "bar", pkJoinColumns = @PrimaryKeyJoinColumn(name = "foo_id", referencedColumnName = "id"))
  class Foo {
  
    @Id
    int id;
  
    @Embedded
    @AttributeOverrides({
      @AttributeOverride(name = "y", column = @Column(table = "bar")),
      @AttributeOverride(name = "z", column = @Column(table = "bar"))
    })
    Bar bar;
  }
  
  @Embeddable
  class Bar {
    String y;
    String z;
  }
  </code></pre>
  
  <p>Is there a less awkward way to do this mapping, using either just standard JPA annotations, or else Hibernate-specific annotations (and without introducing a parent reference in the embeddable object)?</p>
  
  <p>Compare this to how easily a collection of <code>@Embeddable</code> objects can be referenced using an <code>@ElementCollection</code> and <code>@CollectionTable</code>.</p>