title: Hibernate <set> key from joined table
body: <p>I wonder if it's possible to define <code>Set</code> in Hibernate mapping in a such way, that  element would specify not column in original (<strong>FOO</strong>) table, but in joined one (<strong>BAR</strong>). Let's say we have some <code>FooContainer.hbm.xml</code>, which contains <code>Set</code> of <code>Foo</code> objects:</p>
  
  <pre><code>&lt;set ...&gt;
    &lt;key column="COLUMN_FROM_BAR" /&gt;
    &lt;one-to-many class="xyz.Foo" /&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p>Here <strong>FOO</strong> has FK to <strong>BAR</strong> (<strong>FOO.BAR_ID</strong>), so joining is done through element in Foo.hbm.xml:</p>
  
  <pre><code>&lt;many-to-one class="xyz.Bar" fetch="join" column="BAR_ID" foreign-key="barId" ... /&gt;
  </code></pre>
  
  <p>which results in joined <strong>FOO-BAR</strong> select whenever <code>xyz.Foo</code> is fetched.  </p>
  
  <p>Problem is that where condition of generated <code>Set</code> fetching select is something like:</p>
  
  <pre><code>... WHERE _FOO_0.COLUMN_FROM_BAR = ?
  </code></pre>
  
  <p>when desired one is:</p>
  
  <pre><code>... WHERE _BAR_0.COLUMN_FROM_BAR = ?
  </code></pre>