private function insert(IdentifiableOrmEntity $entity) { $id = $entity->_getId(); $idType = $this->identifier->getType(); $generator = !$id && $idType instanceof IOrmEntityIdGenerator ? $idType->getIdGenerator($entity) : null; $generatorType = $generator ? $generator->getType() : null; if ($generatorType && $generatorType->isPre()) { $id = $generator->generate($entity); if ($id) { $entity->_setId($id); } } $affected = $this->executeQuery(InsertQuery::create($this->physicalSchema->getTable())->setValues($this->map->disassemble($entity))); if ($generatorType && $generatorType->isPost()) { $id = $generator->generate($entity); if ($id) { $entity->_setId($id); } } $this->identityMap->add($entity); $entity->setFetched(); }