protected function validateAndCompleteToOneAssociationMetadata(ToOneAssociationMetadata $property)
    {
        $fieldName = $property->getName();

        if ($property->isOwningSide()) {
            if (empty($property->getJoinColumns())) {
                // Apply default join column
                $property->addJoinColumn(new JoinColumnMetadata());
            }

            $uniqueConstraintColumns = [];

            foreach ($property->getJoinColumns() as $joinColumn) {
                /** @var JoinColumnMetadata $joinColumn */
                if ($property instanceof OneToOneAssociationMetadata && $this->inheritanceType !== InheritanceType::SINGLE_TABLE) {
                    if (count($property->getJoinColumns()) === 1) {
                        if (! $property->isPrimaryKey()) {
                            $joinColumn->setUnique(true);
                        }
                    } else {
                        $uniqueConstraintColumns[] = $joinColumn->getColumnName();
                    }
                }

                $joinColumn->setTableName(! $this->isMappedSuperclass ? $this->getTableName() : null);

                if (! $joinColumn->getColumnName()) {
                    $joinColumn->setColumnName($this->namingStrategy->joinColumnName($fieldName, $this->className));
                }

                if (! $joinColumn->getReferencedColumnName()) {
                    $joinColumn->setReferencedColumnName($this->namingStrategy->referenceColumnName());
                }

                $this->fieldNames[$joinColumn->getColumnName()] = $fieldName;
            }

            if ($uniqueConstraintColumns) {
                if (! $this->table) {
                    throw new RuntimeException(
                        'ClassMetadata::setTable() has to be called before defining a one to one relationship.'
                    );
                }

                $this->table->addUniqueConstraint(
                    [
                        'name'    => sprintf('%s_uniq', $fieldName),
                        'columns' => $uniqueConstraintColumns,
                        'options' => [],
                        'flags'   => [],
                    ]
                );
            }
        }

        if ($property->isOrphanRemoval()) {
            $cascades = $property->getCascade();

            if (! in_array('remove', $cascades, true)) {
                $cascades[] = 'remove';

                $property->setCascade($cascades);
            }

            // @todo guilhermeblanco where is this used?
            // @todo guilhermeblanco Shouldn't we iterate through JoinColumns to set non-uniqueness?
            //$property->setUnique(false);
        }

        if ($property->isPrimaryKey() && ! $property->isOwningSide()) {
            throw MappingException::illegalInverseIdentifierAssociation($this->className, $fieldName);
        }
    }