title: grails composite "unique constraint", but how?
body: <p>I'm very close to a solution but anything is still wrong, hope to get help, thanks in advance.</p>
  
  <p>I have a Customer domain model like:</p>
  
  <pre><code>class BoCustomer implements Serializable{
  
      String firstName
      String lastName
      String emailID
      Company company
  }
  </code></pre>
  
  <p>So, I have a primary key = "id" that's okay. So further I need kind of unique constraint that "checks" the following: "only one unique email address for one company" so that inserting the same e-mail should be allowed but only for different companies. Inserting (<strong>test@test.com</strong>, <strong>company-id: 1</strong>) and inserting (<strong>test@test.com</strong>, <strong>company-id: 1</strong>) is not allowed, but inserting (<strong>test@test.com</strong>, <strong>company-id: 1</strong>) and inserting (<strong>test@test.com</strong>, <strong>company-id: 2</strong>) is allowed.</p>
  
  <p>So I tried so far:</p>
  
  <pre><code>static mapping = {
      id column: "customer_id", generator: "identity"
      emailcompany composite: ['emailID', 'company'], unique: true
  }
  </code></pre>
  
  <p>(seems to be "good", but not exactly what I want)</p>
  
  <p>BUT i don't want another column, in my try called "emailcompany" - but I need something like a unique constraint. </p>