title: Create an index on a column of a CollectionTable using Hibernate
body: <p>Suppose I have the following entity which models a subscriber and uses a <code>CollectionTable</code> to model a list of subscriptions like so:</p>
  
  <pre><code>@Entity
  @Table(name = "SUBSCRIBER")
  public class Subscriber {
      @ElementCollection
      @CollectionTable(name = "PERSON_ORG_SUBSCRIPTIONS",
                       joinColumns = { @JoinColumn( name = "PERSON_ID", referencedColumnName = "PERSON_ID" ),
                                       @JoinColumn( name = "ORG_ID", referencedColumnName = "ORG_ID" ) } )
      @Column(name = "SUBSCRIPTION_NAME")
      protected Set&lt;String&gt; _subscriptionNames;
  }
  </code></pre>
  
  <p>So this creates a table with columns for <code>PERSON_ID</code>, <code>ORG_ID</code> and <code>SUBSCRIPTION_NAME</code>.</p>
  
  <p>I'm trying to create a database index on the <code>SUBSCRIPTION_NAME</code> column. But if I put the following annotation on <code>_subscriptionNames</code>:</p>
  
  <pre><code>@org.hibernate.annotations.Index( name="subscription_idx", columnNames={"SUBSCRIPTION_NAMES"} )
  </code></pre>
  
  <p>I get an exception:</p>
  
  <pre><code>org.hibernate.MappingException: Unable to find logical column name from physical name null in table SUBSCRIBER
  </code></pre>
  
  <p>I also tried using the <code>org.hibernate.annotations.Table</code> annotation on the <code>Subscriber</code> entity, but there does not seem to be a way to have it reference the <code>PERSON_ORG_SUBSCRIPTIONS</code> table.</p>
  
  <p>I'm using Hibernate 3.5.3 and PostgreSQL 9.0.</p>