public function find($id, $lockMode = LockMode::NONE, $lockVersion = null)
    {
        // Check identity map first
        if ($entity = $this->xem->getUnitOfWork()->tryGetById($id, $this->class->rootXmlEntityName)) {
            if ($lockMode != LockMode::NONE) {
                $this->xem->lock($entity, $lockMode, $lockVersion);
            }

            return $entity; // Hit!
        }

        if ($lockMode == LockMode::NONE) {
            return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id);
        } else if ($lockMode == LockMode::OPTIMISTIC) {
            if (!$this->class->isVersioned) {
                throw OptimisticLockException::notVersioned($this->entityName);
            }
            $entity = $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id);

            $this->xem->getUnitOfWork()->lock($entity, $lockMode, $lockVersion);

            return $entity;
        } else {
            if (!$this->xem->getConnection()->isTransactionActive()) {
                throw TransactionRequiredException::transactionRequired();
            }

            return $this->xem->getUnitOfWork()->getXmlEntityPersister($this->entityName)->load($id, null, null, array(), $lockMode);
        }
    }