title: hibernate: how to create a composite foreign key in xml?
body: <p>I have a class <code>Event</code> containing a composite primary key (start date and end date).</p>
  
  <p>A <code>EventPlanning</code> class holds a <code>Set</code> of such <code>Event</code> objects and has to persist them using hibernate with XML. 
  I can do this for classes with a common primary key:</p>
  
  <pre><code>&lt;!-- EventPlanning xml --&gt;
  ....
  &lt;id name="id" column="id"&gt;
  &lt;generator class="native" /&gt;
  &lt;/id&gt;
  &lt;property name="name" column="name" type="string" update="false" /&gt;
  
  &lt;set name="events" table="events" cascade="all"&gt;
      &lt;key column="event_id"&gt;   // ###### here! ######
      &lt;/key&gt;
      &lt;one-to-many class="myPackage.Event" /&gt;
  &lt;/set&gt;
  ...
  </code></pre>
  
  <p>but I can't find out how this works with a composite key..</p>
  
  <p>replacing the <code>&lt;key column="event_id"&gt;</code> with the following code doesn't work:</p>
  
  <pre><code>&lt;key&gt;
      &lt;property column="start_date" /&gt;
      &lt;property column="end_date" /&gt;
  &lt;/key&gt;
  </code></pre>
  
  <p>I'd be glad if somebody can show me the right syntax! :)</p>
  
  <p>the Event xml looks like this:</p>
  
  <pre><code>&lt;class name="myPackage.Even" table="events"&gt;
  
          &lt;composite-id&gt;
              &lt;key-property name="startDate" column="start_date" type="date" /&gt;
              &lt;key-property name="endDate" column="end_date" type="date" /&gt;
          &lt;/composite-id&gt;
  
          &lt;property name="signinDeadline" column="signin_deadline"
              type="date" /&gt;
          &lt;property name="confirmationDeadline" column="confirmation_deadline"
              type="date" /&gt;
  
          &lt;set name="participants" table="participants" cascade="all"&gt;
              &lt;key column="event_id"&gt;
              &lt;/key&gt;
              &lt;one-to-many class="myPackage.Participants" /&gt;
          &lt;/set&gt;
  
      &lt;/class&gt;
  </code></pre>
  
  <p>thanks in advance! :)</p>