title: Hibernate `unique` constraints not working if one of the multi-column constraint is null
body: <p>There's a constraint in Hibernate called <code>unique</code> that makes a certain property throws an error if it is not unique when it validates. For example:</p>
  
  <pre><code>class Person {
      String id
      Person mother
      Person father
      String fullName
  
      // Mapping closure goes here
  
      static constraints = {
          father nullable: true
          fullName unique: ["mother", "father"]
          mother nullable: true
      }
  }
  </code></pre>
  
  <p>In this scenario, any value of <code>fullName</code> is allowed as long as it's unique on every <code>mother</code> and <code>father</code> pair. So, if there is a record of a <code>Person</code>, let say, <code>id=03 fullName=Liam</code>, with mother <code>id=01 fullName=Olivia</code> and father <code>id=02 fullName=William</code>, there will be a validation error when another record with the same <code>fullName</code> <code>id=04 fullName=Liam</code> is inserted under the mother <code>id=01 fullName=Olivia</code> and father <code>id=02 fullName=William</code>. The validation works.</p>
  
  <p>The problem is when one of multi-column unique constraint is <code>null</code>. For example, when a record <code>Person</code> <code>id=03 fullName=Liam</code> with mother <code>id=01 fullName=Olivia</code> and a <code>null</code> <code>father</code> is inserted and another record with the identical <code>fullName</code> and <code>mother</code> is inserted after, the validation will not trigger.</p>
  
  <p>I want to know whether this a limitation.</p>
  
  <p>P.S. I know that it is advised to have this unique constraint on the database side. I have that already. What I want is to have an equivalent checking on the Hibernate side.</p>