title: How do I define unique constraint in hibernate for this situation?
body: <p>Destination and DestinationAlias at database level look like this:</p>
  
  <p><img src="https://i.stack.imgur.com/h1lvV.png" alt="DestinationAlias and Destination"></p>
  
  <p>In DestinationAlias, (idDestination, alias) is unique.</p>
  
  <p>POJO for DestinationAlias:</p>
  
  <pre><code>@Entity
  @Table(name = "DESTINATIONALIAS",
  uniqueConstraints = { @UniqueConstraint(columnNames={"IDDESTINATION", "ALIAS"}) }
          )
  public final class DestinationAlias {
  
  // ..
  
      @ManyToOne(fetch=FetchType.LAZY, cascade={CascadeType.ALL})
      @JoinColumn(name="IDDESTINATION", nullable=false)
      public Destination getMainCity() {
          return mainCity;
      }
  }
  </code></pre>
  
  <p>Should the unique constraint be IDDESTINATION or "MAINCITY" ?</p>