public function getIdentity() {
        if ($this->identity === null) {
            foreach ($this->mapping['properties'] as $name => $property) {
                if (isset($property['primary']) && $property['primary']===true) {
                    return $this->identity = new PropertyMapping($this, $property);
                }
            }
            throw new RuntimeException('Invalid mapping for entity "'.$this->getClassName().'" (missing primary key mapping)');
        }
        return $this->identity;
    }