code: private int calculateForeignKeyColumnCount(PersistentEntity refDomainClass, String[] propertyNames) {
          int expectedForeignKeyColumnLength = 0;
          for (String propertyName : propertyNames) {
              PersistentProperty referencedProperty = refDomainClass.getPropertyByName(propertyName);
              if(referencedProperty instanceof ToOne) {
                  ToOne toOne = (ToOne) referencedProperty;
                  PersistentProperty[] compositeIdentity = toOne.getAssociatedEntity().getCompositeIdentity();
                  if(compositeIdentity != null) {
                      expectedForeignKeyColumnLength += compositeIdentity.length;
                  }
                  else {
                      expectedForeignKeyColumnLength++;
                  }
              }
              else {
                  expectedForeignKeyColumnLength++;
              }
          }
          return expectedForeignKeyColumnLength;
      }
docs: number of columns required for a column key we have to perform the calculation here