public function getPrimaryKey()
    {
        if (null === $this->primary) {
            $metadata = $this->getMetadata();
            $constraints = $metadata->getConstraints($this->getTable());

            foreach ($constraints as $constraint) {
                if ($constraint->getType() == 'PRIMARY KEY') {
                    $this->primary = $constraint->getColumns();
                }
            }
        }

        return $this->primary;
    }